Skip to content

[TXN-25] Throw on unrecognised KeyError variants in KvPessimisticLock responses instead of proceeding to prewrite #454

Description

@s2x

Description

TwoPhaseCommitter::pessimisticLockBatch() handles only three KeyError variants per KvPessimisticLock response: deadlock (throw), locked ($needRetry = true) and conflict (throw). Any other variant (e.g. abort, retryable, txn_not_found) falls through the error loop with $needRetry left false, so the batch is treated as fully locked and prewrite proceeds as if every lock was acquired.

This mirrors TXN-09 (#214) but in the lock-acquisition path: the transaction can commit keys whose pessimistic lock was never acquired — the same silent-continue family as TXN-14 (#219). Found while implementing #219 (the post-loop LockWaitTimeoutException throw now covers both budget-exhaustion exits, but unrecognised error variants still exit the loop silently).

Where

  • src/Client/TxnKv/TwoPhaseCommitter.phppessimisticLockBatch(), error branch (if ($needRetry) { ... } else { ... }, ~lines 579-608 on master)

Suggested fix

Terminate the error loop with an unconditional typed exception (e.g. TiKvException / TransactionConflictException) in a default branch for unrecognised variants (mirroring the #214 approach), and add a regression test asserting that an unhandled KvPessimisticLock KeyError blocks prewrite (no KvPrewrite/KvCommit issued).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdata-lossAdded by audit issue importseverity:highAdded by audit issue importtxnkvAdded by audit issue import

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions