branch-4.1: [Improve](Streamingjob) support only snapshot sync for mysql and pg #61389#61615
Open
github-actions[bot] wants to merge 1 commit intobranch-4.1from
Open
branch-4.1: [Improve](Streamingjob) support only snapshot sync for mysql and pg #61389#61615github-actions[bot] wants to merge 1 commit intobranch-4.1from
github-actions[bot] wants to merge 1 commit intobranch-4.1from
Conversation
…61389) ### What problem does this PR solve? #### Background StreamingJob currently supports two offset modes: - `initial`: full snapshot + continuous incremental replication - `latest`: incremental replication only (no snapshot) There is no way to perform a one-time full sync and stop. This is needed for data migration scenarios where only a point-in-time full copy is required, without ongoing replication. #### Usage Set `offset=snapshot` when creating a StreamingJob: ```sql CREATE JOB mysql_db_sync ON STREAMING FROM MYSQL ( ... "user" = "root", "password" = "", "database" = "db", "include_tables" = "user_info,student", "offset" = "snapshot" ) TO DATABASE target_test_db ( ) ``` The job will perform a full table snapshot and automatically transition to FINISHED once all data is synced. No binlog/WAL subscription is established. #### Design The implementation centers on a hasReachedEnd() signal in SourceOffsetProvider: - FE: JdbcSourceOffsetProvider.hasReachedEnd() returns true when in snapshot-only mode and all snapshot splits have been consumed (finishedSplits non-empty, remainingSplits empty). StreamingInsertJob.onStreamTaskSuccess() checks hasReachedEnd() before creating the next task — if true, the job is marked FINISHED. - BE (cdc_client): snapshot maps to StartupOptions.snapshot() for both MySQL and PostgreSQL connectors. The chunk-split path is reused from initial mode. - Crash recovery: if FE crashes before persisting FINISHED, the job resumes via PAUSED→PENDING. handlePendingState() calls replayOffsetProviderIfNeed() then checks hasReachedEnd() — if all splits are already finished, the job transitions directly to FINISHED without creating any new task. #### Testing Added regression tests for both MySQL and PostgreSQL: - test_streaming_mysql_job_snapshot.groovy - test_streaming_postgres_job_snapshot.groovy Both tests verify: 1. All existing data is synced correctly after job finishes 2. Job status transitions to FINISHED
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #61389