-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 advisory locking to mongodb #448
Conversation
0f9cfff
to
0ad2f21
Compare
Pull Request Test Coverage Report for Build 870
💛 - Coveralls |
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.
Thanks for the PR!
rename constants rename query params add new timeout interval query param add new feature flag use timeout context
@dhui I am seeing intermittent cassandra test failures, unrelated to my changes. Is this a known issue? https://travis-ci.com/github/golang-migrate/migrate/jobs/391121339
Edit: force pushed whitespace changes to my branch twice. First time, same issue, second time, build passed |
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.
Thanks for addressing the prev round of feedback.
Re: failing tests
Yeah, unfortunately, some of the integration tests fail intermittently... e.g. docker pull
fails or container fails to start 😞
Force pushing is the best way to re-trigger a build.
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return mc, nil | ||
} | ||
|
||
//Parse the url param, convert it to boolean | ||
// returns error if param invalid. returns defaultValue if param not present | ||
func parseBoolean(urlParam string, defaultValue bool) (bool, 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.
Nice, thanks for the refactors!
Resolves #435
This implements advisory locking for mongodb. The
migrate_advisory_lock
collection will have a unique index on thelocking_key
collection. Migrate processes will attempt to claim the lock by inserting the same unique value into the collection. If succesful, they have the lock, if not, they wait for up to 15s using an exponential backoff.Note that the collection name and backoff max time are configurable with the following query params:
x-advisory-locking
true
x-advisory-lock-collection
migrate_advisory_lock
x-advisory-lock-timout
15
x-advisory-lock-timout-interval
10