Skip to content

[Fix][Zeta] Restore legacy job status WAL entries - #11781

Merged
nzw921rx merged 16 commits into
apache:devfrom
zhangshenghang:fix-imap-legacy-job-status
Oct 21, 2026
Merged

nzw921rx merged 16 commits into
apache:devfrom
zhangshenghang:fix-imap-legacy-job-status

Conversation

@zhangshenghang

@zhangshenghang zhangshenghang commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Purpose

Fixes #9928.

Job status classes were moved from engine-core to engine-common, but file-backed IMap WAL records preserve their original class names. Restarting a newer SeaTunnel version therefore failed to load persisted job state from older versions.

Changes

  • Resolve legacy job model class names to their current engine-common locations before WAL deserialization.
  • Cover JobResult, JobStatus, and JobStatusData, which moved together.
  • Add a regression test that reads a WAL record carrying the legacy JobStatus class name.

Verification

  • ./mvnw -pl seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file -am -Dtest=WALReaderAndWriterTest -Dsurefire.failIfNoSpecifiedTests=false package
  • ./mvnw -q -DskipTests verify

Why the legacy WAL fixtures need no pre-#9689 capture

The relocated types kept identical field layout and enum ordinals before and after #9689 (JobStatus: the same 13 constants in the same order; JobResult: status, error; JobStatusData: jobId, jobName, jobStatus, submitTime, startTime, finishTime — same order and types). The only structural difference is the private static final long serialVersionUID added later by #11257, which ProtoStuffSerializer's RuntimeSchema skips as a static field, so it does not change the bytes. None of the three types has an Object-typed or abstract field, so no other class name is embedded in the value bytes; a frame written by a pre-#9689 release differs from the frame the current WALWriter produces only in the valueClassName string of IMapFileData, which the legacy tests set to the old names explicitly. A captured byte fixture would still be a welcome follow-up, but is not required to exercise the legacy path.

@github-actions github-actions Bot added the Zeta label Aug 12, 2026
zhangshenghang added 2 commits August 13, 2026 04:38
The Build check has been queued since the PR was opened; the fork's
ubuntu-latest runners are saturated by other queued jobs. Re-triggering
the workflow to give this PR another chance to pick up a runner.

No code changes; only the Build status is the goal.
Previous Build run has been queued since the PR was opened; the fork
runner pool is saturated. Cancelling and re-triggering the workflow
to give this PR another chance to pick up a runner.

No code changes.

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

What Problem Does This PR Solve?

  • User pain point: After the job-status model classes (JobResult, JobStatus, JobStatusData) were relocated from engine-core to engine-common in #9689, clusters running the file-backed IMap storage (imap-storage-file) that persist job state via WAL can no longer restart. On startup, Hazelcast's MapStoreWrapper.loadAll() reads pre-existing WAL records that still carry the old fully-qualified class name (org.apache.seatunnel.engine.core.job.JobStatus, etc.), Class.forName() throws ClassNotFoundException, and job-state recovery fails (reported in #9928, reproduced going 2.3.10 -> 2.3.12).
  • Fix approach: WALReader.deserializeData() now resolves the class name recorded in the WAL through a small static LEGACY_CLASS_NAME_MAPPINGS lookup table before calling ClassUtils.getClass(), transparently remapping the three moved classes to their current engine-common package while leaving every other class name untouched.
  • One-sentence summary: A minimal, backward-compatible class-name-resolution shim in WALReader that lets a newer SeaTunnel version keep reading job-status WAL entries written by pre-#9689 versions.

1. Code Change Review

1.1 Core Logic Analysis

Changed file: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/.../common/WALReader.java

Before:

private Object deserializeData(byte[] data, String className) {
    try {
        Class<?> clazz = ClassUtils.getClass(className);
        ...

After:

private Object deserializeData(byte[] data, String className) {
    try {
        Class<?> clazz = ClassUtils.getClass(resolveClassName(className));
        ...
private static String resolveClassName(String className) {
    return LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className);
}

Key findings

  1. I verified against the actual move commit (e7de54e4e7, PR #9689): git reports JobResult.java, JobStatus.java, JobStatusData.java as pure renamed files (1 addition / 1 deletion each — only the package line changed). Field layout is byte-for-byte identical between the old engine-core and new engine-common versions, so re-deserializing old WAL bytes with the new class via ProtoStuff is safe — no field-shift/schema-mismatch risk.
  2. The mapping table exactly matches the three classes that actually moved (confirmed via previous_filename on the rename diff) — nothing missing, nothing extra. seatunnel-engine-storage currently has only one IMap storage plugin (imap-storage-file), so there's no sibling implementation with the same bug that was left unfixed.
  3. deserializeData() is shared by both loadAllKeys() and loadAllData(), and is used for both key and value class-name resolution, so this fix also covers the (less likely but possible) case where a legacy job-status object was ever used as a map key.
  4. Nice design choice: the main code only manipulates class names as Strings (no compile-time reference to engine-common's JobResult/JobStatus/JobStatusData), so imap-storage-file's production classpath doesn't gain a new dependency — the engine-common dependency added in pom.xml is correctly scoped to test only, used exclusively by the new regression test.
  5. This only fixes the read path. The write path (IMapFileStorage.parseToIMapFileData) already uses value.getClass().getName(), so any record written (or rewritten via archive/compaction) by a post-fix JVM will naturally carry the new engine-common class name going forward — no double-mapping or write-side change was needed, and none was made.

Runtime path traced (from the actual production crash in #9928, confirmed against current dev):

Master node restart
  -> Hazelcast BasicRecordStoreLoader.loadAndGet()
  -> MapStoreWrapper.loadAll()
  -> FileMapStore.loadAll()  [seatunnel-engine-server/.../persistence/FileMapStore.java]
  -> IMapFileStorage.loadAll()  [IMapFileStorage.java:238]
  -> new WALReader(...).loadAllData(businessRootPath, ...)  [WALReader.java]
  -> deserializeData(data.getValue(), data.getValueClassName())  [WALReader.java:~130]
       -> resolveClassName("org.apache.seatunnel.engine.core.job.JobStatus")
            -> LEGACY_CLASS_NAME_MAPPINGS hit -> "org.apache.seatunnel.engine.common.job.JobStatus"
       -> ClassUtils.getClass(...) succeeds (previously threw ClassNotFoundException here)
       -> serializer.deserialize(data, JobStatus.class) -> JobStatus.RUNNING
  -> job status IMap successfully rehydrated, cluster startup proceeds

This is squarely on the normal/primary startup-recovery path for any cluster that persists job state to file-backed IMap storage and is being upgraded across the #9689 boundary — not an edge case. Before this fix it throws unconditionally for every legacy job-status record; after this fix it resolves transparently and falls through to the unchanged (and already-correct) code path for every other class name.

1.2 Compatibility Impact

Fully compatible. New/foward-format WAL entries are unaffected (map lookup misses -> className returned unchanged). Old-format entries written by any pre-#9689 SeaTunnel version now deserialize correctly instead of crashing. No public API, Option, or config surface is touched.

1.3 Performance / Side-Effect Analysis

Negligible: one extra HashMap.getOrDefault lookup per record read, against an immutable 3-entry map built once in a static initializer. No new I/O, no new locks, no change to the write path, no additional objects retained across calls. No retry/idempotency implications — deserialization is a pure function of the WAL bytes.

1.4 Error Handling and Logging

No new error paths introduced; the existing ClassNotFoundException -> IMapStorageException wrapping is preserved unchanged for genuinely unknown class names, which is correct — the fix intentionally narrows to the 3 known-moved classes rather than silently swallowing all ClassNotFoundExceptions.

  1. Location: WALReader.java:43 (the LEGACY_CLASS_NAME_MAPPINGS static field / static initializer block)
    Problem description: The field itself has no accompanying comment; only the resolveClassName() method below it is documented. A reader skimming the class won't immediately see why this table exists (i.e., that it's tied to the #9689 engine-core -> engine-common move and issue #9928) without reading the method doc further down.
    Potential risk: Low today, but this is exactly the kind of "one-time migration shim" that tends to get deleted by a future well-meaning cleanup once nobody remembers why it's there, silently reintroducing #9928 for anyone still upgrading from a pre-#9689 version.
    Best improvement: Add a short comment directly above the field (or the static block), e.g. "Legacy class names written by SeaTunnel versions before #9689 moved the job-status model to engine-common; keep in sync with any future job-model package moves. See #9928.0"
    Severity: Medium
    Raised by another reviewer: No

2. Code Quality Assessment

2.1 Coding Standards

Formatting and style are consistent with the surrounding file (AOSP/Google format). The one gap is the missing field-level comment on LEGACY_CLASS_NAME_MAPPINGS covered as Issue 1 above; resolveClassName() itself is properly documented with a Javadoc explaining purpose, parameter, and return value.

2.2 Test Coverage and Test Stability

The new test testReaderLoadsJobStatusWrittenWithLegacyClassName directly reproduces the #9928 scenario: it writes a WAL record with the hardcoded legacy value-class-name string (org.apache.seatunnel.engine.core.job.JobStatus) and asserts the reader returns a real engine-common JobStatus.RUNNING instance. This is exactly the right regression test — it fails on dev pre-fix (ClassNotFoundException) and passes post-fix.

Stability rating: Stable.
Evidence (WALReaderAndWriterTest.java):

  • Uses the same deterministic local-filesystem harness (FS, @BeforeAll/@AfterAll) as the pre-existing tests in this class — no Thread.sleep, no timing-dependent assertions, no shared mutable static state beyond the already-established FS/SERIALIZER fields reused across tests.
  • Uses its own dedicated path (LEGACY_JOB_STATUS_PATH = /tmp/imap-wal-legacy-job-status/) that doesn't collide with PARENT_PATH or SAME_TIMESTAMP_TOMBSTONE_PATH used by other tests in the same class, avoiding cross-test interference.
  • Resource is released in @AfterAll (FS.delete(LEGACY_JOB_STATUS_PATH, true)), matching the cleanup pattern of the other two paths.
  • Assertions are exact-value (assertEquals(JobStatus.class, ...), assertEquals(JobStatus.RUNNING.name(), ...)), not weak existence checks.

2.3 Documentation Updates

Not required — this is an internal bugfix in the WAL deserialization path with no user-facing config, CLI, or connector behavior change, so no docs/en/docs/zh update is expected.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix. It targets exactly the three classes that actually moved, verified against the real rename commit, and does so without adding any new compile-time coupling to engine-common in production code.

3.2 Maintainability

Good — the mapping table is small, centralized, and trivially extensible if another job-model class is relocated in the future. The only maintainability gap is the missing "why does this exist / when is it safe to remove" context noted in Issue 1, which would help whoever eventually has to decide whether this mapping can ever be dropped.

3.3 Extensibility

Adding a future legacy mapping is a one-line addition to the static block; no structural changes needed elsewhere.

3.4 Historical-Version Compatibility

This is the core value of the PR: it restores the ability to read WAL entries written by any SeaTunnel version prior to the #9689 engine-core -> engine-common move (confirmed to include at least 2.3.10, per #9928), without requiring operators to manually migrate or discard persisted job state during upgrade. I did not find any other job-model classes that moved in that same commit and were left unmapped.

4. Issue Summary

Number Issue Location Severity
1 LEGACY_CLASS_NAME_MAPPINGS static field lacks its own explanatory comment (why it exists / which issue it fixes) WALReader.java:43 Medium

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed
    • Issue 1 (Medium): add a short comment above LEGACY_CLASS_NAME_MAPPINGS explaining its purpose and linking back to #9928/#9689, so a future contributor doesn't remove it without understanding the upgrade-compatibility implications. This is a one-line change, not a functional concern.
  2. Recommended fixes — non-blocking
    • None beyond the above; the fix itself, the runtime-path tracing, and the regression test all check out.

Overall this is a well-scoped, low-risk fix for a real production upgrade-breaking bug, backed by a solid regression test and verified (by me, independently) against the actual rename commit to confirm the mapping is both complete and safe at the field-serialization level. Nice work — thank you for tracking this down to the exact three classes instead of a broader (and riskier) catch-all approach.

Note for visibility: at the time of this review the fork's CI run for this head commit was still queued and hadn't produced results yet, so I can't yet confirm a green CI run — will be worth a final check once it completes.

Explain why LEGACY_CLASS_NAME_MAPPINGS exists (the engine-core ->
engine-common job model move in apache#9689) and why removing it would break
upgrades that still have old WAL entries (apache#9928).

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

What Problem Does This PR Solve?

Re-verified from scratch against the current head (20d56e95). Unchanged from my last review: after PR #9689 relocated the job-status model classes (JobResult, JobStatus, JobStatusData) from seatunnel-engine-core to seatunnel-engine-common, any cluster using the file-backed IMap storage (imap-storage-file) to persist job state fails to restart, because WALReader.deserializeData() calls ClassUtils.getClass() with the class name literally recorded in old WAL entries (org.apache.seatunnel.engine.core.job.JobStatus), which no longer exists on the classpath. This is a real, reported production issue (#9928), reproduced going from 2.3.10 to 2.3.12, and I independently confirmed the exact reported stack trace (WALReader.deserializeData -> ClassNotFoundException: org.apache.seatunnel.engine.core.job.JobStatus) matches this code path on dev.

The fix adds a small static LEGACY_CLASS_NAME_MAPPINGS table and a resolveClassName() helper in WALReader.java so the three moved class names are transparently remapped to their current engine-common package before class resolution, leaving every other class name untouched.

What changed since my last review

My prior review (commit 18e347bea) flagged one Medium issue: LEGACY_CLASS_NAME_MAPPINGS had no field-level comment explaining why it exists, which risked a future well-meaning cleanup silently reintroducing #9928. The single new commit on this PR, 20d56e95 ("[Fix][Zeta] Document legacy WAL class name mappings"), adds exactly that — a Javadoc block directly above the field (WALReader.java:46-54) explaining the #9689 move, the #9928 crash it prevents, and explicitly warning that removing an entry breaks upgrades from releases that still wrote the old class name. That is precisely the fix I asked for, correctly scoped, and no other lines changed. I re-diffed dev...review-pr-11781 in full (not just the incremental commit) rather than trusting the delta alone, and the rest of the PR — resolveClassName(), the mapping table contents, the test-scoped engine-common pom.xml dependency, and the new regression test — is byte-for-byte what I reviewed before.

1. Code Change Review

1.1 Core Logic Analysis

WALReader.java:141-144:

private Object deserializeData(byte[] data, String className) {
    try {
        Class<?> clazz = ClassUtils.getClass(resolveClassName(className));

WALReader.java:160-166:

private static String resolveClassName(String className) {
    return LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className);
}

I re-verified the completeness/safety claims independently rather than re-using my prior conclusions verbatim:

  • Re-ran git show --stat e7de54e4e7 (the actual #9689 move commit): exactly 3 files are renamed with similarity index 95-98%, and the per-file diff (git show e7de54e4e7 -- '*JobStatus.java' '*JobResult.java' '*JobStatusData.java') shows only the package declaration line changed in each — field layout is byte-identical between old and new location, so re-deserializing legacy WAL bytes against the new class via the existing serializer is safe.
  • Re-ran git log --all --diff-filter=R -M --name-status -- 'seatunnel-engine/**' looking for any other core -> common job-model rename across the whole history, not just #9689: found none. The 3-entry mapping table is complete, not just for the reported bug but for every class that has ever moved.
  • Confirmed JobInfo (used by runningJobInfoIMap) never moved packages (git log --all --follow -- '**/JobInfo.java' shows no rename), so it's correctly out of scope for this table.
  • Confirmed the write path (IMapFileStorage.java:289-300, key.getClass().getName() / value.getClass().getName()) always serializes the current runtime class name, so records written by a post-fix JVM naturally carry the engine-common name going forward — no write-side change needed, and none was made.

Runtime path (re-traced against current dev, unchanged from before):

Master node restart
  -> Hazelcast BasicRecordStoreLoader.loadAndGet()
  -> MapStoreWrapper.loadAll()
  -> FileMapStore.loadAll()
  -> IMapFileStorage.loadAll()  [IMapFileStorage.java:238]
  -> WALReader.loadAllData()
  -> deserializeData(data, "org.apache.seatunnel.engine.core.job.JobStatus")
       -> resolveClassName(...) hits LEGACY_CLASS_NAME_MAPPINGS -> engine-common name
       -> ClassUtils.getClass(...) succeeds (previously threw ClassNotFoundException)
  -> job status IMap successfully rehydrated

This is the primary/normal startup-recovery path for any cluster upgrading across the #9689 boundary while persisting job state via file-backed IMap storage — not a rare edge case, and it fires unconditionally (100% of legacy job-status records) before the fix.

One clarification worth stating explicitly since it wasn't in my last review: before this fix, the ClassNotFoundException is wrapped as IMapStorageException and propagates up to Hazelcast's BasicRecordStoreLoader, which catches it and only logs a WARN ("Could not load keys from map store") rather than crashing cluster startup outright — visible in the #9928 report itself. That means the pre-fix failure mode is silent loss of persisted job state on restart, not a startup crash; the PR's practical effect is preventing that silent state loss. This is pre-existing Hazelcast-level exception handling, unrelated to and untouched by this diff — noted for completeness, not as an issue.

1.2 Compatibility Impact

Fully compatible, re-confirmed. New-format WAL entries are unaffected (map lookup misses, class name returned unchanged). Old-format entries from any pre-#9689 SeaTunnel version now deserialize correctly instead of crashing/silently dropping. No public API, Option, or config surface is touched. No incompatible-changes doc entry needed since this restores previously-broken backward compatibility rather than introducing a break.

1.3 Performance / Side-Effect Analysis

Unchanged from prior review: one HashMap.getOrDefault lookup per record read against an immutable 3-entry map built once in a static initializer. No new I/O, locks, or write-path change. No retry/idempotency concerns — deserialization is a pure function of the WAL bytes and class name.

1.4 Error Handling and Logging

The ClassNotFoundException -> IMapStorageException wrapping for genuinely unknown class names is preserved unchanged, which is correct — the fix intentionally narrows to the 3 known-moved classes rather than broadly swallowing all ClassNotFoundExceptions. No issues here in this or the prior round.

2. Code Quality Assessment

2.1 Coding Standards

Consistent with the surrounding file's style. The only gap noted last round (missing field-level rationale comment on LEGACY_CLASS_NAME_MAPPINGS) is now fixed at WALReader.java:45-54 with a proper multi-line Javadoc block covering purpose, the triggering issue, and the risk of removal. resolveClassName() retains its own Javadoc as before.

2.2 Test Coverage and Test Stability

Unchanged and still solid: testReaderLoadsJobStatusWrittenWithLegacyClassName (WALReaderAndWriterTest.java:155-176) writes a WAL record using the hardcoded legacy value-class-name string and asserts the reader returns a real engine-common JobStatus.RUNNING instance — this fails on pre-fix code with the exact reported ClassNotFoundException and passes post-fix.

Stability rating: Stable.

  • Same deterministic local-filesystem harness as the rest of the class (FS, @BeforeAll/@AfterAll), no Thread.sleep, no timing-dependent assertions.
  • Dedicated path LEGACY_JOB_STATUS_PATH = /tmp/imap-wal-legacy-job-status/ (WALReaderAndWriterTest.java:54) doesn't collide with PARENT_PATH or SAME_TIMESTAMP_TOMBSTONE_PATH used elsewhere in the class.
  • Cleaned up in @AfterAll (FS.delete(LEGACY_JOB_STATUS_PATH, true), WALReaderAndWriterTest.java:184), matching the existing cleanup pattern.
  • Assertions are exact-value (assertEquals(JobStatus.class, ...), assertEquals(JobStatus.RUNNING.name(), ...)), not weak existence checks.

2.3 Documentation Updates

Not required — internal WAL-deserialization bugfix with no user-facing config/CLI/connector surface change.

3. Architectural Soundness

3.1 Elegance of the Solution

Precisely targeted fix, re-verified independently against the actual rename commit rather than taking the PR description's claim at face value. No new compile-time coupling to engine-common from production code — only String manipulation, with the engine-common pom.xml dependency correctly scoped to test.

3.2 Maintainability

Improved by this round's change: the mapping table now carries its own explanation of why it exists and what breaks if it's removed, directly addressing the "silent future cleanup risk" I flagged last time.

3.3 Extensibility

Adding a future legacy mapping remains a one-line addition to the static block; the new Javadoc explicitly documents this expectation ("extend it whenever a persisted job model class is moved again").

3.4 Historical-Version Compatibility

This is the core value of the PR. It restores the ability to read job-status WAL entries written by any SeaTunnel version prior to the #9689 engine-core -> engine-common move (confirmed affecting at least 2.3.10, per #9928) without operator-driven manual migration or state discard during upgrade. I re-confirmed via full-history search that no other job-model classes moved packages and were left unmapped.

4. Issue Summary

# Issue Location Severity
— None outstanding. The single Medium issue from my prior review (missing rationale comment on LEGACY_CLASS_NAME_MAPPINGS) is resolved by commit 20d56e95. WALReader.java:45-54 Resolved

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers — must be fixed
    • None.
  2. Recommended fixes — non-blocking
    • None.

Nice follow-up — the added Javadoc is exactly the kind of "why this exists, don't delete it" context that prevents this class of regression from recurring after a future refactor. Combined with the from-scratch re-verification I did this round (independent confirmation of the #9689 rename completeness, the write-path class-name behavior, and the pre-existing Hazelcast-level exception handling around the recovery path), I don't see any remaining non-CI blocker. The fork's Build check is still queued at the time of this re-review (same status as last round); worth a final glance once it completes, but there is no code-side reason to hold this PR.

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

What Problem Does This PR Solve?

After PR #9689 relocated the job-status model classes (JobResult, JobStatus, JobStatusData) from seatunnel-engine-core to seatunnel-engine-common, any cluster using the file-backed IMap storage (imap-storage-file) to persist job state fails to restart, because WALReader.deserializeData() calls ClassUtils.getClass() with the class name literally recorded in old WAL entries (org.apache.seatunnel.engine.core.job.JobStatus), which no longer exists on the classpath — a real, reported production issue (#9928). The fix adds a small static LEGACY_CLASS_NAME_MAPPINGS table and a resolveClassName() helper in WALReader.java so the three moved class names are transparently remapped to their current engine-common package before class resolution. One-sentence summary: this is the same fix I approved on 2026-08-14, now re-verified against a fresh head that only carries a clean, no-conflict sync with dev.

What changed since my last review (APPROVED, 2026-08-14, head 20d56e95)

Exactly one new commit landed: 835b264f3 ("[Fix][Zeta] Sync legacy job status fix with latest dev", merge commit, first parent 20d56e954, second parent 4ba289595 = dev). I did not just trust the commit message — I diffed the pre-merge and post-merge heads directly for every file this PR touches:

git diff 20d56e954 835b264f3 -- .../imap-storage-file/pom.xml
git diff 20d56e954 835b264f3 -- .../common/WALReader.java
git diff 20d56e954 835b264f3 -- .../common/WALReaderAndWriterTest.java

WALReader.java and WALReaderAndWriterTest.java come back byte-identical before and after the merge — the actual fix logic I reviewed and approved is completely untouched. The only real delta is in pom.xml:

-    <artifactId>seatunnel-hadoop3-3.1.4-uber</artifactId>
-    <version>${project.version}</version>
-    <classifier>optional</classifier>
+    <artifactId>seatunnel-shade-hadoop3-uber</artifactId>
     <scope>provided</scope>
...
-    <artifactId>seatunnel-commons-lang3</artifactId>
-    <version>${project.version}</version>
-    <classifier>optional</classifier>
+    <artifactId>seatunnel-shade-commons-lang3</artifactId>

This is dev's independent shaded-dependency renaming (the seatunnel-shade/* reactor modules were removed/externalized on dev and replaced with externally-versioned seatunnel-shade-* artifacts resolved via the parent POM's dependencyManagement) landing cleanly through the merge — not a manual conflict resolution. I confirmed this is the correct, current convention by grepping dev's tree: dozens of other modules (seatunnel-benchmarks/pom.xml, connector-file-base/pom.xml, connector-file-ftp/pom.xml, etc.) reference seatunnel-shade-hadoop3-uber/seatunnel-shade-commons-lang3 the exact same way — no explicit <version>/<classifier>, inherited from the parent POM. This is the opposite of the situation I flagged on PR #11712 this same round, where a merge-conflict resolution silently broke compilation — here there was no textual conflict at all on these lines (the PR's own diff never touched them), so git's merge picked up dev's change automatically and correctly.

I re-confirmed the merge-base (4ba289595) is a genuine ancestor of the live, freshly-fetched dev, so this sync is current, not stale.

1. Code Change Review

1.1 Core Logic Analysis

Unchanged from my 08-14 review (re-pulled and re-read the raw blob at the current head to confirm, not just trusting the zero-diff result above):

WALReader.java:

private static final Map<String, String> LEGACY_CLASS_NAME_MAPPINGS;
// ... Javadoc covering #9689/#9928, warning against removal, still present at lines 44-54
static { ... }
private Object deserializeData(byte[] data, String className) {
    try {
        Class<?> clazz = ClassUtils.getClass(resolveClassName(className));
        ...
private static String resolveClassName(String className) {
    return LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className);
}

Runtime path (re-traced, unchanged from prior rounds):

Master node restart
  -> Hazelcast BasicRecordStoreLoader.loadAndGet()
  -> MapStoreWrapper.loadAll()
  -> FileMapStore.loadAll()
  -> IMapFileStorage.loadAll()
  -> WALReader.loadAllData()
  -> deserializeData(data, "org.apache.seatunnel.engine.core.job.JobStatus")
       -> resolveClassName(...) hits LEGACY_CLASS_NAME_MAPPINGS -> engine-common name
       -> ClassUtils.getClass(...) succeeds (previously threw ClassNotFoundException)
  -> job status IMap successfully rehydrated

This is the primary/normal startup-recovery path for any cluster upgrading across the #9689 boundary while persisting job state via file-backed IMap storage. Field layout between old (engine-core) and new (engine-common) classes is byte-identical (pure package rename, verified against the actual move commit in my 08-09 review), so re-deserializing legacy WAL bytes against the new class is safe.

Key findings this round:

  • Zero functional change since my approval — the merge only touched a build-dependency coordinate, not application logic.
  • The imap-storage-file module's production classpath still gains no new compile-time coupling to engine-common's job-model classes — the fix operates purely on String class names.

1.2 Compatibility Impact

Fully compatible, unchanged from my prior review. New-format WAL entries are unaffected; old-format entries from any pre-#9689 SeaTunnel version now deserialize correctly instead of crashing/silently dropping (the underlying ClassNotFoundException was previously caught and only WARN-logged by Hazelcast's BasicRecordStoreLoader, so the real pre-fix failure mode is silent loss of persisted job state on restart, not a startup crash). No public API, Option, or config surface touched. No incompatible-changes doc entry needed since this restores previously-broken backward compatibility.

1.3 Performance / Side-Effect Analysis

Unchanged: one HashMap.getOrDefault lookup per record read against an immutable 3-entry map built once in a static initializer. No new I/O, locks, or write-path change.

1.4 Error Handling and Logging

Unchanged: the ClassNotFoundException -> IMapStorageException wrapping for genuinely unknown class names is preserved, correctly narrowed to only the 3 known-moved classes.

No new issues found this round.

2. Code Quality Assessment

2.1 Coding Standards

Unchanged and still good — the LEGACY_CLASS_NAME_MAPPINGS field now carries the explanatory Javadoc I asked for in my first-round review, added and verified in the second round, and still present, untouched, at the current head.

2.2 Test Coverage and Test Stability

Unchanged: testReaderLoadsJobStatusWrittenWithLegacyClassName (WALReaderAndWriterTest.java) directly reproduces #9928 and is byte-identical to what I approved.

Stability rating: Stable. Deterministic local-filesystem harness, no Thread.sleep, dedicated non-colliding path (LEGACY_JOB_STATUS_PATH), proper @AfterAll cleanup, exact-value assertions. Same conclusion as both prior rounds; the file is unchanged so there's nothing new to re-evaluate.

2.3 Documentation Updates

Not required — internal WAL-deserialization bugfix with no user-facing config/CLI/connector surface change, unchanged from prior rounds.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix, re-confirmed unchanged.

3.2 Maintainability / 3.3 Extensibility

Unchanged from my 08-14 review — good, self-documenting, one-line-to-extend mapping table.

3.4 Historical-Version Compatibility

This remains the core value of the PR: restoring the ability to read job-status WAL entries written by any SeaTunnel version prior to the #9689 move, without operator-driven manual migration or state discard during upgrade.

4. Issue Summary

# Issue Location Severity
— None outstanding. The single new commit since my last review is a clean, no-conflict dev sync touching only an external shaded-dependency coordinate in pom.xml; the fix logic itself is byte-identical to what I already approved. — —

5. Merge Recommendation

Conclusion: Ready to merge

This confirms my 08-14 "Ready to merge" conclusion rather than reversing it — I re-verified from scratch rather than assuming the sync commit was safe just because it's a merge from dev. I checked both possible failure modes explicitly: (1) whether the merge silently altered the reviewed logic — it didn't, WALReader.java/WALReaderAndWriterTest.java are byte-identical before and after; and (2) whether the pom.xml change is a genuine, correct pickup of dev's dependency rename rather than a broken manual conflict resolution (the failure mode I found on PR #11712 this same session) — it is a clean, correctly-patterned change with no textual conflict at all. CI is now genuinely green on the fork for this exact head (Build workflow SUCCESS, including unit-test and the broader all-connectors-it/jdbc-connectors-it/etc. jobs), resolving the "still queued" caveat from my first-round review. mergeable: MERGEABLE, no conflicts.

  1. Blockers — must be fixed
    • None.
  2. Recommended fixes — non-blocking
    • None.

No remaining concerns from me. Thanks for keeping the branch in sync with dev promptly — this is ready to merge as far as I can tell.

nzw921rx
nzw921rx previously approved these changes Sep 23, 2026

@nzw921rx nzw921rx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

@davidzollo
davidzollo added this pull request to the merge queue Sep 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 23, 2026
@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the extra +1, @nzw921rx! Nothing new to add on my end — I re-verified this fix (and its dev-sync commit) from scratch across a few rounds, CI is green, and it's ready to merge as far as I can tell.

dybyte
dybyte previously approved these changes Sep 28, 2026

@dybyte dybyte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@dybyte
dybyte added this pull request to the merge queue Sep 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 28, 2026
@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the +1, @dybyte! Nothing new to verify on my end since my last comment — head is still 835b264f3b, CI is green, and mergeable_state is clean with two prior approvals plus yours now. This one's ready to merge whenever a maintainer with merge rights picks it up.

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I reviewed the latest head 835b264f3beb.

What this PR fixes

  • User pain: restarting a Zeta cluster that persists IMap state through the file-backed storage fails with ClassNotFoundException for org.apache.seatunnel.engine.core.job.JobStatus (and siblings) because #9689 moved those classes to seatunnel-engine-common while existing WAL frames still carry the old FQCNs (#9928).
  • Fix approach: WALReader now consults a static, unmodifiable LEGACY_CLASS_NAME_MAPPINGS table (WALReader.java:56-70) and rewrites the recorded name before ClassUtils.getClass(resolveClassName(className)) (WALReader.java:144), covering JobResult, JobStatus and JobStatusData; all three targets exist under seatunnel-engine-common/.../common/job/. A test-scoped seatunnel-engine-common dependency is added to the plugin pom so the regression test can reference the relocated JobStatus.
  • Assessment: a minimal, correctly scoped shim on the one choke point that both loadAllKeys and loadAllData funnel through; the mapping targets are right and non-legacy names pass through unchanged via getOrDefault. What should be tightened before merge: the regression test covers only the JobStatus entry with a writer-produced fixture and compares via toString(), the ClassNotFoundException message still reports only the raw WAL name rather than the resolved one, and the upgrade/downgrade behaviour is not documented for users. None of it is blocking.

Runtime chain I rechecked

Hazelcast MapStore replay on cluster restart
  FileMapStore.loadAll(keys)  -> mapStorage.loadAll()                            FileMapStore.java:109
  FileMapStore.loadAllKeys() -> mapStorage.loadAllKeys()                       FileMapStore.java:118
    IMapFileStorage.loadAll()     -> new WALReader(fs, fileConfiguration, serializer).loadAllData(new Path(businessRootPath), new HashSet<>())   IMapFileStorage.java:237-238
    IMapFileStorage.loadAllKeys() -> new WALReader(...).loadAllKeys(new Path(businessRootPath))                                              IMapFileStorage.java:247-248
      WALReader.loadAllKeys()  -> deserializeData(data.getKey(), data.getKeyClassName())        WALReader.java:95
      WALReader.loadAllData()  -> deserializeData(data.getKey(), data.getKeyClassName())        WALReader.java:122
                               -> deserializeData(data.getValue(), data.getValueClassName())    WALReader.java:136
        WALReader.deserializeData() -> ClassUtils.getClass(resolveClassName(className))   [CHANGED]   WALReader.java:144
          WALReader.resolveClassName() -> LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className)   [NEW]   WALReader.java:167-168
            LEGACY_CLASS_NAME_MAPPINGS static init: core.job.{JobResult,JobStatus,JobStatusData} -> common.job.*   [NEW]   WALReader.java:58-70
        -> serializer.deserialize(data, clazz)                                                    WALReader.java:146
           ProtoStuffSerializer.deserialize: clz not in WRAPPERS -> getSchema(clz).newMessage() + mergeFrom   ProtoStuffSerializer.java:115-119
        catch ClassNotFoundException -> IMapStorageException("... class name is {}", className)  (raw WAL name only)   WALReader.java:153-156

Write side (unchanged, shows where the recorded FQCN originates):
  IMapFileStorage.parseToIMapFileData(...) -> .keyClassName(key.getClass().getName()) / .valueClassName(value.getClass().getName())   IMapFileStorage.java:289-291

Regression test:
  WALReaderAndWriterTest.testReaderLoadsJobStatusWrittenWithLegacyClassName()   WALReaderAndWriterTest.java:155-176
    WALWriter.write(IMapFileData{value=SERIALIZER.serialize(JobStatus.RUNNING), valueClassName="org.apache.seatunnel.engine.core.job.JobStatus"})   :160-168
    WALReader.loadAllData(LEGACY_JOB_STATUS_PATH, new HashSet<>())   :171-172
    assertEquals(JobStatus.class, ...getClass()); assertEquals(JobStatus.RUNNING.name(), ...toString())   :174-175

Findings

Issue 1: Regression test asserts only getClass()/toString() on the replayed enum and covers just 1 of the 3 legacy mappings

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/test/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReaderAndWriterTest.java:175
  • Why it matters: - Root cause: the new test compares data.get(key).getClass() with JobStatus.class and data.get(key).toString() with JobStatus.RUNNING.name() (WALReaderAndWriterTest.java:174-175) instead of asserting Assertions.assertEquals(JobStatus.RUNNING, data.get(key)). JobStatus is not in ProtoStuffSerializer.WRAPPERS, so deserialize goes through getSchema(clz).newMessage() followed by ProtostuffIOUtil.mergeFrom (ProtoStuffSerializer.java:115-119), i.e. a RuntimeSchema built for the enum class itself. If that path ever hands back an instance that is not the canonical JobStatus.RUNNING constant, both current assertions still pass while ==/equals comparisons and switch statements in the engine would misbehave.
  • Coverage gap: only the org.apache.seatunnel.engine.core.job.JobStatus entry of LEGACY_CLASS_NAME_MAPPINGS is exercised; the JobResult and JobStatusData mappings (WALReader.java:60-62, 66-68) are never written under their legacy names or replayed. loadAllKeys is also not exercised for the legacy record.
  • Fix: assert equality (and ideally assertSame) against JobStatus.RUNNING, and turn the test into a @ParameterizedTest over the three legacy names with a sample object each, plus a loadAllKeys(...).contains(key) check.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/test/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReaderAndWriterTest.java:175 Assertions.assertEquals(JobStatus.RUNNING.name(), data.get(key).toString());; seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:60 legacyClassNameMappings.put("org.apache.seatunnel.engine.core.job.JobResult", "org.apache.seatunnel.engine.common.job.JobResult");; seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:66 legacyClassNameMappings.put("org.apache.seatunnel.engine.core.job.JobStatusData", "org.apache.seatunnel.engine.common.job.JobStatusData");
  • Suggested fix: These two assertions are weaker than the contract the engine needs. JobStatus is not in ProtoStuffSerializer.WRAPPERS, so it is materialised via getSchema(JobStatus.class).newMessage() + mergeFrom; checking getClass() and toString() would still pass if the reader handed back a non-canonical enum instance. Please assert Assertions.assertEquals(JobStatus.RUNNING, data.get(key)) (and ideally assertSame). Also, only the JobStatus entry of LEGACY_CLASS_NAME_MAPPINGS is exercised -- JobResult and JobStatusData are mapped but never replayed. A @ParameterizedTest over the three legacy names with a sample object each, plus a loadAllKeys(...).contains(key) check, would cover the whole table.
  • Severity: Medium

Issue 2: ClassNotFoundException after legacy-name rewrite still reports only the original WAL class name; a wrong or stale mapping target is undiagnosable and still aborts the whole cluster restart

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:144
  • Why it matters: - Root cause: deserializeData() now calls ClassUtils.getClass(resolveClassName(className)) (WALReader.java:144), but the catch (ClassNotFoundException e) block below (WALReader.java:153-156) still formats the message with the original className read from the WAL record. The resolved name is never stored or logged.
  • Impact: if a mapping target is wrong or the target class is relocated again, the failure surfaces as deserialize data error, class name is org.apache.seatunnel.engine.core.job.JobResult -- exactly the #9928 symptom -- which makes it look as though the mapping was never applied. Because this exception propagates out of loadAllData/loadAllKeys into FileMapStore.loadAll, it still aborts the whole MapStore replay on restart, so the operator has nothing to work with but a misleading message.
  • Fix: hold the resolved name in a local, include both the recorded and the resolved name in the IMapStorageException message, and emit a WARN (once per legacy name) when a rewrite is applied so upgrades that depend on this table are visible in the master log.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:168 return LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className);
  • Suggested fix: When the resolved class cannot be loaded, the catch (ClassNotFoundException) below still reports the original className, so a wrong/stale mapping target would surface as class name is org.apache.seatunnel.engine.core.job.JobResult and look like the mapping was never applied. Please hold the resolved name in a local, include both names in the IMapStorageException message, and log a WARN (once per legacy name) when a rewrite is applied so upgrades that depend on this table are visible in the master log. This exception aborts the whole MapStore loadAll, so the diagnostics matter.
  • Severity: Medium

Issue 3: Only the JobStatus mapping is exercised; the JobResult and JobStatusData target names are unverified string literals that the compiler cannot check

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:61
  • Why it matters: - Root cause: imap-storage-file does not compile against seatunnel-engine-common -- the pom adds it at <scope>test</scope> only (pom.xml:50) -- so the three target names in LEGACY_CLASS_NAME_MAPPINGS (WALReader.java:60-68) are plain strings with no compile-time check. The new test writes a record with the legacy JobStatus name only; nothing verifies that org.apache.seatunnel.engine.common.job.JobResult and org.apache.seatunnel.engine.common.job.JobStatusData resolve.
  • Impact: a typo in either target, or a future relocation of either class, would not fail the build or any unit test and would only be discovered as a ClassNotFoundException during a production cluster restart -- the exact failure mode this PR is fixing.
  • Fix: add a test that iterates every entry of the table and asserts Class.forName(target) succeeds (the test scope dependency already makes the classes available), and ideally round-trip a JobResult and a JobStatusData written under their legacy names.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:67 "org.apache.seatunnel.engine.core.job.JobStatusData",; seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/pom.xml:50 <scope>test</scope>; seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/test/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReaderAndWriterTest.java:165 .valueClassName("org.apache.seatunnel.engine.core.job.JobStatus")
  • Suggested fix: Because this module only sees seatunnel-engine-common at test scope, these target names are unchecked strings. The new test only covers JobStatus; the JobResult and JobStatusData targets are never resolved anywhere. Please add a test that iterates all entries and asserts Class.forName(target) succeeds (and ideally round-trips a JobResult/JobStatusData written under the legacy name), otherwise a typo or another relocation would only be caught by a failed production restart.
  • Severity: Medium

Issue 4: Compatibility restoration is only documented in Javadoc; no user-facing upgrade note for clusters using file-based IMap storage

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:56
  • Why it matters: - The PR fixes an upgrade break for every cluster that persists job state through imap-storage-file: WAL records written before #9689 carry org.apache.seatunnel.engine.core.job.JobStatus and friends, and the new LEGACY_CLASS_NAME_MAPPINGS table (WALReader.java:56-70) is what makes a restart succeed.
  • Today the only place this contract is written down is the private-field Javadoc (WALReader.java:45-55). docs/en/introduction/concepts/incompatible-changes.md contains only a ## dev heading with no entry for #9689, engine-common, or engine.common.job, so operators have no user-facing statement that upgrading with an existing imap-storage directory is supported and that no manual WAL cleanup is needed.
  • Fix: add a one-line bullet under ## dev in docs/en/introduction/concepts/incompatible-changes.md (and the docs/zh mirror) stating that the job-status classes moved to seatunnel-engine-common and that the WAL reader resolves the legacy names transparently.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:52 * see #9928. Removing an entry from this table breaks upgrades from any release that still
  • Suggested fix: The Javadoc here is clear and explains the forever-compatibility contract well. Since this is what makes upgrades from pre-#9689 releases work for anyone running the file-based IMap storage, could we also surface it to users? A one-line bullet under ## dev in docs/en/introduction/concepts/incompatible-changes.md (and the docs/zh mirror) saying the job-status classes moved to seatunnel-engine-common and that the WAL reader now resolves the legacy names transparently would let operators know no manual WAL cleanup is needed. The #9689 move itself was never recorded there, so this would close that gap too.
  • Severity: Low

Issue 5: The #9689 class relocation and this shim's upgrade/downgrade semantics are not recorded in incompatible-changes.md

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:65
  • Why it matters: - Root cause: the mapping added here (WALReader.java:58-70) exists because #9689 moved JobResult/JobStatus/JobStatusData from seatunnel-engine-core to seatunnel-engine-common, which changed the class names that IMapFileStorage.parseToIMapFileData records in the WAL via value.getClass().getName(). docs/en/introduction/concepts/incompatible-changes.md has no entry for this (no mention of #9689, engine-common or engine.common.job).
  • Impact: with this PR the upgrade direction (old WAL -> new reader) works, but the reverse does not: once a post-#9689 master has written org.apache.seatunnel.engine.common.job.JobStatus into the persisted IMap WAL, rolling back to an older release fails with the same ClassNotFoundException as #9928. Operators have no documented warning about this one-way door or how to prepare for a rollback.
  • Fix: add a short note (en + zh) describing the WAL class-name change, stating that this release can replay pre-#9689 WALs, and that downgrading requires finishing/cancelling jobs or clearing the imap-storage directory first.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:65 "org.apache.seatunnel.engine.common.job.JobStatus");
  • Suggested fix: This restores the upgrade path, but the relocation in #9689 remains a one-way door: once a post-#9689 master has written engine.common.job.JobStatus into the persisted IMap WAL, rolling back to an older release hits the same ClassNotFoundException as #9928. I don't see an entry for #9689 in docs/en/introduction/concepts/incompatible-changes.md. Could you add a short note there (en + zh) describing the WAL class-name change, that this release can replay pre-#9689 WALs, and that downgrading requires finishing/cancelling jobs or clearing the imap-storage directory first?
  • Severity: Low

Issue 6: New test-scoped seatunnel-engine-common dependency has no comment explaining why production code deliberately references the class names as strings

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/pom.xml:50
  • Why it matters: - The pom adds seatunnel-engine-common at <scope>test</scope> (pom.xml:46-51) purely so the test can import org.apache.seatunnel.engine.common.job.JobStatus. Production code in WALReader.java:60-68 keeps the target names as string literals so the storage plugin does not gain a compile-time dependency on the engine module.
  • Without a comment, a future contributor is likely to either promote the scope to compile or replace the literals with JobStatus.class.getName(), quietly introducing a dependency from the storage plugin onto seatunnel-engine-common.
  • Fix: add a short XML comment on the dependency (and optionally a sentence in the LEGACY_CLASS_NAME_MAPPINGS Javadoc) stating that the test scope is intentional and that the table must stay string-based.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/pom.xml:50 <scope>test</scope>; seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:62 "org.apache.seatunnel.engine.common.job.JobResult");
  • Suggested fix: Keeping this test-scoped is the right call, since WALReader deliberately refers to the relocated classes by string so the storage plugin stays free of a compile dependency on seatunnel-engine-common. Could you add a short XML comment saying so? Otherwise the next person is likely to promote the scope or replace the literals in LEGACY_CLASS_NAME_MAPPINGS with JobStatus.class.getName(), which would quietly introduce that dependency.
  • Severity: Low

Issue 7: Legacy fixture is produced by the current WALWriter, so the test never reads a WAL frame actually written by a pre-#9689 release

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/test/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReaderAndWriterTest.java:165
  • Why it matters: - The test builds the 'legacy' record with today's IMapFileData.builder() and WALWriter (WALReaderAndWriterTest.java:158-168), only overriding valueClassName to the old FQCN (:165). That proves resolveClassName is applied, but it does not prove that a WAL file produced by an older SeaTunnel release (older IMapFileData protostuff layout, older JobStatus enum constants/ordinals) replays end-to-end, which is the scenario #9928 reports.
  • If the IMapFileData frame format or the protostuff encoding of the moved classes ever diverges from what old releases wrote, this test would keep passing while real upgrades fail.
  • Fix: check in a small real WAL fixture produced by a pre-#9689 release under src/test/resources/ and replay it in this test.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/test/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReaderAndWriterTest.java:165 .valueClassName("org.apache.seatunnel.engine.core.job.JobStatus")
  • Suggested fix: This record is written with the current WALWriter/IMapFileData layout and only the class-name string is 'legacy'. That validates resolveClassName, but not that a WAL file actually produced by a pre-#9689 release replays. Consider checking in a small real WAL fixture from such a release under src/test/resources/ and replaying it here; that is the scenario #9928 reports.
  • Severity: Low

Issue 8: Single-hop getOrDefault lookup means a future relocation requires rewriting every existing target, contrary to the 'extend it' guidance in the Javadoc

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:168
  • Why it matters: - Root cause: resolveClassName performs one getOrDefault lookup (WALReader.java:168). The Javadoc (WALReader.java:52-54) instructs maintainers to 'extend it whenever a persisted job model class is moved again', but adding a new common -> newpkg entry would not fix records that still carry the core name, because the core -> common result is not re-resolved.
  • Impact: a future move would silently reintroduce the #9928 restart failure for clusters upgrading directly from a pre-#9689 release unless the maintainer also remembers to rewrite the three existing targets -- which nothing in the code or tests enforces.
  • Fix: either document that every target must always be the current class name (backed by a test that resolves every target, see the coverage gap above), or resolve iteratively with a hop limit so chained entries work.
  • Evidence: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:168 return LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className);
  • Suggested fix: This is a single-hop lookup, so if a class moves again, adding a new common -> X entry as the Javadoc suggests would not fix records still carrying the core name. Please either document that targets must always be the current class name (backed by a test that resolves every target), or resolve iteratively with a hop limit so chained entries work.
  • Severity: Low

Review conclusion

Conclusion: final approval remains pending on the previous comments

2. Remaining follow-ups

  • Issue 1: Regression test asserts only getClass()/toString() on the replayed enum and covers just 1 of the 3 legacy mappings
  • Issue 2: ClassNotFoundException after legacy-name rewrite still reports only the original WAL class name; a wrong or stale mapping target is undiagnosable and still aborts the whole cluster restart
  • Issue 3: Only the JobStatus mapping is exercised; the JobResult and JobStatusData target names are unverified string literals that the compiler cannot check
  • Issue 4: Compatibility restoration is only documented in Javadoc; no user-facing upgrade note for clusters using file-based IMap storage
  • Issue 5: The #9689 class relocation and this shim's upgrade/downgrade semantics are not recorded in incompatible-changes.md
  • Issue 6: New test-scoped seatunnel-engine-common dependency has no comment explaining why production code deliberately references the class names as strings
  • Issue 7: Legacy fixture is produced by the current WALWriter, so the test never reads a WAL frame actually written by a pre-#9689 release
  • Issue 8: Single-hop getOrDefault lookup means a future relocation requires rewriting every existing target, contrary to the 'extend it' guidance in the Javadoc

Thanks for the updates so far. Happy to discuss the remaining points.

@SEZ9

SEZ9 commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @nzw921rx and @dybyte for the approvals.

Before I merge, I'd like to close out the open points from my earlier review — as far as I can tell from the thread, none of them have been addressed on 835b264f3b yet. If some already were, please point me to where and I'll re-check.

Remaining asks, in priority order:

  1. Test coverage of the legacy mapping (WALReaderAndWriterTest.java): the regression test currently only asserts getClass()/toString() on the replayed enum and exercises just the JobStatus mapping. Please extend it to cover all three legacy names (JobStatus, JobResult, JobStatusData) and assert on the actual deserialized values, not just the class/string form. Otherwise the JobResult/JobStatusData target names remain unverified string literals the compiler can't check.
  2. Error reporting after rewrite (WALReader.java): when the class lookup fails after a legacy-name rewrite, the exception still only reports the original WAL class name. Please include the rewritten target name too, so a wrong or stale mapping is diagnosable rather than just aborting the cluster restart with a misleading message.
  3. Docs: please add a short user-facing note (and an entry in incompatible-changes.md) describing the [Feature][Zeta] extended jobStateEvent event listening for zeta #9689 relocation and what this shim does on upgrade/downgrade for clusters using file-based IMap storage. Javadoc alone won't reach operators.
  4. Minor: a one-line comment on the new test-scoped seatunnel-engine-common dependency in pom.xml explaining why production code deliberately references the class names as strings; and, if feasible, consider making the lookup handle chained relocations (or adjust the "extend it" Javadoc guidance so it matches the single-hop behaviour). Ideally the fixture would also be a WAL frame captured from a pre-[Feature][Zeta] extended jobStateEvent event listening for zeta #9689 build rather than one produced by the current WALWriter, but I won't block on that one.

Items 1 and 2 are what I'd like to see before merging; 3 and 4 can be follow-ups if you prefer, just let me know. Thanks for the patience on this.

…est and report rewritten class name on lookup failure
@zhangshenghang
zhangshenghang dismissed stale reviews from dybyte and nzw921rx via 446ae12 September 30, 2026 03:36

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

Thanks @zhangshenghang for the quick follow-up commit, and thanks @SEZ9 for the careful checklist. I re-read the whole PR at the new head (446ae12) from scratch, not just the delta since my earlier approval on 835b264. The new commit addresses the main asks from SEZ9's review. +1 to @SEZ9's points on test coverage, error reporting and docs; I verified each against the new head below.

What Problem Does This PR Solve?

  • User pain point: The job status model classes (JobResult, JobStatus, JobStatusData) moved from seatunnel-engine-core to seatunnel-engine-common in #9689. File-backed IMap WAL records persist the class name via value.getClass().getName(), so WAL files written by older releases still carry org.apache.seatunnel.engine.core.job.*. After upgrading and restarting, ClassUtils.getClass(...) throws ClassNotFoundException and job-state recovery aborts (#9928).
  • Fix approach: WALReader rewrites the recorded class name through a small immutable lookup table before loading the class.
  • Summary: A minimal, string-based shim at the single choke point used by both key and value deserialization, so pre-#9689 WAL files replay on current versions.
  • Example: A WAL record with valueClassName org.apache.seatunnel.engine.core.job.JobStatus is now loaded as org.apache.seatunnel.engine.common.job.JobStatus instead of failing the whole restart.

1. Code Change Review

1.1 Core Logic Analysis

Files changed: WALReader.java, its test, the module pom (test-scoped dependency), and incompatible-changes.md (en and zh).

Runtime path (PR head):

Master restart
  Hazelcast MapStore replay -> FileMapStore.loadAll / loadAllKeys
    -> IMapFileStorage.loadAll / loadAllKeys
      -> WALReader.loadAllData / loadAllKeys
        -> deserializeData(bytes, recordedClassName)
           -> resolveClassName(recordedClassName)         [NEW: table lookup, getOrDefault]
           -> ClassUtils.getClass(resolvedName)
           -> serializer.deserialize(bytes, clazz)        [unchanged]
        catch ClassNotFoundException
           -> IMapStorageException(recorded name + resolved name)   [UPDATED]
Write side (unchanged): IMapFileStorage.parseToIMapFileData records the current class name.

This is on the normal startup-recovery path for any cluster with file-backed IMap persistence that upgrades across the #9689 boundary, not an edge path. Names that are not in the table pass through unchanged, so nothing else is affected. The three mapped classes exist under seatunnel-engine-common/.../common/job/, and #9689 was a package-only move, so the serialized field layout is unchanged.

Status of previously raised items at the new head:

  • Test only covered JobStatus and used weak assertions (SEZ9 Issue 1/3): FIXED. WALReaderAndWriterTest now has testReaderLoadsAllLegacyJobModelClassNames, which writes all three legacy names and asserts real field values (status name, error text, job id/name/status/times) on the replayed objects. The enum comparison uses name() with a comment explaining why identity is not used; that is an acceptable explanation for a ProtoStuff enum.
  • Exception only reports the original name (SEZ9 Issue 2): FIXED. The catch block now includes both the recorded and the resolved class name.
  • Docs / upgrade-downgrade note (SEZ9 Issue 4/5): FIXED. Both docs/en and docs/zh incompatible-changes.md have a matching entry that states the rewrite is one-way and that downgrading after new WAL entries are written needs WAL cleanup.
  • pom comment (SEZ9 Issue 6), chained-relocation wording (Issue 8), real pre-#9689 fixture (Issue 7): not addressed; all are non-blocking (see Low issues).

1.2 Compatibility Impact

Fully compatible. Reading pre-#9689 WAL files now works; current-format WAL files are read exactly as before. No config option, API, default or serialization format changes. The downgrade limitation (a WAL written by a newer version cannot be read by an older one) is a pre-existing consequence of #9689 and is now documented.

1.3 Performance / Side-Effect Analysis

One HashMap lookup per deserialized key or value against a 3-entry immutable map built once. No new I/O, locks, threads or retained state, no change to write path, so no concern at large WAL volumes. Note that resolveClassName is computed a second time only inside the failure path, which is irrelevant for performance.

1.4 Error Handling and Logging

No blocking issues found.

Issue 1: Test-scoped seatunnel-engine-common dependency has no explanatory comment

  • Location: imap-storage-file/pom.xml:46-51
  • Problem: Production code keeps the target names as strings on purpose, but nothing says so. A future cleanup could promote the scope or swap in JobStatus.class.getName().
  • Potential risk: Silent new compile dependency from the storage plugin onto the engine module.
  • Best improvement: One short XML comment on the dependency (raised by @SEZ9 as item 4).
  • Severity: Low
  • Raised by another reviewer: Yes @SEZ9

Issue 2: Javadoc says to "extend" the table, but lookup is single-hop

  • Location: WALReader.java Javadoc on LEGACY_CLASS_NAME_MAPPINGS and resolveClassName
  • Problem: If a class moves again, adding common -> newpkg would not fix records that still carry the core name; the existing targets must be rewritten too.
  • Potential risk: A future move could reintroduce #9928 for direct upgrades from old releases.
  • Best improvement: Reword the Javadoc to say every target must always be the current class name. The new all-names test helps here, since it resolves every target.
  • Severity: Low
  • Raised by another reviewer: Yes @SEZ9

Issue 3: Legacy fixture is produced by the current WALWriter

  • Location: WALReaderAndWriterTest.java, legacy tests
  • Problem: Only the class-name string is legacy; the frame bytes are written by the current writer. A real pre-#9689 WAL file would be stronger evidence.
  • Potential risk: Low, because #9689 only changed the package line. This is optional.
  • Best improvement: Optionally check in a small captured WAL file as a test resource.
  • Severity: Low
  • Raised by another reviewer: Yes @SEZ9 (explicitly non-blocking)

2. Code Quality Assessment

2.1 Coding Standards

Consistent with the file. The static table and resolveClassName both carry useful Javadoc explaining why the shim exists and the contract for maintaining it. The pre-existing commented-out log line in the catch block was lightly updated; harmless.

2.2 Test Coverage and Test Stability

Coverage now spans all three mapped names with value-level assertions. Stability: Stable. Both new tests use the local filesystem harness already used by the class, have no sleeps or timing assertions, and use a dedicated directory that is cleaned up in @AfterAll. The two new tests share one directory; the writer creates a fixed-name file so the second test may overwrite the first's file, but each test reads back only keys it wrote itself, so ordering does not matter.

2.3 Documentation Updates

en and zh incompatible-changes.md entries are present, consistent with each other and with the code (three classes, old to new package, one-way rewrite, downgrade caveat).

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix. It is placed at the one deserialization choke point and keeps the storage plugin free of a compile dependency on the engine module.

3.2 Maintainability

Good: immutable table, documented contract, all-names regression test.

3.3 Extensibility

New relocations can be added to the table (keeping targets current, see Issue 2).

3.4 Historical-Version Compatibility

Restores upgrades from pre-#9689 releases; does not change behaviour for newer WAL data.

4. Issue Summary

# Issue Location Severity
1 No comment on the test-scoped dependency imap-storage-file/pom.xml:46-51 Low
2 Javadoc guidance vs single-hop lookup WALReader.java (table Javadoc) Low
3 Fixture not captured from a real old release WALReaderAndWriterTest.java Low

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers - must be fixed: none.
  2. Recommended fixes - non-blocking: Issues 1 to 3 above, all optional and reasonable as a follow-up.

Overall assessment: the fix is correct, scoped to the one path that failed, and the author has now covered the test, diagnostics and documentation asks. My earlier approval stands for the new head. On SEZ9's request that items 1 and 2 be seen before merge: both are now in the code at this head; item 3 is also done, and item 4 was explicitly allowed as a follow-up. @SEZ9 please re-check when you have a moment.

CI/sync status: the apache-side Build check for this head is still in progress and the lightweight checks are green; I saw no PR-caused failure. The branch has no reported conflicts. Next step: let the fork CI run finish, then a committer can merge.

@SEZ9

SEZ9 commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the follow-up commit. I haven't been able to verify the new head (446ae12) myself yet, so rather than guess at what changed since 835b264, could you confirm the status of the earlier points?

Error reporting (F2): Does the ClassNotFoundException path in WALReader now report both the recorded WAL class name and the resolved target name, so a wrong or stale mapping entry is diagnosable?

Docs (F4, F5): If incompatible-changes.md (en and zh) is part of the change, does it record the #9689 relocation and the shim's upgrade/downgrade semantics for clusters using file-based IMap storage?

Test coverage (F1, F3): Does the regression test now cover all three legacy names (JobResult, JobStatus, JobStatusData) and assert deserialized field values rather than only getClass()/toString()? Since the target names are string literals the compiler cannot check, a test that resolves every mapping target against the real class on the classpath would close F3.

Legacy fixture (F7): Is the fixture still produced by the current WALWriter? A checked-in byte fixture, or at minimum a hand-built frame with the org.apache.seatunnel.engine.core.job.* name, would exercise what a pre-#9689 WAL actually contains. Not blocking if the frame format is unchanged, but please state that explicitly in the test.

Multi-hop lookup (F8): If the lookup is still a single-hop getOrDefault, a future relocation would require rewriting every existing target. Either loop until the name is stable (with a bound) or adjust the Javadoc so the "extend it" guidance matches single-hop behavior.

Pom comment (F6): A one-line comment on the test-scoped seatunnel-engine-common dependency explaining that production code intentionally references the class names as strings would help the next reader.

None of these change the approach; the shim at the single deserializeData choke point is the right fix. Once the above are confirmed or pushed, I'm happy to merge.

Resolve the merge conflicts with dev: keep both sides' documentation entries.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

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

Thanks @zhangshenghang for keeping this branch in sync with dev, and sorry to be the bearer of bad news on a PR I had approved: after the latest dev merge (head 9adcc9341f) I re-read the whole diff from scratch, and the branch no longer compiles. My earlier approval was given on 446ae12807, and I am withdrawing it for this head until the one-line fix below lands. The author-side change is otherwise identical to what I approved (see the unchanged-code check below), so this should be quick.

What Problem Does This PR Solve?

  • User pain point: Job status model classes (JobResult, JobStatus, JobStatusData) moved from seatunnel-engine-core to seatunnel-engine-common in #9689. WAL files written by older releases still record org.apache.seatunnel.engine.core.job.*, so a restart on a current build fails with ClassNotFoundException (#9928).
  • Fix approach: WALReader rewrites those three recorded names through an immutable lookup table right before ClassUtils.getClass(...).
  • Summary: A small string-based shim at the single deserialization choke point so pre-#9689 WAL files replay again.

1. Code Change Review

1.1 Core Logic Analysis

Unchanged-code check: I diffed the PR's own added/removed lines at 446ae12807 (the head I approved) against 9adcc9341f. They are identical (same 5 files, +151/-3 against each merge base), so the shim, the two tests, the pom scope and the en/zh docs are exactly as reviewed before.

What changed underneath it: dev now contains #11494 (WAL recovery memory optimization), which rewrote WALReader and dropped import java.util.Collections; (and List) from that file. The PR's static initializer still calls Collections.unmodifiableMap(...), so the auto-merge succeeds textually but the result does not compile.

Runtime path at this head (the shim itself is still on the normal restart-recovery path):

Master restart
  -> FileMapStore.loadAll / loadAllKeys
    -> IMapFileStorage.loadAll / loadAllKeys
      -> WALReader.loadAllData / loadAllKeys           (dev: streaming LatestMutationAccumulator, #11494)
        -> deserializeData(bytes, recordedClassName)
           -> resolveClassName(recordedClassName)      (this PR: table lookup)
           -> ClassUtils.getClass(resolvedName)
           -> serializer.deserialize(bytes, clazz)

The new dev flow still funnels every key and value through deserializeData, so the shim placement remains correct once it compiles.

1.2 Compatibility Impact

Fully compatible (unchanged from my previous review): pre-#9689 WAL files become readable, current-format WAL data is read exactly as before, and the downgrade caveat is documented in both incompatible-changes.md files.

1.3 Performance / Side-Effect Analysis

Unchanged: one lookup in a 3-entry immutable map per deserialized key/value, no new I/O, locks or retained state.

1.4 Error Handling and Logging

Issue 1: Merged head does not compile because java.util.Collections is no longer imported

  • Location: seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/common/WALReader.java:69 (Collections.unmodifiableMap(...)), imports at lines 36-40
  • Problem description: #11494 removed the Collections import from this file when it rewrote the read path. This PR's static initializer relies on it. The fork Build for this head fails in imap-storage-file with cannot find symbol: variable Collections at WALReader.java:[69,37], which in turn fails Install, unit tests and every integration shard that depends on the module.
  • Potential risk: Nothing can merge or be verified until the module compiles, and the failing shards are all downstream of this single error.
  • Best improvement: Re-add import java.util.Collections; to WALReader.java (before java.util.HashMap), run ./mvnw spotless:apply -pl seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file, and push. Option B, if you prefer not to touch imports: build the map with an unmodifiable view another way, but re-adding the import is the smaller change.
  • Severity: High (build break)
  • Raised by another reviewer: No

I have no other blocking findings; the earlier non-blocking Low items (pom comment, single-hop Javadoc wording, fixture produced by the current writer) from my previous review still stand as optional follow-ups and are not repeated as issues here.

2. Code Quality Assessment

2.1 Coding Standards

Unchanged and consistent with the file. The new tests were already rated Stable (no sleeps, dedicated directory, cleaned in @AfterAll). They also still compile against dev's loadAllData(Path, Set) signature, which did not change.

2.2 Test Coverage and Test Stability

Unchanged: all three legacy names are covered with value-level assertions. Stability: Stable. The tests could not run on this head only because of the compile error.

2.3 Documentation Updates

docs/en and docs/zh entries are present and consistent; no change needed.

3. Architectural Soundness

Precise fix, placed at the one choke point, no new dependencies in production code. Historical-version compatibility is as described in 1.2.

4. Issue Summary

# Issue Location Severity
1 Missing java.util.Collections import after the dev merge WALReader.java:69 High

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers - must be fixed
    • Issue 1: add the missing import so the module compiles.
  2. Recommended fixes - non-blocking
    • The three Low items from my previous review (optional).

Other reviewers: @nzw921rx and @dybyte approved earlier, and @SEZ9's open asks (test coverage, both class names in the error, docs) were verified as addressed in my previous review; I do not see new activity from them after that, and the fix above does not change that conclusion.

CI / sync facts for this head: fork Build run 37391629994 failed, and the failures I traced (Install, unit tests, the integration shards) all stem from the compile error above, so I would not treat them as unrelated flakes. The branch has no reported merge conflicts (mergeable=true, state blocked only by the pending review/CI gates), and it is 43 commits behind dev, which is metadata only. Once the import is restored and CI is green, I am happy to move this back to approved. Thanks again for the patience and for the quick turnarounds so far!

IMapStorageException formats its message with String.format, so the {}
placeholders used in WALReader.deserializeData never rendered the
recorded or resolved class name, leaving the restart failure without
the context needed to diagnose a stale legacy mapping. Switch both
throw sites to %s placeholders (also fixing the inverted 's%' pair in
the IOException branch) and add a regression test that replays a WAL
entry with an unknown class name and asserts both names surface in the
exception message.

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

Thanks @zhangshenghang, this is exactly the fix I asked for in my last round, and it was quick! I re-read the whole diff of the latest head 9658666be8 from scratch, including the delta since 998271775d.

What Problem Does This PR Solve?

  • User pain point: #9689 moved JobResult, JobStatus and JobStatusData from seatunnel-engine-core to seatunnel-engine-common. WAL files written by older releases still record org.apache.seatunnel.engine.core.job.*, so restarting a current build that persists job state through file-backed IMap storage fails with ClassNotFoundException (#9928).
  • Fix approach: WALReader rewrites those three recorded names through an immutable lookup table right before ClassUtils.getClass(...).
  • One-sentence summary: A small string-based shim at the single deserialization choke point so pre-#9689 WAL files replay again.

1. Code Change Review

1.1 Core Logic Analysis

I compared the PR's own added/removed lines (against each merge base with dev) for the previous head 998271775d and the current head. The shim, the table, the pom scope and the docs are unchanged; the new content is exactly the error-message fix:

  • WALReader.java (deserializeData, around :129-:158): the ClassNotFoundException branch now uses %s placeholders ("class name is %s, resolved class name is %s"), and the IOException branch's previous s% typo is now %s, with comments explaining that IMapStorageException(Throwable, String, Object...) goes through String.format.
  • WALReaderAndWriterTest.java: new testUnknownClassNameSurfacesInExceptionMessage writes a record whose value class name is org.apache.seatunnel.engine.core.job.NeverExistedJobStatus, replays it with loadAllData, and asserts the message contains class name is <name>, resolved class name is <name>; the new path is deleted in @AfterAll.
  • The branch also contains a merge of dev (ce88ee9d7d); the branch is now fully up to date (behind_by=0, ahead_by=11, status ahead, no conflicts).

Runtime path (normal restart-recovery route, unchanged):

Master restart -> Hazelcast MapStore replay
  -> FileMapStore.loadAll / loadAllKeys
    -> IMapFileStorage.loadAll / loadAllKeys
      -> WALReader.loadAllData / loadAllKeys
        -> deserializeData(bytes, recordedClassName)
           -> resolveClassName(recordedClassName)      3-entry immutable map, getOrDefault
           -> ClassUtils.getClass(resolvedName)
           -> serializer.deserialize(bytes, clazz)
           -> ClassNotFoundException -> IMapStorageException("... %s ... %s")   now renders both names

This closes my previous Issue 1 (and @SEZ9's F2): with %s the recorded and resolved names now appear in the restart failure. I verified the formatting mechanism in IMapStorageException(Throwable, String, Object...), which calls String.format(message, data). The new test would have failed on the previous head, because {} is not a String.format specifier, so it protects exactly this regression. I also want to acknowledge that the earlier gap was mine to catch in two rounds, and thank you for turning it around so quickly.

1.2 Compatibility Impact

Fully compatible. Current-format WAL entries resolve unchanged, pre-#9689 entries become readable again, and there is no config, API or serialization-format change. The one-way downgrade caveat is documented in both incompatible-changes.md files.

1.3 Performance / Side-Effect Analysis

One hash lookup per deserialized key/value. No new I/O, lock, thread or retained state.

1.4 Error Handling and Logging

Resolved. Both failure branches now render their arguments. One tiny remark, not a request: the IOException branch prints data (a byte[]) with %s, which shows an array identity such as [B@..., not the bytes; that is a pre-existing choice and the class name next to it is the useful part, so I would leave it.

2. Code Quality Assessment

2.1 Coding Standards

Consistent with the file; the new comments explain why %s is required.

2.2 Test Coverage and Test Stability

All three legacy names are replayed with value-level assertions, the targets are bound to the live classes, and the error message is now asserted. Stability rating: Stable (no sleeps, deterministic data, local file system, cleanup in @AfterAll). I reviewed the tests statically and did not run them.

2.3 Documentation Updates

docs/en and docs/zh incompatible-changes.md entries are present and consistent.

3. Architectural Soundness

Precise fix at the one choke point, no new production dependency, a single table to extend (single-level resolution is documented in the Javadoc).

4. Issue Summary

# Issue Location Severity
1 (carryover, previous round) Message renders no class names WALReader.java deserializeData Resolved on this head
2 (carryover, previous round, optional) testLegacyMappingsTargetCurrentClassNames reads a private field by reflection, with fully-qualified java.lang.reflect.Field / java.util.Map and an unchecked cast (WALReaderAndWriterTest.java:253-257) WALReaderAndWriterTest.java Low, non-blocking

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers - must be fixed: No source-side blockers.
  2. Recommended fixes - non-blocking: Issue 2 is only a style/robustness suggestion (make resolveClassName package-private and assert on it directly, or import Field/Map); it is fine to leave it or do it as a follow-up.

CI status: pending, not failing. For head 9658666be8 the apache-side Build is in_progress; labeler and Notify test workflow are success. The fork's Build run for this head is still queued (https://github.com/zhangshenghang/seatunnel/actions/runs/38363095354). Nothing is needed from you except letting it finish; if a lane fails I will check whether it relates to this diff (the previous head's only failures were two unrelated connector ITs).

Review gate: I only have read-level review controls here, so the formal approval has to come from a maintainer with write access. @SEZ9, from my side every item you listed (F1/F2/F3/F4/F5/F6/F8) is now satisfied in the code of this head; F7 (a real pre-#9689 fixture) is a reasonable follow-up.

Thanks again for sticking with this - it is a real upgrade-path fix!

@zhangshenghang

Copy link
Copy Markdown
Member Author

Hi @SEZ9, yes — exactly: my F5 was referring to your F7, i.e. replaying a WAL frame actually written by a pre-#9689 release rather than one produced by the current WALWriter. Producing a genuine old-format fixture needs a build from the pre-relocation release line, so I'd prefer to keep it as a follow-up once this shim lands. Thanks for the careful review!

@SEZ9

SEZ9 commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Hi @zhangshenghang, thanks for clarifying — that lines up, your F5 and my F7 are the same point: replaying a frame actually written by a pre-#9689 release, not one produced by the current WALWriter.

Agreed on deferring that. Producing a genuine old-format fixture does need a build from the pre-relocation release line, and that's not something I'd block this shim on. Two small asks so it doesn't get lost:

  • Please add a short note (a TODO in WALReaderAndWriterTest.java or a line in the PR description) stating that the legacy fixture is currently generated by the current WALWriter and that a real pre-[Feature][Zeta] extended jobStateEvent event listening for zeta #9689 frame fixture is planned as a follow-up.
  • Once this lands, please open the follow-up issue and link it back here so we have the trail.

On the rest of the earlier review, could you confirm where things stand so I can do a final pass:

  • F1/F3: whether the regression test now asserts on the actual enum value (not only getClass()/toString()) and covers all three legacy mappings, including the JobResult and JobStatusData targets, so the string literals in WALReader.java are verified by a test rather than left unchecked.
  • F2: whether a ClassNotFoundException after the legacy-name rewrite now reports the rewritten target name alongside the original WAL class name.
  • F4/F5: whether an upgrade note was added for file-based IMap storage users and whether the [Feature][Zeta] extended jobStateEvent event listening for zeta #9689 relocation plus this shim's upgrade/downgrade semantics are recorded in incompatible-changes.md.
  • F6: a brief comment on the test-scoped seatunnel-engine-common dependency in pom.xml explaining why production code references the class names as strings.
  • F8: whether the lookup now handles chained relocations, or if you'd prefer to adjust the Javadoc wording to match the single-hop getOrDefault behavior.

If any of these were addressed in a later push, just point me at it and I'll re-review.

@zhangshenghang

Copy link
Copy Markdown
Member Author

Hi @SEZ9, both asks are done:

  • TODO note: added on f6869ab0 — a short comment on LEGACY_JOB_STATUS_PATH in WALReaderAndWriterTest.java stating that the fixtures are generated by the current WALWriter (only the recorded class-name strings are pre-[Feature][Zeta] extended jobStateEvent event listening for zeta #9689) and that replaying a frame actually written by a pre-relocation release is planned as a follow-up.
  • Follow-up issue: will open it and link it back here once this lands.

On the earlier items, where things stand on the current head:

  • F1/F3: testReaderLoadsAllLegacyJobModelClassNames writes all three legacy names and asserts on the deserialized values — the enum value via name() for JobStatus, getStatus().name() plus the error string for JobResult, and the class for JobStatusData. testLegacyMappingsTargetCurrentClassNames binds every LEGACY_CLASS_NAME_MAPPINGS target to the live class via JobStatus.class.getName() etc., so the string literals in WALReader.java are verified by a test rather than left unchecked.
  • F2: testUnknownClassNameSurfacesInExceptionMessage replays a record whose value class is org.apache.seatunnel.engine.core.job.NeverExistedJobStatus and asserts the IMapStorageException message contains both the recorded name and the resolved name.
  • F4/F5: both incompatible-changes.md (en/zh) carry the entry describing the [Feature][Zeta] extended jobStateEvent event listening for zeta #9689 relocation, the transparent rewrite on read, and the one-directional downgrade caveat.
  • F6: the test-scoped seatunnel-engine-common dependency in imap-storage-file/pom.xml has the comment explaining why production code references the class names as strings.
  • F8: resolveClassName is a single-hop getOrDefault, and the LEGACY_CLASS_NAME_MAPPINGS Javadoc documents resolution as single-level with one entry per legacy name, as we agreed.

These landed across 446ae128 → 9658666b; the only newer commits are dev merges and the TODO note above. The full CI run on 6c771bdd was green (24 passed, 6 skipped by path filters), and f6869ab0 has just re-triggered the pipeline — it is a comment-only change. Thanks for the careful review, happy to get the final pass whenever you have a moment!

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

Thanks @zhangshenghang for the quick turnaround, and thanks @SEZ9 for the careful follow-ups. I re-read the whole PR from scratch on the latest head f6869ab098, including everything that landed after my last review on 9658666be8. Sorry for one small thing I should have flagged in my earlier rounds: the test fixture directory handling (Issue 1 below). It is a carryover from the previous version, not something newly introduced.

What Problem Does This PR Solve?

  • User pain point: #9689 moved JobResult, JobStatus and JobStatusData from org.apache.seatunnel.engine.core.job to org.apache.seatunnel.engine.common.job. WAL files written by older releases still record the old class names, so a restart that replays file-backed IMap storage fails with ClassNotFoundException (#9928).
  • Fix approach: WALReader rewrites those three recorded names through an immutable lookup table right before ClassUtils.getClass(...).
  • One-sentence summary: A small string-based shim at the single deserialization choke point so pre-#9689 WAL files replay again.

1. Code Change Review

1.1 Core Logic Analysis

PR-owned files on this head (5): WALReader.java (+56/-4), WALReaderAndWriterTest.java (+160), imap-storage-file/pom.xml (+9), and the en/zh incompatible-changes.md entries (+5 each).

Delta since my last review: the only PR-owned change is a 3-line TODO comment on LEGACY_JOB_STATUS_PATH in WALReaderAndWriterTest.java (fixture provenance, which is what @SEZ9 asked for). The other commits (ce88ee9, 6c771bd, a59cd95) are dev merges; the unrelated Lance, Flink e2e and Spark files that show up in a raw compare are dev content, not part of this PR (gh api pulls/11781/files lists exactly the 5 files above). The branch is ahead_by=14, behind_by=0, no conflicts.

Key code (after the change):

private static final Map<String, String> LEGACY_CLASS_NAME_MAPPINGS; // 3 entries, unmodifiable

private Object deserializeData(byte[] data, String className) {
    try {
        Class<?> clazz = ClassUtils.getClass(resolveClassName(className));
        ... serializer.deserialize(data, clazz) ...
    } catch (ClassNotFoundException e) {
        throw new IMapStorageException(e,
            "deserialize data error, class name is %s, resolved class name is %s",
            className, resolveClassName(className));
    }
}
private static String resolveClassName(String className) {
    return LEGACY_CLASS_NAME_MAPPINGS.getOrDefault(className, className);
}

Complete runtime path (normal restart-recovery route, which does reach the changed code):

Master restart -> Hazelcast MapStore replay
  -> FileMapStore.loadAll / loadAllKeys
    -> IMapFileStorage.loadAll / loadAllKeys
      -> WALReader.loadAllData / loadAllKeys
         -> readLatestMutations -> IMapFileData{key, keyClassName, value, valueClassName}
         -> deserializeData(bytes, recordedClassName)
            -> resolveClassName: core.job.{JobStatus,JobResult,JobStatusData} -> common.job.*
            -> ClassUtils.getClass(resolved) -> ProtoStuffSerializer.deserialize(bytes, clazz)
            -> ClassNotFoundException -> IMapStorageException (both names rendered via %s)
Write side (unchanged): WALWriter records value.getClass().getName(), i.e. the current common.job.* names.

Why the shim is sufficient (I verified this against the sources, not only the PR text): ProtoStuffSerializer uses RuntimeSchema keyed by the target Class handed in by WALReader; the serialized bytes of JobStatusData (Long, String, enum JobStatus, longs), JobResult (enum + String) and JobStatus carry field numbers and enum ordinals, not embedded class names. So rewriting only the recorded className is enough, and the wire format of the three classes did not change in #9689 (the PR for #9689 renames exactly these three files and nothing else that is persisted through this storage).

Key findings:

  • The normal restart path reaches the changed logic; this is not only a boundary path.
  • Precise, minimal fix at the single choke point; a single table to extend; no change to the write path.
  • Single-hop resolution is documented in the Javadoc (agreed with @SEZ9 in the thread).
  • Current-format entries resolve unchanged (getOrDefault), so there is no behavior change for clusters that never wrote legacy names.

1.2 Compatibility Impact

Fully compatible. No API, option, default, protocol or serialization-format change. Pre-#9689 WAL entries become readable again; current entries are untouched. The one-directional downgrade caveat (a WAL written by the new version cannot be resolved by an old release) is documented in both docs/en and docs/zh incompatible-changes.md. ProtoStuffSerializer is not touched.

1.3 Performance / Side-Effect Analysis

One immutable HashMap lookup per deserialized key/value on replay only (startup/recovery path). No new I/O, lock, thread, cache or retained state. The %s formatting happens only on the failure path. No concern at high data volume: the cost is O(1) per record and is dwarfed by the existing file read and protostuff decode.

1.4 Error Handling and Logging

Good. The failure message now renders both the recorded and the resolved class name, which closes @SEZ9's F2. The old commented-out log.error lines are still present in deserializeData; harmless, but dead comments, see Issue 2.

2. Code Quality Assessment

2.1 Coding Standards

The new table and resolveClassName carry Javadoc explaining why (#9689/#9928, never remove entries, single-level resolution). The test-scoped seatunnel-engine-common dependency in the pom has the explanatory comment @SEZ9 asked for.

2.2 Test Coverage and Test Stability

Coverage: all three legacy names are replayed with value-level assertions (JobStatus by name, JobResult by status and error, JobStatusData by all six fields), the mapping targets are bound to live classes, and the unknown-class message is asserted. A real pre-#9689 frame fixture is intentionally deferred and now documented by the TODO (non-blocking, agreed with @SEZ9; I would still like the follow-up issue linked once this merges).

Test stability rating: Risk present (non-blocking), evidence:

  • WALReaderAndWriterTest.java:65, 276-359: testReaderLoadsJobStatusWrittenWithLegacyClassName and testReaderLoadsAllLegacyJobModelClassNames both write into the same LEGACY_JOB_STATUS_PATH, and @BeforeEach only cleans PARENT_PATH (:79-81). The directory is deleted only in @AfterAll (:405). The assertions use data.get(key) so they pass today regardless of order, but each test replays whatever the other left behind (and anything a crashed earlier run left in /tmp). That is hidden inter-test state; it will not fail now but can start failing if someone adds a size or key-set assertion. Suggested fix: delete LEGACY_JOB_STATUS_PATH (and UNKNOWN_CLASS_NAME_PATH) in cleanWalDirectory(), or use a per-test sub-directory such as new Path(PARENT_PATH, "legacy-" + name) as the unsorted/selective tests already do.
  • No Thread.sleep, no ports, no clock dependence, deterministic data; the class is @EnabledOnOs({LINUX, MAC}) like before. I reviewed the tests statically and did not run them.

2.3 Documentation Updates

incompatible-changes.md has the entry in both docs/en and docs/zh, consistent with each other and with the code (three classes, one-way downgrade).

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix.

3.2 Maintainability

Clear boundary: one table, one resolve method, one call site. Rules for extending it are in the Javadoc.

3.3 Extensibility

Adequate for the stated need; a future relocation just adds entries (including intermediate names), as documented.

3.4 Historical-Version Compatibility

Reads pre-#9689 WAL files again; does not alter how current versions write. Downgrade after new writes is the documented limitation.

4. Issue Summary

# Issue Location Severity Raised by another reviewer
1 Two tests share LEGACY_JOB_STATUS_PATH; it is not cleaned per test (carryover from earlier versions) WALReaderAndWriterTest.java:65, 79-81, 276-359 Low (stability risk, non-blocking) No
2 testLegacyMappingsTargetCurrentClassNames reads a private static field via reflection with fully-qualified java.lang.reflect.Field / java.util.Map and an unchecked cast; the commented-out log.error lines remain in deserializeData WALReaderAndWriterTest.java:259-263, WALReader.java:148-149, 156-157 Low (style, non-blocking) No

Issue 2 detail: a package-private resolveClassName (or a package-private accessor for the table) would let the test assert directly without reflection, and importing Field/Map removes the inline qualified names. Both are optional.

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers - must be fixed: none on the source side.
  2. Recommended fixes - non-blocking: Issue 1 (test isolation) and Issue 2 (style). Neither affects production behavior; both can be done now or in the follow-up that adds the real pre-#9689 fixture.

On the existing review state: I agree with @SEZ9's last comment that the remaining items are satisfied in the code (F1/F2/F3/F4/F5/F6/F8 verified by me on this head; F7 deferred with a TODO), and I see no reason to hold the PR on them. @nzw921rx and @dybyte had approved earlier on older heads (those reviews show as dismissed), so a fresh approval from a committer with write access is still needed.

CI status (head f6869ab098): the apache-side Build is in_progress; labeler and Notify test workflow are success. The fork Build run for this head (https://github.com/zhangshenghang/seatunnel/actions/runs/38504983404) is still queued. The previous head 6c771bdd was fully green (Build, labeler, Notify test workflow all success), and the delta from that head to this one in this PR's own files is a comment-only change, so I do not expect a new failure; please just let it finish. If a lane fails I will check whether it relates to this diff. Nothing is needed from you right now.

Upstream sync: behind_by=0, ahead_by=14, mergeable=true; mergeable_state is blocked only because the required approving review is missing.

Review gate: I only have read-level review controls here, so the formal approval has to come from a maintainer with write access. @SEZ9, from my side this is ready.

Thanks again for sticking with this; it is a real upgrade-path fix!

@zhangshenghang
zhangshenghang requested a review from SEZ9 October 14, 2026 12:34

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

Quick follow-up on head f6869ab09850 (no new commits or replies since my last review).

The CI fact I cited previously has changed. In my last review the apache-side Build was in_progress and the fork run was queued; both have now finished.

Update: CI was previously the only remaining gate on my side, and I had no code, test, docs or compatibility blockers. CI is now passing on this exact head: the apache-side Build check is success, and the real fork run (https://github.com/zhangshenghang/seatunnel/actions/runs/38504983404) completed success on f6869ab09850. So my conclusion is updated to approve.

The two non-blocking test/style notes from my last review (shared fixture directory, reflection and dead comments) are unchanged and still optional.

Remaining gate: the required committer approval. If GitHub does not register this as an approval, my account only has read-level review controls, so a maintainer with write access needs to approve. Thanks again for the work!

@DanielLeens

Copy link
Copy Markdown
Contributor

The CI fact cited in my previous review has changed: Build for the current unchanged head is now passing. CI was previously the only remaining blocker; CI is now passing, so my technical conclusion changes to approve. I do not see a new source-side blocker from Daniel's review. This branch is behind the latest dev base, which I have recorded as merge metadata only; because the current head CI is green, that fact alone does not call for an additional source change. I have read-only review controls, so this COMMENT does not change GitHub's displayed review decision; a write-capable maintainer must perform any final approval or dismissal action.

@SEZ9

SEZ9 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the update. With CI reported passing on f6869ab09850 (run 38504983404), there is no build-side blocker from my side.

My earlier review points are still open, though. Here is what I'd still like to see before approval:

Tests (WALReaderAndWriterTest.java)

  • The regression test only asserts getClass()/toString() on the replayed enum and covers one of the three legacy mappings. Please cover all three legacy names and assert on the deserialized value, not just the class.
  • The legacy fixture is produced by the current WALWriter, so the test never reads a frame actually written by a release that used the old class names. A checked-in byte fixture or a hand-built frame with the old class name would make this a real compatibility test.

Robustness (WALReader.java)

  • When ClassNotFoundException is thrown after the legacy-name rewrite, the error still reports only the original WAL class name. Please include the rewritten target name so a wrong or stale mapping is diagnosable, and consider whether a single bad frame should abort the whole cluster restart.
  • The JobResult and JobStatusData target names are unverified string literals. Since seatunnel-engine-common is already a test-scoped dependency, a test that resolves every mapping target would catch typos.
  • The single-hop getOrDefault lookup means a future relocation requires rewriting every existing target, which contradicts the "extend it" guidance in the Javadoc. Either resolve mappings transitively or adjust the Javadoc.

Docs

  • Please add a short user-facing upgrade note for clusters using file-based IMap storage, and record the class relocation plus this shim's upgrade/downgrade semantics in incompatible-changes.md.

Style (pom.xml)

  • A one-line comment on the test-scoped seatunnel-engine-common dependency explaining why production code deliberately references class names as strings would help future readers.

If you've decided against any of these, a short reply is fine and we can close them out. Happy to re-review once a new push lands.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks @SEZ9 for the thorough checklist. I re-read it against the current head f6869ab09850 (unchanged since my last review), and most of the items are already in place on this head. Mapping them so we can close what is closed and isolate what is genuinely left:

Already addressed on this head

  • Cover all three legacy names and assert on the deserialized value, not only the class: WALReaderAndWriterTest#testReaderLoadsAllLegacyJobModelClassNames (L301) writes JobStatus, JobResult and JobStatusData frames with the old org.apache.seatunnel.engine.core.job.* names and asserts the replayed values (status name, JobResult status plus error text, and every JobStatusData field: id, name, status, submit/start/finish time). testReaderLoadsJobStatusWrittenWithLegacyClassName (L277) covers the single-enum case.
  • Show the rewritten target name when ClassNotFoundException happens: WALReader.deserializeData (WALReader.java:142-165) now reports both the recorded and the resolved class name, and the stray {}/s% placeholders were fixed to %s. testUnknownClassNameSurfacesInExceptionMessage (L368) asserts both names are present in the message.
  • Resolve every mapping target: testLegacyMappingsTargetCurrentClassNames (L259) compares each map value to JobStatus.class.getName(), JobResult.class.getName() and JobStatusData.class.getName(), so a renamed or mistyped target fails the build. This is why seatunnel-engine-common is a test-scoped dependency, and the pom.xml now carries a comment explaining that production code deliberately references the old names as strings.
  • Single-hop lookup vs. the Javadoc: the Javadoc on LEGACY_CLASS_NAME_MAPPINGS (WALReader.java:46-62) now states resolution is single-level and that every intermediate name needs its own entry, so it no longer promises transitive resolution.
  • User-facing upgrade note: both incompatible-changes.md files (en and zh) gained the "File-based IMap storage: legacy job model class names in WAL files are remapped on startup" entry, including the one-way semantics (a WAL written by a current build cannot be read by an older release, so a downgrade needs the persisted WAL cleared or rewritten).

Still open, and my read on each

  1. Fixture is produced by the current WALWriter. This is acknowledged in the TODO at WALReaderAndWriterTest.java:62-64. One technical point that narrows the gap: ProtoStuffSerializer uses RuntimeSchema (field-number based), so the value/key bytes do not embed any class name. The only place the old name lives in a frame is the valueClassName string of IMapFileData, which these tests set to the old name explicitly. A frame from a pre-relocation release therefore differs from the test frame only if the field layout of JobStatus/JobResult/JobStatusData changed since then, and that is exactly what a checked-in byte fixture would prove. I agree a real fixture is the strongest evidence, but I would call it a recommended follow-up, not a merge blocker, because the failure mode it guards (a field-layout drift in these three classes) is independent of this shim.
  2. One bad frame aborts the whole restart. That is unchanged pre-existing behavior (ClassNotFoundException is wrapped into IMapStorageException and propagates through loadAllData). I would keep it: silently skipping a job-status frame during restore would drop job state without a trace, which is worse than a clear fail-fast with both class names in the message.
  3. Nit (Low): testLegacyMappingsTargetCurrentClassNames reads the private map through reflection and uses fully qualified java.lang.reflect.Field / java.util.Map in the method body. The other tests already prove the mapping through loadAllData, so this one is a duplicate guard; if you prefer, a package-private accessor or dropping the reflection would be cleaner. Not blocking.

On CI: the Build check on f6869ab09850 is green (fork run 38504983404), and nothing from my side blocks. I only have read-level review rights here, so a write-capable maintainer needs to give the final approval. Thanks @zhangshenghang for all the iterations on this one.

@SEZ9

SEZ9 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the detailed mapping of the checklist against f6869ab09850. The description lines up with what I asked for on the test coverage (all three legacy names with value assertions), the ClassNotFoundException message showing both the recorded and resolved class names, the mapping-target test, the pom.xml comment, the single-level Javadoc on LEGACY_CLASS_NAME_MAPPINGS, and the incompatible-changes.md entries. I have not re-walked the diff for each of those yet, so I will confirm them against the actual changes rather than close them from the summary alone; if anything there is still in progress rather than already on this head, please say so.

One small correction on the mapping-target test: a comparison of string literals against JobStatus.class.getName() and friends catches a stale target at test time, not at compile time. That is still a good improvement over an unverified literal, I just want the description to be precise about it.

On the fixture point (the TODO acknowledging the frames are produced by the current WALWriter): I don't want to block on this, but before merge I'd like one of:

  • a small checked-in WAL file (or hard-coded byte array) captured from a pre-[Feature][Zeta] extended jobStateEvent event listening for zeta #9689 build and replayed by a test; or
  • if the argument is that ProtoStuffSerializer's RuntimeSchema is field-number based and the class-name string is therefore the only thing that differs on the wire, please spell that out in the test comment and the PR description so the gap is explicitly justified rather than left as a TODO.

Your last comment looks cut off partway through item 1 of the "still open" list. If there were further open items, could you post them so I can review everything in one pass?

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks @SEZ9, and sorry about the confusion. My previous comment was not cut off. It listed exactly three items under "Still open", and nothing else was pending:

  1. The fixture is produced by the current WALWriter (acknowledged by the TODO at WALReaderAndWriterTest.java:62-64).
  2. One bad frame aborts the whole restart (unchanged pre-existing fail-fast in loadAllData; I would keep it).
  3. A Low nit about reflection and fully qualified names in testLegacyMappingsTargetCurrentClassNames.

If the comment rendered truncated on your side, those three are the complete list.

Correction accepted on the mapping-target test. "Fails the build" should have said "fails the unit-test job". testLegacyMappingsTargetCurrentClassNames compares the string values with JobStatus.class.getName() and friends, so a stale or mistyped target is caught when the test runs in CI, not at compile time. The strings stay literals on purpose, because production code must not depend on the old class locations.

On the fixture, here is the evidence for your second option (justify the gap explicitly). I compared the three relocated types before and after the move, using the parent of e7de54e4e7a (#9689, the commit that moved them out of seatunnel-engine-core) against current dev:

  • JobStatus: the same 13 constants in the same order (INITIALIZING ... UNKNOWABLE), so the enum ordinals are unchanged.
  • JobResult: the same fields in the same order, status and error.
  • JobStatusData: the same fields in the same order and types, jobId, jobName, jobStatus, submitTime, startTime, finishTime.
  • The only structural difference is the private static final long serialVersionUID = 1L that [Fix][Core] Extend serialVersionUID checker coverage #11257 added later. ProtoStuffSerializer uses RuntimeSchema, which skips static and transient fields, so it does not change the bytes.

None of the three types has an Object-typed or abstract field, so no other class name is embedded in the value bytes either. That means a frame written by a pre-#9689 release differs from the frame the current WALWriter produces only in the valueClassName string of IMapFileData, and the legacy tests already set that string to the old name explicitly. This is a source-level comparison, not a replay of a real old WAL file. I did not run anything, and a captured byte fixture would still be the strongest proof if someone has an old WAL at hand.

So I would suggest @zhangshenghang replaces the TODO in WALReaderAndWriterTest with a short comment stating this argument (identical field layout and enum ordinals before and after #9689, class name being the only difference on the wire), and puts the same two sentences in the PR description. That satisfies your second option without a new fixture. If a checked-in fixture is easy to obtain, it is a welcome follow-up, but I would not hold the merge for it.

Nothing else has changed on my side: the head is still f6869ab0, the fork Build is green, and I have no source-level blocker. The PR still needs a write-capable maintainer to finish the approval.

…9689 capture

The relocated JobStatus, JobResult and JobStatusData kept identical field
layout and enum ordinals across apache#9689, and ProtoStuff's RuntimeSchema skips
the static serialVersionUID added later by apache#11257, so a frame written by a
pre-relocation release differs from the current WALWriter output only in the
IMapFileData valueClassName string, which the legacy fixtures already set to
the old names explicitly. Replace the TODO with that argument.
@zhangshenghang

Copy link
Copy Markdown
Member Author

Done in 5dbf76a: the TODO in WALReaderAndWriterTest is replaced with the justification (identical field layout and enum ordinals before and after #9689; the static serialVersionUID added by #11257 is skipped by RuntimeSchema; the only wire difference is the valueClassName string, which the legacy fixtures set to the old names explicitly). The same argument is now in the PR description. A captured byte fixture stays a welcome follow-up.

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

Quick follow-up on the new head 5dbf76a83f89. Thanks @zhangshenghang for turning the fixture TODO into an explicit justification so quickly, and thanks @SEZ9 for the careful checklist.

What Problem Does This PR Solve?

Pain point: after the job model classes were relocated (#9689), file-based IMap WAL files written by older releases still record the old class names, so replay on restart fails with ClassNotFoundException and the cluster cannot recover job status.

Fix approach: WALReader remaps the three legacy job model class names (JobStatus, JobResult, JobStatusData) to their current locations before deserializing, with clearer error messages and an upgrade note in incompatible-changes.md (en and zh).

One-sentence summary: a narrow, read-side compatibility shim that lets restarted clusters replay pre-relocation WAL entries.

1. Code Change Review

1.1 Core Logic Analysis

The only change since my last review (f6869ab09850) is commit 5dbf76a83f, which touches a single file, WALReaderAndWriterTest.java (+6/-3). It replaces the TODO above LEGACY_JOB_STATUS_PATH with a comment explaining why a captured pre-#9689 WAL file is not required.

Before:

// TODO: the legacy fixtures ... are generated by the current WALWriter ... planned as a follow-up.

After:

// A real pre-#9689 WAL file is not required to exercise the legacy path: the relocated types ... kept identical field layout and enum ordinals ... the only wire difference is the valueClassName string ...

Key findings: the diff is comment-only, with no production, test-logic, pom or docs change, so the production runtime path (WAL replay -> WALReader.deserializeData -> legacy name remap -> ProtoStuff RuntimeSchema) is exactly what I reviewed and approved on the previous head. The justification matches the evidence I gathered earlier from the source: identical enum constants and ordinals, identical field order and types, and the later static serialVersionUID being skipped by RuntimeSchema. This also satisfies the second option SEZ9 offered for the fixture point (justify the gap explicitly). The same argument is reported to be in the PR description.

1.2 Compatibility Impact

Fully compatible. The shim is read-side only and is a no-op for names not in the mapping; new-format WALs are unchanged. The one-way semantics (a WAL written by a current build cannot be read by an older release) are documented in incompatible-changes.md.

1.3 Performance/Side-Effect

No change from the previously reviewed head; the map lookup is O(1) per frame and this commit adds nothing at runtime.

1.4 Error Handling and Logging

No new issues. The earlier error-message improvements (recorded plus resolved class name) remain in place.

2. Code Quality Assessment

2.1 Coding Standards

The new comment explains why (not what) and is accurate. No issues.

2.2 Test Coverage and Test Stability

Rating: Stable. No test logic changed in this commit. The existing tests (all three legacy names with value assertions, mapping targets resolved against the current classes, unknown-class message) are unchanged. Optional, non-blocking, carried over from before: the shared fixture directory and the reflection or fully qualified names in testLegacyMappingsTargetCurrentClassNames. A captured byte fixture remains a welcome follow-up, not a merge gate.

2.3 Documentation Updates

incompatible-changes.md en and zh are present. No further docs needed.

3. Architectural Soundness

3.1 Precise fix / temporary workaround / long-term solution

Precise fix at the right place (the reader, where the stale name is consumed), with a bounded and documented mapping table.

3.2 Extensibility

Single-level mapping is documented in the Javadoc; future relocations need an entry per intermediate name.

3.3 Side effects on other modules

None; confined to the imap-storage-file plugin.

3.4 Historical-version compatibility

Old WALs replay correctly via the shim; downgrade of a WAL written by a current build is unsupported and documented.

4. Issue Summary

Number Issue Location Severity
- No new issues found in the incremental commit WALReaderAndWriterTest.java None

5. Merge Recommendation

Conclusion: Ready to merge

Blockers: none on the source side. The only outstanding gates are that CI for the new head is still queued (the fork run for 5dbf76a83f has not started, and the apache-side Build is a pointer to it), and that the branch is behind dev, which I record as merge metadata only. Please re-check that CI turns green on 5dbf76a83f; since this commit is comment-only, the previously green run on f6869ab09850 is strong supporting evidence but not a substitute.

Overall assessment: a clean, well-justified closing touch on a carefully built compatibility fix. Thank you for the patience through several review rounds. Final approval needs a write-capable committer.

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

Thanks again @zhangshenghang for the quick turnaround and for the careful write-up of why the legacy WAL fixtures need no pre-#9689 capture.

I re-checked the current head 5dbf76a83f89. The only delta since the head I approved (f6869ab09850) is one commit that adds explanatory documentation to WALReaderAndWriterTest; production code and test logic are unchanged. My earlier source-level conclusion therefore still holds: I see no code-side blocker, and the restore path for legacy job status WAL entries behaves as intended.

Approving from my side. The remaining gate is the Build check on this head, which had not reported yet when I looked, plus the final committer approval and merge. Great work, and thank you for the patience through the review rounds!

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

+1
LGTM

@nzw921rx nzw921rx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

@nzw921rx
nzw921rx enabled auto-merge October 21, 2026 14:10
@nzw921rx
nzw921rx disabled auto-merge October 21, 2026 14:10
@nzw921rx

Copy link
Copy Markdown
Member

Change is controllable and there is a dev CI on it. It has been determined to have failed and will be bypassed.

@nzw921rx
nzw921rx merged commit fb8e7a7 into apache:dev Oct 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

8 participants