Skip to content

fix: retry for backup object event - #1229

Merged
ferhatelmas merged 2 commits into
masterfrom
ferhat/backup-object
Sep 25, 2026
Merged

ferhatelmas merged 2 commits into
masterfrom
ferhat/backup-object

Conversation

@ferhatelmas

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Backup object handler doesn't throw error so failure doesn't retry.
There are some typos in logs fields.

What is the new behavior?

Rethrow the error so queue can retry (count 5 can work).
Fix typos.

Additional context

We should extend logSchema.error to extend EventLog and cut duplication between error and success but it's for another PR.

Copilot AI review requested due to automatic review settings July 14, 2026 14:20
@ferhatelmas
ferhatelmas requested a review from a team as a code owner July 14, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the backup-object queue handler so that failures propagate (allowing pg-boss retries to occur as configured), and corrects typos in structured log fields used by several event handlers.

Changes:

  • Fix structured logging field typo (jodId → jobId) across multiple event handlers.
  • Correct the event value for BackupObjectEvent error logs and rethrow errors to enable retries (retryLimit: 5).
  • Add a unit test to ensure backup failures reject and the DB connection is disposed.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/storage/events/objects/object-admin-delete.ts Fixes log field typo to use jobId.
src/storage/events/objects/object-admin-delete-all-before.ts Fixes log field typo to use jobId.
src/storage/events/objects/backup-object.ts Fixes error log fields and rethrows on failure so the queue can retry.
src/storage/events/objects/backup-object.test.ts Adds coverage for failure rethrow + connection disposal behavior.
src/storage/events/lifecycle/webhook.ts Fixes log field typo to use jobId.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/storage/events/objects/backup-object.test.ts Outdated
@coveralls

coveralls commented Jul 14, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 36020182684

Coverage increased (+0.03%) to 83.665%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 22 of 22 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14248
Covered Lines: 12348
Line Coverage: 86.66%
Relevant Branches: 8727
Covered Branches: 6874
Branch Coverage: 78.77%
Branches in Coverage %: Yes
Coverage Strength: 769.5 hits per line

💛 - Coveralls

@ferhatelmas
ferhatelmas force-pushed the ferhat/backup-object branch from aa2f1dd to 44f02e3 Compare July 14, 2026 14:44
@ferhatelmas

Copy link
Copy Markdown
Member Author

@claude review always

Comment thread src/storage/events/objects/backup-object.ts Outdated

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no new issues

No new issues were found in this update; 1 finding from earlier reviews is still open above.

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve — the new job.id !== SYNC_JOB_ID guard in backup-object.ts, added in the latest commit, directly addresses the earlier finding that the unconditional rethrow could abort the whole admin orphan-cleanup sweep when BackupObjectEvent.handle is invoked synchronously (via batchSend/send with pgQueueEnable false), and it's now covered by a dedicated test ("logs synchronous backup failures and completes without deleting the source").
Reviewed: the idempotent backup/retry logic in backup-object.ts (NoSuchKey/404 handling, headObject confirmMissing check distinguishing already-backed-up vs. both-missing), the sync-vs-async job id plumbing in queue/event.ts and constants.ts, and the jodId→jobId log-field typo fixes in webhook.ts and the object-admin-delete files.

Extended reasoning...

The diff makes S3 object backup/delete idempotent and retry-safe (backup-object.ts), introduces a shared SYNC_JOB_ID sentinel to distinguish synchronous invocations from queued pg-boss jobs (queue/event.ts, constants.ts), and fixes a log field typo in three unrelated files; none of this touches auth, crypto, or permissions. My prior inline finding (from an earlier run) was that the unconditional rethrow could break ObjectScanner's admin orphan sweep, which calls handle() synchronously in a Promise.all batch with no per-item isolation; the latest commit (1697636) adds the SYNC_JOB_ID check that skips rethrowing exactly in that synchronous path, with a new unit test verifying the behavior. The change is now well covered by a 211-line test file exercising the new retry/idempotency branches, two independent human reviewers already approved on earlier revisions, and no outstanding third-party objections remain unaddressed.

@ferhatelmas
ferhatelmas merged commit 70a1aab into master Sep 25, 2026
36 of 37 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/backup-object branch September 25, 2026 09:21
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.

5 participants