SEZ9 commented on PR #13433: URL: https://github.com/apache/seatunnel/pull/13433#issuecomment-7149515419
Thanks for this review — Issue 1 is correct and it matters, so let me start there. **You're right that I cannot reach the mechanism I wrote down, and neither can I.** I re-traced it against your argument instead of defending the PR, and everything you said holds: - `preApplyResourcesForAll` iterates `physicalPlan.getPipelineList()`, so the whole-job pre-apply installs **every** pipeline's task group keys. - There are only two entry points: `CoordinatorService:440` (whole job) and `SubPlan:882` (one restoring pipeline). - Keys are stable and nothing removes entries. I also checked the one path you didn't mention, because if it existed it would have rescued my claim: a job restored after a master switch. It does not — `restoreJobFromMasterActiveSwitch` puts the job into `pendingJobQueue`, so it reaches `pendingJobSchedule()` and `jobMaster.preApplyResources()` like any other, and the map is fully populated before `run()`. So there is no path on which the restore-time `putAll` inserts a key. A `HashMap` replacing a value on an existing key does not insert or resize. It cannot drop an entry or expose a half-resized table. My Javadoc stated that as fact and it was wrong. ### What I changed **`Closes #13351` → a plain reference.** I've edited the description. I can't demonstrate the issue's stated symptom, so auto-closing it would bury a bug whose cause is still unknown. I have no reproduction, log or stack trace to offer — the PR came from reading the code, and your reading of it is better than mine was. **The Javadoc now states the hazard I can actually defend.** Replacing a value in an unsynchronized `HashMap` still gives a reader on another thread no happens-before relationship, so `ResourceUtils` can observe the future a restore has already replaced — and that stale future carries the slot profile the restore just released through `releasePipelineResource`. That is a visibility problem, not a structural one, and it is the honest reason to keep the change. I'd rather have it described narrowly and correctly than oversold. **Issue 2 is fixed here, and I think it's the better find.** `historyExecutionAddress` really does insert — `JobMaster:182` is a plain `HashSet`, every restoring pipeline calls `add()` on it at `:591` a few lines before the `putAll` I was protecting, a restore landing on a new worker adds a new element, and `DAGUtils` reads it through the Lombok getter while that happens. It is now `ConcurrentHashMap.newKeySet()`. You identified the collection in that method that had the race I was claiming for the other one. **Issues 3 and 4: the test now models the engine's pattern.** It seeds the plan through `setPreApplyResourceFutures`, gives each pipeline its own id, has each of four pipelines replace only its own entries, runs a fifth thread copying the map the way `PendingDiagnosticsCollector` does, and asserts that no entry is added, dropped, or left stale (`assertSame` against each replacement future). ### Where I did not do what you suggested, and why You proposed extending `JobMasterMasterFailoverResourceTest` with two pipelines restoring concurrently as the regression test for #13351. I don't think that test can exist, and I'd rather say so than add one that looks like proof. Now that the mechanism is correctly identified as visibility rather than lost entries, a concurrent two-pipeline restore assertion — "every task group still has a non-null future" — **passes on the old `HashMap` too**, because the keys are pre-installed and nothing is lost. It would be a test that cannot fail, which is the same objection you raised about my original one, just relocated to a heavier harness. A JMM stale read is not deterministically observable, so I've stated in the test comment that it is not claimed as a regression test for the hazard, and said what it does guard: if a future change made restore *insert* keys, the structural hazard returns and the size assertion is the first thing to notice. I did run the existing `JobMasterMasterFailoverResourceTest` as the real regression guard for the type change. `testRestoreRejectsSlotReassignedWithinSameJob` errors with `SeaTunnelEngineRetryableException: Can not get coordinator service from an active master node.` — but it errors identically on unmodified `dev` on this machine, same test, same line 123, same exception, so it is a local environment problem rather than anything this PR did. The other two, including the one that drives `preApplyResources(subPlan)`, pass on both. ### Verification JDK 11.0.32 / Maven 3.8.4, `seatunnel-engine-server`: `PhysicalPlanPreApplyFuturesTest` 4 tests pass. `spotless:apply` applied. Head is `4a6332ad61`. If you'd still rather this PR were only the `historyExecutionAddress` fix, with the map left as a `HashMap` until someone can show the visibility read actually biting, say so and I'll cut it down — that would be a defensible call and I won't argue it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
