Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed race in `readerReconnector`

## v3.117.1
* Fixed scan a column of type `Decimal(precision,scale)` into a struct field of type `types.Decimal{}` using `ScanStruct()`
* Fixed race in integration test `TestTopicWriterLogMessagesWithoutData`
Expand Down
18 changes: 15 additions & 3 deletions internal/topic/topicreaderinternal/stream_reconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,21 @@ func (r *readerReconnector) CloseWithError(ctx context.Context, reason error) er
r.closeOnce.Do(func() {
closeErr = r.background.Close(ctx, reason)

if r.streamVal != nil {
streamCloseErr := r.streamVal.CloseWithError(ctx, xerrors.WithStackTrace(errReaderClosed))
r.streamContextCancel(errReaderClosed)
// Get references under lock
var streamVal batchedStreamReader
var streamCancel context.CancelCauseFunc

r.m.WithLock(func() {
streamVal = r.streamVal
streamCancel = r.streamContextCancel
})

// Make I/O calls outside the lock
if streamVal != nil {
streamCloseErr := streamVal.CloseWithError(ctx, xerrors.WithStackTrace(errReaderClosed))
if streamCancel != nil {
streamCancel(errReaderClosed)
}
if closeErr == nil {
closeErr = streamCloseErr
}
Expand Down
Loading