Skip to content

Commit

Permalink
Rollback the pull/14080: which fixed the potential deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
  • Loading branch information
ahrtr committed Dec 4, 2023
1 parent b89a451 commit 1db3fa0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions server/lease/lessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,6 @@ func (le *lessor) Revoke(id LeaseID) error {
return ErrLeaseNotFound
}

// We shouldn't delete the lease inside the transaction lock, otherwise
// it may lead to deadlock with Grant or Checkpoint operations, which
// acquire the le.mu firstly and then the batchTx lock.
delete(le.leaseMap, id)

defer close(l.revokec)
// unlock before doing external work
le.mu.Unlock()
Expand All @@ -345,6 +340,9 @@ func (le *lessor) Revoke(id LeaseID) error {
txn.DeleteRange([]byte(key), nil)
}

le.mu.Lock()
defer le.mu.Unlock()
delete(le.leaseMap, l.ID)
// lease deletion needs to be in the same backend transaction with the
// kv deletion. Or we might end up with not executing the revoke or not
// deleting the keys if etcdserver fails in between.
Expand Down

0 comments on commit 1db3fa0

Please sign in to comment.