Skip to content

Commit 0370fd8

Browse files
committed
resolevd comments
1 parent 3790e5c commit 0370fd8

4 files changed

Lines changed: 32 additions & 46 deletions

File tree

flow/cmd/handler.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -658,24 +658,6 @@ func (h *FlowRequestHandler) getWorkflowID(ctx context.Context, flowJobName stri
658658
return workflowID, nil
659659
}
660660

661-
func applySnapshotConfigOverrides(config *protos.FlowConnectionConfigs, update *protos.CDCFlowConfigUpdate) {
662-
if update == nil {
663-
return
664-
}
665-
if update.SnapshotNumRowsPerPartition > 0 {
666-
config.SnapshotNumRowsPerPartition = update.SnapshotNumRowsPerPartition
667-
}
668-
if update.SnapshotNumPartitionsOverride > 0 {
669-
config.SnapshotNumPartitionsOverride = update.SnapshotNumPartitionsOverride
670-
}
671-
if update.SnapshotMaxParallelWorkers > 0 {
672-
config.SnapshotMaxParallelWorkers = update.SnapshotMaxParallelWorkers
673-
}
674-
if update.SnapshotNumTablesInParallel > 0 {
675-
config.SnapshotNumTablesInParallel = update.SnapshotNumTablesInParallel
676-
}
677-
}
678-
679661
func (h *FlowRequestHandler) resyncByRecreatingFlow(
680662
ctx context.Context,
681663
flowName string,
@@ -708,11 +690,16 @@ func (h *FlowRequestHandler) resyncByRecreatingFlow(
708690

709691
config.Resync = true
710692
config.DoInitialSnapshot = true
711-
applySnapshotConfigOverrides(config, cdcConfigUpdate)
712693
// validate mirror first because once the mirror is dropped, there's no going back
713-
if _, err := h.ValidateCDCMirror(ctx, &protos.CreateCDCFlowRequest{
714-
ConnectionConfigs: config,
715-
}); err != nil {
694+
if internalVersion, err := internal.PeerDBForceInternalVersion(ctx, config.Env); err != nil {
695+
return NewInternalApiError(err)
696+
} else {
697+
config.Version = internalVersion
698+
}
699+
configCore := pconv.FlowConnectionConfigsToCore(config, 0)
700+
internal.ApplySnapshotConfigOverrides(configCore, cdcConfigUpdate)
701+
702+
if _, err := h.validateCDCMirrorImpl(ctx, configCore, false); err != nil {
716703
return err
717704
}
718705

@@ -721,7 +708,6 @@ func (h *FlowRequestHandler) resyncByRecreatingFlow(
721708
}
722709

723710
workflowID := getWorkflowID(config.FlowJobName)
724-
configCore := pconv.FlowConnectionConfigsToCore(config, 0)
725711
if _, err := h.createCDCFlow(ctx, configCore, workflowID); err != nil {
726712
return err
727713
}

flow/internal/flow_configuration_helpers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,21 @@ func FetchConfigFromDB(ctx context.Context, catalogPool shared.CatalogPool, flow
2626

2727
return &cfgFromDB, nil
2828
}
29+
30+
func ApplySnapshotConfigOverrides(config *protos.FlowConnectionConfigsCore, update *protos.CDCFlowConfigUpdate) {
31+
if update == nil {
32+
return
33+
}
34+
if update.SnapshotNumRowsPerPartition > 0 {
35+
config.SnapshotNumRowsPerPartition = update.SnapshotNumRowsPerPartition
36+
}
37+
if update.SnapshotNumPartitionsOverride > 0 {
38+
config.SnapshotNumPartitionsOverride = update.SnapshotNumPartitionsOverride
39+
}
40+
if update.SnapshotMaxParallelWorkers > 0 {
41+
config.SnapshotMaxParallelWorkers = update.SnapshotMaxParallelWorkers
42+
}
43+
if update.SnapshotNumTablesInParallel > 0 {
44+
config.SnapshotNumTablesInParallel = update.SnapshotNumTablesInParallel
45+
}
46+
}

flow/shared/telemetry/activity_logging.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,6 @@ func LogActivityStartFlowConfigUpdate(ctx context.Context, flowName string, upda
9393
changes = append(changes, fmt.Sprintf("tables removed: %v", removedTables))
9494
}
9595

96-
if update.BatchSize > 0 {
97-
changes = append(changes, fmt.Sprintf("batchSize: %v", update.BatchSize))
98-
}
99-
if update.IdleTimeout > 0 {
100-
changes = append(changes, fmt.Sprintf("idleTimeout: %v", update.IdleTimeout))
101-
}
102-
if update.SnapshotNumPartitionsOverride > 0 {
103-
changes = append(changes, fmt.Sprintf("snapshotNumPartitionsOverride: %v", update.SnapshotNumPartitionsOverride))
104-
}
105-
if update.SnapshotMaxParallelWorkers > 0 {
106-
changes = append(changes, fmt.Sprintf("snapshotMaxParallelWorkers: %v", update.SnapshotMaxParallelWorkers))
107-
}
108-
if update.SnapshotNumTablesInParallel > 0 {
109-
changes = append(changes, fmt.Sprintf("snapshotNumTablesInParallel: %v", update.SnapshotNumTablesInParallel))
110-
}
111-
if update.SnapshotNumRowsPerPartition > 0 {
112-
changes = append(changes, fmt.Sprintf("snapshotNumRowsPerPartition: %v", update.SnapshotNumRowsPerPartition))
113-
}
114-
11596
logActivity(ctx, ActionStartFlowConfigUpdate,
11697
slog.String("flowName", flowName),
11798
slog.String("activityDetails", strings.Join(changes, ", ")))

flow/workflows/cdc_flow.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,12 @@ func CDCFlowWorkflow(
653653
// so we need to NOT sync the tableMappings to catalog to preserve original names
654654

655655
// We still override the snapshot parameters (when resync with updated values)
656-
overrideSnapshotParametersInState(val, state)
657-
resyncCfg := syncStateToConfigProtoInCatalog(ctx, cfg, state)
656+
internal.ApplySnapshotConfigOverrides(cfg, val.GetFlowConfigUpdate().GetCdcFlowConfigUpdate())
657+
uploadConfigToCatalog(ctx, cfg)
658+
658659
state.DropFlowInput = &protos.DropFlowInput{
659-
FlowJobName: resyncCfg.FlowJobName,
660-
FlowConnectionConfigs: resyncCfg,
660+
FlowJobName: cfg.FlowJobName,
661+
FlowConnectionConfigs: cfg,
661662
DropFlowStats: val.DropMirrorStats,
662663
SkipDestinationDrop: val.SkipDestinationDrop,
663664
Resync: true,

0 commit comments

Comments
 (0)