Skip to content

Commit d467ed2

Browse files
fix: skip for table addition and resync
1 parent 9471f04 commit d467ed2

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

flow/workflows/setup_flow.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log/slog"
66
"maps"
77
"slices"
8+
"strings"
89
"time"
910

1011
"go.temporal.io/sdk/log"
@@ -273,6 +274,17 @@ func (s *SetupFlowExecution) runPgDumpSchema(
273274
return ran, nil
274275
}
275276

277+
// isTableAdditionChild reports whether this SetupFlow was launched as part of a
278+
// table-addition child CDC flow. Such workflows are spawned with a parent
279+
// workflow ID prefixed by "additional-cdc-flow-".
280+
func isTableAdditionChild(ctx workflow.Context) bool {
281+
parent := workflow.GetInfo(ctx).ParentWorkflowExecution
282+
if parent == nil {
283+
return false
284+
}
285+
return strings.HasPrefix(parent.ID, "additional-cdc-flow-")
286+
}
287+
276288
// getPGAutomatedSchemaDump checks the PEERDB_PG_AUTOMATED_SCHEMA_DUMP env flag via an activity.
277289
func (s *SetupFlowExecution) getPGAutomatedSchemaDump(ctx workflow.Context, env map[string]string) bool {
278290
checkCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
@@ -319,8 +331,11 @@ func (s *SetupFlowExecution) executeSetupFlow(
319331

320332
// pg_dump silently no-ops for SSH tunnel / non-password-auth peers, so we
321333
// only skip CreateNormalizedTable when the activity reports it actually ran.
334+
// Skip pg_dump for resync (tables get _resync suffix and are swapped) and for
335+
// table-addition child workflows (parent workflow ID prefix "additional-cdc-flow-").
322336
skipCreateTables := false
323-
if config.System == protos.TypeSystem_PG && s.getPGAutomatedSchemaDump(ctx, config.Env) {
337+
if config.System == protos.TypeSystem_PG && !config.Resync && !isTableAdditionChild(ctx) &&
338+
s.getPGAutomatedSchemaDump(ctx, config.Env) {
324339
ran, err := s.runPgDumpSchema(ctx, config)
325340
if err != nil {
326341
return nil, fmt.Errorf("failed to run pg_dump schema migration: %w", err)

0 commit comments

Comments
 (0)