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(spanner): context timeout should be wrapped correctly #7744

Merged
merged 4 commits into from Apr 17, 2023

Conversation

rahul2393
Copy link
Contributor

Fixes: #7740

@rahul2393 rahul2393 requested review from a team as code owners April 13, 2023 03:47
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: spanner Issues related to the Spanner API. labels Apr 13, 2023
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 13, 2023
@@ -533,7 +533,8 @@ func (c *Client) rwTransaction(ctx context.Context, f func(context.Context, *Rea
}
if t.shouldExplicitBegin(attempt) {
if err = t.begin(ctx); err != nil {
return spannerErrorf(codes.Internal, "error while BeginTransaction during retrying a ReadWrite transaction: %v", err)
trace.TracePrintf(ctx, nil, "Error while BeginTransaction during retrying a ReadWrite transaction: %v", ToSpannerError(err))
return ToSpannerError(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have a test that shows that this actually fixes the problem? I'm a little surprised that the sample code given in the original issue gets into this branch of the code, as it indicates that the transaction should use an explicit BeginTransaction call. It's not clear to me why the example would do that, as it just uses a normal SELECT statement as the first statement in the transaction. That would then normally mean that the BeginTransaction is inlined with the execution of that statement.

Copy link
Contributor Author

@rahul2393 rahul2393 Apr 13, 2023

Choose a reason for hiding this comment

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

Added tests, this happend because we do explicit begin transaction if first statement returns error, in this case call to iter.Next() returned cancelled and we returned custom internal error to do explicitBeginTransaction

@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Apr 13, 2023
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 13, 2023
@rahul2393 rahul2393 enabled auto-merge (squash) April 17, 2023 05:29
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 17, 2023
@rahul2393 rahul2393 merged commit f8e22f6 into main Apr 17, 2023
9 checks passed
@rahul2393 rahul2393 deleted the fix_spanner_error branch April 17, 2023 05:38
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 Spanner API. kokoro:force-run Add this label to force Kokoro to re-run the tests. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spanner: Error wraped into Internal
3 participants