You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "davidzollo (via GitHub)" <gi...@apache.org> on 2026/09/05 15:51:29 UTC

[I] [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close() [seatunnel]

davidzollo opened a new issue, #12116:
URL: https://github.com/apache/seatunnel/issues/12116

   ### Search before asking
   - [x] I had searched in the issues and found no similar issues.
   
   ### What happened
   `TestFilterRowKindIT#testFilterRowKindMultiTable` (`filter_row_kind_exclude_insert_multi_table.conf`: FakeSource with 3 tables × 100 rows, parallelism 1, BATCH; `FilterRowKind` drops INSERT for `test.abc`/`test.xyz`; Assert expects `abc=0, xyz=0, www=100`) fails intermittently **only on Flink legs** — Zeta and Spark pass in the same runs — with the Assert sink reporting wrong row counts for `test.www`:
   
   - apache/seatunnel PR #11458, fork run `zhangshenghang/seatunnel` 33971790374, job `transform-v2-it-part-1 (11)`, Flink **1.18.0** leg: `row num :97 fail MIN_ROW 100`, `row num :125 / :150 fail MAX_ROW 100`
   - PR #11077, fork run `hesam-oxe/seatunnel` 33971836407, same job, Flink **1.15.3** leg: `row num :75 fail MIN_ROW 100`, `row num :125 / :150 fail MAX_ROW 100`
   - PR #11503, fork run `nielifeng/seatunnel` 33941523842, same job, same test (`expected: <0> but was: <1>` on the exit code)
   
   None of those PRs touch connector-assert, the transform, or the e2e module. All three heads already contain #11995 ("Remove fixed sleep in AssertSinkWriter close and assert own table only", merged 2026-09-01, `fa001a4e`), so that fix does not cover this.
   
   ### Root cause (from source, `dev` `AssertSinkWriter`)
   - Row counters are **static, JVM-wide**: `private static final Map<String, LongAccumulator> LONG_ACCUMULATOR` and `private static final Set<String> TABLE_NAMES` (lines 49–50).
   - `write()` accumulates into `LONG_ACCUMULATOR[element.getTableId()]` (multi-rule config path), and each writer's `close()` reads that static map for its own `catalogTableName` and throws `RULE_VALIDATION_FAILED` on MIN_ROW/MAX_ROW (lines 104–160).
   - On **Zeta**, each job runs with its own classloader, so the statics are effectively per job and per writer set. On **Flink**, every per-table writer and every sink subtask lives in the same TaskManager JVM and shares those statics, and each writer's `close()` evaluates independently:
     - a writer that closes before the other subtasks/writers finish accumulating sees a **partial** total → `MIN_ROW` failures (`75`, `97`);
     - accumulation from other writers/attempts under the same key inflates the total → `MAX_ROW` failures (`125`, `150` — i.e. 100 + 25/50 chunks).
   
   Both directions appear in the same job, which matches shared mutable static state plus per-subtask close(), not test data.
   
   ### What you expected
   Row-count rules evaluated against the rows the writer (or the job) actually received, isolated per job/table/writer, on every engine.
   
   ### Suggested fix (connector-assert, `src/main`)
   Make the counters instance/per-job state (e.g. per-writer counters aggregated at commit/close via the sink's commit path, or keyed by job id + table), and evaluate `MIN_ROW`/`MAX_ROW` once all writers for the table have finished rather than per-subtask `close()`. Not proposing a test-only workaround: the test is correct and the assertion is the intended contract.
   
   ### SeaTunnel Version
   dev (`04fabece`), reproduced on Flink 1.15.3 and 1.18.0 e2e containers.
   
   ### Engine
   Flink (Zeta and Spark unaffected).
   


-- 
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.apache.org

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


Re: [I] [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close() [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12116:
URL: https://github.com/apache/seatunnel/issues/12116#issuecomment-5584884264

   Thanks for tracing this against the published contract. Current `dev` still has a static `LONG_ACCUMULATOR`, while the Assert documentation says `MIN_ROW` and `MAX_ROW` are evaluated once at close against the rows observed by that writer instance. The row-count part of the intended scope is therefore clear: the first fix should replace the JVM-wide accumulator with writer-owned state and preserve the existing close-time evaluation boundary.
   
   Please keep that PR limited to the row-count defect. Add a deterministic regression with two writers for the same table (and, where relevant, sequential writers in one JVM) proving that one writer's close result cannot be affected by another writer's rows. Do not fold the separate static `TABLE_NAMES` question into this change: aggregate-versus-writer-local table-name semantics need their own documented contract and lifecycle analysis before changing them. The fix must not silently redefine multi-writer assertions as job-global aggregation.
   


-- 
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


Re: [I] [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close() [seatunnel]

Posted by "CryoThrust (via GitHub)" <gi...@apache.org>.
CryoThrust commented on issue #12116:
URL: https://github.com/apache/seatunnel/issues/12116#issuecomment-5556462585

   I traced this against the published Assert contract. The English and Chinese docs say that MIN_ROW/MAX_ROW are evaluated against the cumulative rows received by that Writer instance since it was created. That makes the static JVM-wide LONG_ACCUMULATOR incompatible with the documented scope: writers can observe partial totals, totals from sibling subtasks, and values left by another job or attempt in the same TaskManager JVM.
   
   For the row-count rules, the smallest contract-preserving fix appears to be instance-owned counters, for example a per-writer map keyed by table, with a regression test that creates two writers for the same table and verifies that closing one is unaffected by rows written to the other.
   
   There is a separate semantic question for the static TABLE_NAMES set: should table-names be the union across all parallel writers, or the set observed by each writer? An instance-local set is consistent with the current per-Writer wording but could change multi-table validation; a global union would require an explicit aggregation/lifecycle point rather than JVM statics. Could a maintainer confirm that intended scope before implementation?


-- 
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


Re: [I] [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close() [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12116:
URL: https://github.com/apache/seatunnel/issues/12116#issuecomment-5552994705

   Supporting evidence from the Flink translation layer (`dev`, `seatunnel-translation-flink-common/.../sink/FlinkSink.java` lines 78–88): `FlinkSink#createWriter` wraps `sink.createWriter(stContext)` in one `FlinkSinkWriter` per Flink subtask, with no per-table routing at that level — so every `AssertSinkWriter` instance in a Flink TaskManager receives whatever rows reach its subtask and accumulates into the same static `LONG_ACCUMULATOR`/`TABLE_NAMES`, then evaluates its rules in its own `close()`. Under Zeta each job has its own classloader, so the statics are effectively isolated there, which is why only Flink legs fail. Reproduction count so far on the same dev test: PR #11458 (Flink 1.18.0: 97/125/150), #11077 (Flink 1.15.3: 75/125/150), #11503 (Flink 1.15.3 + one more Flink leg: 87/125/150).


-- 
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


Re: [I] [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close() [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo closed issue #12116: [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close()
URL: https://github.com/apache/seatunnel/issues/12116


-- 
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


Re: [I] [Bug][Connector-V2][Assert] Multi-table row-count rules flaky on Flink: AssertSinkWriter uses static JVM-wide counters evaluated per-subtask close() [seatunnel]

Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on issue #12116:
URL: https://github.com/apache/seatunnel/issues/12116#issuecomment-5595369250

   Two more occurrences for the record, both on #12182, and one detail that may narrow the cause.
   
   Fork run `34135130164` on head `08b4cd2a7`, same test and same symptom as the three cases in the description, `TestFilterRowKindIT.testFilterRowKindMultiTable:53 expected: <0> but was: <1>`:
   
   - attempt 1, job `101784974271`, `transform-v2-it-part-1 (11, ubuntu-latest)`: failed on `{TestContainer}[3]`, which is `tyrantlucifer/flink:1.18.0-scala_2.12_hadoop27`.
   - attempt 3, job `102038075593`, same job name, same head: failed on `{TestContainer}[2]`, which is `tyrantlucifer/flink:1.15.3-scala_2.12_hadoop27`.
   
   The detail that seems worth having on record: this is the same unchanged commit failing twice across reruns, and it moved between Flink minor versions rather than staying on one. In both runs the Zeta leg and both Spark legs of the same test passed, and the `transform-v2-it-part-1 (8, ubuntu-latest)` leg passed. That is consistent with the shared-static-counter diagnosis in the description and against anything data-dependent or version-specific, since the config, the data and the head are identical across the two failures and only the leg that lost the race changed.
   
   For completeness on relevance: #12182 changes `NumericFunction.mod` and two unit test classes under `seatunnel-transforms-v2`. It touches nothing in `connector-assert`, nothing in the `FilterRowKind` transform, and nothing in `seatunnel-e2e`.
   
   Anecdotally the rate looks high rather than rare. Two failures in two executions of that job on the same head, so a rerun has not been a reliable way around it.
   


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

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

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