Split a delete query to avoid deadlocks TICKETS #3446

This commit is contained in:
fermin831 2016-03-16 15:57:45 +01:00
parent 9d2b97dca0
commit b0ac5b78d8
1 changed files with 3 additions and 1 deletions

View File

@ -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)');