Skip to content

Commit

Permalink
fix: server panics during shutdown with reporting metrics: failed to …
Browse files Browse the repository at this point in the history
…store jobs: context canceled
  • Loading branch information
atzoum committed Dec 12, 2023
1 parent 5b94dba commit c07e17a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions enterprise/reporting/error_index/error_index_reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func NewErrorIndexReporter(ctx context.Context, log logger.Logger, configSubscri

// Report reports the metrics to the errorIndex JobsDB
func (eir *ErrorIndexReporter) Report(metrics []*types.PUReportedMetric, tx *Tx) error {
ctx := context.TODO() // TODO: add context to the Report method
failedAt := eir.now()

var jobs []*jobsdb.JobT
Expand Down Expand Up @@ -171,8 +172,8 @@ func (eir *ErrorIndexReporter) Report(metrics []*types.PUReportedMetric, tx *Tx)
if err != nil {
return fmt.Errorf("failed to resolve jobsdb: %w", err)
}
if err := db.WithStoreSafeTxFromTx(eir.ctx, tx, func(tx jobsdb.StoreSafeTx) error {
return db.StoreInTx(eir.ctx, tx, jobs)
if err := db.WithStoreSafeTxFromTx(ctx, tx, func(tx jobsdb.StoreSafeTx) error {
return db.StoreInTx(ctx, tx, jobs)
}); err != nil {
return fmt.Errorf("failed to store jobs: %w", err)
}
Expand Down

0 comments on commit c07e17a

Please sign in to comment.