From 25c5e4686a3a54c74a00417809020bfa43d77874 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 19 Sep 2013 13:06:08 -0400 Subject: [PATCH] defect 3150, check for errors from DB. We can do itgit diff tabutils.pm --- xCAT-server/lib/xcat/plugins/tabutils.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 39e05ef45..bc3c32c55 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -532,7 +532,7 @@ sub tabrestore next LINE; } - #TODO: check for error from DB and rollback + #check for error from DB and rollback my @rc = $tab->setAttribs(\%record, \%record); if (not defined($rc[0])) { @@ -2340,11 +2340,27 @@ else { } #commit all the changes + my $rollback; foreach (keys %tables) { if (exists($tableupdates{$_})) { - $tables{$_}->setAttribs(\%keyhash,\%{$tableupdates{$_}}); + my @rc=$tables{$_}->setAttribs(\%keyhash,\%{$tableupdates{$_}}); + if (not defined($rc[0])) + { + $rollback = 1; + $callback->({error => "DB error " . $rc[1] , errorcode=>[4]}); + } + } + if ($rollback) + { + $tables{$_}->rollback(); + $tables{$_}->close; + undef $tables{$_}; + return; + } + else + { + $tables{$_}->commit; } - $tables{$_}->commit; } } }