[fix](cdc) move SSL/JDBC config before startup mode to fix offset on SSL-required MySQL - #66559
[fix](cdc) move SSL/JDBC config before startup mode to fix offset on SSL-required MySQL#66559maks3201 wants to merge 2 commits into
Conversation
…log offset The generateMySqlConfig() method applied SSL settings (ssl_mode, ssl_rootcert) and JDBC connection properties AFTER the startup mode switch-case block. Modes like "latest", "earliest", and 13-digit timestamp call initializeEffectiveOffset() inside that block, which opens a JDBC connection to resolve the current binlog position via SHOW MASTER STATUS. Since SSL was not yet configured on the factory, this connection used plaintext and failed on MySQL/Aurora instances with require_secure_transport=ON. Fix: move the JDBC properties + SSL + Debezium properties block to before the startup mode block, so initializeEffectiveOffset() uses the correct SSL settings when building its temporary connection. Modes "initial" and "snapshot" never call initializeEffectiveOffset() and are unaffected by this reordering.
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
This bug is present in released versions 4.1.2 and 4.1.3. Could a committer please apply the |
Adds MySqlStartupSslITCase, which guards the ordering fixed in this PR.
The test starts a MySQL container, enables require_secure_transport=ON after
startup (so the Testcontainers readiness probe, which connects without TLS, is
not broken), and runs a CDC job with offset=latest and ssl_mode=require. That
offset mode reaches initializeEffectiveOffset(), the call that opened an
un-encrypted JDBC connection before this fix.
Test methods:
- latestStartupModeSucceedsWithSecureTransport: the regression guard. Also
asserts offset=latest does not replay pre-existing rows.
- nonSslPathStillWorksWithoutSecureTransport: control case proving the
reorder does not change the non-TLS path. Uses a SECOND container without
the secure-transport requirement, rather than toggling the flag on a shared
container, so a mid-test failure cannot leave it OFF and make the SSL
assertions vacuous.
- plaintextConnectionRejectedBySecureTransportServer: sanity check that the
server really enforces TLS.
All SQL the test issues against the TLS-enforcing container goes through the
mysql CLI via execInContainer, because Unix socket connections are exempt from
require_secure_transport while the test's own JDBC connections would otherwise
be rejected too.
Only offset=latest is covered. earliest and the timestamp mode go through the
same initializeEffectiveOffset() path so they add no coverage of the ordering
bug, and they need different assertions because they replay the setup rows
instead of skipping them.
Adds CdcClientWriteHarness.withSslMode() following the existing fluent
withXxx() pattern.
|
Thanks for the triage. You were right that the fix direction was correct but the PR had no regression test, so I have added one: Following your suggestion it starts a MySQL container, turns on I verified it in both directions, because a regression test that passes on patched and unpatched code alike would be worthless. On this PR's code the test passes: With only That is exactly the path described in the issue: the early JDBC connection inside Note that only 1 of the 3 methods fails on unpatched code. That is intended. The non-TLS control case runs against a second container without the secure-transport requirement, and the plaintext sanity check only asserts the server enforces TLS, so neither is affected by the ordering bug. A sibling test, Two notes on the test design, in case they come up in review:
I only covered One thing worth flagging for CI: when I ran this locally the |
What problem does this PR solve?
Issue Number: close #66558
Related PR: N/A
Problem Summary:
In
MySqlSourceReader.generateMySqlConfig(), the startup mode block (handlingoffset=latest,earliest, and timestamp) callsinitializeEffectiveOffset(), which opens a JDBC connection to the source MySQL to resolve the current binlog filename and position. However, SSL properties (ssl_mode,ssl_rootcert) and JDBC connection properties are applied after this block.This means on any MySQL instance configured with
require_secure_transport=ON, the JDBC connection insideinitializeEffectiveOffset()attempts a plaintext connection, which the server rejects. The streaming job fails immediately at startup.The fix moves the JDBC properties and SSL configuration block to before the startup mode switch block. This ensures
initializeEffectiveOffset()uses the correct SSL settings when building its temporary connection.Why the reordering is safe for non-SSL users: When
ssl_modeis not specified in the job properties, the SSLif-blocks are skipped entirely andjdbcPropertiescontains only the URL connection parameters (same as before). The JDBC connection insideinitializeEffectiveOffset()behaves identically whether the properties object is set on the factory before or after the startup mode block — the only difference is that now it is available at the point it is needed.Affected offset modes:
latest— callsinitializeEffectiveOffset()✗ fails without this fixearliest— callsinitializeEffectiveOffset()✗ fails without this fixinitializeEffectiveOffset()✗ fails without this fixinitial/snapshot— do NOT callinitializeEffectiveOffset()→ unaffectedRelease note
Fixed a bug where CDC streaming jobs with
offset=latest,offset=earliest, or a timestamp offset failed immediately on MySQL instances that require SSL (require_secure_transport=ON). The SSL connection properties were being configured after the code that needed them.Check List (For Author)
Test
Note on testing: The defect is a method-call ordering issue within a single method. A unit test cannot meaningfully assert that JDBC properties are set on the factory before
initializeEffectiveOffset()is called without fragile mocking of internal sequencing. A meaningful regression test requires a live MySQL instance withrequire_secure_transport=ON, which is not available in upstream CI. The fix has been validated manually against Aurora MySQL 8.0 with SSL required.If it changes/adds/deletes any user-facing features or behaviours (NO — the fix restores intended behaviour, no new features):
If it affects the operation/behaviour of existing data (NO):
Backport: Please label
dev/4.1.x. This bug is present in 4.1.2 and 4.1.3. The fix applies cleanly tobranch-4.1.