Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #640
This PR adds a new provider method to check for pending migrations.
This functionality is especially useful for cases like @roblaszczak described in #507 (comment) (I'll try to summarize this when writing up the documentation for this).
Important
This underlying implementation does not respect the
SessionLocker
and can be used to check for pending migrations without blocking or being blocked by other operations.I've also added this before running
.Up()
,.UpTo
,.UpByOne
methods, which means those methods don't have to acquire the session lock (if enabled) until it's truly required to begin an operation.This is quite necessary in k8s-type environments where newer pods have long-running migrations, and older pods being bounced/rebooted/recovering from a crash/etc. are blocked by the
SessionLocker
and the entire application is down waiting on the long-running migration from one of the newer pods to complete.There's an edge case that needs to be accounted for. Since
HasPending
doesn't use aSessionLocker
, we need to make the initial table version creation retriable since there can be multiple instances trying to create it in parallel. Worst case instance 1 creates the table and instance 2 fails on its first try, then on the second try it succeeds. Retry 3 times every 1 second.Debug notes