Skip to content

Commit

Permalink
Attempt to address a data race issue within identity store - take 2 (#…
Browse files Browse the repository at this point in the history
…13476) (#13504)

* Attempt to address a data race issue within identity store
* Testcase TestIdentityStore_LocalAliasInvalidations identified a data race issue.
* This reverts the previous attempt to address the issue from #13093
  • Loading branch information
stevendpclark committed Dec 22, 2021
1 parent ae611bd commit 658a8f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog/13476.txt
@@ -0,0 +1,3 @@
```release-note:bug
core/identity: Address a data race condition between local updates to aliases and invalidations
```
5 changes: 2 additions & 3 deletions vault/identity_store.go
Expand Up @@ -750,7 +750,7 @@ func (i *IdentityStore) CreateOrFetchEntity(ctx context.Context, alias *logical.
}

// Check if an entity already exists for the given alias
entity, err = i.entityByAliasFactors(alias.MountAccessor, alias.Name, false)
entity, err = i.entityByAliasFactors(alias.MountAccessor, alias.Name, true)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -837,8 +837,7 @@ func (i *IdentityStore) CreateOrFetchEntity(ctx context.Context, alias *logical.
}

txn.Commit()

return entity, nil
return entity.Clone()
}

// changedAliasIndex searches an entity for changed alias metadata.
Expand Down
2 changes: 1 addition & 1 deletion vault/identity_store_util.go
Expand Up @@ -695,7 +695,7 @@ func (i *IdentityStore) processLocalAlias(ctx context.Context, lAlias *logical.A
return nil, fmt.Errorf("mount accessor %q is not local", lAlias.MountAccessor)
}

alias, err := i.MemDBAliasByFactors(lAlias.MountAccessor, lAlias.Name, true, false)
alias, err := i.MemDBAliasByFactors(lAlias.MountAccessor, lAlias.Name, false, false)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 658a8f2

Please sign in to comment.