Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Improve IdentityStore Invalidate performance into release/1.16.x #27230

Conversation

hc-github-team-secure-vault-core
Copy link
Collaborator

Backport

This PR is auto-generated from #27184 to be assessed for backporting due to the inclusion of the label backport/1.16.x.

🚨

Warning automatic cherry-pick of commits failed. If the first commit failed,
you will see a blank no-op commit below. If at least one commit succeeded, you
will see the cherry-picked commits up to, not including, the commit where
the merge conflict occurred.

The person who merged in the original PR is:
@marcboudreau
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.

merge conflict error: POST https://api.github.com/repos/hashicorp/vault/merges: 409 Merge conflict []

The below text is copied from the body of the original PR.


The Invalidate method of the IdentityStore struct was using a simplistic algorithm to synchronize the MemDB records (entities, groups, local entity aliases) with those from the storage bucket. This simplistic algorithm would result in a large number of MemDB operations within a single transaction whenever the storage bucket contained a large number or records. This large number of operations led to using a much slower comparer function within MemDB which caused the Invalidate function to take a long time to complete and could lead the node to fall so far behind in processing WALs sent over by the primary cluster that the replication state would transition to merkle-sync.

The simplistic approach basically consisted of deleting everything from MemDB that was associated with the invalidated storage bucket and re-inserting those resources using state contained in the storage bucket. Since invalidations usually occur to signal a single resource has changed, been added, or been deleted; when a large number of unchanged resources also exist in the storage bucket, a lot of unnecessary work was being done (deleting and re-adding).

These changes replace the simplistic approach for the handling of entities and local entity aliases since they are the more likely resource to exist in large numbers where this problem occurs.

The new approach consists of comparing the contents of the invalidated storage bucket with the set of resources from MemDB associated that storage bucket. Resources that match in both systems are left alone, and only differences are rectified in MemDB.


Overview of commits

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label May 24, 2024
Copy link

hashicorp-cla-app bot commented May 24, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

github-actions bot commented May 24, 2024

CI Results:
All Go tests succeeded! ✅

@marcboudreau marcboudreau added this to the 1.16.3 milestone May 24, 2024
@marcboudreau marcboudreau marked this pull request as ready for review May 24, 2024 18:46
Copy link

github-actions bot commented May 24, 2024

Build Results:
All builds succeeded! ✅

Marc Boudreau added 2 commits May 24, 2024 16:00
* improve identitystore invalidate performance

* add changelog

* adding test to cover invalidation of entity bucket keys within IdentityStore

* minor clean ups

* adding tests

* add missing godoc for tests
@marcboudreau marcboudreau force-pushed the backport/marcboudreau/VAULT-27060/identity-store-invalidation/truly-humble-skunk branch from 29bf087 to d53f2a0 Compare May 24, 2024 20:00
…identity-store-invalidation/truly-humble-skunk
@marcboudreau marcboudreau merged commit d8dca05 into release/1.16.x May 24, 2024
76 checks passed
@marcboudreau marcboudreau deleted the backport/marcboudreau/VAULT-27060/identity-store-invalidation/truly-humble-skunk branch May 24, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants