Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove chan close in rehydration receiver shutdowns #2128

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
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