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)
  • Loading branch information
ianferguson authored Feb 10, 2021
1 parent fc74567 commit 9f86fcc
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 9f86fcc

Please sign in to comment.