From 403e11e01027c0063e4e48ee76d40a11cd06f599 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 16 Mar 2016 15:57:45 +0100 Subject: [PATCH] Split a delete query to avoid deadlocks TICKETS #3446 --- pandora_server/util/pandora_db.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 3834fa26ef..03bd859e71 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -710,7 +710,9 @@ sub pandora_checkdb_integrity { db_do ($dbh, 'DELETE FROM tagente_modulo WHERE id_agente NOT IN (SELECT id_agente FROM tagente)'); # Delete orphan modules in tagente_estado - db_do ($dbh, 'DELETE FROM tagente_estado WHERE id_agente NOT IN (SELECT id_agente FROM tagente)'); + while (defined (get_db_value ($dbh, 'SELECT id_agente FROM tagente_estado WHERE id_agente NOT IN (SELECT id_agente FROM tagente)'))) { + db_delete_limit ($dbh, 'tagente_estado', 'id_agente NOT IN (SELECT id_agente FROM tagente)', $BIG_OPERATION_STEP); + } # Delete orphan data_inc reference records db_do ($dbh, 'DELETE FROM tagente_datos_inc WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM tagente_modulo)');