-
Notifications
You must be signed in to change notification settings - Fork 502
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
services/horizon: Lock ingestion while applying DB migrations #4587
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.
I think that the implementation is almost there - I've added few comments.
return 0, err | ||
} | ||
|
||
tx, err := txConn.BeginTx(context.Background(), nil) |
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.
given that you've already used BeginTx
instead of the "classic" Begin
, why don't you take advantage of that and use the TxOptions
?
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.
Conn
only exposes BeginTx
method.
@stellar/horizon-committers PTAL, tests pass and I applied changes suggested by @tsachiherman. |
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Acquire ingestion lock before applying DB migrations to stop ingestion.
Why
When applying
58_add_index_by_id_optimization.sql
migration file we experienced a deadlock. It can happen when ingestion is running because ingestion by inserting or updating certain rows can acquireRowExclusiveLock
which conflicts with other locks (likeShareLock
when creating a new index).Close #4588.
Known limitations
We lock ingestion only for
up
migrations.down
migrations can remove key-value table which can lead to deadlocks.