You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/04/20 06:56:41 UTC

Re: [PR] [Improve] Remove SourceSplitEnumerator::currentUnassignedSplitSize [seatunnel]

DanielLeens commented on PR #9780:
URL: https://github.com/apache/seatunnel/pull/9780#issuecomment-4278483612

   Hi @HighandLight, thank you for working on simplifying the Source split enumerator API. I reviewed the latest code locally against the current `dev` branch.
   
   Local review context:
   
   - Local branch: `seatunnel-review-9780`
   - PR head: `23137d30ffb654affb0d127f801b2495473367be`
   - Merge base used for review: `ad5278c5bbec7e9a0b6e94ed7b69c96c73b4ff87`
   - Current local `upstream/dev`: `b9cdfeb79e2df010718acde1d6e45b956a76f4fa`
   - Diff size: 37 files, 182 deletions
   - Local runtime tests: not run; this review is based on local diff inspection, call-chain analysis, merge conflict analysis, and GitHub check metadata.
   - CI: `Build` is currently failed/cancelled; the old logs are no longer downloadable, so I cannot determine the exact failure from logs.
   
   # What this PR solves
   
   - User pain point: `SourceSplitEnumerator.currentUnassignedSplitSize()` is not used by SeaTunnel's normal internal Source scheduling path, but every enumerator implementation still has to implement it.
   - Fix approach: the PR removes this method from `SourceSplitEnumerator` and deletes the corresponding implementations and several test assertions.
   - In one sentence: this is a reasonable cleanup direction for an unused internal scheduling hook, but it changes a public API and the current branch no longer merges cleanly with `dev`.
   
   Simple example: before this PR, a custom Source enumerator had to implement `currentUnassignedSplitSize()` even if the engine never asked for that value. After this PR, the project code no longer requires it. However, an external connector that still has `@Override currentUnassignedSplitSize()` will fail to compile against the new API, and old code that calls the method through `SourceSplitEnumerator` may fail at runtime.
   
   # 1. Code Change Review
   
   ## 1.1 Core Logic Analysis
   
   Precise change:
   
   - `seatunnel-api/src/main/java/org/apache/seatunnel/api/source/SourceSplitEnumerator.java:71` removes `currentUnassignedSplitSize()` from the public Source enumerator interface.
   - Connector implementations remove methods that returned values such as `pendingSplit.size()`, `allSplit.size() - assignedSplit.size()`, or `0`.
   - Several tests remove assertions that previously checked whether all splits had been assigned.
   
   Before:
   
   ```java
   void addSplitsBack(List<SplitT> splits, int subtaskId);
   
   int currentUnassignedSplitSize();
   
   void handleSplitRequest(int subtaskId);
   ```
   
   After:
   
   ```java
   void addSplitsBack(List<SplitT> splits, int subtaskId);
   
   void handleSplitRequest(int subtaskId);
   ```
   
   Key findings:
   
   - The normal SeaTunnel Source scheduling path does not hit `currentUnassignedSplitSize()` after this PR; `rg` found no remaining Java references in the PR branch.
   - The PR is an API cleanup, not a runtime bug fix.
   - The internal cleanup is mostly coherent, but deleting a method from `seatunnel-api` is externally visible and needs a compatibility plan.
   - The branch currently has real merge conflicts with the latest `dev`.
   - Some tests lost "no remaining unassigned splits" coverage without an equivalent replacement.
   
   Full running chain:
   
   ```text
   SeaTunnelSource.createEnumerator(context)
     -> returns a concrete SourceSplitEnumerator
         -> open()
         -> run()
             -> discovers/enumerates splits
             -> assignSplit / signalNoMoreSplits
         -> registerReader(subtaskId)
         -> handleSplitRequest(subtaskId)
         -> addSplitsBack(splits, subtaskId)
             -> reassigns splits after reader failure or restore
         -> snapshotState(checkpointId)
             -> checkpoints enumerator state
         -> close()
   
   Current PR branch:
     -> SourceSplitEnumerator no longer declares currentUnassignedSplitSize()
     -> project-local Java references are fully removed
     -> SeaTunnel's normal Source scheduling path no longer calls the removed method
   
   External API path:
     -> third-party connector implements SourceSplitEnumerator
         -> if it still has @Override currentUnassignedSplitSize(), compilation against the new API fails
     -> external code/tests/monitoring call SourceSplitEnumerator.currentUnassignedSplitSize()
         -> when run with the new API, this may fail due to the missing method
   ```
   
   ## 1.2 Compatibility Impact
   
   Conclusion: partially incompatible.
   
   - API: incompatible for external connector implementations and any external callers of `currentUnassignedSplitSize()`.
   - Config options: compatible; no user-facing config change.
   - Default values: compatible; no default value change.
   - Protocols: compatible; no RPC or SourceEvent protocol change.
   - Serialization format: compatible; no split/checkpoint state serialization change.
   - Historical behavior: partially incompatible because the public Source SPI contract changes.
   
   If the community still wants to remove this method, please document the migration in both English and Chinese incompatible-change docs. A safer option would be to keep a `default int currentUnassignedSplitSize()` method, mark it as deprecated, and remove it in a future major version.
   
   ## 1.3 Performance / Side Effects
   
   There is no meaningful CPU, memory, GC, network, lock-contention, retry, idempotency, or resource-release impact from the deletion itself. The main side effect is compatibility and test coverage, not runtime performance.
   
   ## 1.4 Error Handling and Logs
   
   No new exception handling or logging behavior is introduced. I found the following formal issues:
   
   Issue 1: The branch has real conflicts with the latest `dev`
   
   - Location: `seatunnel-connectors-v2/connector-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeSourceSplitEnumerator.java:77`, `seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/split/MultipleTableFileSourceSplitEnumerator.java:133`, `seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/source/HbaseSourceSplitEnumerator.java:135`
   - Description: `git merge-tree` against the current `dev` shows `changed in both` and conflict markers. This is not only a documentation conflict; it touches Source enumerator implementation code.
   - Risk: the PR cannot be merged safely in its current state, and conflict resolution could accidentally drop recent enumerator changes.
   - Suggested fix: rebase or merge the latest `dev`, resolve all enumerator/test conflicts, and re-run the relevant checks.
   - Severity: High
   
   Issue 2: Removing a public `SourceSplitEnumerator` method is an API compatibility risk without migration documentation
   
   - Location: `seatunnel-api/src/main/java/org/apache/seatunnel/api/source/SourceSplitEnumerator.java:71`
   - Description: `SourceSplitEnumerator` is part of `seatunnel-api` and is used by external connectors. Removing `currentUnassignedSplitSize()` directly can break external source implementations or external code that still calls this method.
   - Risk: third-party connectors may fail to compile or fail at runtime after upgrading SeaTunnel.
   - Suggested fix: preferably keep the method as a deprecated default method for one release cycle, then remove it in a future major version. If it must be removed now, please update both English and Chinese incompatible-change docs with migration guidance.
   - Severity: High
   
   Issue 3: Some split-assignment tests lose equivalent "all splits assigned" coverage
   
   - Location: `seatunnel-connectors-v2/connector-file/connector-file-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/source/split/FileSourceSplitEnumeratorTest.java:90`, `seatunnel-connectors-v2/connector-file/connector-file-base/src/test/java/org/apache/seatunnel/connectors/seatunnel/file/source/split/MultipleTableFileSourceSplitEnumeratorTest.java:83`, `seatunnel-connectors-v2/connector-doris/src/test/java/org/apache/seatunnel/connectors/doris/split/DorisSourceSplitEnumeratorTest.java:95`
   - Description: the removed assertions previously checked that no unassigned splits remained after assignment. The remaining assertions still check assignment count/balance/duplicates, but they do not fully replace that state-convergence check.
   - Risk: a future enumerator regression could leave pending splits behind and later cause duplicate assignment during reader re-registration, retry, or restore.
   - Suggested fix: do not restore the public API just for tests. Instead, add behavior-level assertions: all expected split IDs are assigned exactly once, repeated registration/request does not assign already assigned splits, and add-back/retry paths still converge.
   - Severity: Medium
   
   # 2. Code Quality
   
   ## 2.1 Style
   
   The deletion itself is simple and follows the surrounding style. `git diff --check` is clean. However, the branch is not merge-ready because of conflicts with current `dev`.
   
   ## 2.2 Test Coverage
   
   The PR removes tests that used `currentUnassignedSplitSize()` but does not add equivalent behavior-level coverage. Please replace those assertions with externally observable split assignment checks instead of depending on the removed public API.
   
   ## 2.3 Documentation
   
   Because this changes a public API, documentation is needed:
   
   - `docs/en` should mention the incompatible API change and migration path.
   - `docs/zh` should be updated consistently.
   - The current PR does not include that documentation.
   
   # 3. Architecture
   
   ## 3.1 Solution Elegance
   
   The cleanup is understandable, but directly deleting a public SPI method is too abrupt. This is better handled as a deprecation-first API evolution.
   
   ## 3.2 Maintainability
   
   The project code becomes slightly smaller, but external connector maintainability gets worse unless the migration is documented and staged.
   
   ## 3.3 Extensibility
   
   This PR does not establish a reusable API-evolution pattern. A default deprecated method would give the project a safer pattern for future Source/Sink SPI cleanup.
   
   ## 3.4 Historical Compatibility
   
   Partially incompatible. Internal runtime behavior is mostly unchanged, but external connector source code may need to remove the override or stop calling the method.
   
   # 4. Issue Summary
   
   | No. | Issue | Location | Severity |
   |---|---|---|---|
   | 1 | Branch has real conflicts with latest `dev` | `FakeSourceSplitEnumerator.java:77`, `MultipleTableFileSourceSplitEnumerator.java:133`, `HbaseSourceSplitEnumerator.java:135` | High |
   | 2 | Public API removal lacks compatibility/migration plan | `SourceSplitEnumerator.java:71` | High |
   | 3 | Some split-assignment tests lose equivalent state-convergence coverage | `FileSourceSplitEnumeratorTest.java:90`, `MultipleTableFileSourceSplitEnumeratorTest.java:83`, `DorisSourceSplitEnumeratorTest.java:95` | Medium |
   
   # 5. Merge Conclusion
   
   ### Conclusion: Not recommended to merge
   
   1. Blocking items that must be fixed
   
   - Issue 1: the branch conflicts with the latest `dev` and cannot be merged safely.
   - Issue 2: the PR removes a public `seatunnel-api` method without a compatibility or migration plan.
   
   2. Recommended non-blocking fix
   
   - Issue 3: please replace the removed `currentUnassignedSplitSize()` test assertions with behavior-level split assignment coverage. This is not the only blocker, but it should be fixed while revising the API approach.
   
   Overall assessment: the cleanup target is real and the internal call path no longer depends on this method, but the implementation is too risky as a direct public API deletion. My recommended path is: keep a deprecated default method first, document the migration, resolve current `dev` conflicts, and then reassess whether a future major version should remove the method completely.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org