Skip to content

Commit fecc3bf

Browse files
fix: remove panic on missing rangeLastWaitKey in lock conflict handler
The panic "BUG: missing range last wait key" can be triggered by a legitimate race condition: 1. txn3 acquires range lock [k1,k4], conflicts with txn1 at k4 2. txn3 waiter is added to k4, rangeLastWaitKey set to k4 3. txn3 blocks in wait() — releases l.mu 4. txn1 unlocks k4: closeTxn() notifies txn3 waiter, isEmpty() returns true, k4 is deleted from store 5. txn3 wakes, retries, conflicts at k2 6. handleLockConflictLocked tries to clean up old k4 waiter 7. k4 no longer exists → panic Between step 3 (waiter blocks without lock) and step 6 (conflict retry), another transaction can legitimately delete the lock entry. The next line already guards with `if ok &&`, so removing the panic is safe — the waiter was already cleaned up by the unlock path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ce192d9 commit fecc3bf

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

pkg/lockservice/lock_table_local.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,6 @@ func (l *localLockTable) handleLockConflictLocked(
547547

548548
if len(c.rangeLastWaitKey) > 0 {
549549
v, ok := l.mu.store.Get(c.rangeLastWaitKey)
550-
if !ok {
551-
panic("BUG: missing range last wait key")
552-
}
553550
if ok && v.closeWaiter(c.w, l.logger) {
554551
l.mu.store.Delete(c.rangeLastWaitKey)
555552
}

0 commit comments

Comments
 (0)