Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(runner): fix race condition in auto rollout creation (#19159)
boojack9b570d1d375f
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.goindex e887426daf..22d5a70ca1 100644--- a/backend/runner/approval/runner.go+++ b/backend/runner/approval/runner.go@@ -102,6 +102,33 @@ func (r *Runner) processIssue(ctx context.Context, issueUID int64) {slog.String("issue_title", issue.Title),log.BBError(err))// Don't persist error - user can rerun plan check to retry+ return+ }++ // After approval finding is done, check if the issue is now approved+ // (e.g., skip approval case where no template is required).+ // If approved, trigger rollout creation.+ if issue.PlanUID != nil {+ // Re-fetch issue to get updated approval state+ issue, err = r.store.GetIssue(ctx, &store.FindIssueMessage{UID: &uid})+ if err != nil {+ slog.Error("failed to re-fetch issue after approval finding",+ slog.Int64("issue_uid", issueUID), log.BBError(err))+ return+ }+ if issue == nil {+ return+ }++ approved, err := utils.CheckIssueApproved(issue)+ if err != nil {+ slog.Error("failed to check if issue is approved",+ slog.Int64("issue_uid", issueUID), log.BBError(err))+ return+ }+ if approved {+ r.bus.RolloutCreationChan <- *issue.PlanUID+ }}}diff --git a/backend/runner/plancheck/scheduler.go b/backend/runner/plancheck/scheduler.goindex e722f6c9a5..4a926fe4d8 100644--- a/backend/runner/plancheck/scheduler.go+++ b/backend/runner/plancheck/scheduler.go@@ -164,7 +164,8 @@ func (s *Scheduler) markPlanCheckRunDone(ctx context.Context, uid int, planUID ireturn}- // Auto-create rollout if plan checks pass+ // Trigger approval finding after plan checks complete.+ // The approval runner will trigger rollout creation after it finishes.issue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{PlanUID: &planUID})if err != nil {slog.Error("failed to get issue for approval check after plan check",@@ -173,10 +174,8 @@ func (s *Scheduler) markPlanCheckRunDone(ctx context.Context, uid int, planUID ireturn}if issue != nil && issue.PlanUID != nil {- // Trigger approval finding+ // Trigger approval finding.s.bus.ApprovalCheckChan <- int64(issue.UID)- // Trigger rollout creation (existing behavior)- s.bus.RolloutCreationChan <- planUID}}