fix(source-mssql): pin data.query.mode=function to fix CDC hang on large change tables - #84356
Conversation
…rge change tables
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksPR Slash CommandsAirbyte Maintainers (that's you!) can execute the following slash commands on your PR:
📚 Show Repo GuidanceHelpful Resources
|
|
/publish-connectors-prerelease connector=source-mssql
|
|
|
↪️ Triggering Reason: Draft PR, CI checks passing, and no |
|
🟡 No Regression Detected — Fix Not ExercisedProve-fix validation of Summary: the change does exactly what it says — the preview provably executes the CDC function query instead of Debezium 3.4's default direct change-table query — and it causes no correctness regression. What could not be shown is that this resolves the reported failure: the originating symptom never reproduced, and the performance rationale behind the change did not survive measurement. Merging is low risk; treating this as a confirmed fix for the incident is not yet justified. Pre-flightThe diff adds one Debezium property and bumps 1. The property takes effect — provenConnector logs carry no SQL, so the executed statements were captured server-side with SQL Server Extended Events on a synthetic local database: Captured CDC streaming statementsControl SELECT [__$start_lsn], [__$seqval], [__$operation], [__$update_mask], ...
FROM [CdcTest].cdc.[dbo_users_CT]
WHERE ...
ORDER BY [__$start_lsn] ASC, [__$command_id] ASC, [__$seqval] ASC, [__$operation] ASCTarget SELECT [__$start_lsn], [__$seqval], [__$operation], [__$update_mask], ...
FROM [CdcTest].cdc.[fn_cdc_get_all_changes_dbo_users]( @P0, @P1, N'all update old')
WHERE ...
ORDER BY [__$start_lsn] ASC, [__$seqval] ASC, [__$operation] ASCThe target's startup configuration prints 2. No correctness regression — provenDrain comparisons (read → extract state → read again until a read emits zero records), same fixtures and same DML for both images:
Each experiment ended with a single duplicate delete in the cumulative comparison — on the target side in one run, on the control side in the other — i.e. at-least-once behaviour at a resume boundary, present in both query modes and idempotent at the destination. No records were lost in either mode. One behaviour worth documenting, affecting both versions identically: a read that reaches its target position mid-transaction stops there ( 3. The performance rationale — refuted at the scale testedThe natural explanation for a hang would be that direct mode must sort a large change set before returning a first row while the function query streams it. Measured against 1.5M change rows (
At this scale the function mode is the one that sorts, and it was slightly slower. That does not rule out different behaviour on a much larger change table with a different schema and index state, but the stated rationale is not supported by anything measurable locally. The related upstream bug debezium/dbz#2012 — direct mode dropping deferred-update rows when a transaction spans a Regression testingTwo comparison runs were executed with all four verbs, all streams, debug logs enabled — first with default credentials, then sourcing config/catalog/state from an internal (non-customer) SQL Server CDC connection:
Both Why 🟡 rather than 🟢The fix's mechanism is confirmed and it is regression-free, but the failure it targets was never reproduced, and the local measurements point the other way on performance. Proving it requires a live run with the preview pinned on an affected connection, comparing time-to-first-record and progress against recent failures — that needs human approval before any pinning and has not been requested. Worth settling first whether the query shape is really the cause: if the stall is platform-side heartbeat handling rather than the change-table query, this property will not address it. Detailed, connection-specific evidence is in the linked private oncall issue. |
|
🙋 Escalated per Hands-Free AI Triage Project — |
Fixes:
https://github.com/airbytehq/oncall/issues/13173
What
data.query.modefromfunctiontodirectwhen upgrading tov3.4.3, ref. This mode addedLEFT JOINandORDER BYthat can explain why syncs are slower.How
Review guide
User Impact
Can this PR be safely reverted and rolled back?