You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "liking2354 (via GitHub)" <gi...@apache.org> on 2026/04/15 14:43:57 UTC
[I] [Bug] [Connector-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
liking2354 opened a new issue, #10770:
URL: https://github.com/apache/seatunnel/issues/10770
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues.
### What happened
Issue Description:
The Keyset cursor state (lastOrderingKeyValues) is stored on the ClickhousePart object, but the same Part object is shared and read by multiple threads, causing the state to be overwritten.
Test Scenario:
Today, I upgraded from v2.3.12 to v2.3.13 for testing. During the synchronization from freight_a to freight_b, the source database orders had 500,000 records, but only 376,526 records were synchronized after completion. I have uploaded a screenshot.
My Analysis:
Multiple threads concurrently read the same Part, each maintaining an independent OFFSET.
Bug Location:
In PartStrategySplitter.java, lines 86-88:
`HashSet<ClickhousePart> partSet = new HashSet<>(shardPartsEntry.getValue());`
HashSetdoes not guarantee order, and combined with ClickhouseSourceSplitEnumerator's addPendingSplitdistributing Splits to multiple Readers based on hash, the same Part is processed by multiple concurrent Readers (or multiple threads of the same Reader). Each thread has an independent OFFSET, and there is no shared lastOrderingKeyValuesstate.
Data Loss Mechanism:
1.Thread A reads Part X, OFFSET 0 → 1024 → 2048...
2.Thread B also reads Part X, OFFSET 0 → 1024 → 2048... (overlapping with A)
3.Each thread reads some portions and skips others, resulting in incomplete data when merged.
4.ClickHouse MergeTree deduplicates repeated data (keeping only one copy), causing the missed data to be permanently lost.
After rolling back to version 2.3.12, the data in the source and target databases became consistent when the synchronization was executed again.
### SeaTunnel Version
SeaTunnel 2.3.13
### SeaTunnel Config
```conf
No problem. I've already rolled back to version 2.3.12. If needed, I can provide further information.
```
### Running Command
```shell
No problem. I've already rolled back to version 2.3.12. If needed, I can provide further information.
```
### Error Exception
```log
No errors were reported, and the task completed normally. It's just that the target database has fewer records than the source database.
```
### Zeta or Flink or Spark Version
_No response_
### Java or Scala Version
_No response_
### Screenshots
<img width="596" height="408" alt="Image" src="https://github.com/user-attachments/assets/869daf9b-7698-4e8d-b474-739d3979ab75" />
<img width="498" height="360" alt="Image" src="https://github.com/user-attachments/assets/1e4a7a86-c291-4979-8fee-7707f1f2f5a2" />
<img width="570" height="312" alt="Image" src="https://github.com/user-attachments/assets/7218b52b-991a-4d11-a9cd-725ff30f38cb" />
<img width="596" height="282" alt="Image" src="https://github.com/user-attachments/assets/6af77a05-c567-4290-bbf9-338b0947031e" />
<img width="596" height="238" alt="Image" src="https://github.com/user-attachments/assets/dcd46618-fffa-4722-859e-4f349caae955" />
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "JeremyXin (via GitHub)" <gi...@apache.org>.
JeremyXin commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4257916883
<img width="2120" height="270" alt="Image" src="https://github.com/user-attachments/assets/b4a96ee8-fd16-4679-afac-56644052d89f" />
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "liking2354 (via GitHub)" <gi...@apache.org>.
liking2354 commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4261229721
@DanielLeens @JeremyXin Thank you both for your analysis and suggestions. It's possible that the issue lies with the data itself. I have rolled back to version 2.3.12 as the practical choice for actual use. If any further issues arise, I will provide additional feedback. Thanks again.
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4259451313
Thanks @JeremyXin, I agree with this direction.
After checking the attached server log and the latest screenshot again, the current evidence does not support the "same ClickhousePart is concurrently mutated by multiple readers" path:
1. the reproduced job uses parallelism = 1
2. PartStrategySplitter generated only 1 split for freight_a.orders
3. that split was assigned to reader [0]
So we should not make a broad concurrency/state-sharing fix unless a separate reproduction proves that path.
The issue is still worth treating as a real 2.3.13 ClickHouse source data-completeness regression. The suspicious path remains the keyset pagination introduced around ClickhouseValueReader: _part filtering + ORDER BY created_at, id + LIMIT ... WITH TIES, then advancing with lastOrderingKeyValues.
To move the fix forward, the most useful next evidence is:
1. the real ClickHouse DDL from SHOW CREATE TABLE freight_a.orders, especially ENGINE, PARTITION BY, ORDER BY, PRIMARY KEY, and the exact types of created_at / id
2. clarification of the actual reproducing table, because the posted config mentions freight_a.drivers but the log and row-count symptom also show freight_a.orders
3. a primary-key based diff, for example missing id ranges or a small reproducible dataset, not only total row count
For a PR, I suggest starting with a focused regression test for part batch reading with a composite sorting key and keyset cursor. Once that test reproduces the missing rows, the fix can stay narrowly scoped to the ClickhouseValueReader pagination logic.
Rolling back to 2.3.12 remains the safest temporary workaround until this path is fixed.
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "liking2354 (via GitHub)" <gi...@apache.org>.
liking2354 closed issue #10770: [Bug] [Connector-Clickhouse] This is a concurrency safety bug introduced by PR #9801
URL: https://github.com/apache/seatunnel/issues/10770
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "liking2354 (via GitHub)" <gi...@apache.org>.
liking2354 commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4253123495
[ClickhouseValueReader.java](https://github.com/user-attachments/files/26753745/ClickhouseValueReader.java)
Here are my proposed modifications, though I'm not entirely certain if they are correct.
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "liking2354 (via GitHub)" <gi...@apache.org>.
liking2354 commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4257111313
{
"env" : {
"job.mode" : "BATCH",
"job.name" : "BATCH-20260416-100832",
"parallelism" : 1
},
"sink" : [
{
"bulk_size" : "20000",
"clickhouse.config" : {
"nullAsDefault" : 2,
"use_server_time_zone" : "true"
},
"data_save_mode" : "DROP_DATA",
"database" : "freight_b",
"host" : "9.134.89.84:8123",
"password" : "******",
"plugin_input" : [
"src_drivers"
],
"plugin_name" : "Clickhouse",
"save_mode_create_template" : "CREATE TABLE IF NOT EXISTS `${database}`.`${table_name}` (\n${rowtype_fields}\n) ENGINE = MergeTree()\nORDER BY tuple()\nSETTINGS index_granularity = 8192",
"schema_save_mode" : "CREATE_SCHEMA_WHEN_NOT_EXIST",
"table" : "drivers",
"username" : "******"
}
],
"source" : [
{
"clickhouse.config" : {
"use_server_time_zone" : "true"
},
"host" : "9.134.89.84:8123",
"password" : "******",
"plugin_name" : "Clickhouse",
"plugin_output" : "src_drivers",
"table_path" : "freight_a.drivers",
"username" : "******"
}
],
"transform" : []
}
[seatunnel-engine-server.log](https://github.com/user-attachments/files/26769019/seatunnel-engine-server.log)
<!-- Failed to upload "dump-freight_a-202604161051.sql" -->
Task ID: 1096980624788619265. Detailed logs and data from the test database have been provided in the attachments.
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4253294641
Thanks for the detailed report and for narrowing this down to the 2.3.13 change.
I checked the current execution path around `PartStrategySplitter`, `ClickhouseSourceSplitEnumerator`, and `ClickhouseSourceReader`. From the current code, one `ClickhouseSourceSplit` is assigned to exactly one reader, and that reader consumes its assigned split serially, so the "same Part is concurrently processed by multiple readers" explanation in the issue body does not look like the confirmed path yet.
That said, this still looks like a credible regression introduced by #9801. The more suspicious area is the new keyset pagination path in `ClickhouseValueReader` (`WITH TIES` + `lastOrderingKeyValues`) rather than split assignment itself.
The attached patch is helpful, but I do not want to lock in that fix before we confirm the exact failing branch.
To pin this down and review the fix correctly, could you share:
1. the source table DDL, especially the `ORDER BY` / sorting key definition
2. the SeaTunnel source config with `parallelism`, `split_size`, `batch_size`, `sql`, and `filter_query` (mask sensitive fields)
3. whether the sorting key is unique, and the exact types of the sorting key columns
4. if possible, a minimal reproducible dataset around one missing range
Rolling back to 2.3.12 is a reasonable temporary workaround for now.
If you want to prepare a PR, a focused regression test around the #9801 keyset path would be the best starting point. @JeremyXin, could you also take a look here since #9801 introduced this code path?
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "JeremyXin (via GitHub)" <gi...@apache.org>.
JeremyXin commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4257873914
For the 86-88 lines of code you said about the `PartStrateggSplitter` code
HashSet is mainly used here to remove duplication from the `ClickhousePart` obtained under each shard. In my design, in the end, each Split in `ClickhouseSourceSplitEnumerator` will only be assigned to one Reader.
```
for (ClickhouseSourceSplit split : splits) {
int ownerReader = getSplitOwner(split.splitId(), readerCount);
LOG.debug("Assigning {} to {} reader. ", split, ownerReader);
pendingSplit.computeIfAbsent(ownerReader, r -> new ArrayList<>()).add(split);
}
```
Moreover, when parallelism = 1, all split splits should only be allocated to one Reader to read, and there should be no such thing as 'multiple readers sharing and muting the same ClickhousePart object'.
I see that the Table structure for table orders you posted is a MYSQL data table? Not a Clikckhouse data sheet? Can I post the DDL of the 'freight_a.drivers' data table?
If you have any further questions, please feel free to communicate with me
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "liking2354 (via GitHub)" <gi...@apache.org>.
liking2354 closed issue #10770: [Bug] [Connector-Clickhouse] This is a concurrency safety bug introduced by PR #9801
URL: https://github.com/apache/seatunnel/issues/10770
--
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-Clickhouse] This is a concurrency safety bug introduced by PR #9801 [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #10770:
URL: https://github.com/apache/seatunnel/issues/10770#issuecomment-4257429947
Thanks for the additional config and server log. This new log is very useful.
I rechecked it against the current ClickHouse source path. For job `1096980624788619265`, the log shows:
1. `parallelism = 1`
2. `PartStrategySplitter` generated only `1` split for `freight_a.orders`
3. `NoMoreSplitsEvent` was sent to reader `[0]`
So based on this evidence, I do not think the confirmed root cause is "multiple readers sharing and mutating the same `ClickhousePart` object". This run is one split / one reader.
That said, I agree this still looks like a real 2.3.13 regression in the ClickHouse source. The suspicious path is the keyset pagination introduced by #9801 in `ClickhouseValueReader`. The log shows the reader using `_part` plus cursor conditions like:
```sql
WHERE _part = '...' AND ((created_at, id) > (...))
ORDER BY created_at, id
LIMIT 1024 WITH TIES
```
Since the job finishes normally but the target row count is lower, this should be treated as a data-completeness bug path, not an exception path.
For the PR / fix, please focus on proving and fixing that keyset pagination path first:
1. add a regression test or minimal reproduction for batch part reading with a composite sorting key such as `created_at, id`
2. share / verify the real ClickHouse source DDL from `SHOW CREATE TABLE freight_a.orders`, especially `ORDER BY`, primary key, and the exact types of `created_at` and `id`
3. compare source and target by primary-key set or missing ranges, not only by total count
4. avoid a broad concurrency fix unless the regression test proves shared `ClickhousePart` state; this attached log does not show that path
Rolling back to 2.3.12 is still a reasonable temporary workaround.
@JeremyXin could you also help review the keyset pagination branch here, since #9801 introduced this code path?
--
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