You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(backup): close manifest summary writer before rename - #9885
CreateManifestSummary deferred w.Close() until after h.Rename(tmp, summary). On S3 the writer is a pipe to a background upload and the object only exists once Close() returns, so Rename copied the previous backup's manifest_summary_tmp.json. That left manifest_summary.json one backup behind manifest.json. On the first backup into a new directory the copy retried 100 times and failed with "The specified key does not exist". The file backend writes synchronously and wasn't affected.
The fix closes the writer and checks the error before Rename, the same way CreateManifest does. The writer is also closed on an encode error.
Test
Added TestCreateManifestSummary_DeferredUpload in worker/backup_manifest_test.go. It uses a handler whose CreateFile only writes the file on Close(), like the S3 upload. It runs two summaries back to back, then checks the first succeeds into an empty directory and the second publishes its own state. The test fails without the fix and passes with it. I ran the TestCreateManifestSummary and TestListBackupManifests tests in worker; I haven't run it against MinIO or real S3, and trunk check wasn't run.
No actionable comments were generated in the recent review.
Walkthrough
CreateManifestSummary now closes the summary writer before renaming the temporary file. A new regression test uses a deferred-write handler to verify that the second summary is published and the temporary file is removed.
Changes: Manifest summary publication
Layer / File(s)
Summary
Close summary before rename worker/backup_manifest.go, worker/backup_manifest_test.go
CreateManifestSummary closes the writer after encoding and renames the temporary file only after a successful close. The regression test verifies that the second summary is published and that no temporary summary file remains.
dgraph-io/dgraph#9874: Both PRs close the summary writer before rename. PR #9874 also updates dependencies and migrates Docker and metrics APIs.
Suggested labels:area/core, area/testing, go
Suggested reviewers:shiva-istari
Merge Risk: Minimal · up to 35dae
This change makes the backup manifest summary publish correctly on S3-style storage by closing the writer before the rename. No concrete merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: CreateManifestSummary now closes the manifest summary writer before the rename. The raw summary confirms the signature change, the close-before-rename ordering, and th…
Linked Issues check
[#9884] At head 35daedc, CreateManifestSummary in worker/backup_manifest.go no longer defers w.Close(). On encode failure it calls w.Close() (error ignored) and returns the encode error. On su…
Out of Scope Changes check
[#9884] All changed hunks relate to the reported defect. The CreateManifestSummary change removes the deferred close and adds the explicit close and error check. The signature change from named `ret…
Full details: Title check
Explanation
The title names the main change: CreateManifestSummary now closes the manifest summary writer before the rename. The raw summary confirms the signature change, the close-before-rename ordering, and the new test. The title is specific and matches the linked issue's objective.
Full details: Linked Issues check
Explanation
[#9884] At head 35daedc, CreateManifestSummary in worker/backup_manifest.go no longer defers w.Close(). On encode failure it calls w.Close() (error ignored) and returns the encode error. On success it calls w.Close(), wraps and returns any close error, and only then calls h.Rename. This matches the CreateManifest pattern the issue requests. The deferred-upload regression test TestCreateManifestSummary_DeferredUpload in worker/backup_manifest_test.go covers the first summary into an empty directory and the second summary publishing its own state. The MinIO system test in systest/backup/minio/backup_test.go checks that manifest_summary.json has the expected entry count and that manifest_summary_tmp.json is absent. The S3 CopyObject path is not exercised by unit tests and was not run against MinIO or S3 in this review. The issue's open question about whether the first-backup error fails the backup in worker/backup.go was not changed by this PR and is not a coding requirement here.
Full details: Out of Scope Changes check
Explanation
[#9884] All changed hunks relate to the reported defect. The CreateManifestSummary change removes the deferred close and adds the explicit close and error check. The signature change from named retErr to error follows from removing the deferred close. The unit test uses a deferred-upload fake handler to reproduce the S3 behavior. The systest addition validates summary contents and tmp-file removal after each backup, which the issue's fix depends on. No unrelated code changes were found in the reviewed diffs.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
golangci-lint (2.15.0)
level=error msg="[linters_context] typechecking error: build constraints exclude all Go files in /systest/backup/minio"
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 25e9d744-a229-408b-8f56-4d965bf58bee
Commits
Reviewing files that changed from the base of the PR and between e492894 and 35daedc.
Files selected for processing: 1
systest/backup/minio/backup_test.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
CreateManifestSummary deferred w.Close() until after h.Rename(). On S3 the
writer is a pipe to a background upload, so the object only exists once
Close returns. Rename copied the previous backup's temporary file, leaving
manifest_summary.json one backup behind. On the first backup into a new
directory the copy failed with "The specified key does not exist".
Close and check the error before Rename, as CreateManifest already does.
Add a regression test with a handler that only materializes the file on
Close.
Fixes#9884
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
After each backup, check that manifest_summary.json exists in the bucket with
the same number of entries as manifest.json and that manifest_summary_tmp.json
was removed. Covers the S3 CopyObject path that the fake-handler unit test
cannot exercise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9884.
CreateManifestSummarydeferredw.Close()until afterh.Rename(tmp, summary). On S3 the writer is a pipe to a background upload and the object only exists onceClose()returns, soRenamecopied the previous backup'smanifest_summary_tmp.json. That leftmanifest_summary.jsonone backup behindmanifest.json. On the first backup into a new directory the copy retried 100 times and failed with "The specified key does not exist". The file backend writes synchronously and wasn't affected.The fix closes the writer and checks the error before
Rename, the same wayCreateManifestdoes. The writer is also closed on an encode error.Test
Added
TestCreateManifestSummary_DeferredUploadinworker/backup_manifest_test.go. It uses a handler whoseCreateFileonly writes the file onClose(), like the S3 upload. It runs two summaries back to back, then checks the first succeeds into an empty directory and the second publishes its own state. The test fails without the fix and passes with it. I ran theTestCreateManifestSummaryandTestListBackupManifeststests inworker; I haven't run it against MinIO or real S3, andtrunk checkwasn't run.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit
Bug Fixes
Tests