Skip to content

bug: CDC Date clamping consistent with initial load limits#4600

Merged
pfcoperez merged 5 commits into
mainfrom
cdc/date-clamping
Jul 21, 2026
Merged

bug: CDC Date clamping consistent with initial load limits#4600
pfcoperez merged 5 commits into
mainfrom
cdc/date-clamping

Conversation

@pfcoperez

Copy link
Copy Markdown
Member

In #4534 we added logic to proactively clamp dates to CH Date32 limits at the time.

However, the scope of that change didn't include CDC. CDC normalization was therefore constrained by ClickHouse's parseDateTime64BestEffortOrNull limits.

These limits changed with with ClickHouse/ClickHouse#107907 leaving initial loads and cdc supported date ranges inconsistent with each other.

This PR aligns CDC to use the same limits as initial load.

From now this is a constant to [1900-01-01, 2299-12-31] but might want to follow up with a piece of functionality probing destination CH valid ranges to make the most of the target CH version capabilities.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

❌ 8 Tests Failed:

Tests completed Failed Passed Skipped
3033 8 3025 377
View the top 3 failed test(s) by shortest run time
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMariaDB_CH
Stack Traces | 0.01s run time
=== RUN   TestPeerFlowE2ETestSuiteMariaDB_CH
=== PAUSE TestPeerFlowE2ETestSuiteMariaDB_CH
=== CONT  TestPeerFlowE2ETestSuiteMariaDB_CH
--- FAIL: TestPeerFlowE2ETestSuiteMariaDB_CH (0.01s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster
Stack Traces | 0.01s run time
=== RUN   TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster
=== PAUSE TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster
=== CONT  TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster
2026/07/20 15:13:25 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
--- FAIL: TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster (0.01s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMySQL_CH
Stack Traces | 0.01s run time
=== RUN   TestPeerFlowE2ETestSuiteMySQL_CH
=== PAUSE TestPeerFlowE2ETestSuiteMySQL_CH
=== CONT  TestPeerFlowE2ETestSuiteMySQL_CH
2026/07/20 15:13:25 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
--- FAIL: TestPeerFlowE2ETestSuiteMySQL_CH (0.01s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMySQL_CH_Cluster
Stack Traces | 0.01s run time
=== RUN   TestPeerFlowE2ETestSuiteMySQL_CH_Cluster
=== PAUSE TestPeerFlowE2ETestSuiteMySQL_CH_Cluster
=== CONT  TestPeerFlowE2ETestSuiteMySQL_CH_Cluster
--- FAIL: TestPeerFlowE2ETestSuiteMySQL_CH_Cluster (0.01s)
2026/07/20 15:26:10 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:26:10 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:26:10 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_api_s7ddtuvc.t1
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMariaDB_CH/Test_MySQL_DateTime_ClickHouse_Range
Stack Traces | 20.1s run time
=== RUN   TestPeerFlowE2ETestSuiteMariaDB_CH/Test_MySQL_DateTime_ClickHouse_Range
=== PAUSE TestPeerFlowE2ETestSuiteMariaDB_CH/Test_MySQL_DateTime_ClickHouse_Range
=== CONT  TestPeerFlowE2ETestSuiteMariaDB_CH/Test_MySQL_DateTime_ClickHouse_Range
2026/07/20 15:27:17 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:27:17 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    clickhouse_mysql_test.go:2139: WaitFor waiting on snapshot 2026-07-20 15:27:21.78304777 +0000 UTC m=+836.206518636
    clickhouse_mysql_test.go:2143: WaitFor waiting on cdc 2026-07-20 15:27:21.787746356 +0000 UTC m=+836.211217212
    clickhouse_mysql_test.go:2160: 
        	Error Trace:	.../flow/e2e/clickhouse_mysql_test.go:2160
        	            				.../flow/e2e/clickhouse_mysql_test.go:2172
        	            				.../hostedtoolcache/go/1.26.5.../src/runtime/asm_amd64.s:1771
        	Error:      	Not equal: 
        	            	expected: "1900-01-01 05:30:45.000000"
        	            	actual  : "1000-06-15 05:30:45.000000"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-1900-01-01 05:30:45.000000
        	            	+1000-06-15 05:30:45.000000
        	Test:       	TestPeerFlowE2ETestSuiteMariaDB_CH/Test_MySQL_DateTime_ClickHouse_Range
--- FAIL: TestPeerFlowE2ETestSuiteMariaDB_CH/Test_MySQL_DateTime_ClickHouse_Range (20.13s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
Stack Traces | 20.2s run time
=== RUN   TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
=== PAUSE TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
=== CONT  TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
2026/07/20 15:19:23 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:19:23 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:19:23 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_machcl_tmmk739b.test_mysql_ghost_schema
    clickhouse_mysql_test.go:2139: WaitFor waiting on snapshot 2026-07-20 15:19:28.880576877 +0000 UTC m=+363.304047733
    clickhouse_mysql_test.go:2143: WaitFor waiting on cdc 2026-07-20 15:19:28.886969784 +0000 UTC m=+363.310440641
2026/07/20 15:19:28 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:19:28 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_machcl_tmmk739b.test_mysql_ghost_schema
    clickhouse_mysql_test.go:2160: 
        	Error Trace:	.../flow/e2e/clickhouse_mysql_test.go:2160
        	            				.../flow/e2e/clickhouse_mysql_test.go:2172
        	            				.../hostedtoolcache/go/1.26.5.../src/runtime/asm_amd64.s:1771
        	Error:      	Not equal: 
        	            	expected: "1900-01-01 05:30:45.000000"
        	            	actual  : "1000-06-15 05:30:45.000000"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-1900-01-01 05:30:45.000000
        	            	+1000-06-15 05:30:45.000000
        	Test:       	TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
--- FAIL: TestPeerFlowE2ETestSuiteMariaDB_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range (20.24s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMySQL_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
Stack Traces | 20.3s run time
=== RUN   TestPeerFlowE2ETestSuiteMySQL_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
=== PAUSE TestPeerFlowE2ETestSuiteMySQL_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
=== CONT  TestPeerFlowE2ETestSuiteMySQL_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
2026/07/20 15:24:53 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:24:53 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    clickhouse_mysql_test.go:2139: WaitFor waiting on snapshot 2026-07-20 15:24:58.542636469 +0000 UTC m=+692.966107325
    clickhouse_mysql_test.go:2143: WaitFor waiting on cdc 2026-07-20 15:24:58.55027006 +0000 UTC m=+692.973740926
    clickhouse_mysql_test.go:2160: 
        	Error Trace:	.../flow/e2e/clickhouse_mysql_test.go:2160
        	            				.../flow/e2e/clickhouse_mysql_test.go:2172
        	            				.../hostedtoolcache/go/1.26.5.../src/runtime/asm_amd64.s:1771
        	Error:      	Not equal: 
        	            	expected: "1900-01-01 05:30:45.000000"
        	            	actual  : "1000-06-15 05:30:45.000000"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-1900-01-01 05:30:45.000000
        	            	+1000-06-15 05:30:45.000000
        	Test:       	TestPeerFlowE2ETestSuiteMySQL_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range
--- FAIL: TestPeerFlowE2ETestSuiteMySQL_CH_Cluster/Test_MySQL_DateTime_ClickHouse_Range (20.26s)
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuiteMySQL_CH/Test_MySQL_DateTime_ClickHouse_Range
Stack Traces | 20.3s run time
=== RUN   TestPeerFlowE2ETestSuiteMySQL_CH/Test_MySQL_DateTime_ClickHouse_Range
=== PAUSE TestPeerFlowE2ETestSuiteMySQL_CH/Test_MySQL_DateTime_ClickHouse_Range
=== CONT  TestPeerFlowE2ETestSuiteMySQL_CH/Test_MySQL_DateTime_ClickHouse_Range
2026/07/20 15:21:54 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:21:54 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/20 15:21:54 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mych_ayempky1.test_exclude_ch
    clickhouse_mysql_test.go:2139: WaitFor waiting on snapshot 2026-07-20 15:21:58.190251255 +0000 UTC m=+512.613722121
    clickhouse_mysql_test.go:2143: WaitFor waiting on cdc 2026-07-20 15:21:58.19516076 +0000 UTC m=+512.618631626
2026/07/20 15:21:58 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mych_ayempky1.test_exclude_ch
    clickhouse_mysql_test.go:2160: 
        	Error Trace:	.../flow/e2e/clickhouse_mysql_test.go:2160
        	            				.../flow/e2e/clickhouse_mysql_test.go:2172
        	            				.../hostedtoolcache/go/1.26.5.../src/runtime/asm_amd64.s:1771
        	Error:      	Not equal: 
        	            	expected: "1900-01-01 05:30:45.000000"
        	            	actual  : "1000-06-15 05:30:45.000000"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-1900-01-01 05:30:45.000000
        	            	+1000-06-15 05:30:45.000000
        	Test:       	TestPeerFlowE2ETestSuiteMySQL_CH/Test_MySQL_DateTime_ClickHouse_Range
2026/07/20 15:22:14 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mych_ekw34gll.test_bit
--- FAIL: TestPeerFlowE2ETestSuiteMySQL_CH/Test_MySQL_DateTime_ClickHouse_Range (20.33s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: A real bug: the cdc/date-clamping PR fails Test_MySQL_DateTime_ClickHouse_Range deterministically across all 4 ClickHouse suite variants because out-of-range MySQL DATETIME values aren't clamped to the 1900-01-01 boundary (got raw 1000-06-15), indicating incomplete DATETIME64 clamping logic.
Confidence: 0.98

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@pfcoperez
pfcoperez marked this pull request as ready for review July 20, 2026 15:42
@pfcoperez
pfcoperez requested a review from a team as a code owner July 20, 2026 15:42
@claude

claude Bot commented Jul 20, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@pfcoperez
pfcoperez enabled auto-merge (squash) July 20, 2026 17:21
@pfcoperez
pfcoperez disabled auto-merge July 20, 2026 17:21
@pfcoperez
pfcoperez enabled auto-merge (squash) July 20, 2026 17:21
Comment thread flow/connectors/clickhouse/normalize_query.go Outdated
@pfcoperez
pfcoperez force-pushed the cdc/date-clamping branch from 39f6d63 to 09ca7ae Compare July 20, 2026 20:50
@pfcoperez
pfcoperez merged commit a2be15c into main Jul 21, 2026
18 checks passed
@pfcoperez
pfcoperez deleted the cdc/date-clamping branch July 21, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants