Skip to content

Commit

Permalink
Always close pipe reader on WriteWALSegment return
Browse files Browse the repository at this point in the history
The pipe writer will deadlock if writing out the WAL segment fails
for any reason.
  • Loading branch information
hifi committed Dec 16, 2023
1 parent 9d79838 commit 2b4ec80
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ func (r *Replica) syncWAL(ctx context.Context) (err error) {
var g errgroup.Group
g.Go(func() error {
_, err := r.Client.WriteWALSegment(ctx, pos, pr)

// Always close pipe reader to signal writers.
if e := pr.CloseWithError(err); err == nil {
return e
}

return err
})

Expand Down

0 comments on commit 2b4ec80

Please sign in to comment.