[core] Surface JDBC lock acquisition failures - #10272
Open
LuciferYang wants to merge 1 commit into
Open
LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
lockAcquire converted every SQLException of the lock INSERT into false, so anything but a held lock — a lock key exceeding the column size, a missing lock table, a connection failover — silently spun for the whole acquire timeout and then failed without a cause. Treat only constraint violations as a held lock and rethrow the rest. Assisted-by: GLM-5.3
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.
Purpose
AbstractDistributedLockDialect.lockAcquirecaught everySQLExceptionand returnedfalse, meaning "lock not acquired". Real contention does surface as a primary-key constraint violation on the lock row, sofalseis correct there, but a non-contention error (a dead pooled connection, a missingdistributed_lockstable, access denied) was swallowed the same way:JdbcCatalogLock.lock()then busy-spins for the whole lock-acquire timeout re-issuing the same failing INSERT and finally throws a genericAcquire lock failed with time: ...that hides the cause.This returns
falseonly for a constraint violation (contention) and rethrows any otherSQLException, so a non-retryable failure fails fast with its root cause and the operator can tell "someone else holds the lock" apart from "the lock table is gone". Contention is classified by SQLState23xxxorSQLIntegrityConstraintViolationException, with a message-substring fallback for dialects that report neither (SQLite, where the fallback is load-bearing). The high-value errors this surfaces (connection reset, missing table, column overflow) do not contain the fallback substrings, so they are not reclassified as contention.This closes #10271.
Tests
testBrokenLockInsertSurfacesRootCausepins that a non-contention failure on the lock INSERT propagates instead of being retried for the full timeout.testAcquireLockFailcontinues to pin that real contention returnsfalseand times out as before.API and Format
No.
Documentation
No.