Skip to content

Commit 7e14751

Browse files
committed
fix(main): seed keyviz routes after distribution catalog applies
Codex round-1 P1 on PR #647: seedKeyVizRoutes ran BEFORE setupDistributionCatalog. setupDistributionCatalog calls distribution.EnsureCatalogSnapshot which applies a catalog snapshot back into the engine — including the durable non-zero RouteIDs from the catalog. Seeding earlier registered the placeholder RouteID=0 entries from buildEngine; subsequent dispatches (which resolve to post-snapshot RouteIDs) found no slot and Observe dropped every mutation, leaving the heatmap empty even when traffic was flowing. Move the seed call to after setupDistributionCatalog returns so the sampler sees the catalog's authoritative IDs. Existing tests cover the seed mechanics; the ordering bug surfaced only in the live startup path which the unit tests don't exercise.
1 parent 8344cc0 commit 7e14751

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,20 @@ func run() error {
289289
lockResolver := kv.NewLockResolver(shardStore, shardGroups, nil)
290290
cleanup.Add(func() { lockResolver.Close() })
291291
sampler := buildKeyVizSampler()
292-
seedKeyVizRoutes(sampler, cfg.engine)
293292
coordinate := kv.NewShardedCoordinator(cfg.engine, shardGroups, cfg.defaultGroup, clock, shardStore).
294293
WithLeaseReadObserver(metricsRegistry.LeaseReadObserver()).
295294
WithSampler(keyVizSamplerForCoordinator(sampler))
296295
distCatalog, err := setupDistributionCatalog(ctx, runtimes, cfg.engine)
297296
if err != nil {
298297
return err
299298
}
299+
// Seed AFTER setupDistributionCatalog so the sampler picks up the
300+
// catalog-assigned RouteIDs. EnsureCatalogSnapshot inside
301+
// setupDistributionCatalog applies a snapshot back into the engine
302+
// with durable non-zero RouteIDs; seeding earlier would register
303+
// the placeholder zero IDs from buildEngine and Observe would miss
304+
// every dispatched mutation.
305+
seedKeyVizRoutes(sampler, cfg.engine)
300306
eg, runCtx := errgroup.WithContext(ctx)
301307
eg.Go(func() error {
302308
return runDistributionCatalogWatcher(runCtx, distCatalog, cfg.engine)

0 commit comments

Comments
 (0)