Skip to content

Commit

Permalink
rolemembershipcache: extract cache to new package
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rafiss committed Dec 2, 2024
1 parent fd2fec8 commit a63a689
Show file tree
Hide file tree
Showing 8 changed files with 447 additions and 385 deletions.
1 change: 1 addition & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,7 @@ GO_TARGETS = [
"//pkg/sql/regionliveness:regionliveness",
"//pkg/sql/regions:regions",
"//pkg/sql/regions:regions_test",
"//pkg/sql/rolemembershipcache:rolemembershipcache",
"//pkg/sql/roleoption:roleoption",
"//pkg/sql/row:row",
"//pkg/sql/row:row_test",
Expand Down
1 change: 1 addition & 0 deletions pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ go_library(
"//pkg/sql/privilege",
"//pkg/sql/querycache",
"//pkg/sql/rangeprober",
"//pkg/sql/rolemembershipcache",
"//pkg/sql/roleoption",
"//pkg/sql/scheduledlogging",
"//pkg/sql/schemachanger/scdeps",
Expand Down
5 changes: 3 additions & 2 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
"github.com/cockroachdb/cockroach/pkg/sql/querycache"
"github.com/cockroachdb/cockroach/pkg/sql/rangeprober"
"github.com/cockroachdb/cockroach/pkg/sql/rolemembershipcache"
"github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scdeps"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scexec"
Expand Down Expand Up @@ -983,8 +984,8 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
VirtualSchemas: virtualSchemas,
HistogramWindowInterval: cfg.HistogramWindowInterval(),
RangeDescriptorCache: cfg.distSender.RangeDescriptorCache(),
RoleMemberCache: sql.NewMembershipCache(
serverCacheMemoryMonitor.MakeBoundAccount(), cfg.stopper,
RoleMemberCache: rolemembershipcache.NewMembershipCache(
serverCacheMemoryMonitor.MakeBoundAccount(), cfg.internalDB, cfg.stopper,
),
SequenceCacheNode: sessiondatapb.NewSequenceCacheNode(),
SessionInitCache: sessioninit.NewCache(
Expand Down
3 changes: 1 addition & 2 deletions pkg/sql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ go_library(
"//pkg/sql/isql",
"//pkg/sql/lex",
"//pkg/sql/lexbase",
"//pkg/sql/memsize",
"//pkg/sql/mutations",
"//pkg/sql/oidext",
"//pkg/sql/opt",
Expand Down Expand Up @@ -469,6 +468,7 @@ go_library(
"//pkg/sql/querycache",
"//pkg/sql/regionliveness",
"//pkg/sql/regions",
"//pkg/sql/rolemembershipcache",
"//pkg/sql/roleoption",
"//pkg/sql/row",
"//pkg/sql/rowcontainer",
Expand Down Expand Up @@ -587,7 +587,6 @@ go_library(
"//pkg/util/startup",
"//pkg/util/stop",
"//pkg/util/syncutil",
"//pkg/util/syncutil/singleflight",
"//pkg/util/timeutil",
"//pkg/util/timeutil/pgdate",
"//pkg/util/tochar",
Expand Down
Loading

0 comments on commit a63a689

Please sign in to comment.