You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "merlau (via GitHub)" <gi...@apache.org> on 2026/09/10 13:17:03 UTC
[PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
merlau opened a new pull request, #12258:
URL: https://github.com/apache/seatunnel/pull/12258
### Purpose of this pull request
This pull request introduces native **MariaDB** support to Apache SeaTunnel, adding both a native **JDBC dialect & catalog** and a dedicated **MariaDB CDC Connector**:
1. **MariaDB JDBC Extension (`seatunnel-connectors-v2/connector-jdbc`)**:
- Dedicated `MariaDBDialect` and `MariaDBCatalog` with comprehensive data type mapping (45+ SQL types, `TINYINT(1)` boolean handling, unsigned integers, bit types, spatial geometry, and NTZ/LTZ timestamp handling).
- Native upsert SQL generation (`INSERT ... ON DUPLICATE KEY UPDATE`).
2. **Dedicated MariaDB CDC Connector (`seatunnel-connectors-v2/connector-cdc/connector-cdc-mariadb`)**:
- Independent CDC module supporting incremental snapshot reading, binlog streaming, watermark alignment, dynamic in-flight schema evolution, and checkpoint restore.
- Native MariaDB 3-part integer GTID sequence parsing (`<domain_id>-<server_id>-<sequence_no>`) and state restoration.
---
### Root Causes & Historical Context
This implementation directly resolves recurring community issues where users attempted to run MariaDB workloads against SeaTunnel:
1. **Unresolved Bug [#9148](https://github.com/apache/seatunnel/issues/9148) (`MySQL CDC Unsupported MySQL version: 11.4.2-MariaDB-log`)**:
- Users attempting to use `MySQL-CDC` against MariaDB 11.x encountered fatal startup crashes:
```
java.lang.UnsupportedOperationException: Unsupported MySQL version: 11.4.2-MariaDB-log
at org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.mysql.MySqlVersion.parse
```
- *Status*: Automatically closed by stale-bot with zero fix, leaving MariaDB CDC completely unsupported.
2. **Unresolved Bug [#10030](https://github.com/apache/seatunnel/issues/10030) (`Unsupported MySQL version: 11.4.7-4-MariaDB-enterprise-log`)**:
- Enterprise users attempting to connect to MariaDB with standard MySQL JDBC configurations crashed during catalog resolution.
3. **Limitations of Prior Stopgap PR [#11604](https://github.com/apache/seatunnel/pull/11604)**:
- PR #11604 attempted to mitigate #10030 via documentation by warning users not to use MySQL JDBC drivers, directing them to `org.mariadb.jdbc.Driver`.
- *Why this was insufficient*: Instructing users to use `org.mariadb.jdbc.Driver` forced SeaTunnel into the fallback `GenericDialect`. This resulted in:
- No catalog/schema metadata introspection (`GenericCatalog`).
- Inability to perform high-performance primary-key upserts (`INSERT ... ON DUPLICATE KEY UPDATE`).
- Loss of 30+ MariaDB-specific type conversions.
- **Zero support for CDC** (PR #11604 only applied to batch JDBC).
4. **Fulfills Tracking Issue [#3018](https://github.com/apache/seatunnel/issues/3018)**:
- Fulfills item #141 on the SeaTunnel Connector-V2 master tracking list.
---
### Architectural Rationale: Why a Dedicated Connector is Required
Rather than attempting to retrofit MariaDB workarounds into the existing MySQL modules, isolating MariaDB into dedicated modules was strictly necessary due to fundamental engine divergence:
* **Incompatible GTID Formats**: MySQL uses 128-bit UUID interval sets (`uuid:1-100`). MariaDB uses integer sequence triples (`domain_id-server_id-sequence`). GTID purge comparisons, offset algebra, and restore mechanics cannot parse across engine formats.
* **Binlog Event Protocol Divergence**: MariaDB binlogs introduce specific event types (`MARIADB_GTID_EVENT` [162], `MARIADB_GTID_LIST_EVENT` [163], `ANNOTATE_ROWS_EVENT` [160]) and require specific slave capability handshakes (`SET @mariadb_slave_capability = 4`).
* **Driver Streaming Differences**: MySQL Connector/J requires `statement.setFetchSize(Integer.MIN_VALUE)` to avoid client memory exhaustion. The MariaDB JDBC driver respects positive user-defined fetch sizes.
* **Future-Proof Debezium Roadmaps**: Forking the connector architecture isolates MariaDB's future Debezium parser and binlog client upgrades, eliminating any risk of regressions to the production-critical `connector-cdc-mysql`.
---
### Does this PR introduce _any_ user-facing change?
Yes:
* Users can now configure `source { MariaDB-CDC { ... } }` for streaming binlog ingestion from MariaDB 10.x and 11.x servers.
* Users can now use `source { Jdbc { ... } }` and `sink { Jdbc { ... } }` with `url = "jdbc:mariadb://..."` and `driver = "org.mariadb.jdbc.Driver"`, enjoying full native dialect features (catalog discovery, upsert, schema evolution).
---
### How was this patch tested?
Full 1:1 test parity was ported and validated against the MySQL test suites:
#### 1. Unit Tests (100% Parity)
- Added `MariaDbBinlogOffsetTest`, `MariaDbGtidSetTest`, `MariaDbGtidUtilsTest`, `MariaDbConnectionConfigurationTest`, `MariaDbDatabaseFilterTest`, `MariaDbDateTypeConvertTest`, `MariaDbDialectFactoryTest`, `MariaDbDialectTest`, `MariaDbGeometryTypeConvertTest`, `MariaDbNumericTypeConvertTest`, `MariaDbSchemaTest`, `MariaDbTableFilterTest`, `MariaDbTimeTypeConvertTest`.
#### 2. E2E Integration Tests (100% Parity)
- **JDBC E2E**:
- `JdbcMariaDBIT`: Expanded from 8 types to 45+ data types, testing `TINYINT(1)` boolean handling, unsigned integers, and spatial data.
- `JdbcMariaDBMultipleTablesIT`: Multi-table routing and schema mismatch recovery.
- `JdbcMariaDBTimestampIT`: Session-aware LTZ vs NTZ timestamp mappings.
- **CDC E2E**:
- `MariaDbCDCSingleTableIT`, `MariaDbCDCMultiTableIT`, `MariaDbCDCCheckpointIT`, `MariaDbCDCStopIT`, `MariaDbCDCBinlogDeleteIT`.
- `MariaDbCDCWithSchemaChangeIT` & `MariaDbCDCWithFlinkSchemaChangeIT`.
- *Note on deactivated test*: `testMysqlCdcWithSchemaEvolutionCaseExactlyOnce` is marked `@Disabled` citing upstream MariaDB engine constraint [MDEV-14732](https://jira.mariadb.org/browse/MDEV-14732) (`XAER_PROTO` error when executing `XA START` on connections with transactions in `PREPARED` state, preventing single-connection 2PC XA sinks). All non-XA in-flight schema evolution DDL tests pass 100%.
#### Verification Commands Executed:
- `./mvnw spotless:apply` (Enforced Google Java Format across all modified and new files)
- `./mvnw clean test-compile -DskipTests` (`BUILD SUCCESS` across all affected modules)
---
### Check list
* [x] If any new Jar binary package adding in your PR, please add License Notice according [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
* [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR. (N/A - Purely additive)
* [x] If you are contributing the connector code, please check that the following files are updated:
1. [x] Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
2. [x] Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. [x] Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml) (covered by existing `seatunnel-connectors-v2/connector-cdc/**`)
4. [x] Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. [x] Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5661833626
Pushed `16e377bb7b` (test-only, `MariaDbCDCCheckpointRestoreIT.java`): since the `order by id` fix in `2367cfc7` still hits the identical `index [6][0], expected: <21> but was: <12>` failure on its own CI run, sorting has already ruled out physical-scan-order as the cause — a sorted comparison can't diverge at a fixed index/value pair from row ordering alone. That means the two result sets actually differ in content, and the single differing-index message can't distinguish "sink has an extra duplicate `12`" from "sink hasn't caught up to `21`/`22` yet within the 2-minute window."
Working backwards from the reported index/value: for `21` to land at position 6 in a correctly-converged, `ORDER BY id`-sorted 8-row set (`1,2,3,11,12,12,21,22`), the sink would have to contain *more* rows with `id=12` than the two the test expects (one from before the checkpoint, one replayed after `dropPrimaryKey`) — consistent with the restored job also redelivering the `11`/`12` rows that were already part of the checkpoint being restored from, on top of the correctly-replayed post-checkpoint duplicate. I want to flag this as a reasoned hypothesis from the numbers, not an observed fact — I don't have a live dump of the sink table at failure time, and I did not find the redelivery decision itself inside this connector's own code (`MariaDbBinlogFetchTask`/`MariaDbSourceFetchTaskContext` delegate binlog resume entirely to the reused `io.debezium.connector.mysql.MySqlStreamingChangeEventSource`); it would come from whatever offset/GTID state this connector's own `MariaDbSource
FetchTaskContext`/`MariaDbGtidUtils` hands to that shared reader on restore, which I have not traced to a definitive line yet.
Rather than guess further at production code without ground truth, I added a diagnostic-only change: `awaitSourceAndSinkConsistent` now logs the full source and sink row sets when the polling window is exhausted, so the next CI run shows the actual divergence directly (extra duplicate vs. missing/lagging row) instead of leaving it to be inferred. No production code touched.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5726060022
Sounds right, @merlau — that matches where I landed it too. This PR is already approved on `bd08491a3` and its own blocker (the offset-counter fix) is confirmed green in CI; the two `updated-modules-integration-test-part-5` legs are the only thing actually held up on #12346, since they're failing the same tracked dev-wide `OpengaussCDCIT` issue (#12344) that's hitting other unrelated PRs too, not anything in this branch.
I just checked: #12346 is still open, not yet merged. Once it lands on `dev` and you sync this branch, a rerun should clear `part-5`, and (per my last CI note) `part-3`'s dependency-resolution failure and the Windows unit-test flake should also clear on a plain rerun without needing #12346 at all — so a fresh sync + rerun should get you to a fully green `Build`. Nothing further needed from me until then.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5711758423
CI follow-up for head `bd08491a32` (fork run `35097572107`). I read the failing job logs directly rather than the `Build` pointer check.
**The PR's own blocker is closed.** `updated-modules-integration-test-part-6` - the job that failed deterministically on `MariaDbCDCCheckpointRestoreIT.testMysqlCdcRestoresAfterCheckpointedFullPipelineFailure` on every previous head - is green on both JDK 8 and JDK 11, as is `part-2` (the MariaDB JDBC E2E classes).
**`Build` is still red from 4 jobs, none of which runs code this PR touches:**
| Job | Failure | Classification |
|---|---|---|
| `updated-modules-integration-test-part-5` (8 and 11) | `OpengaussCDCIT.testAddFieldWithRestore:476` `ConditionTimeout` | Tracked dev-wide failure, #12344 (reported as 24/24 failing legs on unrelated PRs); fix in flight in #12346. Scheduled here only because `connector-cdc-opengauss` depends on `connector-jdbc`. |
| `updated-modules-integration-test-part-3` (8) | `Could not resolve dependencies for connector-jdbc-e2e-part-2`: `org.testcontainers:database-commons:1.20.1`, `com.sap.cloud.db.jdbc:ngdbc:2.21.11` | Maven artifact resolution failure before any test ran; the JDK 11 leg of the same job passed. |
| `unit-test (11, windows-latest)` | `FileCollectReaderBehaviorTest.rediscoversFileAfterInactiveCursorClosed:101` `ConditionTimeout` in `seatunnel-edge-agent-connector` | Module not touched by this PR; the JDK 8 Windows leg and both Ubuntu legs passed. |
**Path to a green `Build`:** the `part-3` and Windows unit-test legs should clear on a rerun of the failed jobs (`gh run rerun 35097572107 --failed` - @merlau, this has to come from your side, the run lives on your fork and maintainers cannot rerun it). The two `part-5` legs will keep failing on any rerun until #12346 (or another fix for #12344) lands on `dev` and this branch picks it up, so I would not spend CI on them before that.
On the one non-blocking review note (a narrow unit test for the offset-counter handoff): `loadStartingOffsetState` is private and needs a live connection/binlog client, so covering it in isolation means reshaping production code for testability. I'd rather not do that on an approved head and restart a 4h CI run that is currently exposed to #12344; happy to do it as a follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "merlau (via GitHub)" <gi...@apache.org>.
merlau commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5652877709
Thanks for checking the CI runs and logs! We investigated both issues and addressed them in a77b9375:
1. mariadb:10.11 404: The image was not evicted by runner disk pressure, but explicitly deleted by AbstractJdbcIT.tearDown() (dockerClient.removeImageCmd(...)) run by prior sibling tests in the module. Since JdbcMariaDBTimestampIT relies on Testcontainers' in-memory JVM cache, it didn't re-pull the deleted image. We followed the existing SeaTunnel pattern (AbstractJdbcIT:338, JdbcMysqlMultipleTablesIT:287) by adding .withImagePullPolicy(PullPolicy.alwaysPull()).
2. MariaDbCDCCheckpointRestoreIT index mismatch: Upstream bbde2509143 is unrelated here since it only modifies SnapshotSplitAssigner (snapshot phase), whereas this failure happened at Checkpoint 2 during pure binlog streaming (IncrementalSplitAssigner). In fact, all 8 rows were restored without data loss (asserted by row counts in lines 327–333). The mismatch at index [6][0] was caused by SOURCE_SQL_TEMPLATE and SINK_SQL_TEMPLATE lacking an ORDER BY id clause on a table without a primary key after an ALTER TABLE ... DROP PRIMARY KEY rebuild, causing non-deterministic scan ordering. We added deterministic ORDER BY id to the query templates.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5697629769
Root cause found and fixed in `bd08491a32` (production code, `connector-cdc-mariadb` only; one file, no shared code touched).
**Evidence from this head's own CI run** (`merlau/seatunnel` run `34848994932`, `updated-modules-integration-test-part-6 (8)`): the diagnostic dump shows the sink at `[1, 2, 3, 11, 12, 12, 12, 21, 22]` vs. source `[1, 2, 3, 11, 12, 12, 21, 22]` - exactly one extra copy of `12`, the last row delivered before the restored checkpoint. The restored source state logged by the restore job (`Restore create source from checkpoint state`) is:
```
startupOffset={transaction_id=null, ts_sec=1789397780, file=mariadb-bin.000002, pos=92893, gtids=1-223344-57, row=1, server_id=223344, event=3}
```
That is a mid-transaction *restart* offset - the Debezium `sourceOffset()` attached to the last emitted row: the enclosing transaction's start position plus the `event`/`row` counters of that transaction already emitted. Debezium (`MySqlOffsetContext.Loader.load` -> `setInitialSkips`) re-reads the transaction from `pos` and uses those two counters to skip what it already delivered.
**The bug**: `MariaDbSourceFetchTaskContext.loadStartingOffsetState` forced `event`/`row` to `0` for every startup mode other than `specific` before handing the map to the loader (`MariaDbSourceFetchTaskContext.java:285-291` before this fix). So on restore the transaction at `pos=92893` was replayed with nothing skipped and its row (`12`) was emitted a second time. `MySqlSourceFetchTaskContext` passes `offset.getOffset()` through untouched, which is why the identical `MysqlCDCCheckpointRestoreIT` passes on `dev`. The two other restore tests in this class pass because their restored offsets came from watermark/heartbeat positions with no counters at all (e.g. the savepoint test's restored state: `{..., pos=71176, gtids=1-223344-44, server_id=223344}`), so there was nothing to lose.
**Fix**: hand the offset map to the Debezium loader untouched, exactly as the MySQL connector does (offsets without counters are loaded as `0` by `longOffsetValue`, so watermark/`initial`/`earliest`/`timestamp` startups are unaffected; `specific` was never altered). `MariaDbIncrementalSourceStartupConfigTest`/`MariaDbIncrementalSplitStateTest` already assert that user-supplied and checkpointed skip counters are preserved, which this now honours end to end. The regression coverage is `testMysqlCdcRestoresAfterCheckpointedFullPipelineFailure` itself - it should go green on this head; I have not observed that run yet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5664679605
Pushed `10a35041ef` addressing the review's Issue 1: `query(String)` wraps any `SQLException` as a bare `RuntimeException`, which `Awaitility.untilAsserted` does not retry, so it would propagate immediately out of `await()` and past the `ConditionTimeoutException`-only `catch` from `16e377bb7b`, silently skipping the dump on that path. Given this test drops/re-adds a primary key on the sink table right around the restore it's exercising, a transient `SQLException` during that window is plausible, not hypothetical.
Added a second `catch (RuntimeException e)` that also fires the dump when `e.getCause() instanceof SQLException`, and pulled the dump itself into a `dumpTableContentsOnBestEffort` helper that swallows a failure in the dump's own queries (logs a warning) rather than let it mask the original failure being explained. Also switched the fully-qualified `ConditionTimeoutException` reference to a normal import per the earlier nit.
Still test-only, no production code touched. This doesn't change the open question (Issue 2, the actual source/sink divergence) — it just makes sure the next CI run's diagnostic actually fires regardless of which of the two ways this test can fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "merlau (via GitHub)" <gi...@apache.org>.
merlau commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5714810621
Thanks for the review and fixes, I'll wait for 12346 to be merdged before merging with dev, this should also rerun the CI for part3
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Add MariaDB JDBC and CDC connector support [seatunnel]
Posted by "merlau (via GitHub)" <gi...@apache.org>.
merlau commented on PR #12258:
URL: https://github.com/apache/seatunnel/pull/12258#issuecomment-5647640668
Hello @DanielLeens, it seems to me that the tests are failing on a notoriously flaky test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org