Repository navigation
fix: bounded retry for TransferPage write to prevent DN OOM under IO faults - #24337
mergify[bot] merged 8 commits into
Conversation
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
Under IOChaos filesystem error injection, WriteTransferPage fails silently and still sets invalid paths on pages, while the flusher keeps scheduling new flushes — causing an allocation storm that OOMs DN in 2 minutes. Changes: - WriteTransferPage now retries up to 3 times with exponential backoff (100ms, 200ms, 400ms) before giving up - WriteTransferPage returns an error; paths are only set on pages when the write actually succeeds - Callers (flushTableTail, mergeObjects) log the failure but still keep pages in-memory so transfers continue to work without disk persistence - Added unit tests with mock FS to verify retry behavior Fixes matrixorigin#24334 Co-Authored-By: Claude Opus 4.6 <[email protected]>
87ff9e9 to
3d30f62
Compare
Co-Authored-By: Claude Opus 4.6 <[email protected]>
aunjgr
left a comment
There was a problem hiding this comment.
Direction is right — unbounded silent-failure retries were indeed the OOM vector — but the implementation has blockers.
Blocking
1. Doesn't compile against current main. The PR was authored against an older tree. On current main (pkg/vm/engine/tae/model/pages.go:427,450):
AddTransferPage(page, ioVector, bufs)takes 3 argsWriteTransferPage(ctx, fs, pages, ioVector, bufs)takes 5 args and callsReleaseMarshalBufs(bufs)on its exit path
The PR's diff reverts to the older 2-arg / 4-arg signatures and drops the ReleaseMarshalBufs call. On rebase this means either the build breaks, or you reintroduce the pooled-buffer leak that was fixed upstream. Please rebase onto current main and preserve the bufs plumbing — including calling ReleaseMarshalBufs on every exit path of the new retry loop (success, exhausted, context-cancelled).
2. time.Sleep in the retry loop ignores context cancellation. On shutdown, ctx.Done() fires but the goroutine sleeps up to 400ms per attempt then re-enters fs.Write with a fresh 5s timeout. Replace with:
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(transferPageWriteBaseWait << attempt):
}3. PR description's worst-case delay is wrong. "3 attempts, 100/200/400ms" understates it. Real ceiling per call is 3 × 5s (fs.Write timeout) + 100ms + 200ms ≈ 15.3s. This runs on the commit pipeline (flushTableTail.go:PrepareCommit, mergeobjects.go:PrepareCommit), so under sustained IO faults commits stall for ~15s per batch. Worth stating plainly — 15s is still better than the 93GB storm, but the PR body should not advertise "700ms".
Correctness concern (not blocking, but worth addressing)
4. In-memory fallback has a data-loss window, not a memory leak. TransferTable.TTL() fires every 5s (pages.go:175-184) and clearMemory nils the hashmap even when path.Name == "". Readers after t+5s get ok=false from loadTable (pages.go:355-357). The pre-PR code had a bornTS += 1min hack to delay eviction; the new code drops it and flushTableTail.go:176-181 unconditionally stomps bornTS to now anyway. So under persistent IO faults, memory is bounded (good) but transfer lookups silently return empty from t+5s onward. Worth either preserving the bornTS extension on write failure, or documenting the 5s post-failure correctness window.
Test gaps
5. pages_test.go covers all-retries-fail, success-after-retry, success-first-try. Missing:
- Mid-retry context cancellation (would catch finding #2 above).
- Reader-side behavior after write failure — assert
Transfer()withpath.Name==""returnsok=falsewithout panicking through the hashmap-cleared path. - Consider parameterizing
transferPageWriteBaseWaitso tests don't eat 300ms of real sleeps.
Error propagation
addTransferPages/prepareTransferPage log the error and return nil, continuing the commit. Intentional ("graceful degradation"), fine — but make sure no downstream metric/log claims persistence success. Spot-checked nothing does, but worth a glance.
Please address #1–#3 before merge; #4–#5 are strong requests, not blockers.
…ory TTL 1. Replace time.Sleep with select on ctx.Done() so shutdown/cancellation is respected during retry backoff (review #2). 2. When WriteTransferPage fails, extend page bornTS by (diskTTL - ttl) so the in-memory hashmap survives ~5 minutes instead of being evicted after 5s by the TTL sweeper. This preserves transfer correctness for the full diskTTL window under sustained IO faults (review #4). 3. Add test for context cancellation mid-retry. 4. Add test for Transfer() behavior after hashmap eviction with no path set. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
LGTM on the current head (41004b2). All blocking items from my earlier review are addressed:
- FileAlreadyExists → treated as success (lines 424-436), paths set correctly.
- Retry amplification in mergeobjects →
writeFailedflag (line 121) fail-fasts the remaining dropped objects after first failure. Exactly what was suggested. - Stale bornTS dance → now uses
writeErr != nil/writeFailedto conditionally extend bornTS bydiskTTL - TTL, giving in-memory pages survival time. - Shift-backoff comment → present at line 397-398.
- Retry metrics →
transfer_page_write_retry_total{succeeded|exhausted}counter registered and incremented at the right spots.
Also verified aunjgr's blockers are resolved:
- Context-aware backoff (select on ctx.Done vs time.After) at lines 441-445.
TestWriteTransferPage_ContextCancellationcovers early exit.TestWriteTransferPage_FileAlreadyExistsOnRetryand_OnFirstAttemptcover that edge.- bornTS extension under write failure keeps pages alive for the full diskTTL window.
CI all green. The fix correctly bounds the retry-storm OOM vector while preserving in-memory fallback correctness during sustained IO faults.
Merge Queue Status
This pull request spent 1 hour 38 minutes 44 seconds in the queue, including 55 minutes 17 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) does this PR fix or relate to?
Fixes #24334
What this PR does / why we need it:
Under IOChaos filesystem error injection, WriteTransferPage fails silently and still sets invalid paths on pages. The flusher keeps scheduling new flush tasks causing a 93 GB cumulative allocation storm that OOMs DN in 2 minutes.
Changes: