support arbitrary string parallel snapshotting - #4522
Conversation
bd316b6 to
3c9cf7d
Compare
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
❌ Test FailureAnalysis: The PR's own new feature test (Test_MySQL_String_Partition_Key_Arbitrary_Parallel_Snapshot) fails deterministically across all three relevant suites with a value-correctness mismatch (expected 8, got 1), indicating a real bug in the arbitrary-string parallel-snapshot logic rather than a flake. |
❌ Test FailureAnalysis: A real bug: the new Test_MySQL_String_Partition_Key_Arbitrary_Parallel_Snapshot test (the exact feature this branch implements) fails deterministically across two suite variants with an identical partition-count assertion mismatch (expected 8, got 1), indicating the arbitrary-string-key parallel snapshot isn't splitting into multiple partitions — no timeout, race, or network signature. |
3c9cf7d to
87683c6
Compare
❌ Test FailureAnalysis: The new Test_MySQL_String_Partition_Key_Arbitrary_Parallel_Snapshot test added by this PR fails deterministically across all four CH suite variants with a consistent partition-key string value mismatch, indicating a real logic bug in the PR's arbitrary-string parallel snapshot feature rather than a flaky/timeout/race failure. |
87683c6 to
4b4de52
Compare
❌ Test FailureAnalysis: The new test Test_MySQL_String_Partition_Key_Arbitrary_Parallel_Snapshot (matching the PR's own feature branch) fails deterministically with assertion mismatches on partition/row counts across all three suites and matrix jobs, indicating a real bug in the PR's new feature rather than flakiness. |
4b4de52 to
2817e2e
Compare
❌ Test FailureAnalysis: The PR's own new test Test_MySQL_String_Partition_Key_Arbitrary_Parallel_Snapshot fails deterministically with partition/row-count assertion mismatches across every suite and compatibility matrix, indicating a real bug in the arbitrary-string-parallel-snapshot feature rather than flakiness. |
2817e2e to
29d182c
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
29d182c to
83aeb72
Compare
❌ Test FailureAnalysis: A deterministic, pure unit test (TestBuildAdaptiveStringPartitions_MixedCase_UUID, 0.00s, no network/concurrency) newly added by this PR fails because adaptive string partitioning produced 3 partitions instead of the expected 5 for mixed-case UUIDs — a real logic bug in the PR's own feature, not flakiness. |
|
The last commit 7e97b79 also fixes the flaky test scenario TestBuildAdaptiveStringPartitions_MixedCase_UUID reported above, which happens occasionally if the generated UUIDs have a midpoint that does not return a valid |
7e97b79 to
547be48
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
14261af to
7640e12
Compare
❌ Test FailureAnalysis: The PR's new test Test_MySQL_String_Partition_Key_Special_Chars_Parallel_Snapshot fails deterministically across all 4 MySQL suites and all 3 matrix jobs because the new string-partition-key parallel snapshot drops one record (destination reaches 49/50 rows), so it's a real bug in the feature this PR adds, not flakiness. |
if fetchNextRealKey does not find a valid key; try fetchPrevRealKey before deeming the partition as unsplittable. This is useful for narrow ranges
…e sensitive data, make test verify contiguous chain
7640e12 to
590974f
Compare
🔄 Flaky Test DetectedAnalysis: The MySQL_BinlogIncident e2e test failed with a connection-level EOF during the initial MySQL handshake ("connection was bad") in test setup, an infrastructure/network flake that affected only 1 of 3 matrix jobs and is unrelated to the PR's changes. ✅ Automatically retrying the workflow |
ilidemi
left a comment
There was a problem hiding this comment.
Great round of improvements!
| // mysql.Escape must NOT be used because MySQL connector session has sql_mode set | ||
| // to NO_BACKSLASH_ESCAPES (see setSessionSettings). Only quotes needs to be escaped. |
There was a problem hiding this comment.
Claude likes adding these types of comments but this really should be a task and a sweep (def too big for this PR)
| // The interpolated midpoint may be unrepresentable in the column charset, | ||
| // in which case the server cannot transcode the string literal for comparison | ||
| // and fails with ERROR 3854 (ER_CANNOT_CONVERT_STRING). Treat it as "no key found". | ||
| if mErr, ok := errors.AsType[*mysql.MyError](err); ok && mErr.Code == 3854 { |
There was a problem hiding this comment.
Awesome fallback, just don't split the partition if we're in a complete encoding rabbithole
There was a problem hiding this comment.
This is still an issue today that I didn't address in this PR yet. It doesn't impact correctness when that happens (this == consecutively invalid partition, not just transcode error), but we are unnecessarily creating a bunch of single-row partitions with only 1 bulk partition when that happen. I'll take this as a follow-up to not expand this PR further. Should be a relatively small fix where we check min/max to see if they are splittable upfront, and if they are both over, or both under the acceptable ascii, then fallback to single partition.
There was a problem hiding this comment.
actually nvm, the transcoding error rabbithole is not a real issue because with found == false, it would end partitioning logic quickly. (vs. the issue with all PK being outside of the ascii bound)
| if _, err := conn.Execute("SET NAMES utf8mb4"); err != nil { | ||
| c.logger.Warn("utf8mb4 not supported, ignoring", slog.Any("error", err)) | ||
| } |
There was a problem hiding this comment.
Not introduced in this PR but related: if this fails, this gives us more cases where we have to deal with invalid utf-8, so safer to just error out here. Statement itself is supported everywhere and the cases it's being hit are all network errors/driver bugs https://c.house/NEzPf5hrTg
There was a problem hiding this comment.
good point, will address this as a follow-up
…row partitions (#4617) Follow up to #4522 Main thing to clean up is the edge case where if both start and end boundary string's first differing byte (the most significant byte for determining the midpoint) are below or above printable ascii, continuing with midpoint interpolation in the extreme case can result in generating a lot of single-row partitions, until we are left with one large final partition. Terminate early when this happens to avoid introducing unnecessary latency. It may still be a full table snapshot, but we don't want to generate a lot of meaningless partitions. --------- Co-authored-by: Ilia Demianenko <ilia.demianenko@clickhouse.com>
Add parallel snapshotting support for arbitrary string using an adaptive bisection strategy.
The partitions are determined by starting with a single partition using min/max fetched values; and then continuously bisecting the largest partition into 2 smaller partitions, until we reached the target number of partitions or until they are no longer splittable.
There are known edge cases that can lead to skewed partitions (see unit tests), but never compromises on correctness. We sacrifice some balancing optimization for a more simple, deterministic partitioning algorithm.
Fixes: DBI-885