Skip to content

Commit

Permalink
Correct lock acquisition order in the pathEntityMergeID identity to…
Browse files Browse the repository at this point in the history
… fix deadlock condition (#10877) (#11251)

Co-authored-by: Ian Ferguson <[email protected]>
  • Loading branch information
ncabatoff and ianferguson authored Apr 12, 2021
1 parent bf60d0a commit 470f653
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/10877.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/identity: Fix deadlock in entity merge endpoint.
```
5 changes: 4 additions & 1 deletion vault/identity_store_entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func (i *IdentityStore) pathEntityMergeID() framework.OperationFunc {
force := d.Get("force").(bool)

// Create a MemDB transaction to merge entities
i.lock.Lock()
defer i.lock.Unlock()

txn := i.db.Txn(true)
defer txn.Abort()

Expand All @@ -172,7 +175,7 @@ func (i *IdentityStore) pathEntityMergeID() framework.OperationFunc {
return nil, err
}

userErr, intErr := i.mergeEntity(ctx, txn, toEntity, fromEntityIDs, force, true, false, true)
userErr, intErr := i.mergeEntity(ctx, txn, toEntity, fromEntityIDs, force, false, false, true)
if userErr != nil {
return logical.ErrorResponse(userErr.Error()), nil
}
Expand Down

0 comments on commit 470f653

Please sign in to comment.