Repository navigation
fix(jindo): remove duplicate send on MetadataSyncDoneCh in jindocache and jindofsx - #6298
neo0007777 wants to merge 1 commit into
Conversation
088c4fc to
dc85e48
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change removing duplicate metadata-sync result sends.
No open issues 🎉
What changed in this PR
Fixes #6297 by removing duplicate metadata-sync result sends in JindoCache and JindoFSx, preventing the second send from blocking indefinitely or panicking on a closed channel.
Changes:
- Retains a single guarded
SafeSendin both engines, matching the other runtime implementations. - Adds a shared regression-test helper to check channel initialization, cleanup, and closure without a duplicate result.
- Extends both engines’ tests to exercise synchronization starting with a nil result channel.
| File | Description |
|---|---|
pkg/utils/testutil/metadata_sync.go |
Adds shared checks for metadata-sync channel completion. |
pkg/ddc/jindofsx/metadata.go |
Removes the duplicate unguarded result send. |
pkg/ddc/jindofsx/metadata_test.go |
Adds regression coverage using the shared helper. |
pkg/ddc/jindocache/metadata.go |
Removes the duplicate unguarded result send. |
pkg/ddc/jindocache/metadata_test.go |
Adds regression coverage using the shared helper. |
Review effort: Balanced
cheyang
left a comment
There was a problem hiding this comment.
Two independent reviews of this fix for #6297, and both came back clean.
First, the premise is real: on the merge base, the bare resultChan <- result after base.SafeSend in syncMetadataInternal() leaks one goroutine per completed metadata sync in both jindocache and jindofsx — we each reproduced it with our own contract tests (a second value is observable on MetadataSyncDoneCh, goroutine count 3→4 and never returns, so the deferred SafeClose is starved). One nuance worth recording for posterity: the issue's other failure mode, a panic on send to a closed channel, is not actually reachable in these engines — nothing outside the sync goroutine ever closes the channel there — so the leak is the real story, and this PR removes both modes anyway.
On head, the contract holds: exactly one send, the channel gets closed, the goroutine exits, in both engines, under -race. The full suites for pkg/ddc/jindocache, pkg/ddc/jindofsx, pkg/ddc/base, and pkg/utils/testutil all pass, and the new regression tests provably bite — re-applying the deleted line, or grafting the PR's test onto the base code, turns them red. The diff is also the right shape: a one-line deletion per engine, matching the SafeSend-only pattern every other engine already follows. Required CI (DCO, SonarCloud) is green at this head.
No blocking findings from either reviewer; the only meaningful disagreement in the debate was over the git-history lineage of a dead commented-out line, not over the fix.
Next round
[MUST] (none — nothing gates merge from either review; all acceptance criteria pass and required CI is green at this head)
[SHOULD] optionally drop the dead resultChan <- result text at pkg/ddc/jindo/metadata.go:164 (inside a commented-out block — pre-existing, and per the corrected history it is not the origin of the live bug, just greppable residue worth removing); consider a follow-up issue to add the alluxio-style base.SafeClose(e.MetadataSyncDoneCh) to jindocache/jindofsx shutdown paths (pre-existing minor: a never-consumed sync still parks its sender goroutine, and the engine object with it, until process exit); optionally split the channel-lifecycle check into its own test function for cleaner failure attribution
[Filed] (no issues filed this round)
Reviewer C (Copilot) also reviewed this head and raised no findings.
Both verification harnesses — with raw results and a one-command re-verify.sh — live on the reviewer fork: verify/jindo-metadata-dup-send-claude and verify/jindo-metadata-dup-send-codex.
Non-blocking observations (4) — not part of this round's ask; fix now, follow up, or file an issue as you see fit
- pkg/ddc/jindocache/metadata.go:141 [minor] — pre-existing, not introduced by this PR — jindocache/jindofsx never close MetadataSyncDoneCh on engine shutdown (pre-existing)
Unlike alluxio (pkg/ddc/alluxio/shutdown.go:52-53) and vineyard (pkg/ddc/vineyard/shut_down.go:39-40), the jindocache and jindofsx engines never close MetadataSyncDoneCh on engine shutdown. This PR fixes the per-completed-sync goroutine leak, but if a sync result is never consumed (dataset removed mid-sync, runtime.Spec.Master.Disabled flipped, or UfsTotal set through another path while a sync is in flight), the sender goroutine stays parked inside base.SafeSend until process exit — and, because its closure captures the engine, it pins the entire JindoCacheEngine/JindoFSxEngine object (client, runtime, log) for process lifetime. Pre-existing, not introduced by this PR; suggest a follow-up issue adding base.SafeClose(e.MetadataSyncDoneCh) to both engines' shutdown paths, matching the alluxio pattern. Same in pkg/ddc/jindofsx/metadata.go:141. - pkg/ddc/jindocache/metadata.go:178 [nit] — Issue/PR overstate the panic-on-closed-channel mechanism
The issue #6297 / PR body claim that the duplicate send 'panicked with send on closed channel if the channel had already been closed' is not reachable in jindocache/jindofsx: nothing outside the sync goroutine ever closes MetadataSyncDoneCh in those engines. The real, reproduced defect is the goroutine leak, which this PR fixes. Purely an accuracy note so future debugging of this code does not chase an unreachable panic path; the fix is correct regardless. - pkg/ddc/jindo/metadata.go:164 [nit] — pre-existing, not introduced by this PR — Leftover duplicate-send line inside commented-out block in jindo engine
pkg/ddc/jindo/metadata.go:164 still contains 'resultChan <- result' inside a /* ... */ commented-out block (the disabled LoadMetadataWithoutTimeout early-return path, roughly lines 154-166). It is dead text but greppable residue of exactly the footgun this PR fixes; deleting it would prevent a future copy-paste reintroduction. Pre-existing, strictly optional. Note: this block is NOT the origin of the live bug — per git history, the duplicate was born in-place in jindofsx (#2536 added SafeSend above the existing bare send without deleting it, after #1801 created the file) and propagated to jindocache by #3346; the comment block was disabled earlier by #977. - pkg/ddc/jindocache/metadata_test.go:352 [nit] — Channel-lifecycle check appended as tail block inside TestSyncMetadataInternal
The new async-channel verification via testutil.VerifyMetadataSyncChannelClosedOnce(engines[1].syncMetadataInternal, ...) is appended as a tail block inside the existing table test TestSyncMetadataInternal, whose testCase list still only exercises engines[0]. A separate focused test function (e.g. TestSyncMetadataInternalChannelLifecycle) would make failures attributable at a glance instead of surfacing as a generic TestSyncMetadataInternal failure. Works correctly as-is (verified: the block fails on base code and passes on head, also under -race; engines[1] starts with MetadataSyncDoneCh: nil so the block takes the start-sync branch, and the accessor closure reads the same struct copy the method mutates — no aliasing hazard). Same shape in pkg/ddc/jindofsx/metadata_test.go:352.
Verified review delta
- F3-no-shutdown-close-metadata-channels: open (preexisting)
- F1-panic-claim-unreachable: open (initial-pr)
- F2-jindo-commented-dup-send: open (preexisting)
- F4-channel-lifecycle-test-structure: open (initial-pr)
Code: clear. CI: success; attribution: unknown. Required CI checks still apply.
… and jindofsx Signed-off-by: Shiva Sharma <shivaumj@gmail.com>
dc85e48 to
eb524f4
Compare
|
Thanks @cheyang for the thorough review! Updated the PR to address all four notes:
All unit tests and |
|



Ⅰ. Describe what this PR does
Removes the duplicate unguarded channel send
resultChan <- resultafterbase.SafeSend(resultChan, result)insyncMetadataInternal()for bothJindoCacheEngine(pkg/ddc/jindocache/metadata.go) andJindoFSxEngine(pkg/ddc/jindofsx/metadata.go), and drops the leftoverresultChan <- resultinside the disabled comment block inpkg/ddc/jindo/metadata.go.Previously, because
MetadataSyncDoneChis unbuffered and the receiver reads at most once before settinge.MetadataSyncDoneCh = nil, the second send blocked the goroutine forever on every completed metadata sync, leaking a goroutine and bypassingdefer base.SafeClose(resultChan). Removing the duplicate send ensures each completed sync sends once viabase.SafeSend, closesresultChan, and exits cleanly.(Note: in
jindocacheandjindofsx, nothing outside the sync goroutine currently closesMetadataSyncDoneCh, so the goroutine leak is the reachable failure mode here; closingMetadataSyncDoneChon shutdown likealluxio/vineyardis tracked in #6308.)Ⅱ. Does this pull request fix one issue?
fixes #6297
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
VerifyMetadataSyncChannelClosedOnceinpkg/utils/testutil/metadata_sync.goTestSyncMetadataInternalChannelLifecycleinpkg/ddc/jindocache/metadata_test.goandpkg/ddc/jindofsx/metadata_test.goto verify that starting withMetadataSyncDoneCh == nilinitializes the channel, clears it on follow-up sync, and closes the channel cleanly without blocking on a duplicate send.Ⅳ. Describe how to verify it
Run the unit tests for
testutil,jindocache,jindofsx, andjindo:Ⅴ. Special notes for reviews
TestSyncMetadataInternalChannelLifecycleinto a dedicated test function in both engines.resultChan <- resultresidue inpkg/ddc/jindo/metadata.go.SafeSend-only pattern already used inalluxio,jindo,juicefs, andthin([BUGFIX] Support recovery from metadata sync channel panics #2536).