Add context support and cancelable readers to PostgreSQL+S3 integration#175
Add context support and cancelable readers to PostgreSQL+S3 integration#175ambyte wants to merge 1 commit into
Conversation
…able readers. Update Dump and DumpZip methods to return io.ReadCloser, allowing for process cancellation. Modify S3Upload to accept context for better control over uploads.
📝 WalkthroughWalkthroughThis PR adds context-aware cancellation and proper resource cleanup across PostgreSQL dumps and S3 uploads. A new ChangesContext-aware cancellation flow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/integration/storage/s3.go (1)
106-110: 💤 Low valueHeadObject ignores parent context cancellation.
The timeout context derives from
context.Background()rather thanctx. If the caller cancelsctxafter the upload completes,HeadObjectcontinues for up to 30 seconds before returning.If immediate cancellation is desired, derive from the parent context:
Suggested fix
- headCtx, cancelHeadCtx := context.WithTimeout(context.Background(), 30*time.Second) + headCtx, cancelHeadCtx := context.WithTimeout(ctx, 30*time.Second)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/integration/storage/s3.go` around lines 106 - 110, The HeadObject call uses a timeout context derived from context.Background() so it won't observe caller cancellation; change the context creation to derive from the parent ctx (use context.WithTimeout(ctx, 30*time.Second)) so headCtx and cancelHeadCtx for s3Client.HeadObject will be canceled if the incoming ctx is canceled, keeping defer cancelHeadCtx() as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/integration/storage/s3.go`:
- Around line 106-110: The HeadObject call uses a timeout context derived from
context.Background() so it won't observe caller cancellation; change the context
creation to derive from the parent ctx (use context.WithTimeout(ctx,
30*time.Second)) so headCtx and cancelHeadCtx for s3Client.HeadObject will be
canceled if the incoming ctx is canceled, keeping defer cancelHeadCtx() as-is.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d9a3024a-1593-46f9-b1c4-6b9c5a9cca67
📒 Files selected for processing (3)
internal/integration/postgres/postgres.gointernal/integration/storage/s3.gointernal/service/executions/run_execution.go
Enhance PostgreSQL and S3 integration with context support and cancelable readers. Update Dump and DumpZip methods to return io.ReadCloser, allowing for process cancellation. Modify S3Upload to accept context for better control over uploads.
Summary by CodeRabbit