Skip to content

Commit

Permalink
concurrency: use atomic.Uint64 to track sequence numbers
Browse files Browse the repository at this point in the history
Burns down a TODO.

Epic: none

Release note: None
  • Loading branch information
arulajmani committed Aug 25, 2023
1 parent 6e83704 commit 2b1a106
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/kv/kvserver/concurrency/lock_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ type lockTableImpl struct {
// A.
// Now in the queues for A and B req1 is behind req3 and vice versa and
// this deadlock has been created entirely due to the lock table's behavior.
// TODO(nvanbenschoten): use an atomic.Uint64.
seqNum uint64
seqNum atomic.Uint64

// locks contains the btree object (wrapped in the treeMu structure) that
// contains the actual keyLocks objects. These keyLocks objects represent the
Expand Down Expand Up @@ -3448,7 +3447,7 @@ func (t *lockTableImpl) ScanAndEnqueue(req Request, guard lockTableGuard) lockTa

func (t *lockTableImpl) newGuardForReq(req Request) *lockTableGuardImpl {
g := newLockTableGuardImpl()
g.seqNum = atomic.AddUint64(&t.seqNum, 1)
g.seqNum = t.seqNum.Add(1)
g.lt = t
g.txn = req.Txn
g.ts = req.Timestamp
Expand Down

0 comments on commit 2b1a106

Please sign in to comment.