Skip to content

Commit 61a81f9

Browse files
committed
test: disable metrics on the embedded stored_schema cache
The embedded SpiceDB helper (pkg/spicedb/spicedb.go) already disables metrics on the dispatch and namespace caches, but left the stored_schema cache at its default (Metrics: true). That cache registers Prometheus collectors named "stored_schema" on the global registry, so when more than one embedded instance is created in a single test process the second registration intermittently fails with "duplicate metrics collector registration attempted", flaking the Unit and e2e CI jobs. With Metrics: false the cache is built without registering anything (see CacheConfig.Complete in spicedb's server package), so multiple embedded instances can no longer collide. Unrelated to the REST mapper concurrency fix in this PR; included only because this flake was blocking CI on this branch (and on main). Signed-off-by: Víctor Roldán Betancort <vroldanbet@authzed.com>
1 parent 726364a commit 61a81f9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pkg/spicedb/spicedb.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ func NewServer(ctx context.Context, bootstrapFilePath string, bootstrapContent m
4545
server.WithDispatchCacheConfig(server.CacheConfig{Enabled: false, Metrics: false}),
4646
server.WithNamespaceCacheConfig(server.CacheConfig{Enabled: false, Metrics: false}),
4747
server.WithClusterDispatchCacheConfig(server.CacheConfig{Enabled: false, Metrics: false}),
48+
// Disable metrics on the stored-schema cache. With Metrics: true (the default) the
49+
// cache registers Prometheus collectors named "stored_schema" on the global
50+
// registry, so creating more than one embedded instance in a single process (as the
51+
// tests do) fails with "duplicate metrics collector registration attempted". With
52+
// Metrics: false the cache is built without registering anything.
53+
server.WithStoredSchemaCacheConfig(server.CacheConfig{
54+
Name: "stored_schema",
55+
Enabled: true,
56+
Metrics: false,
57+
NumCounters: 1_000,
58+
MaxCost: "32MiB",
59+
}),
4860
server.WithEnableRelationshipExpiration(true),
4961
server.WithDatastoreConfig(
5062
*datastore.NewConfigWithOptionsAndDefaults().WithOptions(

0 commit comments

Comments
 (0)