Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdc: don't send normalize-done after sync flow finished #1397

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions flow/workflows/cdc_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func (w *CDCFlowWorkflowExecution) addCdcPropertiesSignalListener(
selector workflow.Selector,
state *CDCFlowWorkflowState,
) {
// add a signal to change CDC properties
cdcPropertiesSignalChan := model.CDCDynamicPropertiesSignal.GetSignalChannel(ctx)
cdcPropertiesSignalChan.AddToSelector(selector, func(cdcConfigUpdate *protos.CDCFlowConfigUpdate, more bool) {
// only modify for options since SyncFlow uses it
Expand All @@ -240,21 +239,11 @@ func (w *CDCFlowWorkflowExecution) addCdcPropertiesSignalListener(
}

func (w *CDCFlowWorkflowExecution) startSyncFlow(ctx workflow.Context, config *protos.FlowConnectionConfigs, options *protos.SyncFlowOptions) {
w.syncFlowFuture = workflow.ExecuteChildWorkflow(
ctx,
SyncFlowWorkflow,
config,
options,
)
w.syncFlowFuture = workflow.ExecuteChildWorkflow(ctx, SyncFlowWorkflow, config, options)
}

func (w *CDCFlowWorkflowExecution) startNormFlow(ctx workflow.Context, config *protos.FlowConnectionConfigs) {
w.normFlowFuture = workflow.ExecuteChildWorkflow(
ctx,
NormalizeFlowWorkflow,
config,
nil,
)
w.normFlowFuture = workflow.ExecuteChildWorkflow(ctx, NormalizeFlowWorkflow, config, nil)
}

func CDCFlowWorkflow(
Expand Down Expand Up @@ -499,6 +488,7 @@ func CDCFlowWorkflow(

if restart {
w.logger.Info("sync finished, finishing normalize")
w.syncFlowFuture = nil
_ = model.NormalizeSignal.SignalChildWorkflow(ctx, w.normFlowFuture, model.NormalizePayload{
Done: true,
SyncBatchID: -1,
Expand All @@ -519,6 +509,7 @@ func CDCFlowWorkflow(

if restart {
w.logger.Info("normalize finished")
w.normFlowFuture = nil
finished = true
} else {
w.logger.Warn("normalize flow ended, restarting", slog.Any("error", err))
Expand Down Expand Up @@ -576,7 +567,9 @@ func CDCFlowWorkflow(
if !parallel {
normDoneChan := model.NormalizeDoneSignal.GetSignalChannel(ctx)
normDoneChan.AddToSelector(mainLoopSelector, func(x struct{}, _ bool) {
_ = model.NormalizeDoneSignal.SignalChildWorkflow(ctx, w.syncFlowFuture, x).Get(ctx, nil)
if w.syncFlowFuture != nil {
_ = model.NormalizeDoneSignal.SignalChildWorkflow(ctx, w.syncFlowFuture, x).Get(ctx, nil)
}
})
}

Expand Down
Loading