googleapis / googleapis/google-cloud-node

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

Open
#7,371 1 comment 0 reactions 1 assignee Claimed by @surbhigarg92 View on GitHub
api: spanner library: spanner priority: p2 type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

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](https://github.com/googleapis/nodejs-spanner/blob/main/src/transaction.ts#L1333) . But since this request is not awaited, error is thrown to the catch block and begin transaction continues in parallel , ultimately throwing unhandled exception.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.