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 Nov 15, 2023
1 parent 69e435b commit 5e9c94f
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 @@ -238,6 +238,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 5e9c94f

Please sign in to comment.