@@ -33,6 +33,7 @@ use crate::barrier::{
33
33
Scheduled ,
34
34
} ;
35
35
use crate :: hummock:: CommitEpochInfo ;
36
+ use crate :: stream:: SourceChange ;
36
37
use crate :: { MetaError , MetaResult } ;
37
38
38
39
impl GlobalBarrierWorkerContext for GlobalBarrierWorkerContextImpl {
@@ -166,7 +167,7 @@ impl CommandContext {
166
167
. await ?;
167
168
barrier_manager_context
168
169
. source_manager
169
- . apply_source_change ( None , None , Some ( split_assignment. clone ( ) ) , None , None )
170
+ . apply_source_change ( SourceChange :: SplitChange ( split_assignment. clone ( ) ) )
170
171
. await ;
171
172
}
172
173
@@ -180,17 +181,18 @@ impl CommandContext {
180
181
. await ?;
181
182
}
182
183
Command :: CreateStreamingJob { info, job_type } => {
183
- let mut fragment_replacements = None ;
184
- let mut dropped_actors = None ;
184
+ let mut is_sink_into_table = false ;
185
185
match job_type {
186
186
CreateStreamingJobType :: SinkIntoTable (
187
187
replace_plan @ ReplaceStreamJobPlan {
188
+ old_fragments,
188
189
new_fragments,
189
190
dispatchers,
190
191
init_split_assignment,
191
192
..
192
193
} ,
193
194
) => {
195
+ is_sink_into_table = true ;
194
196
barrier_manager_context
195
197
. metadata_manager
196
198
. catalog_controller
@@ -201,8 +203,15 @@ impl CommandContext {
201
203
init_split_assignment,
202
204
)
203
205
. await ?;
204
- fragment_replacements = Some ( replace_plan. fragment_replacements ( ) ) ;
205
- dropped_actors = Some ( replace_plan. dropped_actors ( ) ) ;
206
+ barrier_manager_context
207
+ . source_manager
208
+ . handle_replace_job (
209
+ old_fragments,
210
+ new_fragments. stream_source_fragments ( ) ,
211
+ init_split_assignment. clone ( ) ,
212
+ replace_plan. fragment_replacements ( ) ,
213
+ )
214
+ . await ;
206
215
}
207
216
CreateStreamingJobType :: Normal => { }
208
217
CreateStreamingJobType :: SnapshotBackfill ( snapshot_backfill_info) => {
@@ -247,19 +256,17 @@ impl CommandContext {
247
256
)
248
257
. await ?;
249
258
250
- // Extract the fragments that include source operators.
251
- let source_fragments = stream_job_fragments. stream_source_fragments ( ) ;
252
- let backfill_fragments = stream_job_fragments. source_backfill_fragments ( ) ?;
253
- barrier_manager_context
254
- . source_manager
255
- . apply_source_change (
256
- Some ( source_fragments) ,
257
- Some ( backfill_fragments) ,
258
- Some ( init_split_assignment. clone ( ) ) ,
259
- dropped_actors,
260
- fragment_replacements,
261
- )
262
- . await ;
259
+ if !is_sink_into_table {
260
+ barrier_manager_context
261
+ . source_manager
262
+ . apply_source_change ( SourceChange :: CreateJob {
263
+ added_source_fragments : stream_job_fragments. stream_source_fragments ( ) ,
264
+ added_backfill_fragments : stream_job_fragments
265
+ . source_backfill_fragments ( ) ?,
266
+ split_assignment : init_split_assignment. clone ( ) ,
267
+ } )
268
+ . await ;
269
+ }
263
270
}
264
271
Command :: RescheduleFragment {
265
272
reschedules,
@@ -296,19 +303,11 @@ impl CommandContext {
296
303
// Apply the split changes in source manager.
297
304
barrier_manager_context
298
305
. source_manager
299
- . drop_source_fragments_vec ( std:: slice:: from_ref ( old_fragments) )
300
- . await ;
301
- let source_fragments = new_fragments. stream_source_fragments ( ) ;
302
- // XXX: is it possible to have backfill fragments here?
303
- let backfill_fragments = new_fragments. source_backfill_fragments ( ) ?;
304
- barrier_manager_context
305
- . source_manager
306
- . apply_source_change (
307
- Some ( source_fragments) ,
308
- Some ( backfill_fragments) ,
309
- Some ( init_split_assignment. clone ( ) ) ,
310
- Some ( replace_plan. dropped_actors ( ) ) ,
311
- Some ( replace_plan. fragment_replacements ( ) ) ,
306
+ . handle_replace_job (
307
+ old_fragments,
308
+ new_fragments. stream_source_fragments ( ) ,
309
+ init_split_assignment. clone ( ) ,
310
+ replace_plan. fragment_replacements ( ) ,
312
311
)
313
312
. await ;
314
313
}
0 commit comments