|
5 | 5 | "log/slog" |
6 | 6 | "maps" |
7 | 7 | "slices" |
| 8 | + "strings" |
8 | 9 | "time" |
9 | 10 |
|
10 | 11 | "go.temporal.io/sdk/log" |
@@ -273,6 +274,17 @@ func (s *SetupFlowExecution) runPgDumpSchema( |
273 | 274 | return ran, nil |
274 | 275 | } |
275 | 276 |
|
| 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 | + |
276 | 288 | // getPGAutomatedSchemaDump checks the PEERDB_PG_AUTOMATED_SCHEMA_DUMP env flag via an activity. |
277 | 289 | func (s *SetupFlowExecution) getPGAutomatedSchemaDump(ctx workflow.Context, env map[string]string) bool { |
278 | 290 | checkCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ |
@@ -319,8 +331,11 @@ func (s *SetupFlowExecution) executeSetupFlow( |
319 | 331 |
|
320 | 332 | // pg_dump silently no-ops for SSH tunnel / non-password-auth peers, so we |
321 | 333 | // 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-"). |
322 | 336 | 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) { |
324 | 339 | ran, err := s.runPgDumpSchema(ctx, config) |
325 | 340 | if err != nil { |
326 | 341 | return nil, fmt.Errorf("failed to run pg_dump schema migration: %w", err) |
|
0 commit comments