You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "WXPNG (via GitHub)" <gi...@apache.org> on 2026/09/17 03:07:13 UTC

[PR] [Feature][Connector-V2] Add dry-run validation for MySQL CDC Source and Elasticsearch Sink [seatunnel]

WXPNG opened a new pull request, #12358:
URL: https://github.com/apache/seatunnel/pull/12358

   ### Purpose of this pull request
   
   This PR adds dry-run validation support for **MySQL CDC Source** and **Elasticsearch Sink** connectors by implementing the `SupportSourceDryRunValidation` and `SupportSinkDryRunValidation` SPIs respectively.
   
   Closes #12357 
   
   ### Details
   
   #### MySQL CDC Source (`MySqlIncrementalSourceFactory`)
   - Implements `SupportSourceDryRunValidation` interface
   - **`inferSchemaForDryRun()`**: Loads the MySQL JDBC driver and reads table metadata to infer schema, which implicitly validates connectivity and basic SELECT privilege
   - **`validateConnectionForDryRun()`**: Creates a real MySQL connection via Debezium's `MySqlConnection` and validates that the configured user has:
     - `REPLICATION SLAVE` privilege (required for reading binlog events)
     - `REPLICATION CLIENT` privilege (required for `SHOW MASTER STATUS`)
   - Permission validation is also performed in `restoreSource()` so issues surface at task submission time (both HTTP API and CLI)
   - Error messages include actionable `GRANT` statements for quick remediation
   
   #### Elasticsearch Sink (`ElasticsearchSinkFactory`)
   - Implements `SupportSinkDryRunValidation` interface
   - **`validateConnectionForDryRun()`**: Creates an `EsRestClient` and performs:
     1. Cluster connectivity & authentication check via `GET /` (fetches cluster info)
     2. Target index accessibility check via `HEAD /{index}`
   - Skips index existence check for dynamic index names containing `${...}` placeholders (e.g., `seatunnel_${age}`)
   - Adds `INDEX_VARIABLE_PREFIX` constant to `ElasticsearchSinkOptions`
   - Connection validation is also performed in `createSink()` for early failure at task submission time
   
   ### Changes Summary
   
   | File | Change |
   |------|--------|
   | `MySqlIncrementalSourceFactory.java` | Implement `SupportSourceDryRunValidation`, add CDC permission validation |
   | `MySqlIncrementalSourceFactoryTest.java` | Add unit tests for dry-run validation |
   | `ElasticsearchSinkFactory.java` | Implement `SupportSinkDryRunValidation`, add connection validation |
   | `ElasticsearchSinkOptions.java` | Add `INDEX_VARIABLE_PREFIX` constant |
   | `ElasticsearchSinkDryRunValidationTest.java` | Add unit tests for dry-run validation (new file) |
   
   ### How to test
   
   1. **MySQL CDC Source**: Configure a MySQL CDC source job with incorrect credentials or a user lacking REPLICATION privileges, then run with `--dry-run`. The error should be reported immediately with an actionable GRANT statement.
   2. **Elasticsearch Sink**: Configure an Elasticsearch sink job with wrong hosts or credentials, then run with `--dry-run`. The connection error should be reported immediately.
   
   ### Checklist
   
   - [x] Code formatted with `./mvnw spotless:apply`
   - [x] Unit tests added and passing
   - [x] No incompatible changes to existing APIs
   - [x] Apache License header present on all new files
   


-- 
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 dry-run validation for MySQL CDC Source and Elasticsearch Sink [seatunnel]

Posted by "WXPNG (via GitHub)" <gi...@apache.org>.
WXPNG closed pull request #12358: [Feature][Connector-V2] Add dry-run validation for MySQL CDC Source and Elasticsearch Sink
URL: https://github.com/apache/seatunnel/pull/12358


-- 
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 dry-run validation for MySQL CDC Source and Elasticsearch Sink [seatunnel]

Posted by "WXPNG (via GitHub)" <gi...@apache.org>.
WXPNG commented on PR #12358:
URL: https://github.com/apache/seatunnel/pull/12358#issuecomment-5714859327

   Thanks for the thorough and detailed review — the analysis of the checkpoint/savepoint restore path was especially valuable.
   
   I've adopted **Option A** for both Issue 1 and Issue 2: the validation logic is now **only** invoked from the dry-run SPI methods (`validateConnectionForDryRun`), and has been completely removed from the production path (`restoreSource()` / `createSink()`). This addresses the core concern that the new connection/privilege check was silently entering the recovery path.
   
   Per-issue summary:
   
   1. **Issue 1 (High)** — Fixed. Removed `validateMySqlPermissions()` from `restoreSource()`. The MySQL privilege check now runs only on the `--dry-run` path, never on checkpoint/savepoint reconstruction.
   2. **Issue 2 (Medium)** — Fixed. Removed `validateElasticsearchConnection()` from `createSink()`. ES connectivity/index validation now runs only on the dry-run path.
   3. **Issue 3 (Medium)** — Documented the MySQL 8 role-based grant limitation in both the Javadoc and the connector docs (en/zh).
   4. **Issue 4 (Medium)** — Rewrote the four network-dependent MySQL tests to use `MockedStatic` for `MySqlConnectionUtils`/`MySqlConnection` (mirroring the Elasticsearch test pattern), removing the real DNS/network dependency.
   5. **Issue 5 (Low)** — Added `--dry-run` validation notes to the MySQL-CDC and Elasticsearch connector docs (en/zh).
   6. **Issue 6 (Low)** — Enabled GitHub Actions on my fork so CI can run against this branch.
   
   Regarding the API-submission-time validation you raised: I agree that belongs in a separate discussion/PR (with an explicit opt-in rather than a silent production-path change). I'll keep this PR scoped to the dry-run SPI only, as you recommended.
   
   Local verification: MySQL CDC tests 8/8, Elasticsearch tests 10/10 pass. PTAL, thanks again.


-- 
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