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

rolemembershipcache: extract cache to new package #136514

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Dec 2, 2024

The caching logic was getting to be quite large, and it already was
nicely contained in an easy to move struct.

This is a purely mechanical refactor.


sql, sessioninit: lookup tables by ID, not name

These tables all have fixed IDs, so looking them up by name is not
necessary.


Epic: None
Release note: None

The caching logic was getting to be quite large, and it already was
nicely contained in an easy to move struct.

This is a purely mechanical refactor.

Release note: None
@rafiss rafiss requested a review from fqazi December 2, 2024 19:58
@rafiss rafiss requested a review from a team as a code owner December 2, 2024 19:58
Copy link

blathers-crl bot commented Dec 2, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 8 of 8 files at r1, 11 of 11 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @fqazi and @rafiss)


pkg/sql/rolemembershipcache/cache.go line 0 at r1 (raw file):
It seems like none of the unit tests were self-contained enough to be copied over to the new package, is that right?

These tables all have fixed IDs, so looking them up by name is not
necessary.

Release note: None
@rafiss rafiss force-pushed the refactor-membership-cache branch from b659da6 to 97edf1f Compare December 3, 2024 17:38
Copy link
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tftr!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @fqazi and @spilchen)


pkg/sql/rolemembershipcache/cache.go line at r1 (raw file):

Previously, spilchen wrote…

It seems like none of the unit tests were self-contained enough to be copied over to the new package, is that right?

that's right, and one of the benefits of this refactor is that it makes that quite clear. i didn't want to make the new tests block the improvement to organizing the code.

though one related test is in pkg/sql/cacheutil. we started to make a general purpose package for caches that work like this one, but unfortunately haven't updated them all to use that package. each cache has subtle differences in implementation that makes the consolidation a bit tricky to get right.

func TestCache(t *testing.T) {

@craig craig bot merged commit ef46c67 into cockroachdb:master Dec 3, 2024
22 of 23 checks passed
@rafiss rafiss deleted the refactor-membership-cache branch December 3, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants