-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add retry support for serializable transactions #386
Add retry support for serializable transactions #386
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c65d2bc
to
4c59544
Compare
var err error | ||
for i := 0; i < numRetries; i++ { | ||
select { | ||
case <-ctx.Done(): |
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.
noob Q: What does this select on this ctx do?
The default case returns nil when it finishes succesfully, but ctx seems like some sort of global context? When would it trigger?
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.
If you ctrl+c
or the context is out of time, then ctx.Done()
channel will receive a struct and this select
block will return the error.
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.
Exactly. It just stops you from continuing retries when the server is in the process of shutting down
The specific tests that were failing are a little worrying to me because they all used random wallets and inboxes, and executed each test serially, so they should be isolated from one another. We may have to do some debugging around exactly what Postgres considers a "conflict" in the specific queries we are using here. Maybe it's a broader set of rows than you'd expect. But these retries are a generally good idea regardless and we can tackle that separately. |
tl;dr
I noticed our
libxmtp
test suite was occasionally failing due to serializable transaction errors. This adds retries, which are required when using the serializable isolation level since errors are common and transient thanks to Postgres' conflict detection