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