Skip to content

Commit 812081d

Browse files
committed
Fixed data race on close topic writer
1 parent e20088b commit 812081d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

internal/topic/topicwriterinternal/writer_reconnector.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,17 @@ func (w *WriterReconnector) close(ctx context.Context, reason error) (resErr err
347347
onDone(resErr)
348348
}()
349349

350-
closeErr := w.queue.Close(reason)
351-
if resErr == nil && closeErr != nil {
352-
resErr = closeErr
353-
}
354-
350+
// stop background work and single stream writer
355351
bgErr := w.background.Close(ctx, reason)
356352
if resErr == nil && bgErr != nil {
357353
resErr = bgErr
358354
}
359355

356+
closeErr := w.queue.Close(reason)
357+
if resErr == nil && closeErr != nil {
358+
resErr = closeErr
359+
}
360+
360361
return resErr
361362
}
362363

internal/topic/topicwriterinternal/writer_reconnector_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func TestWriterImpl_CloseWithFlush(t *testing.T) {
632632
t.Run(test.name, func(t *testing.T) {
633633
xtest.TestManyTimes(t, func(t testing.TB) {
634634
f(t, test.flush)
635-
}, xtest.StopAfter(time.Minute))
635+
})
636636
})
637637
}
638638
}

0 commit comments

Comments
 (0)