-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Fixes: #7740