From 1a7f4ea546c065e7ee18bf8f3bf46fa38a823bd4 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 1 Aug 2025 05:30:24 -0700 Subject: [PATCH] Add missing reuse policy --- backend/postgres/postgres.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/postgres/postgres.go b/backend/postgres/postgres.go index e8c9b6f..ba4f17e 100644 --- a/backend/postgres/postgres.go +++ b/backend/postgres/postgres.go @@ -361,7 +361,10 @@ func (be *postgresBackend) CompleteOrchestrationWorkItem(ctx context.Context, wi for _, msg := range wi.State.PendingMessages() { if es := msg.HistoryEvent.GetExecutionStarted(); es != nil { // Need to insert a new row into the DB - if _, err := be.createOrchestrationInstanceInternal(ctx, msg.HistoryEvent, tx); err != nil { + if _, err := be.createOrchestrationInstanceInternal(ctx, msg.HistoryEvent, tx, backend.WithOrchestrationIdReusePolicy(&protos.OrchestrationIdReusePolicy{ + OperationStatus: []protos.OrchestrationStatus{protos.OrchestrationStatus_ORCHESTRATION_STATUS_FAILED}, + Action: api.REUSE_ID_ACTION_TERMINATE, + })); err != nil { if errors.Is(err, backend.ErrDuplicateEvent) { be.logger.Warnf( "%v: dropping sub-orchestration creation event because an instance with the target ID (%v) already exists.",