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
docs(spanner): fix the result handling after BufferWrite #3803
docs(spanner): fix the result handling after BufferWrite #3803
Conversation
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.
Good catch.
Transaction.BufferWrite
will however normally not throw any errors (unless you have manually closed the transaction) as it only buffers the mutation in an in-memory data structure. So this would not affect transaction retries if you were to implement your own transaction functions using this sample. Any Aborted
error would be returned by the Commit
that is executed after the transaction function has returned.
spanner/doc.go
Outdated
@@ -300,12 +300,10 @@ of the transaction: | |||
} | |||
balance -= 10 | |||
m := spanner.Update("Accounts", []string{"user", "balance"}, []interface{}{"alice", balance}) | |||
txn.BufferWrite([]*spanner.Mutation{m}) | |||
|
|||
return txn.BufferWrite([]*spanner.Mutation{m}) |
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.
nit: could we move this line to after the comment. It does not feel right to have a comment after the return statement of a function.
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.
Yup, I actually I wondered if it's right.
Then, fixed this with the similar code I referred to.
@olavloite Thanks for your explanation.
Btw, how can we do this? I'm just curisous. |
You cannot do it with the normal transaction runner, but you could do it if you use statement-based transactions, by calling
I'm pretty sure that that is either coincidence or caused by a different change that was applied at the same time, as the |
Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot. |
@tbpg Would you be able to merge this one? The integration tests are not running as the PR comes from a fork. They are green however (and not really relevant, as it is only a documentation change). |
Fixes #3802