Skip to content

fix: bound cleanup goroutines, fix retry off-by-one, log dispatch errors in S3 adapter#407

Merged
bootjp merged 4 commits intofeature/s3-implfrom
copilot/sub-pr-396
Mar 22, 2026
Merged

fix: bound cleanup goroutines, fix retry off-by-one, log dispatch errors in S3 adapter#407
bootjp merged 4 commits intofeature/s3-implfrom
copilot/sub-pr-396

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

Three reliability issues in the S3 adapter identified during review of the add s3 adapter PR.

Changes

  • retryS3Mutation off-by-one: attempt >= s3TxnRetryMaxAttempts with attempt starting at 0 allowed maxAttempts+1 total calls. Switched to for attempt := range s3TxnRetryMaxAttempts with an early break on the last iteration — exactly 8 attempts, no wasted backoff after final failure.

  • Unbounded cleanupManifestBlobsAsync goroutines: High write/delete churn could spawn unbounded goroutines (each holding a 2m timeout context). Added a cleanupSem chan struct{} semaphore (capacity s3ManifestCleanupWorkers = 16) to S3Server; cleanup is skipped via non-blocking select when all slots are occupied rather than queuing indefinitely.

    select {
    case s.cleanupSem <- struct{}{}:
    default:
        // All cleanup workers busy; orphaned blobs persist until next overwrite/delete.
        return
    }
    go func() {
        defer func() { <-s.cleanupSem }()
        ...
    }()
  • Silent coordinator.Dispatch failures in cleanupManifestBlobs: Dispatch errors were discarded with _, _. Now logged via slog.ErrorContext with structured fields (bucket, generation, object_key, upload_id, err) so cleanup failures are observable.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI self-assigned this Mar 22, 2026
Copilot AI changed the title [WIP] Add S3 adapter for elastickv with extended transaction support fix: bound cleanup goroutines, fix retry off-by-one, log dispatch errors in S3 adapter Mar 22, 2026
Copilot AI requested a review from bootjp March 22, 2026 16:04
@bootjp
Copy link
Owner

bootjp commented Mar 22, 2026

@copilot fix golangci-lint

Copy link
Contributor Author

Copilot AI commented Mar 22, 2026

@copilot fix golangci-lint

Fixed in commit 52cf0ec. The cyclop linter reported cleanupManifestBlobs had complexity 11 (max 10). Extracted the per-part chunk key building into a new appendPartBlobKeys helper method, which reduces the complexity of cleanupManifestBlobs to within the limit. golangci-lint run ./adapter/... now reports 0 issues.

@bootjp bootjp marked this pull request as ready for review March 22, 2026 17:02
@bootjp bootjp merged commit dd673c0 into feature/s3-impl Mar 22, 2026
4 checks passed
@bootjp bootjp deleted the copilot/sub-pr-396 branch March 22, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants