Commit d430e29
[Feature](streamjob) Streaming job support cdc_stream TVF (#61826)
### What problem does this PR solve?
Previously, streaming jobs only supported the non-TVF path (FROM Source
TO Database) for CDC ingestion. This PR adds support for streaming jobs
to drive CDC ingestion via the
cdc_stream Table-Valued Function (TVF), enabling a more flexible and
SQL-native approach.
```sql
CREATE JOB test_streaming_job_cdc_stream_postgres_name
ON STREAMING DO INSERT INTO db.table
SELECT name, age FROM cdc_stream(
"type" = "postgres",
"jdbc_url" = "jdbc:postgresql://127.0.0.1:5432/postgres",
"driver_url" = "postgresql-42.5.0.jar",
"driver_class" = "org.postgresql.Driver",
"user" = "postgres",
"password" = "123456",
"database" = "postgres",
"schema" = "cdc_test",
"table" = "test_streaming_job_cdc_stream_postgres_src",
"offset" = "initial"
)
```
Core flow:
1. Snapshot phase: FE fetches split chunks from BE, persists them to the
meta table, then creates one StreamingInsertTask per split (or batch).
The TVF parameters are
rewritten per-task with meta (split boundary info), job.id, and task.id.
2. Binlog phase: After all snapshot splits are completed, transitions to
continuous binlog ingestion via the same cdc_stream TVF with binlog
offset as meta.
3. Offset commit (2PC safe): After fetchRecordStream completes on BE,
the actual end offset is stored in PipelineCoordinator.taskOffsetCache.
FE pulls this via brpc in
beforeCommitted and stores it in the txn attachment — ensuring the
offset is committed atomically with the data.
4. FE restart recovery: State is recovered via txn replay
(replayOnCommitted) rather than EditLog, rebuilding
chunkHighWatermarkMap and remainingSplits from the meta table.1 parent 7a0ec6d commit d430e29
27 files changed
Lines changed: 1497 additions & 72 deletions
File tree
- fe
- fe-common/src/main/java/org/apache/doris/job/cdc
- fe-core/src/main/java/org/apache/doris
- job
- extensions/insert/streaming
- offset
- jdbc
- s3
- nereids/trees/plans/commands
- planner
- qe
- tablefunction
- fs_brokers/cdc_client/src/main
- java/org/apache/doris/cdcclient
- controller
- service
- source/reader
- mysql
- postgres
- resources
- regression-test
- data/job_p0/streaming_job/cdc/tvf
- suites/job_p0/streaming_job/cdc/tvf
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
Lines changed: 41 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
303 | | - | |
304 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
305 | 310 | | |
306 | 311 | | |
307 | 312 | | |
| |||
536 | 541 | | |
537 | 542 | | |
538 | 543 | | |
| 544 | + | |
| 545 | + | |
539 | 546 | | |
540 | 547 | | |
541 | 548 | | |
| |||
653 | 660 | | |
654 | 661 | | |
655 | 662 | | |
656 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
657 | 671 | | |
658 | 672 | | |
659 | 673 | | |
| |||
757 | 771 | | |
758 | 772 | | |
759 | 773 | | |
760 | | - | |
| 774 | + | |
| 775 | + | |
761 | 776 | | |
762 | 777 | | |
763 | 778 | | |
| |||
1016 | 1031 | | |
1017 | 1032 | | |
1018 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
1019 | 1045 | | |
1020 | 1046 | | |
1021 | 1047 | | |
1022 | 1048 | | |
1023 | 1049 | | |
1024 | 1050 | | |
1025 | 1051 | | |
1026 | | - | |
| 1052 | + | |
1027 | 1053 | | |
1028 | 1054 | | |
1029 | 1055 | | |
| |||
1186 | 1212 | | |
1187 | 1213 | | |
1188 | 1214 | | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
| 1215 | + | |
1193 | 1216 | | |
1194 | 1217 | | |
1195 | 1218 | | |
| |||
1278 | 1301 | | |
1279 | 1302 | | |
1280 | 1303 | | |
| 1304 | + | |
1281 | 1305 | | |
1282 | 1306 | | |
1283 | 1307 | | |
| |||
1298 | 1322 | | |
1299 | 1323 | | |
1300 | 1324 | | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1301 | 1333 | | |
1302 | 1334 | | |
1303 | 1335 | | |
| |||
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertTask.java
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
129 | 138 | | |
130 | 139 | | |
131 | 140 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| |||
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
39 | 54 | | |
40 | 55 | | |
41 | 56 | | |
| |||
59 | 74 | | |
60 | 75 | | |
61 | 76 | | |
| 77 | + | |
62 | 78 | | |
63 | 79 | | |
64 | 80 | | |
65 | 81 | | |
66 | | - | |
| 82 | + | |
67 | 83 | | |
68 | 84 | | |
69 | 85 | | |
| |||
110 | 126 | | |
111 | 127 | | |
112 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
113 | 153 | | |
114 | 154 | | |
115 | 155 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
Lines changed: 31 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| |||
155 | 165 | | |
156 | 166 | | |
157 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
158 | 171 | | |
159 | | - | |
160 | | - | |
161 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
162 | 175 | | |
163 | 176 | | |
164 | 177 | | |
| |||
347 | 360 | | |
348 | 361 | | |
349 | 362 | | |
350 | | - | |
| 363 | + | |
351 | 364 | | |
352 | 365 | | |
353 | 366 | | |
| |||
415 | 428 | | |
416 | 429 | | |
417 | 430 | | |
418 | | - | |
| 431 | + | |
419 | 432 | | |
420 | 433 | | |
421 | 434 | | |
| |||
541 | 554 | | |
542 | 555 | | |
543 | 556 | | |
544 | | - | |
| 557 | + | |
545 | 558 | | |
546 | 559 | | |
547 | 560 | | |
| |||
550 | 563 | | |
551 | 564 | | |
552 | 565 | | |
553 | | - | |
| 566 | + | |
554 | 567 | | |
555 | 568 | | |
556 | 569 | | |
557 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
558 | 578 | | |
559 | 579 | | |
560 | 580 | | |
| |||
0 commit comments