Correct lock acquisition order in the `pathEntityMergeID` identity to fix deadlock condition (#10877)

This commit is contained in:
Ian Ferguson 2021-02-10 11:05:16 -05:00 committed by GitHub
parent a2394e7353
commit 865df63c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

3
changelog/10877.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
core/identity: Fix deadlock in entity merge endpoint.
```

View File

@ -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()
@ -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
}