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

fix: unhandled exception error catch #2091

Merged
merged 9 commits into from
Aug 9, 2024

Conversation

alkatrivedi
Copy link
Contributor

fixes: #1972

@alkatrivedi alkatrivedi requested review from a team as code owners August 7, 2024 07:58
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Aug 7, 2024
test/spanner.ts Outdated Show resolved Hide resolved
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Aug 7, 2024
@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Aug 7, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 7, 2024
@surbhigarg92 surbhigarg92 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Aug 7, 2024
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Aug 7, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 7, 2024
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Outdated Show resolved Hide resolved
test/spanner.ts Outdated Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
test/spanner.ts Outdated
.filter(val => (val as v1.ExecuteSqlRequest).sql)
.map(req => req as v1.ExecuteSqlRequest);

assert.strictEqual(requests.length, 6);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there 6 requests ? There should be 4 requests.

test/spanner.ts Show resolved Hide resolved
@surbhigarg92 surbhigarg92 force-pushed the uncaught-exception-fix branch from 9db3dd8 to e1b3784 Compare August 8, 2024 14:09
@surbhigarg92 surbhigarg92 force-pushed the uncaught-exception-fix branch from e1b3784 to d104bc8 Compare August 8, 2024 14:41
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Aug 9, 2024
@surbhigarg92 surbhigarg92 force-pushed the uncaught-exception-fix branch from 57f1fc6 to 8f69542 Compare August 9, 2024 07:21
@@ -1219,8 +1227,16 @@ export class Snapshot extends EventEmitter {
this._update(response.metadata!.transaction);
}
})
.on('error', () => {
if (!this.id && this._useInRunner) {
.on('error', err => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a different refactor PR: It seems that runStream and createReadStream have a lot of duplicated code. Could we combine more of those?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

test/spanner.ts Show resolved Hide resolved
test/spanner.ts Show resolved Hide resolved
const database = newTestDatabase();
await database.runTransactionAsync(async tx => {
try {
await Promise.all([tx!.run(selectSql), tx!.run(invalidSql)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we already have a test for the same with these requests in the other order? That is; with the invalid SQL first?

If not, can we add that as well, and verify that:

  1. The initial call to ExecuteStreamingSql fails, which also means that there is no transaction ID that is returned.
  2. The transaction is retried with an explicit BeginTransaction and then the invalid SQL + working SQL statement.
  3. Catch the error from the invalid SQL statement.
  4. Commit the transaction (even though one of the statements failed).
  5. The result should be (I think):
ExecuteSql(transaction{begin: {readwrite=true}})
BeginTransaction(readwrite=true)
ExecuteSql(transaction{id:...})
ExecuteSql(transaction{id:...})
Commit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be doing this in a separate PR

@surbhigarg92 surbhigarg92 added owlbot:run Add this label to trigger the Owlbot post processor. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Aug 9, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 9, 2024
@surbhigarg92 surbhigarg92 merged commit e277752 into googleapis:main Aug 9, 2024
17 checks passed
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. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught exception with concurrent queries and inline begin
4 participants