Skip to content

fix(backup): use logical file sizes for MinIO stream copies on 4.2-dev - #32080

Merged
XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
LeftHandCold:fix/4.2-backup-minio-known-size
Nov 4, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
LeftHandCold:fix/4.2-backup-minio-known-size

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Nov 3, 2026 •

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 #32077

Main companion: #32079. Validated source commit: c2fb54e6eecb4e5e7db711df413df29abd2fcecc.

Review requested, not a merge request: publish for review with the performance tradeoff below disclosed. Do not merge or enable auto-merge pending that review.

What this PR does / why we need it:

4.2-dev has the same backup/MinIO integration inefficiency as main: stream copies pass Size=-1 even for immutable source files with an available logical length. MinIO's unknown-length path allocates a 528 MiB multipart buffer per active upload, including tiny metadata files. This is allocation amplification, not a proven permanent leak.

This is the equivalent narrow main fix, adapted to 4.2-dev's existing backup tests and retention code:

  • Opt in only for physical backup destinations explicitly configured with is_minio=true.
  • Keep provider-side copying first, including the independent destination-checksum retry. Stat only after it declines server-side copying, before opening the source GET.
  • Pass FileService's logical source length to the existing upload SDK. CRC-framed local files and subpaths must not use their raw on-disk length.
  • Reject truncated/extended sources. Withhold the last byte until source EOF is confirmed, so a downstream LimitReader/ReadFull cannot report success for an underestimated length; explicitly validate empty sources.
  • Propagate an immutable private backup policy through data, checkpoint, GC metadata and table-ID-history copying. Incremental NeedCopy=false files stay untouched.
  • Preserve public copy defaults for datasync and non-MinIO callers; preserve provider-copy behavior, backup selection/retention, formats, worker counts, TN and GC. No SDK or FileService implementation changes.

Validation

Server 50, Linux amd64, 4.2-dev base 10d204b8763f19b2b37ba2147d1d4c1a7828d6d4, Go 1.26.4 and matching native artifacts:

  • Complete pkg/backup package, including existing 4.2-specific history/retention/restore tests and new size/configuration/error-boundary tests.
  • pkg/datasync TestCopyFile, preserving the public caller contract.
  • golangci-lint 2.6.2 (Go 1.26.4) for pkg/backup: 0 issues.
  • Real MinIO 0/1/31-byte, 64 MiB minus/at/plus-one and 128 MiB copies; checksum verification and rejection of small/multipart size mismatches without publishing the invalid target.
  • Actual execBackup plus fresh-directory TAE restore: 300 rows, 13 columns, complete restored row multisets match with both old and fixed paths.
  • Real 15 x 128 MiB parallel copy using the production size policy, not an injected-size adapter: all checksums match, 15 active upload buffers are 16 MiB each (240 MiB total), observed process peak RSS about 367 MiB.
  • The small complete backup's cumulative allocation fell from approximately 20.15 GiB to 36.54 MiB in this pair. These are cumulative allocations, not simultaneous RSS.

No full CN/TN/Proxy deployment or mo-backup CLI incremental-chain acceptance is claimed. The real backup fixture validates the kernel copy/restore boundary; unchanged incremental selection and newly added skip assertions are covered by package tests.

Performance Tradeoff / Hold Before Merge

An actual streamed file gains a source Stat/HEAD. For 128 MiB objects the existing SDK uses 8 parts instead of 1, so fifteen files issue 120 rather than 15 part requests. File concurrency is unchanged. This 4.2 copy run completed in about 100.5 s during substantial shared-host I/O pressure; it is not a controlled timing comparison or a speedup claim.

The equivalent main patch was measured with a smaller real-TAE foreground-read ABBA test: two concurrent 128 MiB backup files, real MinIO and 80 ms per-part response delay. QPS improved from 5.93/5.71 to 6.13/6.19 and P99 from 908/971 ms to 321/244 ms, but P95 rose from 165/166 ms to 249/225 ms. This is not a 4.2-specific benchmark or proof of zero business interference. The fifteen-worker mixed test did not finish the comparison within budget and is not counted as a pass.

The user explicitly accepted publishing the minimal patch for review with this risk, not merging it. Shared-storage latency must be assessed before rollout; do not raise backup concurrency because the buffer allocation falls. Source objects retain their existing immutability assumption; the new reader does not detect same-length overwrites.

@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 →

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

Fixed the SCA failure in 836c4ef, matching the main-branch fix in #32079. Makefile err-check rejected errors.New in production code; it now uses moerr.NewInternalErrorNoCtx. Existing overlong-source tests assert the MO error code and non-retryability. No successful-copy path, buffer size, concurrency, or other SDK behavior changes.

Validation on server 50: repository-wide make err-check; focused BackupSizeReader/SizedCopy/MinioSizePolicy tests; full pkg/backup tests; golangci-lint 2.6.2 on pkg/backup; go vet with the branch-pinned molint on pkg/backup. All passed. git diff --check also passed.

The previous run also had a separate BVT failure, which blocked coverage aggregation. This SCA-only update does not claim to resolve that failure or make the whole CI green. The new CI must finish. The PR remains for review only, with the existing performance-validation caveat unchanged; do not merge based on this update alone.

@XuPeng-SH

XuPeng-SH commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 836c4efa8d6e3ed0391e22523a14c934a898e5e0

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 836c4efa8d6e3ed0391e22523a14c934a898e5e0

Assessment: approve

Approve the complete 4.2-dev integration. It reuses logical StatFile and the pinned MinIO SDK's size-aware uploads. The constant-space EOF guard is necessary behind existing length-limited readers and avoids another buffering mechanism. The immutable copier policy reaches data, checkpoint, GC and table-ID-history paths while preserving public defaults, provider-copy behavior, retention and backup formats. Source/error/cleanup analysis and branch-specific tests close the affected paths. Extra source stats and multipart requests are explicit costs of the memory tradeoff; approval does not claim improved foreground latency. The discussion's MO error-class correction is supported by current source, assertions and frozen CI.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Preflight and frozen-range git diff --check passed. The assigned source and diagnostic validation clone remained clean at 836c4ef; preflight.log, diff-check.log and their command/source/exit receipts are retained.

  • Fresh repository make -j4 cgo succeeded for this release branch. native-build.log and native-inputs.json retain the build receipt, exact native input trees, Go 1.26.4 environment and 44 native-file hashes. No incompatible main-branch native artifacts or another job's Go caches were reused.

  • Full ./pkg/backup passed with Go 1.26.4 through repository mo-cgo-test and this member's test-exec, -mod=readonly -json -count=1 -timeout=360s: 69 top-level tests, 214 including subtests, no skips/failures, 120.579 seconds. The four new size-policy/reader/copy/logical-size tests and inherited-GC history, snapshot retention, fresh-WAL restore and table-ID-history cases passed. Evidence: backup-normal.jsonl, backup-normal.stderr.log, backup-normal.exit and checks/1793706423748040380-3.json.

  • Datasync TestCopyFile and TestCopyFiles passed through the same build/runtime owners: two top-level tests, five including subtests, no skips/failures, 0.154 seconds. Evidence: datasync-copy.jsonl, datasync-copy.stderr.log, datasync-copy.exit and checks/1793706645773369323-3.json.

  • The retained sdk-part-size.go probe passed against pinned minio-go/v7 v7.0.99: unknown size selects 528 MiB parts; known 128 MiB selects eight 16 MiB parts. Evidence: sdk-part-size.log and checks/1793706264992867019-3.json. This verifies SDK sizing, not measured RSS or latency.

  • validation-audit.json/log/exit match eight setup/product checks to successful receipts and retained logs, verify clean source fingerprints and assigned caches, reverify all 44 native hashes, and confirm all three discussion keys are covered exactly once in discussion-assessment.json. The audit itself also has a successful check-run receipt. Frozen evidence reports successful applicable UT/build/SCA/BVT checks; skipped jobs were not counted as passes, and no CI was rerun.

Limitations:

  • Real-MinIO boundary uploads, invalid-length publication rejection, fresh end-to-end restore and allocation/RSS results are author-reported in the supplied PR/linked issue evidence; their raw artifacts were not supplied locally. Local validation used package tests and the SDK probe, without a full CN/TN/Proxy deployment or mo-backup CLI incremental-chain acceptance run.

  • The supplied 4.2 copy timing is not a controlled baseline/candidate latency comparison. Main-branch foreground results include increased P95 and incomplete maximum-concurrency validation and do not establish 4.2 latency acceptance. The additional per-stream stat and smaller multipart requests remain explicit costs; no throughput, foreground-latency or whole-process memory guarantee is inferred.

  • The existing immutable backup-source assumption remains applicable; same-length concurrent source replacement is outside this size/EOF guard's protection.

This branch was successfully deployed

No deployments
ci — 536c5e63 Deployed Nov 4, 2026 by XuPeng-SH
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 kind/enhancement size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants