You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "JNSimba (via GitHub)" <gi...@apache.org> on 2026/03/16 11:11:16 UTC
[PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
JNSimba opened a new pull request, #61389:
URL: https://github.com/apache/doris/pull/61389
### What problem does this PR solve?
#### Background
StreamingJob currently supports two offset modes:
- `initial`: full snapshot + continuous incremental replication
- `latest` / `earliest`: 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 returns null from getNextOffset()
when all snapshot splits are consumed in snapshot-only mode.
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
auto-resumes via PAUSED→PENDING. getNextOffset() returns null,
the task no-ops safely, and onStreamTaskSuccess() re-checks
hasReachedEnd() to correctly transition to FINISHED.
#### 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
3. Data inserted after the job finishes is not consumed
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2944943492
##########
fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/source/reader/mysql/MySqlSourceReader.java:
##########
@@ -163,7 +163,7 @@ public List<AbstractSourceSplit> getSourceSplits(FetchTableSplitsRequest ftsReq)
StartupMode startupMode = sourceConfig.getStartupOptions().startupMode;
List<MySqlSnapshotSplit> remainingSnapshotSplits = new ArrayList<>();
MySqlBinlogSplit remainingBinlogSplit = null;
- if (startupMode.equals(StartupMode.INITIAL)) {
+ if (startupMode.equals(StartupMode.INITIAL) || startupMode.equals(StartupMode.SNAPSHOT)) {
remainingSnapshotSplits =
Review Comment:
In snapshot/initial startup modes, `remainingBinlogSplit` is left as null, but if `startSplitChunks(...)` returns an empty list the code falls through to the `else` branch and dereferences `remainingBinlogSplit` (NPE). Please handle the “no snapshot splits generated” case explicitly (e.g., throw a clear exception, or ensure a valid split is created for snapshot mode, and only build a binlog split when one is actually initialized).
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4072078707
<details>
<summary>TPC-H: <b>Total hot run time: 26747 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 5c8c55bf9b678ee05dfc309a6bd89d85f1e95f24, data reload: false
------ Round 1 ----------------------------------
orders Doris NULL NULL 0 0 0 NULL 0 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 17629 4459 4273 4273
q2 q3 10641 767 517 517
q4 4682 355 245 245
q5 7554 1178 1015 1015
q6 171 171 146 146
q7 785 835 652 652
q8 9292 1491 1323 1323
q9 4877 4747 4721 4721
q10 6322 1902 1690 1690
q11 461 256 239 239
q12 736 568 467 467
q13 18058 2985 2167 2167
q14 232 242 208 208
q15 q16 730 741 680 680
q17 722 850 424 424
q18 5847 5394 5258 5258
q19 1113 977 621 621
q20 531 492 368 368
q21 4484 1803 1403 1403
q22 347 330 468 330
Total cold run time: 95214 ms
Total hot run time: 26747 ms
----- Round 2, with runtime_filter_mode=off -----
orders Doris NULL NULL 150000000 42 6422171781 NULL 22778155 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 4802 4729 4613 4613
q2 q3 3849 4330 3837 3837
q4 869 1210 811 811
q5 4063 4313 4356 4313
q6 187 173 139 139
q7 1756 1625 1525 1525
q8 2463 2661 2516 2516
q9 7595 7300 7550 7300
q10 3739 3972 3560 3560
q11 509 433 424 424
q12 471 602 453 453
q13 2731 3171 2485 2485
q14 314 306 275 275
q15 q16 753 771 713 713
q17 1149 1411 1374 1374
q18 7302 6755 6675 6675
q19 885 883 928 883
q20 2031 2156 1987 1987
q21 3940 3513 3308 3308
q22 439 410 377 377
Total cold run time: 49847 ms
Total hot run time: 47568 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4101320766
run external
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4095973681
PR approved by at least one committer and no changes requested.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4095892569
run buildall
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2944098452
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -116,7 +116,11 @@ public Offset getNextOffset(StreamingJobProperties jobProps, Map<String, String>
nextOffset.setSplits(snapshotSplits);
return nextOffset;
} else if (currentOffset != null && currentOffset.snapshotSplit()) {
- // snapshot to binlog
+ if (isSnapshotOnlyMode()) {
+ // snapshot-only mode: all splits done, signal job to stop
+ return null;
Review Comment:
`getNextOffset()` returns `null` in snapshot-only mode once all snapshot splits are consumed. Callers like `StreamingInsertTask.before()` and `StreamingMultiTblTask.before()` immediately call `runningOffset.toString()` and pass the offset into `rewriteTvfParams(...)`, so a `null` offset would trigger an NPE if a task is ever created in this state. Consider keeping `getNextOffset()` non-null (and rely solely on `hasReachedEnd()` to stop scheduling), or update the task implementations to explicitly handle a `null` offset as a no-op/terminal condition.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4066902978
/review
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4096377922
<details>
<summary>TPC-H: <b>Total hot run time: 27083 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 40b82bd9b1e568b5730e56c3e8ba239b8fb16b66, data reload: false
------ Round 1 ----------------------------------
orders Doris NULL NULL 0 0 0 NULL 0 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 17608 4468 4296 4296
q2 q3 10643 800 532 532
q4 4677 352 246 246
q5 7573 1206 1038 1038
q6 182 173 145 145
q7 784 844 690 690
q8 9298 1450 1381 1381
q9 4865 4793 4756 4756
q10 6299 1939 1658 1658
q11 474 278 241 241
q12 725 569 469 469
q13 18048 2906 2198 2198
q14 241 242 219 219
q15 q16 739 736 677 677
q17 746 852 463 463
q18 6008 5419 5257 5257
q19 1101 980 649 649
q20 546 485 372 372
q21 4554 1873 1492 1492
q22 543 358 304 304
Total cold run time: 95654 ms
Total hot run time: 27083 ms
----- Round 2, with runtime_filter_mode=off -----
orders Doris NULL NULL 150000000 42 6422171781 NULL 22778155 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 4769 4575 4635 4575
q2 q3 3920 4375 3838 3838
q4 923 1205 858 858
q5 4109 4413 4414 4413
q6 191 171 139 139
q7 1763 1660 1536 1536
q8 2500 2759 2590 2590
q9 7636 7364 7375 7364
q10 3787 4178 3631 3631
q11 518 430 422 422
q12 515 594 477 477
q13 2890 3223 2586 2586
q14 289 306 278 278
q15 q16 731 789 740 740
q17 1167 1408 1351 1351
q18 7255 6975 6732 6732
q19 943 982 960 960
q20 2086 2173 2012 2012
q21 4000 3495 3309 3309
q22 458 435 395 395
Total cold run time: 50450 ms
Total hot run time: 48206 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba merged PR #61389:
URL: https://github.com/apache/doris/pull/61389
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4096917595
<details>
<summary>TPC-H: <b>Total hot run time: 26867 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 8231b8ee2d9248201481884ed33b2c6ef40e64ae, data reload: false
------ Round 1 ----------------------------------
orders Doris NULL NULL 0 0 0 NULL 0 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 17590 4574 4284 4284
q2 q3 10644 816 518 518
q4 4668 361 258 258
q5 7543 1211 1021 1021
q6 178 172 147 147
q7 778 844 688 688
q8 9627 1533 1384 1384
q9 5327 4736 4738 4736
q10 6324 1930 1652 1652
q11 465 252 246 246
q12 738 578 472 472
q13 18056 2951 2193 2193
q14 225 239 212 212
q15 q16 776 741 676 676
q17 752 872 424 424
q18 5882 5308 5274 5274
q19 1133 997 632 632
q20 543 497 370 370
q21 4538 1860 1433 1433
q22 348 293 247 247
Total cold run time: 96135 ms
Total hot run time: 26867 ms
----- Round 2, with runtime_filter_mode=off -----
orders Doris NULL NULL 150000000 42 6422171781 NULL 22778155 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 4381 4331 4314 4314
q2 q3 3865 4293 3788 3788
q4 875 1174 810 810
q5 4017 4382 4317 4317
q6 182 172 139 139
q7 1709 1612 1493 1493
q8 2451 2648 2505 2505
q9 7631 7590 7514 7514
q10 3774 3964 3599 3599
q11 519 442 430 430
q12 541 611 449 449
q13 2869 3248 2307 2307
q14 286 314 282 282
q15 q16 735 764 746 746
q17 1180 1430 1388 1388
q18 7215 6790 6670 6670
q19 1049 988 965 965
q20 2087 2178 2037 2037
q21 4133 3673 3396 3396
q22 470 440 382 382
Total cold run time: 49969 ms
Total hot run time: 47531 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2939726347
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -535,7 +545,21 @@ private boolean checkNeedSplitChunks(Map<String, String> sourceProperties) {
if (startMode == null) {
return false;
}
- return DataSourceConfigKeys.OFFSET_INITIAL.equalsIgnoreCase(startMode);
+ return DataSourceConfigKeys.OFFSET_INITIAL.equalsIgnoreCase(startMode)
+ || DataSourceConfigKeys.OFFSET_SNAPSHOT.equalsIgnoreCase(startMode);
+ }
+
+ private boolean isSnapshotOnlyMode() {
+ String offset = sourceProperties.get(DataSourceConfigKeys.OFFSET);
+ return DataSourceConfigKeys.OFFSET_SNAPSHOT.equalsIgnoreCase(offset);
+ }
+
+ @Override
+ public boolean hasReachedEnd() {
+ return isSnapshotOnlyMode()
+ && currentOffset != null
+ && currentOffset.snapshotSplit()
+ && remainingSplits.isEmpty();
Review Comment:
**Note:** `hasReachedEnd()` calls `currentOffset.snapshotSplit()` which requires non-null, non-empty splits (enforced by `Preconditions.checkState` in `JdbcOffset.snapshotSplit()`). After crash recovery for a completed snapshot-only job, `currentOffset` has null splits (see comment on `replayIfNeed`), so this method will throw `IllegalStateException`.
Consider either:
1. Adding a null-safe split check here directly: `currentOffset.getSplits() != null && !currentOffset.getSplits().isEmpty() && currentOffset.snapshotSplit()`
2. Or ensuring `replayIfNeed` always leaves `currentOffset` in a valid state with actual splits set.
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -535,7 +545,21 @@ private boolean checkNeedSplitChunks(Map<String, String> sourceProperties) {
Review Comment:
**Bug (Critical): `currentOffset` created with null/empty splits causes crash on recovery**
When `isSnapshotOnlyMode()` is true and `lastSnapshotSplits.isEmpty()`, this code creates a `JdbcOffset` via `new JdbcOffset()` at line 382 but never calls `setSplits()`. The `splits` field remains `null` (default from `@NoArgsConstructor`).
Later, `hasReachedEnd()` calls `currentOffset.snapshotSplit()` which does:
```java
Preconditions.checkState(splits != null && !splits.isEmpty(), "splits is null or empty");
```
This throws `IllegalStateException`. Same crash path via `hasMoreDataToConsume()` → `currentOffset.snapshotSplit()`.
**Suggested fix:** Either:
1. Set a sentinel split list so `snapshotSplit()` works, or
2. Modify `hasReachedEnd()` to check for null/empty splits directly without calling `snapshotSplit()`, or
3. In this branch, handle the snapshot-only completed state by transitioning the job to FINISHED immediately during replay (best approach).
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingMultiTblTask.java:
##########
@@ -110,6 +110,11 @@ public void before() throws Exception {
this.status = TaskStatus.RUNNING;
this.startTimeMs = System.currentTimeMillis();
this.runningOffset = offsetProvider.getNextOffset(null, sourceProperties);
+ if (this.runningOffset == null) {
+ // snapshot-only mode: all splits completed, task exits immediately
+ log.info("streaming multi task {} offset is null (snapshot-only completed), skip execution", taskId);
+ return;
+ }
log.info("streaming multi task {} get running offset: {}", taskId, runningOffset.toString());
Review Comment:
**Bug (High): Early return from `before()` when offset is null leaves the job stuck**
When `getNextOffset()` returns null (snapshot-only completed), this task returns early from `before()`, then `run()` also returns early, then `onSuccess()` returns `false` without calling `onStreamTaskSuccess()`. The `StreamingMultiTblTask.onSuccess()` never calls `onStreamTaskSuccess()` — it always returns false (line 243).
The job completion signal for multi-table tasks only comes via the external `commitOffset()` → `successCallback()` → `onStreamTaskSuccess()` callback path, which is never triggered for a no-op task (no data sent to BE, no offset committed).
Result: The task finishes silently, the job stays in `RUNNING` with a dead task reference, eventually times out to `PAUSED`, auto-resumes to `PENDING`, creates another null-offset task, and loops forever.
**Suggested fix:** In `StreamingMultiTblTask.onSuccess()`, when `runningOffset == null`, directly call `streamingInsertJob.onStreamTaskSuccess(this)` (after acquiring the write lock via the appropriate path). Alternatively, handle this in `before()` by checking `offsetProvider.hasReachedEnd()` and signaling the job directly.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4107602967
PR approved by at least one committer and no changes requested.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "Thearas (via GitHub)" <gi...@apache.org>.
Thearas commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4066898701
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR).
Please clearly describe your PR:
1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
3. What features were added. Why was this function added?
4. Which code was refactored and why was this part of the code refactored?
5. Which functions were optimized and what is the difference before and after the optimization?
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4107595379
run buildall
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4072108147
<details>
<summary>TPC-DS: <b>Total hot run time: 168669 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 5c8c55bf9b678ee05dfc309a6bd89d85f1e95f24, data reload: false
query5 4326 623 495 495
query6 328 217 198 198
query7 4211 464 261 261
query8 325 234 216 216
query9 8717 2733 2721 2721
query10 536 382 345 345
query11 6977 5087 4842 4842
query12 186 143 126 126
query13 1270 461 336 336
query14 5796 3707 3448 3448
query14_1 2897 2822 2807 2807
query15 209 195 176 176
query16 986 473 458 458
query17 1006 718 622 622
query18 2451 467 327 327
query19 201 203 182 182
query20 135 136 123 123
query21 207 137 109 109
query22 13203 14118 14592 14118
query23 16235 15709 15854 15709
query23_1 16073 15694 15695 15694
query24 7218 1625 1233 1233
query24_1 1201 1226 1223 1223
query25 549 466 409 409
query26 1227 260 155 155
query27 2766 478 286 286
query28 4509 1847 1858 1847
query29 848 555 495 495
query30 306 228 191 191
query31 1002 933 881 881
query32 89 71 69 69
query33 513 325 272 272
query34 906 855 521 521
query35 636 693 604 604
query36 1094 1132 951 951
query37 135 93 82 82
query38 2945 2939 2890 2890
query39 868 839 828 828
query39_1 778 789 777 777
query40 231 150 135 135
query41 62 58 59 58
query42 254 257 252 252
query43 233 253 226 226
query44
query45 195 186 179 179
query46 889 1013 618 618
query47 2137 2152 2049 2049
query48 309 312 226 226
query49 633 464 382 382
query50 715 268 207 207
query51 4089 4115 4046 4046
query52 260 264 253 253
query53 295 332 288 288
query54 308 279 266 266
query55 90 87 79 79
query56 318 337 311 311
query57 1899 1562 1757 1562
query58 284 274 266 266
query59 2792 2937 2756 2756
query60 341 326 323 323
query61 156 149 154 149
query62 621 594 528 528
query63 310 275 277 275
query64 5097 1263 988 988
query65
query66 1469 447 363 363
query67 24269 24230 24217 24217
query68
query69 393 326 293 293
query70 982 973 954 954
query71 339 306 305 305
query72 2802 2799 2658 2658
query73 541 555 329 329
query74 9605 9602 9406 9406
query75 2855 2760 2491 2491
query76 2318 1041 701 701
query77 378 395 317 317
query78 10879 11133 10487 10487
query79 1409 773 566 566
query80 1366 665 610 610
query81 545 256 223 223
query82 972 154 119 119
query83 338 268 250 250
query84 268 121 99 99
query85 909 508 446 446
query86 423 300 294 294
query87 3144 3094 3062 3062
query88 3511 2659 2630 2630
query89 419 370 346 346
query90 2028 180 177 177
query91 173 159 138 138
query92 81 76 70 70
query93 996 862 496 496
query94 652 319 282 282
query95 594 406 313 313
query96 652 511 227 227
query97 2461 2467 2398 2398
query98 228 217 220 217
query99 1011 991 917 917
Total cold run time: 249896 ms
Total hot run time: 168669 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2944101960
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -116,7 +116,11 @@ public Offset getNextOffset(StreamingJobProperties jobProps, Map<String, String>
nextOffset.setSplits(snapshotSplits);
return nextOffset;
} else if (currentOffset != null && currentOffset.snapshotSplit()) {
- // snapshot to binlog
+ if (isSnapshotOnlyMode()) {
+ // snapshot-only mode: all splits done, signal job to stop
+ return null;
Review Comment:
**[Medium — Fragile Contract]** `getNextOffset()` returning `null` is a new behavior not documented in the `SourceOffsetProvider` interface contract. Both callers (`StreamingInsertTask.before()` line 92 and `StreamingMultiTblTask.before()` line 113) immediately call `.toString()` on the result, which would NPE if reached.
In practice, this is currently safe because `onStreamTaskSuccess()` checks `hasReachedEnd()` before creating a new task (and thus before `before()` is called). However, this safety depends on callers always checking `hasReachedEnd()` first — a fragile implicit contract.
Suggestion: Either (a) throw an explicit `IllegalStateException("No more offsets in snapshot-only mode")` instead of returning null, so any future caller that forgets the `hasReachedEnd()` check gets a clear error instead of an NPE, or (b) add a `@Nullable` annotation and document the contract in the interface.
##########
fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/source/reader/mysql/MySqlSourceReader.java:
##########
@@ -789,8 +789,9 @@ private MySqlSourceConfig generateMySqlConfig(Map<String, String> cdcConfig, Str
// setting startMode
String startupMode = cdcConfig.get(DataSourceConfigKeys.OFFSET);
if (DataSourceConfigKeys.OFFSET_INITIAL.equalsIgnoreCase(startupMode)) {
Review Comment:
**[Info — Behavioral Change on Existing Mode]** Uncommenting `configFactory.startupOptions(StartupOptions.initial())` for `OFFSET_INITIAL` changes the behavior of the existing `initial` mode. Previously the factory default startup option was used (which is likely `INITIAL` anyway in Flink CDC). Now it's set explicitly.
This is needed for correctness — `getSourceSplits()` at line 163 reads `sourceConfig.getStartupOptions().startupMode` to decide between snapshot splits and binlog split, and with the new `SNAPSHOT` mode branch, `INITIAL` needs to be explicit too. Just confirming this is intentional and has been tested with the existing `initial` mode regression tests.
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/DataSourceConfigValidator.java:
##########
@@ -82,8 +82,9 @@ private static boolean isValidValue(String key, String value) {
}
if (key.equals(DataSourceConfigKeys.OFFSET)
- && !(value.equals(DataSourceConfigKeys.OFFSET_INITIAL)
- || value.equals(DataSourceConfigKeys.OFFSET_LATEST))) {
+ && !(value.equalsIgnoreCase(DataSourceConfigKeys.OFFSET_INITIAL)
Review Comment:
**[Low — Behavioral Side-Effect]** Changing from `equals()` to `equalsIgnoreCase()` for `OFFSET_INITIAL` and `OFFSET_LATEST` is a behavioral change for existing offset values. Previously `"INITIAL"`, `"Initial"`, `"LATEST"` etc. would fail validation; now they pass. This is probably fine (and arguably a UX improvement), but it's worth noting as a scope expansion beyond the snapshot feature.
Also note: `OFFSET_EARLIEST` is still missing from this validator. This appears to be a pre-existing omission (the old code also excluded it), but since this PR touches this exact block, it would be a good time to add it if `earliest` is a valid option for the multi-table streaming job path.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4071999691
/review
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4096269077
# FE UT Coverage Report
Increment line coverage ` 0.00% (0/26)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/61389_40b82bd9b1e568b5730e56c3e8ba239b8fb16b66/fe_increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/61389_40b82bd9b1e568b5730e56c3e8ba239b8fb16b66/fe_report/index.html)
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4096966331
<details>
<summary>TPC-DS: <b>Total hot run time: 168417 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 8231b8ee2d9248201481884ed33b2c6ef40e64ae, data reload: false
query5 4319 631 508 508
query6 331 240 215 215
query7 4218 472 274 274
query8 370 246 233 233
query9 8723 2710 2733 2710
query10 471 416 353 353
query11 7004 5122 4925 4925
query12 184 130 124 124
query13 1311 455 344 344
query14 5771 3709 3471 3471
query14_1 2879 2826 2834 2826
query15 206 194 190 190
query16 1009 470 451 451
query17 1126 745 623 623
query18 2457 455 354 354
query19 221 206 187 187
query20 136 124 132 124
query21 226 137 111 111
query22 13316 13919 14558 13919
query23 16229 16310 15732 15732
query23_1 15783 15579 15522 15522
query24 7220 1628 1243 1243
query24_1 1236 1246 1244 1244
query25 567 508 402 402
query26 1234 257 155 155
query27 2764 483 298 298
query28 4450 1819 1840 1819
query29 880 574 479 479
query30 299 221 189 189
query31 1014 956 874 874
query32 82 70 73 70
query33 520 332 303 303
query34 884 880 532 532
query35 642 687 602 602
query36 1077 1110 949 949
query37 133 97 89 89
query38 2916 3005 2927 2927
query39 858 829 799 799
query39_1 793 789 799 789
query40 233 189 133 133
query41 63 59 61 59
query42 262 256 256 256
query43 247 253 220 220
query44
query45 192 190 185 185
query46 878 973 598 598
query47 2110 2129 2055 2055
query48 309 324 235 235
query49 635 488 388 388
query50 690 283 224 224
query51 4118 3960 4007 3960
query52 262 263 260 260
query53 298 333 282 282
query54 302 266 271 266
query55 95 88 87 87
query56 317 343 326 326
query57 1935 1664 1821 1664
query58 291 272 271 271
query59 2791 2949 2743 2743
query60 341 336 327 327
query61 158 154 151 151
query62 625 591 547 547
query63 307 286 275 275
query64 5082 1282 1004 1004
query65
query66 1478 466 366 366
query67 24159 24292 24122 24122
query68
query69 419 313 285 285
query70 939 933 943 933
query71 334 307 310 307
query72 2845 2737 2461 2461
query73 563 562 318 318
query74 9644 9557 9425 9425
query75 2865 2745 2488 2488
query76 2305 1025 689 689
query77 358 396 310 310
query78 10897 11034 10481 10481
query79 3421 784 570 570
query80 1737 636 549 549
query81 574 257 230 230
query82 789 152 122 122
query83 334 262 250 250
query84 261 114 103 103
query85 937 498 468 468
query86 501 311 282 282
query87 3138 3126 3053 3053
query88 4726 2676 2652 2652
query89 433 381 344 344
query90 2081 177 181 177
query91 176 169 140 140
query92 81 78 72 72
query93 2720 840 494 494
query94 639 323 277 277
query95 592 412 324 324
query96 659 529 232 232
query97 2430 2453 2430 2430
query98 243 219 222 219
query99 1010 986 904 904
Total cold run time: 254292 ms
Total hot run time: 168417 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4095973943
PR approved by anyone and no changes requested.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4096712442
run buildall
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "CalvinKirs (via GitHub)" <gi...@apache.org>.
CalvinKirs commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2972507920
##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_postgres_job_snapshot.groovy:
##########
@@ -0,0 +1,130 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+/**
+ * Test snapshot-only mode (offset=snapshot):
+ * 1. Job syncs existing data via full snapshot.
+ * 2. Job transitions to FINISHED after snapshot completes (no binlog phase).
+ * 3. Data inserted after job finishes is NOT synced to Doris.
+ */
+suite("test_streaming_postgres_job_snapshot", "p0,external,pg,external_docker,external_docker_pg,nondatalake") {
+ def jobName = "test_streaming_postgres_job_snapshot_name"
+ def currentDb = (sql "select database()")[0][0]
+ def table1 = "user_info_pg_snapshot1"
+ def table2 = "user_info_pg_snapshot2"
+ def pgDB = "postgres"
+ def pgSchema = "cdc_test"
+ def pgUser = "postgres"
+ def pgPassword = "123456"
+
+ sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+ sql """drop table if exists ${currentDb}.${table1} force"""
+ sql """drop table if exists ${currentDb}.${table2} force"""
+
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ String pg_port = context.config.otherConfigs.get("pg_14_port")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String s3_endpoint = getS3Endpoint()
+ String bucket = getS3BucketName()
+ String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/postgresql-42.5.0.jar"
+
+ // prepare source tables and pre-existing data in postgres
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table1}"""
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table2}"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table1} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('A1', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('B1', 2)"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table2} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('A2', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('B2', 2)"""
+ }
+
+ // create streaming job with offset=snapshot (snapshot-only mode)
+ sql """CREATE JOB ${jobName}
+ ON STREAMING
+ FROM POSTGRES (
+ "jdbc_url" = "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}",
+ "driver_url" = "${driver_url}",
+ "driver_class" = "org.postgresql.Driver",
+ "user" = "${pgUser}",
+ "password" = "${pgPassword}",
+ "database" = "${pgDB}",
+ "schema" = "${pgSchema}",
+ "include_tables" = "${table1},${table2}",
+ "offset" = "snapshot"
+ )
+ TO DATABASE ${currentDb} (
+ "table.create.properties.replication_num" = "1"
+ )
+ """
+
+ // wait for job to transition to FINISHED
+ try {
+ Awaitility.await().atMost(300, SECONDS)
+ .pollInterval(2, SECONDS).until(
+ {
+ def jobStatus = sql """select Status from jobs("type"="insert") where Name = '${jobName}' and ExecuteType='STREAMING'"""
+ log.info("jobStatus: " + jobStatus)
+ jobStatus.size() == 1 && jobStatus.get(0).get(0) == 'FINISHED'
+ }
+ )
+ } catch (Exception ex) {
+ def showjob = sql """select * from jobs("type"="insert") where Name='${jobName}'"""
+ def showtask = sql """select * from tasks("type"="insert") where JobName='${jobName}'"""
+ log.info("show job: " + showjob)
+ log.info("show task: " + showtask)
+ throw ex
+ }
+
+ // verify snapshot data is correctly synced
+ qt_select_snapshot_table1 """ SELECT * FROM ${table1} order by name asc """
+ qt_select_snapshot_table2 """ SELECT * FROM ${table2} order by name asc """
+
+ // insert new data into postgres after job is FINISHED
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('C1', 3)"""
+ sql """UPDATE ${pgDB}.${pgSchema}.${table1} SET age = 99 WHERE name = 'A1'"""
+ }
+
+ // wait a bit and confirm new data is NOT synced (job is done, no binlog reading)
+ sleep(30000)
Review Comment:
Sleep(30000) is a bad usage.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4096431243
<details>
<summary>TPC-DS: <b>Total hot run time: 168190 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 40b82bd9b1e568b5730e56c3e8ba239b8fb16b66, data reload: false
query5 4325 625 509 509
query6 333 231 211 211
query7 4216 486 283 283
query8 348 265 236 236
query9 8712 2758 2734 2734
query10 561 384 335 335
query11 6974 5053 4904 4904
query12 188 127 138 127
query13 1287 461 352 352
query14 5750 3723 3447 3447
query14_1 2804 2819 2807 2807
query15 202 192 176 176
query16 957 467 457 457
query17 894 743 633 633
query18 2447 455 355 355
query19 217 211 189 189
query20 140 131 134 131
query21 219 136 113 113
query22 13266 13949 14671 13949
query23 16411 15753 15531 15531
query23_1 15786 15493 15402 15402
query24 7150 1621 1213 1213
query24_1 1227 1260 1231 1231
query25 538 464 441 441
query26 1244 261 150 150
query27 2786 482 294 294
query28 4502 1868 1812 1812
query29 820 557 472 472
query30 291 224 190 190
query31 999 924 854 854
query32 80 72 74 72
query33 512 326 284 284
query34 901 870 514 514
query35 653 669 599 599
query36 1123 1155 1003 1003
query37 127 93 89 89
query38 2952 2865 2844 2844
query39 865 824 794 794
query39_1 787 785 790 785
query40 230 153 134 134
query41 62 58 57 57
query42 265 253 293 253
query43 241 249 220 220
query44
query45 199 195 191 191
query46 880 987 618 618
query47 2113 2154 2053 2053
query48 309 312 231 231
query49 638 459 386 386
query50 698 286 207 207
query51 4096 4141 4064 4064
query52 261 270 255 255
query53 287 339 282 282
query54 304 270 264 264
query55 99 85 84 84
query56 311 307 309 307
query57 1895 1848 1630 1630
query58 287 271 302 271
query59 2787 2931 2709 2709
query60 333 329 324 324
query61 158 164 159 159
query62 625 595 536 536
query63 309 272 281 272
query64 4988 1296 998 998
query65
query66 1468 458 364 364
query67 24155 24317 24166 24166
query68
query69 413 309 295 295
query70 965 967 970 967
query71 348 309 312 309
query72 2979 2888 2728 2728
query73 538 549 323 323
query74 9640 9604 9408 9408
query75 2893 2747 2503 2503
query76 2277 1023 672 672
query77 379 384 312 312
query78 10972 11141 10436 10436
query79 1140 771 564 564
query80 1341 623 536 536
query81 559 262 223 223
query82 1009 153 121 121
query83 343 259 241 241
query84 302 114 101 101
query85 907 480 452 452
query86 422 307 273 273
query87 3133 3116 2999 2999
query88 3562 2685 2656 2656
query89 432 371 339 339
query90 2018 181 181 181
query91 178 165 141 141
query92 80 76 72 72
query93 956 834 491 491
query94 643 333 298 298
query95 580 405 321 321
query96 659 525 224 224
query97 2459 2492 2409 2409
query98 235 243 221 221
query99 1011 1011 944 944
Total cold run time: 249519 ms
Total hot run time: 168190 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4073052946
run buildall
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4073578400
<details>
<summary>TPC-DS: <b>Total hot run time: 168329 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 7e4ae23b7632fcecb2a352310b7f1cf8281be2d6, data reload: false
query5 4333 635 519 519
query6 329 232 210 210
query7 4210 476 274 274
query8 350 262 253 253
query9 8761 2702 2723 2702
query10 520 394 347 347
query11 6829 5089 4907 4907
query12 184 130 128 128
query13 1281 468 356 356
query14 5740 3703 3457 3457
query14_1 2844 2856 2821 2821
query15 209 192 174 174
query16 979 472 447 447
query17 916 740 631 631
query18 2457 454 357 357
query19 220 219 187 187
query20 140 131 128 128
query21 219 134 112 112
query22 13199 14111 14727 14111
query23 16340 15829 15595 15595
query23_1 15787 15558 15384 15384
query24 7145 1602 1222 1222
query24_1 1199 1225 1269 1225
query25 557 480 405 405
query26 1226 263 152 152
query27 2778 485 300 300
query28 4483 1852 1859 1852
query29 845 560 473 473
query30 297 224 192 192
query31 1006 931 889 889
query32 83 70 71 70
query33 512 360 291 291
query34 921 891 529 529
query35 647 678 600 600
query36 1111 1134 970 970
query37 137 88 83 83
query38 2951 2913 2883 2883
query39 889 847 816 816
query39_1 787 790 790 790
query40 233 156 137 137
query41 62 61 58 58
query42 262 251 258 251
query43 238 239 220 220
query44
query45 193 188 182 182
query46 871 991 614 614
query47 2125 2125 2023 2023
query48 315 316 236 236
query49 627 450 388 388
query50 682 279 213 213
query51 4062 4066 4024 4024
query52 260 268 257 257
query53 292 335 285 285
query54 307 277 269 269
query55 104 90 82 82
query56 315 319 317 317
query57 1890 1514 1597 1514
query58 322 277 264 264
query59 2801 2947 2754 2754
query60 348 351 334 334
query61 161 158 157 157
query62 640 596 544 544
query63 307 278 274 274
query64 5123 1298 1015 1015
query65
query66 1470 462 352 352
query67 24333 24396 24250 24250
query68
query69 413 320 281 281
query70 970 951 977 951
query71 341 298 313 298
query72 3005 2900 2547 2547
query73 539 545 322 322
query74 9667 9547 9414 9414
query75 2859 2744 2466 2466
query76 2277 1033 685 685
query77 358 389 318 318
query78 10884 11112 10462 10462
query79 1152 805 572 572
query80 1342 646 548 548
query81 554 271 233 233
query82 1009 155 124 124
query83 345 265 243 243
query84 294 114 101 101
query85 923 527 458 458
query86 409 307 296 296
query87 3141 3117 3023 3023
query88 3528 2639 2623 2623
query89 435 376 354 354
query90 2021 182 174 174
query91 169 169 139 139
query92 78 75 73 73
query93 988 863 490 490
query94 641 326 292 292
query95 596 396 327 327
query96 649 520 232 232
query97 2500 2475 2380 2380
query98 242 227 220 220
query99 952 947 915 915
Total cold run time: 249148 ms
Total hot run time: 168329 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2944739854
##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_postgres_job_snapshot.groovy:
##########
@@ -0,0 +1,130 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+/**
+ * Test snapshot-only mode (offset=snapshot):
+ * 1. Job syncs existing data via full snapshot.
+ * 2. Job transitions to FINISHED after snapshot completes (no binlog phase).
+ * 3. Data inserted after job finishes is NOT synced to Doris.
+ */
+suite("test_streaming_postgres_job_snapshot", "p0,external,pg,external_docker,external_docker_pg,nondatalake") {
+ def jobName = "test_streaming_postgres_job_snapshot_name"
+ def currentDb = (sql "select database()")[0][0]
+ def table1 = "user_info_pg_snapshot1"
+ def table2 = "user_info_pg_snapshot2"
+ def pgDB = "postgres"
+ def pgSchema = "cdc_test"
+ def pgUser = "postgres"
+ def pgPassword = "123456"
+
+ sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+ sql """drop table if exists ${currentDb}.${table1} force"""
+ sql """drop table if exists ${currentDb}.${table2} force"""
+
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ String pg_port = context.config.otherConfigs.get("pg_14_port")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String s3_endpoint = getS3Endpoint()
+ String bucket = getS3BucketName()
+ String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/postgresql-42.5.0.jar"
+
+ // prepare source tables and pre-existing data in postgres
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table1}"""
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table2}"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table1} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('A1', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('B1', 2)"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table2} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('A2', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('B2', 2)"""
+ }
+
+ // create streaming job with offset=snapshot (snapshot-only mode)
+ sql """CREATE JOB ${jobName}
+ ON STREAMING
+ FROM POSTGRES (
+ "jdbc_url" = "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}",
+ "driver_url" = "${driver_url}",
+ "driver_class" = "org.postgresql.Driver",
+ "user" = "${pgUser}",
+ "password" = "${pgPassword}",
+ "database" = "${pgDB}",
+ "schema" = "${pgSchema}",
+ "include_tables" = "${table1},${table2}",
+ "offset" = "snapshot"
+ )
+ TO DATABASE ${currentDb} (
+ "table.create.properties.replication_num" = "1"
+ )
+ """
+
+ // wait for job to transition to FINISHED
+ try {
+ Awaitility.await().atMost(300, SECONDS)
+ .pollInterval(2, SECONDS).until(
+ {
+ def jobStatus = sql """select Status from jobs("type"="insert") where Name = '${jobName}' and ExecuteType='STREAMING'"""
+ log.info("jobStatus: " + jobStatus)
+ jobStatus.size() == 1 && jobStatus.get(0).get(0) == 'FINISHED'
+ }
+ )
+ } catch (Exception ex) {
+ def showjob = sql """select * from jobs("type"="insert") where Name='${jobName}'"""
+ def showtask = sql """select * from tasks("type"="insert") where JobName='${jobName}'"""
+ log.info("show job: " + showjob)
+ log.info("show task: " + showtask)
+ throw ex
+ }
+
+ // verify snapshot data is correctly synced
+ qt_select_snapshot_table1 """ SELECT * FROM ${table1} order by name asc """
+ qt_select_snapshot_table2 """ SELECT * FROM ${table2} order by name asc """
+
+ // insert new data into postgres after job is FINISHED
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('C1', 3)"""
+ sql """UPDATE ${pgDB}.${pgSchema}.${table1} SET age = 99 WHERE name = 'A1'"""
+ }
+
+ // wait a bit and confirm new data is NOT synced (job is done, no binlog reading)
+ sleep(30000)
Review Comment:
Using a fixed `sleep(30000)` makes this regression test timing-dependent and potentially flaky (slow CI / busy external Docker). Prefer polling with Awaitility until the target table is stable for a window (or until a "no new tasks"/"FINISHED" invariant holds) instead of a hard sleep.
##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_postgres_job_snapshot.groovy:
##########
@@ -0,0 +1,130 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+/**
+ * Test snapshot-only mode (offset=snapshot):
+ * 1. Job syncs existing data via full snapshot.
+ * 2. Job transitions to FINISHED after snapshot completes (no binlog phase).
+ * 3. Data inserted after job finishes is NOT synced to Doris.
+ */
+suite("test_streaming_postgres_job_snapshot", "p0,external,pg,external_docker,external_docker_pg,nondatalake") {
+ def jobName = "test_streaming_postgres_job_snapshot_name"
+ def currentDb = (sql "select database()")[0][0]
+ def table1 = "user_info_pg_snapshot1"
+ def table2 = "user_info_pg_snapshot2"
+ def pgDB = "postgres"
+ def pgSchema = "cdc_test"
+ def pgUser = "postgres"
+ def pgPassword = "123456"
+
+ sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+ sql """drop table if exists ${currentDb}.${table1} force"""
+ sql """drop table if exists ${currentDb}.${table2} force"""
+
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ String pg_port = context.config.otherConfigs.get("pg_14_port")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String s3_endpoint = getS3Endpoint()
+ String bucket = getS3BucketName()
+ String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/postgresql-42.5.0.jar"
+
+ // prepare source tables and pre-existing data in postgres
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table1}"""
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table2}"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table1} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('A1', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('B1', 2)"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table2} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('A2', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('B2', 2)"""
+ }
+
+ // create streaming job with offset=snapshot (snapshot-only mode)
+ sql """CREATE JOB ${jobName}
+ ON STREAMING
+ FROM POSTGRES (
+ "jdbc_url" = "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}",
+ "driver_url" = "${driver_url}",
+ "driver_class" = "org.postgresql.Driver",
+ "user" = "${pgUser}",
+ "password" = "${pgPassword}",
+ "database" = "${pgDB}",
+ "schema" = "${pgSchema}",
+ "include_tables" = "${table1},${table2}",
+ "offset" = "snapshot"
+ )
+ TO DATABASE ${currentDb} (
+ "table.create.properties.replication_num" = "1"
+ )
+ """
+
+ // wait for job to transition to FINISHED
+ try {
+ Awaitility.await().atMost(300, SECONDS)
+ .pollInterval(2, SECONDS).until(
+ {
+ def jobStatus = sql """select Status from jobs("type"="insert") where Name = '${jobName}' and ExecuteType='STREAMING'"""
+ log.info("jobStatus: " + jobStatus)
+ jobStatus.size() == 1 && jobStatus.get(0).get(0) == 'FINISHED'
+ }
+ )
+ } catch (Exception ex) {
+ def showjob = sql """select * from jobs("type"="insert") where Name='${jobName}'"""
+ def showtask = sql """select * from tasks("type"="insert") where JobName='${jobName}'"""
+ log.info("show job: " + showjob)
+ log.info("show task: " + showtask)
+ throw ex
+ }
+
+ // verify snapshot data is correctly synced
+ qt_select_snapshot_table1 """ SELECT * FROM ${table1} order by name asc """
+ qt_select_snapshot_table2 """ SELECT * FROM ${table2} order by name asc """
+
+ // insert new data into postgres after job is FINISHED
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('C1', 3)"""
+ sql """UPDATE ${pgDB}.${pgSchema}.${table1} SET age = 99 WHERE name = 'A1'"""
Review Comment:
Same issue here: DML against Postgres should not prefix the table with `${pgDB}.` (database/catalog). Use `${pgSchema}.${table1}` to avoid cross-database reference errors.
##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_postgres_job_snapshot.groovy:
##########
@@ -0,0 +1,130 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+/**
+ * Test snapshot-only mode (offset=snapshot):
+ * 1. Job syncs existing data via full snapshot.
+ * 2. Job transitions to FINISHED after snapshot completes (no binlog phase).
+ * 3. Data inserted after job finishes is NOT synced to Doris.
+ */
+suite("test_streaming_postgres_job_snapshot", "p0,external,pg,external_docker,external_docker_pg,nondatalake") {
+ def jobName = "test_streaming_postgres_job_snapshot_name"
+ def currentDb = (sql "select database()")[0][0]
+ def table1 = "user_info_pg_snapshot1"
+ def table2 = "user_info_pg_snapshot2"
+ def pgDB = "postgres"
+ def pgSchema = "cdc_test"
+ def pgUser = "postgres"
+ def pgPassword = "123456"
+
+ sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+ sql """drop table if exists ${currentDb}.${table1} force"""
+ sql """drop table if exists ${currentDb}.${table2} force"""
+
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ String pg_port = context.config.otherConfigs.get("pg_14_port")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String s3_endpoint = getS3Endpoint()
+ String bucket = getS3BucketName()
+ String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/postgresql-42.5.0.jar"
+
+ // prepare source tables and pre-existing data in postgres
+ connect("${pgUser}", "${pgPassword}", "jdbc:postgresql://${externalEnvIp}:${pg_port}/${pgDB}") {
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table1}"""
+ sql """DROP TABLE IF EXISTS ${pgDB}.${pgSchema}.${table2}"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table1} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('A1', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table1} (name, age) VALUES ('B1', 2)"""
+ sql """CREATE TABLE ${pgDB}.${pgSchema}.${table2} (
+ "name" varchar(200),
+ "age" int2,
+ PRIMARY KEY ("name")
+ )"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('A2', 1)"""
+ sql """INSERT INTO ${pgDB}.${pgSchema}.${table2} (name, age) VALUES ('B2', 2)"""
Review Comment:
In PostgreSQL SQL, using a 3-part name like `${pgDB}.${pgSchema}.${table1}` is treated as `catalog.schema.table` and can fail with cross-database reference errors. Since the JDBC URL already selects `${pgDB}`, use `${pgSchema}.${table1}` / `${pgSchema}.${table2}` for DROP/CREATE/INSERT statements.
##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_mysql_job_snapshot.groovy:
##########
@@ -0,0 +1,127 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+/**
+ * Test snapshot-only mode (offset=snapshot):
+ * 1. Job syncs existing data via full snapshot.
+ * 2. Job transitions to FINISHED after snapshot completes (no binlog phase).
+ * 3. Data inserted after job finishes is NOT synced to Doris.
+ */
+suite("test_streaming_mysql_job_snapshot", "p0,external,mysql,external_docker,external_docker_mysql,nondatalake") {
+ def jobName = "test_streaming_mysql_job_snapshot_name"
+ def currentDb = (sql "select database()")[0][0]
+ def table1 = "user_info_mysql_snapshot1"
+ def table2 = "user_info_mysql_snapshot2"
+ def mysqlDb = "test_cdc_db"
+
+ sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+ sql """drop table if exists ${currentDb}.${table1} force"""
+ sql """drop table if exists ${currentDb}.${table2} force"""
+
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ String mysql_port = context.config.otherConfigs.get("mysql_57_port")
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String s3_endpoint = getS3Endpoint()
+ String bucket = getS3BucketName()
+ String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar"
+
+ // prepare source tables and pre-existing data in mysql
+ connect("root", "123456", "jdbc:mysql://${externalEnvIp}:${mysql_port}") {
+ sql """CREATE DATABASE IF NOT EXISTS ${mysqlDb}"""
+ sql """DROP TABLE IF EXISTS ${mysqlDb}.${table1}"""
+ sql """DROP TABLE IF EXISTS ${mysqlDb}.${table2}"""
+ sql """CREATE TABLE ${mysqlDb}.${table1} (
+ `name` varchar(200) NOT NULL,
+ `age` int DEFAULT NULL,
+ PRIMARY KEY (`name`)
+ ) ENGINE=InnoDB"""
+ sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES ('A1', 1)"""
+ sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES ('B1', 2)"""
+ sql """CREATE TABLE ${mysqlDb}.${table2} (
+ `name` varchar(200) NOT NULL,
+ `age` int DEFAULT NULL,
+ PRIMARY KEY (`name`)
+ ) ENGINE=InnoDB"""
+ sql """INSERT INTO ${mysqlDb}.${table2} (name, age) VALUES ('A2', 1)"""
+ sql """INSERT INTO ${mysqlDb}.${table2} (name, age) VALUES ('B2', 2)"""
+ }
+
+ // create streaming job with offset=snapshot (snapshot-only mode)
+ sql """CREATE JOB ${jobName}
+ ON STREAMING
+ FROM MYSQL (
+ "jdbc_url" = "jdbc:mysql://${externalEnvIp}:${mysql_port}/${mysqlDb}",
+ "driver_url" = "${driver_url}",
+ "driver_class" = "com.mysql.cj.jdbc.Driver",
+ "user" = "root",
+ "password" = "123456",
+ "database" = "${mysqlDb}",
+ "include_tables" = "${table1},${table2}",
+ "offset" = "snapshot"
+ )
+ TO DATABASE ${currentDb} (
+ "table.create.properties.replication_num" = "1"
+ )
+ """
+
+ // wait for job to transition to FINISHED
+ try {
+ Awaitility.await().atMost(300, SECONDS)
+ .pollInterval(2, SECONDS).until(
+ {
+ def jobStatus = sql """select Status from jobs("type"="insert") where Name = '${jobName}' and ExecuteType='STREAMING'"""
+ log.info("jobStatus: " + jobStatus)
+ jobStatus.size() == 1 && jobStatus.get(0).get(0) == 'FINISHED'
+ }
+ )
+ } catch (Exception ex) {
+ def showjob = sql """select * from jobs("type"="insert") where Name='${jobName}'"""
+ def showtask = sql """select * from tasks("type"="insert") where JobName='${jobName}'"""
+ log.info("show job: " + showjob)
+ log.info("show task: " + showtask)
+ throw ex
+ }
+
+ // verify snapshot data is correctly synced
+ qt_select_snapshot_table1 """ SELECT * FROM ${table1} order by name asc """
+ qt_select_snapshot_table2 """ SELECT * FROM ${table2} order by name asc """
+
+ // insert new data into mysql after job is FINISHED
+ connect("root", "123456", "jdbc:mysql://${externalEnvIp}:${mysql_port}") {
+ sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES ('C1', 3)"""
+ sql """UPDATE ${mysqlDb}.${table1} SET age = 99 WHERE name = 'A1'"""
+ }
+
+ // wait a bit and confirm new data is NOT synced (job is done, no binlog reading)
+ sleep(30000)
+
+ qt_select_after_finish_table1 """ SELECT * FROM ${table1} order by name asc """
+
Review Comment:
Using a fixed `sleep(30000)` makes this regression test timing-dependent and potentially flaky. Prefer an Awaitility poll (e.g., assert the result remains unchanged for N polling cycles) instead of a hard sleep.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2944732897
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/DataSourceConfigValidator.java:
##########
@@ -82,8 +82,9 @@ private static boolean isValidValue(String key, String value) {
}
if (key.equals(DataSourceConfigKeys.OFFSET)
- && !(value.equals(DataSourceConfigKeys.OFFSET_INITIAL)
- || value.equals(DataSourceConfigKeys.OFFSET_LATEST))) {
+ && !(value.equalsIgnoreCase(DataSourceConfigKeys.OFFSET_INITIAL)
+ || value.equalsIgnoreCase(DataSourceConfigKeys.OFFSET_LATEST)
+ || value.equalsIgnoreCase(DataSourceConfigKeys.OFFSET_SNAPSHOT))) {
Review Comment:
**[Missing `earliest` in validator]** `OFFSET_EARLIEST` is still missing from the validation whitelist. The comment in `DataSourceConfigKeys.java:30` says `// initial,earliest,latest,snapshot,...` but the validator only allows `initial`, `latest`, and `snapshot`. This means `offset=earliest` would be rejected at job creation time.
This is a pre-existing issue (not introduced by this PR), but since this PR already touches this exact block and adds `snapshot`, it would be a good opportunity to also add `OFFSET_EARLIEST`:
```java
|| value.equalsIgnoreCase(DataSourceConfigKeys.OFFSET_EARLIEST)
```
Also, the `equalsIgnoreCase` change (from `equals`) is a minor behavioral expansion — previously `INITIAL` or `Initial` would be rejected, now they're accepted. This is arguably correct but worth noting.
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -116,7 +116,8 @@ public Offset getNextOffset(StreamingJobProperties jobProps, Map<String, String>
nextOffset.setSplits(snapshotSplits);
return nextOffset;
} else if (currentOffset != null && currentOffset.snapshotSplit()) {
- // snapshot to binlog
+ // initial mode: snapshot to binlog
+ // snapshot-only mode must be intercepted by hasReachedEnd() before reaching here
Review Comment:
**[Comment-only guard for snapshot-only mode — consider adding defensive assertion]** The comment says "snapshot-only mode must be intercepted by hasReachedEnd() before reaching here" but there's no actual code guard. If a future code change introduces a path that calls `getNextOffset()` without first checking `hasReachedEnd()`, snapshot-only mode would silently create a `BinlogSplit`, which is semantically incorrect.
Consider adding a check here:
```java
} else if (currentOffset != null && currentOffset.snapshotSplit()) {
if (isSnapshotOnlyMode()) {
throw new IllegalStateException(
"snapshot-only mode should not reach binlog phase; hasReachedEnd() was not checked");
}
// initial mode: snapshot to binlog
...
```
Per project conventions: error means failure, never allow silent continuation on invariant violations.
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -376,10 +380,16 @@ public void replayIfNeed(StreamingInsertJob job) throws JobException {
if (!lastSnapshotSplits.isEmpty()) {
currentOffset.setSplits(lastSnapshotSplits);
} else {
- // when snapshot to binlog phase fe restarts
- BinlogSplit binlogSplit = new BinlogSplit();
- binlogSplit.setFinishedSplits(finishedSplits);
- currentOffset.setSplits(Collections.singletonList(binlogSplit));
+ if (!isSnapshotOnlyMode()) {
+ // initial mode: rebuild binlog split for snapshot-to-binlog transition
+ BinlogSplit binlogSplit = new BinlogSplit();
+ binlogSplit.setFinishedSplits(finishedSplits);
+ currentOffset.setSplits(Collections.singletonList(binlogSplit));
+ } else {
+ // snapshot-only mode: all splits finished, restore from finishedSplits
+ // so snapshotSplit() works correctly and hasReachedEnd() can detect completion
+ currentOffset.setSplits(new ArrayList<>(finishedSplits));
Review Comment:
**[Replay correctness for snapshot-only mode]** When all splits are finished in snapshot-only mode, the code sets:
```java
currentOffset.setSplits(new ArrayList<>(finishedSplits));
```
This makes `snapshotSplit()` return true (because the splits list contains `SnapshotSplit` instances), which is critical for `hasReachedEnd()` to work. However, this also means `getShowCurrentOffset()` (line 134) would serialize and display all finished snapshot splits as the "current offset", which could be a very large JSON string for tables with many chunks. This is a cosmetic concern, not a correctness issue, but worth being aware of.
##########
fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/source/reader/mysql/MySqlSourceReader.java:
##########
@@ -789,8 +789,9 @@ private MySqlSourceConfig generateMySqlConfig(Map<String, String> cdcConfig, Str
// setting startMode
String startupMode = cdcConfig.get(DataSourceConfigKeys.OFFSET);
if (DataSourceConfigKeys.OFFSET_INITIAL.equalsIgnoreCase(startupMode)) {
Review Comment:
**[Behavioral change to existing `initial` mode]** This line was previously commented out (`// configFactory.startupOptions(StartupOptions.initial())`) and is now uncommented. This means the `initial` startup mode behavior changes for *all* existing MySQL streaming jobs, not just the new `snapshot` mode.
With the Flink CDC library, `StartupOptions.initial()` explicitly sets `StartupMode.INITIAL` on the config. Previously, the default startup mode of `MySqlSourceConfigFactory` was used (which happens to be INITIAL anyway based on the Flink CDC source). So this is likely a no-op in practice, but it's worth confirming that the default was indeed INITIAL. If the default was something else (or if a future Flink CDC version changes the default), this uncommented line changes behavior for all existing `initial` mode jobs.
Please confirm this is intentional and that the Flink CDC default for `MySqlSourceConfigFactory.startupOptions` is `StartupOptions.initial()`.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4073513107
<details>
<summary>TPC-H: <b>Total hot run time: 26696 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 7e4ae23b7632fcecb2a352310b7f1cf8281be2d6, data reload: false
------ Round 1 ----------------------------------
orders Doris NULL NULL 0 0 0 NULL 0 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 17607 4470 4312 4312
q2 q3 10645 787 527 527
q4 4674 343 255 255
q5 7568 1192 1028 1028
q6 175 171 145 145
q7 808 839 687 687
q8 9312 1478 1332 1332
q9 4857 4732 4675 4675
q10 6253 1954 1621 1621
q11 456 254 250 250
q12 707 577 476 476
q13 18048 2946 2185 2185
q14 239 231 217 217
q15 q16 759 725 672 672
q17 753 869 414 414
q18 5931 5435 5219 5219
q19 1109 969 628 628
q20 553 498 382 382
q21 4407 1842 1369 1369
q22 345 302 430 302
Total cold run time: 95206 ms
Total hot run time: 26696 ms
----- Round 2, with runtime_filter_mode=off -----
orders Doris NULL NULL 150000000 42 6422171781 NULL 22778155 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 4805 4759 4659 4659
q2 q3 3878 4350 3793 3793
q4 878 1212 791 791
q5 4106 4380 4319 4319
q6 190 183 147 147
q7 1778 1666 1544 1544
q8 2477 2668 2611 2611
q9 7632 7376 7417 7376
q10 3721 4067 3599 3599
q11 507 459 433 433
q12 543 615 445 445
q13 3005 3206 2341 2341
q14 288 299 274 274
q15 q16 717 763 730 730
q17 1153 1375 1361 1361
q18 7205 6899 6715 6715
q19 969 871 898 871
q20 2088 2209 2030 2030
q21 3961 3526 3435 3435
q22 494 493 382 382
Total cold run time: 50395 ms
Total hot run time: 47856 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4107661616
<details>
<summary>TPC-H: <b>Total hot run time: 27019 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 73fff896e363d27e98a97d826a17a1d23a3e06fa, data reload: false
------ Round 1 ----------------------------------
orders Doris NULL NULL 0 0 0 NULL 0 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 17644 4506 4301 4301
q2 q3 10661 772 524 524
q4 4674 360 248 248
q5 7586 1233 1029 1029
q6 180 175 145 145
q7 797 861 672 672
q8 9982 1506 1341 1341
q9 5710 4757 4735 4735
q10 6355 1961 1662 1662
q11 458 260 242 242
q12 735 598 465 465
q13 18036 2966 2166 2166
q14 233 230 219 219
q15 q16 744 751 675 675
q17 731 871 416 416
q18 6030 5519 5342 5342
q19 1491 987 607 607
q20 536 499 379 379
q21 4636 2112 1566 1566
q22 379 354 285 285
Total cold run time: 97598 ms
Total hot run time: 27019 ms
----- Round 2, with runtime_filter_mode=off -----
orders Doris NULL NULL 150000000 42 6422171781 NULL 22778155 NULL NULL 2023-12-26 18:27:23 2023-12-26 18:42:55 NULL utf-8 NULL NULL
============================================
q1 4792 4656 4608 4608
q2 q3 3930 4374 3855 3855
q4 914 1272 799 799
q5 4101 4437 4321 4321
q6 180 175 143 143
q7 1798 1670 1552 1552
q8 2546 2709 2609 2609
q9 7649 7348 7437 7348
q10 3891 3995 3618 3618
q11 500 427 410 410
q12 495 592 467 467
q13 2850 3238 2319 2319
q14 294 306 283 283
q15 q16 779 763 732 732
q17 1188 1400 1376 1376
q18 7227 6943 6619 6619
q19 1001 925 882 882
q20 2101 2207 2018 2018
q21 3959 3499 3331 3331
q22 457 522 440 440
Total cold run time: 50652 ms
Total hot run time: 47730 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4099643373
run external
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4071989110
run buildall
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4072740511
/review
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #61389:
URL: https://github.com/apache/doris/pull/61389#discussion_r2939719914
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -116,7 +116,11 @@ public Offset getNextOffset(StreamingJobProperties jobProps, Map<String, String>
nextOffset.setSplits(snapshotSplits);
return nextOffset;
} else if (currentOffset != null && currentOffset.snapshotSplit()) {
- // snapshot to binlog
+ if (isSnapshotOnlyMode()) {
+ // snapshot-only mode: all splits done, signal job to stop
+ return null;
Review Comment:
`getNextOffset()` returns `null` to signal completion in snapshot-only mode. The `SourceOffsetProvider` contract doesn't document that `null` is allowed, and other task implementations (e.g. `StreamingInsertTask`) call `runningOffset.toString()` without a null check. It’s safer to return a non-null Offset (or a dedicated “end” offset) and rely on `hasReachedEnd()` to stop scheduling / mark the job FINISHED.
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/DataSourceConfigValidator.java:
##########
@@ -83,7 +83,8 @@ private static boolean isValidValue(String key, String value) {
if (key.equals(DataSourceConfigKeys.OFFSET)
&& !(value.equals(DataSourceConfigKeys.OFFSET_INITIAL)
- || value.equals(DataSourceConfigKeys.OFFSET_LATEST))) {
+ || value.equals(DataSourceConfigKeys.OFFSET_LATEST)
+ || value.equals(DataSourceConfigKeys.OFFSET_SNAPSHOT))) {
return false;
Review Comment:
Offset value validation is case-sensitive (`value.equals(...)`), but the rest of the code treats offset modes case-insensitively (e.g. `equalsIgnoreCase` in source readers). This will reject inputs like `OFFSET='SNAPSHOT'` even though they are otherwise supported. Consider normalizing `value` to lower-case or switching these comparisons to `equalsIgnoreCase`.
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingMultiTblTask.java:
##########
@@ -119,6 +124,10 @@ public void run() throws JobException {
log.info("streaming task has been canceled, task id is {}", getTaskId());
return;
}
+ if (this.runningOffset == null) {
+ // offset is null when source has reached end (e.g. snapshot-only mode completed)
+ return;
+ }
Review Comment:
If `runningOffset` is null, the task exits `before()`/`run()` early but never transitions to SUCCESS (that normally happens via `successCallback()` after BE calls `commitOffset`). This can leave the task stuck in RUNNING and never removed from `StreamingTaskManager`, and the job may never reach the `onStreamTaskSuccess()` path that marks FINISHED. If you keep the null-offset approach, make sure the task marks itself SUCCESS and notifies the job (or avoid scheduling tasks when `offsetProvider.hasReachedEnd()` is true).
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java:
##########
@@ -620,6 +620,12 @@ public void onStreamTaskSuccess(AbstractStreamingTask task) throws JobException
}
Env.getCurrentEnv().getJobManager().getStreamingTaskManager().removeRunningTask(task);
+ if (offsetProvider.hasReachedEnd()) {
+ // offset provider has reached a natural end, mark job as finished
+ log.info("Streaming insert job {} source data fully consumed, marking job as FINISHED", getJobId());
+ updateJobStatus(JobStatus.FINISHED);
+ return;
+ }
Review Comment:
`hasReachedEnd()` is only checked inside `onStreamTaskSuccess()`, which requires a task to successfully commit an offset. In snapshot-only recovery scenarios where FE restarts after snapshot completion, `hasMoreDataToConsume()` can become false and the scheduler will only delay/reschedule tasks, never reaching this callback to mark the job FINISHED. Consider adding a FINISHED transition when `offsetProvider.hasReachedEnd()` becomes true even without another successful task commit (e.g. in the scheduler’s pre-checks or job state restoration).
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -376,10 +383,13 @@ public void replayIfNeed(StreamingInsertJob job) throws JobException {
if (!lastSnapshotSplits.isEmpty()) {
currentOffset.setSplits(lastSnapshotSplits);
} else {
- // when snapshot to binlog phase fe restarts
- BinlogSplit binlogSplit = new BinlogSplit();
- binlogSplit.setFinishedSplits(finishedSplits);
- currentOffset.setSplits(Collections.singletonList(binlogSplit));
+ if (!isSnapshotOnlyMode()) {
+ // initial mode: rebuild binlog split for snapshot-to-binlog transition
+ BinlogSplit binlogSplit = new BinlogSplit();
+ binlogSplit.setFinishedSplits(finishedSplits);
+ currentOffset.setSplits(Collections.singletonList(binlogSplit));
+ }
+ // snapshot-only: leave splits empty, hasReachedEnd() will return true
Review Comment:
In snapshot-only mode this branch leaves `currentOffset` with an empty `splits` list, but later logic calls `currentOffset.snapshotSplit()` (e.g. `getNextOffset()`, `hasMoreDataToConsume()`, `hasReachedEnd()`), and `JdbcOffset.snapshotSplit()` throws when `splits` is null/empty. This can break crash recovery right after the snapshot completes. Consider ensuring `currentOffset` is either null, or always contains a non-empty snapshot marker split, and/or make `hasReachedEnd()`/`getNextOffset()` robust to an empty `splits` list.
##########
fe/fe-common/src/main/java/org/apache/doris/job/cdc/DataSourceConfigKeys.java:
##########
@@ -27,11 +27,12 @@ public class DataSourceConfigKeys {
public static final String SCHEMA = "schema";
public static final String INCLUDE_TABLES = "include_tables";
public static final String EXCLUDE_TABLES = "exclude_tables";
- // initial,earliest,latest,{binlog,postion},\d{13}
+ // initial,earliest,latest,snapshot,{binlog,postion},\d{13}
Review Comment:
Typo in the offset mode comment: `postion` should be `position` (also applies to the `{binlog,position}` placeholder).
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4107797468
# FE UT Coverage Report
Increment line coverage ` 0.00% (0/26)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/61389_73fff896e363d27e98a97d826a17a1d23a3e06fa/fe_increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/61389_73fff896e363d27e98a97d826a17a1d23a3e06fa/fe_report/index.html)
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4107596694
run buildall
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [Improve](Streamingjob) support only snapshot sync for mysql and pg [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #61389:
URL: https://github.com/apache/doris/pull/61389#issuecomment-4107701246
<details>
<summary>TPC-DS: <b>Total hot run time: 167498 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 73fff896e363d27e98a97d826a17a1d23a3e06fa, data reload: false
query5 4334 619 489 489
query6 337 237 216 216
query7 4207 497 272 272
query8 350 244 227 227
query9 8718 2695 2679 2679
query10 541 400 365 365
query11 7013 5088 4913 4913
query12 182 130 123 123
query13 1272 468 344 344
query14 5792 3704 3438 3438
query14_1 2848 2841 2828 2828
query15 207 194 175 175
query16 971 473 455 455
query17 886 747 629 629
query18 2449 447 355 355
query19 216 214 186 186
query20 134 127 125 125
query21 215 140 129 129
query22 13258 13233 13036 13036
query23 15846 15455 15789 15455
query23_1 15943 15818 15775 15775
query24 7870 1717 1277 1277
query24_1 1350 1402 1305 1305
query25 599 541 468 468
query26 1388 282 157 157
query27 2953 523 367 367
query28 5704 1929 1923 1923
query29 912 627 511 511
query30 302 241 201 201
query31 995 950 870 870
query32 83 70 69 69
query33 509 345 279 279
query34 913 898 533 533
query35 644 668 599 599
query36 1076 1121 986 986
query37 136 98 83 83
query38 2920 2892 2889 2889
query39 855 825 796 796
query39_1 796 788 792 788
query40 227 151 135 135
query41 62 62 57 57
query42 261 257 257 257
query43 241 261 221 221
query44
query45 196 191 184 184
query46 885 984 614 614
query47 2508 2522 2061 2061
query48 307 319 252 252
query49 673 470 378 378
query50 696 285 208 208
query51 4045 4080 4009 4009
query52 261 265 251 251
query53 292 336 287 287
query54 304 278 289 278
query55 91 86 83 83
query56 316 317 316 316
query57 1927 1776 1538 1538
query58 299 272 281 272
query59 2791 2947 2759 2759
query60 355 336 328 328
query61 156 148 154 148
query62 623 582 538 538
query63 307 272 286 272
query64 5090 1261 995 995
query65
query66 1461 456 356 356
query67 24301 24467 24148 24148
query68
query69 403 318 296 296
query70 918 901 867 867
query71 332 303 292 292
query72 2803 2736 2417 2417
query73 550 558 320 320
query74 9630 9575 9376 9376
query75 2853 2771 2488 2488
query76 2266 1029 676 676
query77 372 395 315 315
query78 11006 11104 10502 10502
query79 3014 762 575 575
query80 1720 627 553 553
query81 571 263 222 222
query82 983 158 119 119
query83 328 259 247 247
query84 301 122 95 95
query85 951 497 443 443
query86 471 314 292 292
query87 3171 3154 2984 2984
query88 3573 2693 2684 2684
query89 427 373 343 343
query90 1985 179 179 179
query91 181 169 143 143
query92 77 79 72 72
query93 1406 861 496 496
query94 649 317 295 295
query95 588 399 323 323
query96 652 513 228 228
query97 2462 2499 2386 2386
query98 241 225 215 215
query99 1025 1003 955 955
Total cold run time: 254885 ms
Total hot run time: 167498 ms
```
</details>
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org