diff --git a/indexer/indexer.go b/indexer/indexer.go index 94721b5f..2c1114a7 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -108,25 +108,16 @@ func NewIndexer(cfg config.Config) *CoreIndexer { } } -// Start runs the ETL indexer alongside the aggregates calculator. Both are -// long-lived; errgroup propagates the first error (and the ctx cancellation -// it triggers) to all members. -// -// Caveat: etl.Indexer.Run() uses its own internal context.Background() rather -// than honoring `ctx` — graceful shutdown via ctx cancellation isn't supported -// by the upstream API today. Process termination (SIGTERM) still works the -// way Go programs always do, and DB connections drain via pool finalizers on -// process exit. Acceptable tradeoff to avoid forking ETL. func (ci *CoreIndexer) Start(ctx context.Context) error { - eg := errgroup.Group{} + eg, gCtx := errgroup.WithContext(ctx) eg.Go(func() error { - return ci.aggregatesCalculator.Start(ctx) + return ci.aggregatesCalculator.Start(gCtx) }) eg.Go(func() error { ci.logger.Info("Starting ETL indexer") return ci.etlIndexer.Run() }) - ci.startParityJobs(ctx) + ci.startParityJobs(gCtx) return eg.Wait() }