Skip to content

fix(backup): preserve GC metadata watermarks and sizes - #25972

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25935-25938-copy-gc-metadata
Jul 21, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25935-25938-copy-gc-metadata

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #25935
issue #25938

What this PR does / why we need it:

CopyGCDir violated two invariants while processing the same filtered GC
metadata set:

  1. It iterated over copyFiles but detected the last entry with
    len(metaFiles). If an earlier metadata file was filtered because one of
    its objects could not be copied, the last successfully retained metadata
    file did not inherit the checkpoint minimum timestamp.
  2. It recorded the GC metadata file's directory-entry size for every referenced
    data object. That incorrect value was serialized into tae_list and summed
    into tae_sum.

Use the filtered slice for the last-entry decision. After each successful data
object copy, stat the destination object and record its actual size; fail the
backup if the copied object's size cannot be established instead of emitting a
false manifest.

The regression fixture writes real GC metadata and objects through MemoryFS.
It covers filtering plus watermark inheritance, the per-object tae_list
field, and the aggregate tae_sum. This PR does not claim that object contents
were corrupted; the confirmed defects are the restored watermark invariant
and manifest accounting.

Validation:

  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/backup
  • go build ./pkg/backup (repository CGo environment)
  • go vet ./pkg/backup (repository CGo environment)

@LeftHandCold
LeftHandCold requested a review from XuPeng-SH as a code owner July 21, 2026 09:49
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@gouhongshen gouhongshen 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.

Codex automated review

No defects found. Existing reviews, issue comments, and inline threads contain no actionable feedback. Focused local tests could not start because cgo/libmo.dylib is absent; current PR CI is green.

@XuPeng-SH XuPeng-SH 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.

I checked this from correctness / robustness / unhappy-path angles and I did not find a blocker.

The two functional fixes both look right:

  • recording the copied object size from dstFs.StatFile(...) fixes the manifest accounting bug instead of reusing the .fullgc entry size for every referenced object;
  • comparing against len(copyFiles)-1 is the correct way to decide which retained GC metadata file should inherit the watermark when some earlier metadata files are skipped.

The new regression tests cover the two bugs being fixed.

Optional follow-up only: I would still like a few more unhappy-path unit tests in pkg/backup/tae_gc_test.go (for example StatFile failure after a successful copy, corrupt GC metadata, and the non-inheritance branch when end >= min), but I do not see that as a merge blocker for this patch.

@mergify mergify Bot added the queued label Jul 21, 2026
@mergify

mergify Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-21 11:06 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-21 14:15 UTC · at 04c2f4426f760edb7045113b664f1389549685b3

This pull request spent 3 hours 9 minutes 3 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

This pull request seems to come from a fork, and Mergify needs the author's permission to update its branch.
The author needs to enable "Allow edits from maintainers" on this pull request, or update the branch manually.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…25972)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25935
issue matrixorigin#25938

## What this PR does / why we need it:

`CopyGCDir` violated two invariants while processing the same filtered
GC
metadata set:

1. It iterated over `copyFiles` but detected the last entry with
`len(metaFiles)`. If an earlier metadata file was filtered because one
of
its objects could not be copied, the last successfully retained metadata
   file did not inherit the checkpoint minimum timestamp.
2. It recorded the GC metadata file's directory-entry size for every
referenced
data object. That incorrect value was serialized into `tae_list` and
summed
   into `tae_sum`.

Use the filtered slice for the last-entry decision. After each
successful data
object copy, stat the destination object and record its actual size;
fail the
backup if the copied object's size cannot be established instead of
emitting a
false manifest.

The regression fixture writes real GC metadata and objects through
MemoryFS.
It covers filtering plus watermark inheritance, the per-object
`tae_list`
field, and the aggregate `tae_sum`. This PR does not claim that object
contents
were corrupted; the confirmed defects are the restored watermark
invariant
and manifest accounting.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s
./pkg/backup`
- `go build ./pkg/backup` (repository CGo environment)
- `go vet ./pkg/backup` (repository CGo environment)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…25972)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25935
issue matrixorigin#25938

## What this PR does / why we need it:

`CopyGCDir` violated two invariants while processing the same filtered
GC
metadata set:

1. It iterated over `copyFiles` but detected the last entry with
`len(metaFiles)`. If an earlier metadata file was filtered because one
of
its objects could not be copied, the last successfully retained metadata
   file did not inherit the checkpoint minimum timestamp.
2. It recorded the GC metadata file's directory-entry size for every
referenced
data object. That incorrect value was serialized into `tae_list` and
summed
   into `tae_sum`.

Use the filtered slice for the last-entry decision. After each
successful data
object copy, stat the destination object and record its actual size;
fail the
backup if the copied object's size cannot be established instead of
emitting a
false manifest.

The regression fixture writes real GC metadata and objects through
MemoryFS.
It covers filtering plus watermark inheritance, the per-object
`tae_list`
field, and the aggregate `tae_sum`. This PR does not claim that object
contents
were corrupted; the confirmed defects are the restored watermark
invariant
and manifest accounting.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s
./pkg/backup`
- `go build ./pkg/backup` (repository CGo environment)
- `go vet ./pkg/backup` (repository CGo environment)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…25972)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25935
issue matrixorigin#25938

## What this PR does / why we need it:

`CopyGCDir` violated two invariants while processing the same filtered
GC
metadata set:

1. It iterated over `copyFiles` but detected the last entry with
`len(metaFiles)`. If an earlier metadata file was filtered because one
of
its objects could not be copied, the last successfully retained metadata
   file did not inherit the checkpoint minimum timestamp.
2. It recorded the GC metadata file's directory-entry size for every
referenced
data object. That incorrect value was serialized into `tae_list` and
summed
   into `tae_sum`.

Use the filtered slice for the last-entry decision. After each
successful data
object copy, stat the destination object and record its actual size;
fail the
backup if the copied object's size cannot be established instead of
emitting a
false manifest.

The regression fixture writes real GC metadata and objects through
MemoryFS.
It covers filtering plus watermark inheritance, the per-object
`tae_list`
field, and the aggregate `tae_sum`. This PR does not claim that object
contents
were corrupted; the confirmed defects are the restored watermark
invariant
and manifest accounting.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s
./pkg/backup`
- `go build ./pkg/backup` (repository CGo environment)
- `go vet ./pkg/backup` (repository CGo environment)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants