{"record":{"id":"8e59add5c188dc3a","repo":"temporalio/temporal","slug":"unable-to-delete-workflow-execution-w","errorCode":null,"errorMessage":"unable to delete workflow execution: %w","messagePattern":"unable to delete workflow execution: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/persistence/sql/sqlplugin/mysql/visibility.go","lineNumber":206,"sourceCode":"\ttx, err := db.BeginTxx(ctx, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\terr := tx.Rollback()\n\t\t// If the error is sql.ErrTxDone, it means the transaction already closed, so ignore error.\n\t\tif err != nil && !errors.Is(err, sql.ErrTxDone) {\n\t\t\t// Transaction rollback error should never happen, unless db connection was lost.\n\t\t\tretError = fmt.Errorf(\"transaction rollback failed: %w\", retError)\n\t\t}\n\t}()\n\t_, err = tx.NamedExecContext(ctx, templateDeleteCustomSearchAttributes, filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to delete custom search attributes: %w\", err)\n\t}\n\tresult, err = tx.NamedExecContext(ctx, templateDeleteWorkflowExecution_v8, filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to delete workflow execution: %w\", err)\n\t}\n\t_, err = tx.NamedExecContext(ctx, templateDeleteChasmSearchAttributes, filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to delete chasm search attributes: %w\", err)\n\t}\n\terr = tx.Commit()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result, nil\n}\n\n// SelectFromVisibility reads one or more rows from visibility table\nfunc (mdb *db) SelectFromVisibility(\n\tctx context.Context,\n\tfilter sqlplugin.VisibilitySelectFilter,\n) ([]sqlplugin.VisibilityRow, error) {\n\tif len(filter.Query) == 0 {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/persistence/sql/sqlplugin/mysql/visibility.go#L188-L224","documentation":"Returned when the main DELETE (templateDeleteWorkflowExecution_v8) on the executions_visibility table fails within DeleteFromVisibility. The deferred rollback discards all prior statements in the transaction. The wrapped error holds the driver-level cause.","triggerScenarios":"DeleteFromVisibility when the workflow-execution delete statement fails: connection loss, lock wait timeout, or schema version that doesn't match templateDeleteWorkflowExecution_v8 (older schema lacking expected columns).","commonSituations":"Running a newer server against an old visibility schema (v8 template expects columns/tables added in later migrations); concurrent deletes or foreign-key constraints blocking the row; DB connectivity blips.","solutions":["Read the wrapped driver error for the exact MySQL errno (e.g. 1146 unknown table, 1205 lock timeout).","Apply pending visibility schema migrations so the table matches templateDeleteWorkflowExecution_v8.","Retry the operation after transient lock-timeout errors.","Check for long-running transactions/holders of the row lock in SHOW ENGINE INNODB STATUS / information_schema.innodb_trx."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Go: verify schema version matches expected template (v8) before serving\nSELECT version FROM schema_version WHERE schema_name = 'visibility';","typeGuard":null,"tryCatchPattern":"// Go\nif err := store.DeleteFromVisibility(ctx, req); err != nil {\n    if isLockTimeout(err) || isConnErr(err) {\n        return retryWithBackoff(ctx, op)\n    }\n    return err\n}","preventionTips":["Run all pending schema migrations on upgrade","Monitor information_schema.innodb_trx for long-running lock holders","Retry transient MySQL errors with exponential backoff","Check wrapped driver errno before classifying the failure"],"tags":["mysql","database","delete","schema-migration","lock-timeout"],"backgroundTag":"sql-query-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}