Skip to content

Commit 2adfd5c

Browse files
committed
fix race in batchstats batcher init
1 parent 25c37a1 commit 2adfd5c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

coderd/batchstats/batcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ func New(ctx context.Context, opts ...Option) (*Batcher, func(), error) {
105105
b.tickCh = b.ticker.C
106106
}
107107

108+
b.initBuf(b.batchSize)
109+
108110
cancelCtx, cancelFunc := context.WithCancel(ctx)
109111
done := make(chan struct{})
110112
go func() {
@@ -172,7 +174,6 @@ func (b *Batcher) Add(
172174

173175
// Run runs the batcher.
174176
func (b *Batcher) run(ctx context.Context) {
175-
b.initBuf(b.batchSize)
176177
// nolint:gocritic // This is only ever used for one thing - inserting agent stats.
177178
authCtx := dbauthz.AsSystemRestricted(ctx)
178179
for {

0 commit comments

Comments
 (0)