Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session lastUsed parameter not updated correctly for a Transaction #1933

Open
asthamohta opened this issue Oct 10, 2023 · 0 comments
Open

Session lastUsed parameter not updated correctly for a Transaction #1933

asthamohta opened this issue Oct 10, 2023 · 0 comments
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@asthamohta
Copy link
Contributor

Each pooled session has a parameter lastUsed which indicates the timestamp when the session was last used. If we make successive RPC calls within a transaction, this parameter only gets updated at the start of the transaction (when we begin transaction) and does not get updated with subsequent RPC calls. This is becuase this time is set when a session is assigned to a transaction.

    database.getSnapshot(async (err, transaction) => {
    const queryOne = 'SELECT SingerId, AlbumId, AlbumTitle FROM Albums';

    try {
      // first RPC
      const [qOneRows] = await transaction.run(queryOne);

      const queryTwo = {
        columns: ['SingerId', 'AlbumId', 'AlbumTitle'],
      };

      // second RPC
      const [qTwoRows] = await transaction.read('Albums', queryTwo);
    } catch (err) {
      console.error('ERROR:', err);
    } 

Bug : In the above example we would expect the timestamp to get updated for each query but is only updated before the first RPC.

@asthamohta asthamohta added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Oct 10, 2023
@product-auto-label product-auto-label bot added api: spanner Issues related to the googleapis/nodejs-spanner API. samples Issues that are directly related to samples. labels Oct 10, 2023
@asthamohta asthamohta changed the title Each pooled session has a parameter lastUseTime which indicates the timestamp when the session was last used. If we make successive RPC calls within a transaction, this parameter only gets updated at the start of the transaction (when we begin transaction) and does not get updated with subsequent RPC calls. For ex - Consider the below sample Session lastUsed parameter not updated correctly for a Transaction Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant