From 381235ddb35f18b598f2a5e58f13fb5c16317323 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 3 Sep 2010 10:58:57 +0000 Subject: [PATCH] 2010-09-03 Sergio Martin * util/pandora_db.pl: Added a delete buffer to the delete of the pending_delete modules git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3217 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 ++++ pandora_server/util/pandora_db.pl | 45 ++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 437d1365a9..1857342c0b 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2010-09-03 Sergio Martin + + * util/pandora_db.pl: Added a delete buffer to the delete of + the pending_delete modules + 2010-08-29 Raúl Mateos * util/tentacle_serverd: Use same message texts format as Pandora Server. diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 8599b16dec..34c322cca5 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -191,12 +191,45 @@ sub pandora_purgedb ($$) { my @deleted_modules = get_db_rows ($dbh, 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1'); foreach my $module (@deleted_modules) { - print " Deleting data for module " . $module->{'id_agente_modulo'} . "\n"; - db_do ($dbh, "DELETE FROM tagente_datos WHERE id_agente_modulo = ?", $module->{'id_agente_modulo'}); - db_do ($dbh, "DELETE FROM tagente_datos_log4x WHERE id_agente_modulo = ?", $module->{'id_agente_modulo'}); - db_do ($dbh, "DELETE FROM tagente_datos_string WHERE id_agente_modulo = ?", $module->{'id_agente_modulo'}); - db_do ($dbh, "DELETE FROM tagente_datos_inc WHERE id_agente_modulo = ?", $module->{'id_agente_modulo'}); - db_do ($dbh, "DELETE FROM tagente_estado WHERE id_agente_modulo = ?", $module->{'id_agente_modulo'}); + + my $buffer = 1000; + my $id_module = $module->{'id_agente_modulo'}; + + print " Deleting data for module " . $id_module . "\n"; + + while(1) { + my $nd = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_datos_string WHERE id_agente_modulo=?', $id_module); + my $ndinc = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_datos_string WHERE id_agente_modulo=?', $id_module); + my $ndlog4x = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_datos_string WHERE id_agente_modulo=?', $id_module); + my $ndstring = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_datos_string WHERE id_agente_modulo=?', $id_module); + my $nstate = get_db_value ($dbh, 'SELECT count(id_agente_modulo) FROM tagente_estado WHERE id_agente_modulo=?', $id_module); + + my $ntot = $nd + $ndinc + $ndlog4x + $ndstring + $nstate; + + if($ntot == 0) { + last; + } + + if($nd > 0) { + db_do ($dbh, 'DELETE FROM tagente_datos WHERE id_agente_modulo=? LIMIT ?', $id_module, $buffer); + } + + if($ndinc > 0) { + db_do ($dbh, 'DELETE FROM tagente_datos_inc WHERE id_agente_modulo=? LIMIT ?', $id_module, $buffer); + } + + if($ndlog4x > 0) { + db_do ($dbh, 'DELETE FROM tagente_datos_log4x WHERE id_agente_modulo=? LIMIT ?', $id_module, $buffer); + } + + if($ndstring > 0) { + db_do ($dbh, 'DELETE FROM tagente_datos_string WHERE id_agente_modulo=? LIMIT ?', $id_module, $buffer); + } + + if($nstate > 0) { + db_do ($dbh, 'DELETE FROM tagente_estado WHERE id_agente_modulo=? LIMIT ?', $id_module, $buffer); + } + } } print "[PURGE] Delete pending deleted modules (status, module table)...\n";