{"record":{"id":"0b9745c57e97608e","repo":"argoproj/argo-workflows","slug":"failed-to-archive-workflow-w","errorCode":null,"errorMessage":"failed to archive workflow: %w","messagePattern":"failed to archive workflow: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/controller.go","lineNumber":1407,"sourceCode":"\nfunc (wfc *WorkflowController) archiveWorkflowAux(ctx context.Context, obj any) error {\n\tun, ok := obj.(*unstructured.Unstructured)\n\tif !ok {\n\t\treturn nil\n\t}\n\twf, err := util.FromUnstructured(un)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert to workflow from unstructured: %w\", err)\n\t}\n\terr = wfc.hydrator.Hydrate(ctx, wf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to hydrate workflow: %w\", err)\n\t}\n\tlogger := logging.RequireLoggerFromContext(ctx)\n\tlogger.WithFields(logging.Fields{\"namespace\": wf.Namespace, \"workflow\": wf.Name, \"uid\": wf.UID}).Info(ctx, \"archiving workflow\")\n\terr = wfc.wfArchive.ArchiveWorkflow(ctx, wf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to archive workflow: %w\", err)\n\t}\n\tdata, err := json.Marshal(map[string]any{\n\t\t\"metadata\": metav1.ObjectMeta{\n\t\t\tLabels: map[string]string{\n\t\t\t\tcommon.LabelKeyWorkflowArchivingStatus: \"Archived\",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal patch: %w\", err)\n\t}\n\t_, err = wfc.wfclientset.ArgoprojV1alpha1().Workflows(un.GetNamespace()).Patch(\n\t\tctx,\n\t\tun.GetName(),\n\t\ttypes.MergePatchType,\n\t\tdata,\n\t\tmetav1.PatchOptions{},\n\t)","sourceCodeStart":1389,"sourceCodeEnd":1425,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/controller.go#L1389-L1425","documentation":"archiveWorkflowAux (workflow/controller/controller.go:1407) fails when wfc.wfArchive.ArchiveWorkflow cannot persist the hydrated workflow into the workflow archive store (server-side archive backed by persist/sqldb, Postgres or MySQL). The workflow completed fine; only its archive copy failed, so it will be retried while it remains in the cluster.","triggerScenarios":"Insert into the archived_workflows table fails — archive DB unreachable, schema mismatch (older archive table without newer columns), duplicate-UID insert rejected due to a UNIQUE constraint on an already-archived workflow with the same UID, or connection-pool exhaustion.","commonSituations":"Archive DB out of disk/space or max_connections hit; upgrading Argo without running the DB schema migrations for the new archive tables; archived workflow for the same UID already present (resubmitted workflows keeping UIDs); MySQL/Postgres credentials rotated.","solutions":["Inspect the wrapped DB error; fix connectivity/credentials in the persistence config (workflow-controller-configmap persistence block).","Apply the schema migrations matching your Argo version to the archive database (persist/sqldb migration scripts).","If it's a duplicate-UID insert, verify the existing archived row — the archive is keyed by UID; stale rows may need manual cleanup.","Scale DB connections / fix pool settings if max_connections is exhausted; retry happens on subsequent archiving passes."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight: verify archive DB schema and connection\nrows, err := db.Query(\"SELECT uid FROM argo_archived_workflows LIMIT 1\")\nif err != nil { log.Fatal(\"archive schema missing or DB unreachable: \", err) }","typeGuard":null,"tryCatchPattern":"err := wfc.wfArchive.ArchiveWorkflow(ctx, wf)\nif err != nil {\n    if util/errors.IsTransientErr(ctx, err) { requeueWithBackoff(err) }\n    return fmt.Errorf(\"failed to archive workflow: %w\", err)\n}","preventionTips":["Run DB schema migrations matching your Argo release before upgrading the controller","Monitor DB disk space and max_connections","Don't rotate DB credentials without updating the controller's persistence config","Use util/errors.IsTransientErr for retry decisions on archive writes"],"tags":["database","archiving","postgres","mysql","persistence"],"backgroundTag":"archive-db-write-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}