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

Unhandled exception when running parallel queries with first query as "invalid" in a transaction. #2092

Open
surbhigarg92 opened this issue Aug 12, 2024 · 0 comments
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@surbhigarg92
Copy link
Contributor

surbhigarg92 commented Aug 12, 2024

The Nodejs library does not handle below scenario, where the first query throws an error while trying to execute parallel queries in a transaction .

await database.runTransactionAsync(async tx => {
        try {
          await Promise.all([tx!.run(invalidSql), tx!.run(selectSql)]);
          await tx.commit();
        } catch (err) {
          console.log(err);
        }

Expected: The initial call to ExecuteStreamingSql should fail, which also means that there is no transaction ID that is returned. The transaction is retried with an explicit BeginTransaction and then the invalid SQL + working SQL statement are executed again. Error will be thrown from the invalid SQL statement.

Actual: The initial call to ExecuteStreamingSql fails which initiates a explicit BeginTransaction as per this code . But since this request is not awaited, error is thrown to the catch block and begin transaction continues in parallel , ultimately throwing unhandled exception.

@surbhigarg92 surbhigarg92 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 Aug 12, 2024
@surbhigarg92 surbhigarg92 self-assigned this Aug 12, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Aug 12, 2024
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. 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