Skip to content

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

@surbhigarg92

Description

@surbhigarg92

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.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/nodejs-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions