Repository navigation
fix(backup): use logical file sizes for MinIO stream copies - #32079
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Fixed the SCA failure in 280a554. The failing gate was Makefile err-check, which rejects errors.New in production code, before golangci-lint ran. The size-mismatch error now uses moerr.NewInternalErrorNoCtx. Existing boundary tests additionally assert the MO error code and that an overlong source is not retryable. 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.14.0 on pkg/backup; the branch-pinned molint check on pkg/backup. All passed. git diff --check also passed. This is scoped validation, not a claim that the new full CI has finished. The new CI is running. The previous review-only status and disclosed performance-validation caveat remain unchanged; this update does not authorize merging. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 280a554c5c10b13a0d6dd96ba85afe15e5772d36
Assessment: approve
The MinIO-only policy coherently reuses logical FileService sizes and existing SDK uploads while preserving public copy defaults and provider-copy retry behavior. The constant-space EOF guard closes the bounded-reader truncation risk; existing SDK byte counting cannot replace it. Data, checkpoint, GC and table-history paths carry the policy. No actionable correctness or design defect remains. Extra stat/part requests and the disclosed latency tradeoff are retained as scoped costs, without a production-performance claim.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Full pkg/backup passed at the frozen head: 64 top-level tests, 180 including subtests, no skips, -count=1; includes new size/error/policy tests and existing restore tests. Receipt checks/1793702385971151086-3.json; backup-normal.jsonl and backup-normal.stderr.log.
-
Datasync TestCopyFile and TestCopyFiles passed with -count=1 and the supplied test-exec; named output in datasync-copy.jsonl. Receipt and terminal exit reconciled in validation-audit.json.
-
Pinned minio-go/v7 v7.0.99 sizing probe passed: unknown length selects 528 MiB; 128 MiB selects eight 16 MiB parts. Receipt checks/1793702234178990290-3.json; sdk-part-size.go and sdk-part-size.log. This checks sizing, not workload latency.
-
Private-tmp/loopback preflight and frozen-range git diff --check passed. Native provenance matched current inputs; repository mo-cgo-test linked both test runs. validation-audit.json reconciles clean head fingerprints, receipts, exits, log hashes and all three discussion keys.
-
Frozen evidence reports successful current-head build, UT, SCA and applicable BVT checks. Skipped and neutral checks are excluded. Complete patch, linked issue and discussion reviewed.
Limitations:
-
Real-MinIO upload/restore experiments are author-reported; their raw artifacts were not included in local_validation. Local package tests and SDK sizing were reproduced independently.
-
Earlier memory and mixed-workload measurements predate main integration. The disclosed P95 increase and incomplete 15-worker foreground run remain limitations; production latency, full CN/TN/proxy deployment and CLI incremental-chain behavior were not independently validated.
🚫 Left the queue · pull request branch update failedLess than a minute in the queue, with no time running CI. So far
Reason The pull request can't be updated
To get back in the queue
Requeued — the merge queue status continues in this comment ↓. Times in UTC · dashboard · how the merge queue works |
🚫 Left the queue · pull request branch update failed49 min in the queue, with no time running CI. So far
Reason The pull request can't be updated
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
#32080) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] 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. --------- Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #32077
What this PR does / why we need it:
Physical backup stream copies currently pass
Size=-1for stat-able immutable files. The MinIO SDK chooses its worst-case unknown-length multipart buffer: 528 MiB per active upload, including tiny metadata files. This causes large live allocations and allocation churn; it is not a demonstrated permanent memory leak.This patch only opts in when the backup destination explicitly sets
is_minio=true:CopyObjectfirst and its independent destination-checksum retry. Only a declined provider copy reaches the changed stream fallback.os.Stat.CopyFile/CopyFileWithRetrydefaults used by datasync. Non-MinIO backups, ordinary business FileService writes, provider-copy success, TN/GC, file selection, backup formats and worker counts do not change.Validation
Linux amd64 validation on server 50, pinned main base
dd2499cdcdf2722848851d4debca6cd6c66b4751, with matching Go/native artifacts:LimitReader/ReadFull, cancellation/failure closure, provider-copy checksum retry, CRC/raw source sizes, incremental skip and default behavior.pkg/backuppackage tests.pkg/datasyncTestCopyFileand golangci-lint 2.14.0 forpkg/backup(0 issues).execBackup, 300 rows/13 columns, then a fresh-directory TAE restore: all columns and the complete row multiset match for both old and fixed paths. This is not a full CN/TN/Proxy deployment or a mo-backup CLI incremental-chain acceptance run.Tradeoffs And Review
The existing SDK now chooses 8 parts instead of 1 for a 128 MiB file: this pair issued 120 rather than 15 part requests, still with 15 file workers. Every streamed file also gains a source Stat/HEAD. The controlled copy pair completed in 11.52 s / 9.22 s; timing on this shared host does not establish a general speedup.
No global buffer tuning, pooling, extra background workers, backup-concurrency increase, filesystem/cache changes, or new upload algorithm. The policy is immutable during copying and each source reader retains the existing close owner. Same-length overwrites remain outside the pre-existing immutable-source assumption.
The high-concurrency foreground-read experiment did not complete its comparison within budget: the old path took about 206 s during substantial host I/O pressure. Its partial results are not counted as passing business-performance evidence. Shared-storage rollout still requires workload observation; this PR does not promise zero contention or a fixed total CN memory bound.
A smaller completed ABBA experiment used the same real MinIO, restored 300-row TAE table, two 128 MiB backup files, and 80 ms per-part response delay. Each foreground observation window was 8 s and performed real object-store GETs (17,940-20,670/window), with zero query errors:
QPS/P99 improved relative to the old path, but P95 increased. This is an explicit latency-distribution tradeoff, not a passed "no business-performance impact" claim. The completed mixed test has two backup workers, not fifteen; the separate fifteen-worker test establishes copying correctness and memory behavior only. No change is proposed to production concurrency.
Main advanced to
1876b2f93e14c03ba538e3806e245e3c3203979a(#32053, MinIO bounded-read changes) after the pinned validation base. Mergify synchronized it into this PR as387da6a1280b13e10936896f522d4ddb15f27555. A follow-up on 50 matched that integrated source and passed the complete backup package, real MinIO size/boundary/retry tests and fresh-directory 300-row/13-column TAE restore. The memory/foreground-performance numbers above remain from the earlier pinned source; performance was not rerun after this merge, and no production deployment is claimed.