Repository navigation
Fix multi-block inserts to Alias with insert_deduplication_token - #103246
Conversation
|
FYI @nauu and @jkartseva as you've been involved in other Alias PRs I'm trying to learn the CH codebase and as I was already working on Alias and deduplication I tried to fix this bug reported by @clickgapai. I'll be responsive to feedback so lmk if you have any |
|
Thanks for the suggestion about PR #103246. I investigated this approach, but unfortunately it wouldn't work for our case - that PR modifies ClickHouse source code (StorageAlias.cpp), while test fixes need to stay within the test framework itself. I also tested it locally and encountered timeouts, indicating the approach has some issues. |
|
Workflow [PR], commit [42d7236] Summary: ✅ AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
|
I'm reviewing flakiness in the proposed approach |
In `AliasSink`, each sink instance builds its own `InterpreterInsertQuery` pipeline. That pipeline contains an `AddDeduplicationInfoTransform` whose `block_number` counter starts at zero. With `max_insert_threads > 1`, multiple `AliasSink` instances are created in parallel and each produces deduplication tokens like `<user_token>_0`, `<user_token>_1`, ... starting from zero. Tokens collide across sinks and parts are deduplicated against each other, losing rows. Test `04102_storage_alias_insert_dedup_token` failed under the flaky check which randomizes settings (e.g. `--max_insert_threads 2` or `3`), producing 6 rows instead of 10. Override `supportsParallelInsert` to return `false` for `StorageAlias` so that only a single sink is created. Failing CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103246&sha=1eea22708c3752717263f69ad86608b72d9eb3ba&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 PR: ClickHouse#103246 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@alexey-milovidov I thought it was a shame to disable parallel inserts completely for Alias and wanted to review if the issue is only when |
|
I've made some progress on this today. I'm trying to assign a |
7474b36 to
5cef624
Compare
|
I think I've managed to keep parallel insert for Alias and the expected deduplication behaviour. The main change is that the DeduplicationInfo that sets the source block number before the parallel fan-out. I've updated Fast tests passed on my machine. Hope this doesn't break anything else. (sorry for the force push reverting the parallel insert disable. I'll get it back if this approach doesn't work) Update: I see there's a bunch of failures. Hopefully all for the same reason. I'll tackle them tomorrow |
5cef624 to
77c16c9
Compare
58a0db4 to
0ca5dab
Compare
|
Just a couple flaky test failures. Rebased and pushed Update: the stress test is not flaky :D Fixing the logical error that makes it fail. |
0ca5dab to
1281af5
Compare
|
Whew, we got very lucky with the stress tests and they surfaced a bug that was not specifically exercised in tests. Essentially:
What I've done:
|
|
This was fixed by #105146. Let's update the branch. |
|
Been AFK on the weekend but I'm inclined to have supportsSampling() raise UNKNOWN_TABLE, as that's what StorageMaterializedView does. And I'll do the same for the rest of supports... methods. I'll push the changes tomorrow. I'm aware that this is blocking #103488 so I'm keen to get it over the line |
Keep a single `InterpreterInsertQuery` pipeline across all chunks so they get a different `source_block_number`
The reference file incorrectly contained the test's SQL statements as if they were echoed in the test output. `clickhouse-test` does not echo queries from `.sql` tests; only the `SELECT` outputs are captured. The test consistently failed on Fast test because the reference contained many lines that were not present in the actual output. Strip the reference down to the three `SELECT` outputs the test produces. Failing CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103246&sha=2e04445c1f6d5bbdfb5f3181f4300d8029893cf5&name_0=PR&name_1=Fast%20test
This fixes multi-block parallel inserts through Alias. AliasSink now forwards incoming Chunk infos to the nested target insert pipeline. AddDeduplicationInfoTransform then reuses an existing source identity in DeduplicationInfo, while still updating the current insert dependencies and original block.
2c38a0d to
b3f794a
Compare
b3f794a to
9e43c4e
Compare
|
I'm feeling quite good about this branch now. Hope CI agrees. The last run only had a failure that I deemed as unrelated and that has failed in other PRs recently (cidb) I'll mark as ready to review if no jobs have failed before my day ends even if some jobs are is still going. |
LLVM Coverage Report
Changed lines: 59.09% (65/110) | lost baseline coverage: 2 line(s) · Uncovered code |
Keep a single
InterpreterInsertQuerypipeline across all chunks so they get a differentsource_block_numberCloses #103118
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix multi-block inserts to
Aliaswithinsert_deduplication_tokenso all blocks are keptDocumentation entry for user-facing changes
Version info
26.5.1.832