From 2e600ce6fc91a4be90413ea126095a82a26b9477 Mon Sep 17 00:00:00 2001
From: Andras Kovi <akovi@nokia.com>
Date: Tue, 21 Jul 2020 09:36:48 +0200
Subject: [PATCH] Generalize caught exceptions on workflow delete

OsloDB sometimes does not convert the underlying SQLAlchemy
errors into DBError. Sometimes it happens that the "too deep
cascade delete" error manifests in sa.OperationalError instead
of DBError. We generalize to catch both cases as the underlying
issue is the same (just as the message of the error).

Change-Id: Icce8dfa6edb18973ca2a4eb594818ea9d504b49a
---
 mistral/db/v2/sqlalchemy/api.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mistral/db/v2/sqlalchemy/api.py b/mistral/db/v2/sqlalchemy/api.py
index 09f048791..33c5b6d68 100644
--- a/mistral/db/v2/sqlalchemy/api.py
+++ b/mistral/db/v2/sqlalchemy/api.py
@@ -916,7 +916,7 @@ def delete_workflow_execution(id, session=None):
             raise exc.DBEntityNotFoundError(
                 "WorkflowExecution not found [id=%s]" % id
             )
-    except db_exc.DBError as e:
+    except Exception as e:
         if is_mysql_max_depth_error(e) or is_mariadb_max_depth_error(e):
             # https://bugs.launchpad.net/mistral/+bug/1832300
             # mysql cascade delete error