File tree 1 file changed +8
-2
lines changed 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ func (b *Batcher) Add(
175
175
// Run runs the batcher.
176
176
func (b * Batcher ) run (ctx context.Context ) {
177
177
// nolint:gocritic // This is only ever used for one thing - inserting agent stats.
178
- authCtx := dbauthz .AsSystemRestricted (context . Background () )
178
+ authCtx := dbauthz .AsSystemRestricted (ctx )
179
179
for {
180
180
select {
181
181
case <- b .tickCh :
@@ -185,7 +185,13 @@ func (b *Batcher) run(ctx context.Context) {
185
185
b .flush (authCtx , true , "reaching capacity" )
186
186
case <- ctx .Done ():
187
187
b .log .Debug (ctx , "context done, flushing before exit" )
188
- b .flush (authCtx , true , "exit" )
188
+
189
+ // We must create a new context here as the parent context is done.
190
+ ctxTimeout , cancel := context .WithTimeout (context .Background (), 15 * time .Second )
191
+ defer cancel () //nolint:revive // We're returning, defer is fine.
192
+
193
+ // nolint:gocritic // This is only ever used for one thing - inserting agent stats.
194
+ b .flush (dbauthz .AsSystemRestricted (ctxTimeout ), true , "exit" )
189
195
return
190
196
}
191
197
}
You can’t perform that action at this time.
0 commit comments