Skip to content

Commit

Permalink
remove closing of done chan in shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaasman00 committed Jan 29, 2025
1 parent 5974b73 commit 270cd88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion receiver/awss3rehydrationreceiver/reciever.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func (r *rehydrationReceiver) Shutdown(ctx context.Context) error {
if r.cancelFunc != nil {
r.cancelFunc()
}
close(r.doneChan)

// wait for any in-progress object rehydrations to finish
done := make(chan struct{})
Expand All @@ -180,9 +179,14 @@ func (r *rehydrationReceiver) Shutdown(ctx context.Context) error {
if err := r.handleCheckpoint(ctx); err != nil {
errs = errors.Join(errs, fmt.Errorf("handle checkpoint: %w", err))
}

r.checkpointMutex.Lock()
defer r.checkpointMutex.Unlock()

if err := r.checkpointStore.Close(ctx); err != nil {
errs = errors.Join(errs, fmt.Errorf("close checkpoint store: %w", err))
}
r.logger.Info("Shutdown complete")
return errs
}

Expand Down
8 changes: 4 additions & 4 deletions receiver/azureblobrehydrationreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ func (r *rehydrationReceiver) Shutdown(ctx context.Context) error {
shutdownCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()

// signal shutdown intent
close(r.doneChan)

// wait for any in-progress operations to finish
done := make(chan struct{})
go func() {
Expand All @@ -195,10 +192,13 @@ func (r *rehydrationReceiver) Shutdown(ctx context.Context) error {
errs = errors.Join(errs, fmt.Errorf("error while saving checkpoint: %w", err))
}

r.mut.Lock()
defer r.mut.Unlock()

if err := r.checkpointStore.Close(shutdownCtx); err != nil {
errs = errors.Join(errs, fmt.Errorf("error while closing checkpoint store: %w", err))
}

r.logger.Info("Shutdown complete")
return errs
}

Expand Down

0 comments on commit 270cd88

Please sign in to comment.