@@ -240,21 +240,22 @@ func processTableAdditions(
240
240
additionalTablesUUID := GetUUID (ctx )
241
241
childAdditionalTablesCDCFlowID := GetChildWorkflowID ("additional-cdc-flow" , cfg .FlowJobName , additionalTablesUUID )
242
242
additionalTablesCfg := proto .CloneOf (cfg )
243
- additionalTablesCfg .DoInitialSnapshot = ! flowConfigUpdate .SkipInitialSnapshotForTableAdditions
243
+ // Default to doing initial snapshot for additional tables
244
+ additionalTablesCfg .DoInitialSnapshot = true
244
245
additionalTablesCfg .InitialSnapshotOnly = true
245
246
additionalTablesCfg .TableMappings = append (additionalTablesCfg .TableMappings , flowConfigUpdate .AdditionalTables ... )
246
247
additionalTablesCfg .Resync = false
247
- if state .SnapshotNumRowsPerPartition > 0 {
248
- additionalTablesCfg .SnapshotNumRowsPerPartition = state .SnapshotNumRowsPerPartition
248
+ if flowConfigUpdate .SnapshotNumRowsPerPartition > 0 {
249
+ additionalTablesCfg .SnapshotNumRowsPerPartition = flowConfigUpdate .SnapshotNumRowsPerPartition
249
250
}
250
- if state .SnapshotNumPartitionsOverride > 0 {
251
- additionalTablesCfg .SnapshotNumPartitionsOverride = state .SnapshotNumPartitionsOverride
251
+ if flowConfigUpdate .SnapshotNumPartitionsOverride > 0 {
252
+ additionalTablesCfg .SnapshotNumPartitionsOverride = flowConfigUpdate .SnapshotNumPartitionsOverride
252
253
}
253
- if state .SnapshotMaxParallelWorkers > 0 {
254
- additionalTablesCfg .SnapshotMaxParallelWorkers = state .SnapshotMaxParallelWorkers
254
+ if flowConfigUpdate .SnapshotMaxParallelWorkers > 0 {
255
+ additionalTablesCfg .SnapshotMaxParallelWorkers = flowConfigUpdate .SnapshotMaxParallelWorkers
255
256
}
256
- if state .SnapshotNumTablesInParallel > 0 {
257
- additionalTablesCfg .SnapshotNumTablesInParallel = state .SnapshotNumTablesInParallel
257
+ if flowConfigUpdate .SnapshotNumTablesInParallel > 0 {
258
+ additionalTablesCfg .SnapshotNumTablesInParallel = flowConfigUpdate .SnapshotNumTablesInParallel
258
259
}
259
260
260
261
uploadConfigToCatalog (ctx , additionalTablesCfg )
@@ -274,7 +275,7 @@ func processTableAdditions(
274
275
childAddTablesCDCFlowFuture := workflow .ExecuteChildWorkflow (
275
276
childAddTablesCDCFlowCtx ,
276
277
CDCFlowWorkflow ,
277
- additionalTablesCfg .FlowJobName ,
278
+ internal . CreateMinimalConfigFromFlowJobName ( additionalTablesCfg .FlowJobName ) ,
278
279
nil , // nil is passed to trigger `setup` flow.
279
280
)
280
281
addTablesSelector .AddFuture (childAddTablesCDCFlowFuture , func (f workflow.Future ) {
@@ -283,15 +284,10 @@ func processTableAdditions(
283
284
}
284
285
})
285
286
286
- // additional tables should also be resynced, we don't know how much was done so far
287
- // state.SyncFlowOptions.TableMappings = append(state.SyncFlowOptions.TableMappings, flowConfigUpdate.AdditionalTables...)
288
-
289
287
for res == nil {
290
288
addTablesSelector .Select (ctx )
291
289
if state .ActiveSignal == model .TerminateSignal || state .ActiveSignal == model .ResyncSignal {
292
290
if state .ActiveSignal == model .ResyncSignal {
293
- // additional tables should also be resynced, we don't know how much was done so far
294
- // state.SyncFlowOptions.TableMappings = append(state.SyncFlowOptions.TableMappings, flowConfigUpdate.AdditionalTables...)
295
291
resyncCfg := syncStateToConfigProtoInCatalog (ctx , cfg , state .FlowConfigUpdate )
296
292
state .DropFlowInput .FlowJobName = resyncCfg .FlowJobName
297
293
state .DropFlowInput .FlowConnectionConfigs = resyncCfg
@@ -318,7 +314,7 @@ func processTableRemovals(
318
314
cfg * protos.FlowConnectionConfigs ,
319
315
state * CDCFlowWorkflowState ,
320
316
) error {
321
- state .updateStatus (ctx , logger , protos .FlowStatus_STATUS_MODIFYING )
317
+ state .updateStatus (ctx , logger , protos .FlowStatus_STATUS_RUNNING )
322
318
removeTablesSelector := workflow .NewNamedSelector (ctx , "RemoveTables" )
323
319
removeTablesSelector .AddReceive (ctx .Done (), func (_ workflow.ReceiveChannel , _ bool ) {})
324
320
flowSignalStateChangeChan := model .FlowSignalStateChange .GetSignalChannel (ctx )
@@ -428,24 +424,25 @@ func addCdcPropertiesSignalListener(
428
424
slog .Uint64 ("SnapshotNumPartitionsOverride" , uint64 (cdcConfigUpdate .SnapshotNumPartitionsOverride )),
429
425
slog .Uint64 ("SnapshotMaxParallelWorkers" , uint64 (cdcConfigUpdate .SnapshotMaxParallelWorkers )),
430
426
slog .Uint64 ("SnapshotNumTablesInParallel" , uint64 (cdcConfigUpdate .SnapshotNumTablesInParallel )),
431
- slog .Bool ("SkipInitialSnapshotForTableAdditions" , cdcConfigUpdate .SkipInitialSnapshotForTableAdditions ),
432
427
)
433
428
})
434
429
}
435
430
436
431
func CDCFlowWorkflow (
437
432
ctx workflow.Context ,
438
- flowJobName string ,
439
- // cfg *protos.FlowConnectionConfigs,
433
+ cfg * protos.FlowConnectionConfigs ,
440
434
state * CDCFlowWorkflowState ,
441
435
) (* CDCFlowWorkflowResult , error ) {
442
- cfg , err := internal .FetchConfigFromDB (flowJobName )
443
- if cfg == nil {
444
- return nil , errors .New ("invalid connection configs" )
445
- }
436
+ // Fetch full config from DB using the flowJobName from the minimal config
437
+ cfgFromDB , err := internal .FetchConfigFromDB (cfg .FlowJobName )
446
438
if err != nil {
447
- return nil , fmt .Errorf ("unable to unmarshal flow config: %w" , err )
439
+ return nil , fmt .Errorf ("unable to fetch flow config from DB: %w" , err )
440
+ }
441
+ if cfgFromDB == nil {
442
+ return nil , errors .New ("invalid connection configs" )
448
443
}
444
+ // Use the config from DB for all operations
445
+ cfg = cfgFromDB
449
446
450
447
logger := log .With (workflow .GetLogger (ctx ), slog .String (string (shared .FlowNameKey ), cfg .FlowJobName ))
451
448
if state == nil {
@@ -533,7 +530,7 @@ func CDCFlowWorkflow(
533
530
534
531
logger .Info ("mirror resumed" , slog .Duration ("after" , time .Since (startTime )))
535
532
state .updateStatus (ctx , logger , protos .FlowStatus_STATUS_RUNNING )
536
- return state , workflow .NewContinueAsNewError (ctx , CDCFlowWorkflow , cfg .FlowJobName , state )
533
+ return state , workflow .NewContinueAsNewError (ctx , CDCFlowWorkflow , internal . CreateMinimalConfigFromFlowJobName ( cfg .FlowJobName ) , state )
537
534
}
538
535
539
536
originalRunID := workflow .GetInfo (ctx ).OriginalRunID
@@ -678,7 +675,7 @@ func CDCFlowWorkflow(
678
675
}
679
676
}
680
677
681
- // TODOAS: here we will also store the table mappings in the state.
678
+ // here we will also store the table mappings in the state.
682
679
maps .Copy (cfg .SrcTableIdNameMapping , setupFlowOutput .SrcTableIdNameMapping )
683
680
uploadConfigToCatalog (ctx , cfg )
684
681
@@ -701,7 +698,7 @@ func CDCFlowWorkflow(
701
698
// during any operation that triggers another snapshot (INCLUDING add tables).
702
699
// this could fail for very weird Temporal resets
703
700
704
- // TODOAS : this will send the additionalTables to `temporal`, meaning
701
+ // This will send the additionalTables to `temporal`, meaning
705
702
// that we cannot add too many tables at once, or we risk the blob is too
706
703
// large (2MB limit).
707
704
snapshotFlowFuture := workflow .ExecuteChildWorkflow (
@@ -803,7 +800,7 @@ func CDCFlowWorkflow(
803
800
logger .Info ("executed setup flow and snapshot flow, start running" )
804
801
state .updateStatus (ctx , logger , protos .FlowStatus_STATUS_RUNNING )
805
802
}
806
- return state , workflow .NewContinueAsNewError (ctx , CDCFlowWorkflow , cfg .FlowJobName , state )
803
+ return state , workflow .NewContinueAsNewError (ctx , CDCFlowWorkflow , internal . CreateMinimalConfigFromFlowJobName ( cfg .FlowJobName ) , state )
807
804
}
808
805
809
806
var finished bool
@@ -933,7 +930,7 @@ func CDCFlowWorkflow(
933
930
if state .ActiveSignal == model .TerminateSignal || state .ActiveSignal == model .ResyncSignal {
934
931
return state , workflow .NewContinueAsNewError (ctx , DropFlowWorkflow , state .DropFlowInput )
935
932
}
936
- return state , workflow .NewContinueAsNewError (ctx , CDCFlowWorkflow , cfg .FlowJobName , state )
933
+ return state , workflow .NewContinueAsNewError (ctx , CDCFlowWorkflow , internal . CreateMinimalConfigFromFlowJobName ( cfg .FlowJobName ) , state )
937
934
}
938
935
}
939
936
}
0 commit comments