temporalio/temporal · error
unable to delete workflow execution: %w
Error message
unable to delete workflow execution: %w
What it means
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.
Source
Thrown at common/persistence/sql/sqlplugin/mysql/visibility.go:206
tx, err := db.BeginTxx(ctx, nil)
if err != nil {
return nil, err
}
defer func() {
err := tx.Rollback()
// If the error is sql.ErrTxDone, it means the transaction already closed, so ignore error.
if err != nil && !errors.Is(err, sql.ErrTxDone) {
// Transaction rollback error should never happen, unless db connection was lost.
retError = fmt.Errorf("transaction rollback failed: %w", retError)
}
}()
_, err = tx.NamedExecContext(ctx, templateDeleteCustomSearchAttributes, filter)
if err != nil {
return nil, fmt.Errorf("unable to delete custom search attributes: %w", err)
}
result, err = tx.NamedExecContext(ctx, templateDeleteWorkflowExecution_v8, filter)
if err != nil {
return nil, fmt.Errorf("unable to delete workflow execution: %w", err)
}
_, err = tx.NamedExecContext(ctx, templateDeleteChasmSearchAttributes, filter)
if err != nil {
return nil, fmt.Errorf("unable to delete chasm search attributes: %w", err)
}
err = tx.Commit()
if err != nil {
return nil, err
}
return result, nil
}
// SelectFromVisibility reads one or more rows from visibility table
func (mdb *db) SelectFromVisibility(
ctx context.Context,
filter sqlplugin.VisibilitySelectFilter,
) ([]sqlplugin.VisibilityRow, error) {
if len(filter.Query) == 0 {View on GitHub (pinned to bde624efd1)
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.
Defensive patterns
Strategy: retry
Validate before calling
// Go: verify schema version matches expected template (v8) before serving SELECT version FROM schema_version WHERE schema_name = 'visibility';
Try / catch
// Go
if err := store.DeleteFromVisibility(ctx, req); err != nil {
if isLockTimeout(err) || isConnErr(err) {
return retryWithBackoff(ctx, op)
}
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- unable to delete custom search attributes: %w
- unable to delete chasm search attributes: %w
- transaction rollback failed: %w
- rowsAffected returned error when initializing DLQ metadata
- ErrQueueAlreadyExists
AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01).
Data as JSON: /api/errors/8e59add5c188dc3a.
Report an issue: GitHub.