Add x-no-lock option to database drivers with real distributed locks#1372
Open
gstarikov wants to merge 2 commits intogolang-migrate:masterfrom
Open
Add x-no-lock option to database drivers with real distributed locks#1372gstarikov wants to merge 2 commits intogolang-migrate:masterfrom
gstarikov wants to merge 2 commits intogolang-migrate:masterfrom
Conversation
Add x-no-lock URL parameter to postgres, pgx, pgx/v5, sqlserver, cockroachdb, and yugabytedb drivers following the existing MySQL pattern. When set to true, Lock()/Unlock() become no-ops, allowing driver initialization and Version() calls without acquiring advisory or table-based locks. Drivers with in-process-only atomic locks (sqlite, clickhouse, etc.) are not changed as they never block.
…, yugabytedb Add param validation unit test and integration lock/unlock test following the existing MySQL TestNoLockParamValidation/TestNoLockWorks pattern.
8a9d83f to
26525b5
Compare
EvgenySerg
reviewed
Mar 20, 2026
| func (c *CockroachDb) Lock() error { | ||
| return database.CasRestoreOnErr(&c.isLocked, false, true, database.ErrLocked, func() (err error) { | ||
| if c.config.NoLock { | ||
| return nil |
There was a problem hiding this comment.
Hi. Why don't we return error here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add x-no-lock URL parameter to postgres, pgx, pgx/v5, sqlserver, cockroachdb, and yugabytedb drivers following the existing MySQL pattern. When set to true, Lock()/Unlock() become no-ops, allowing driver initialization and Version() calls without acquiring advisory or table-based locks.
Drivers with in-process-only atomic locks (sqlite, clickhouse, etc.) are not changed as they never block.