Enhance DB recovery to survive a failed recovery attempt

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11018 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2011-11-15 15:51:21 +00:00
parent 670d5cb754
commit 4fdc6b5850

View File

@ -274,6 +274,14 @@ sub handle_dbc_request {
}
my $oldhandle = $::XCAT_DBHS->{$dbindex}; #store old handle off
$::XCAT_DBHS->{$dbindex} = $::XCAT_DBHS->{$dbindex}->clone(); #replace broken db handle with nice, new, working one
unless ($::XCAT_DBHS->{$dbindex}) { #this means the clone failed
#most likely result is the DB is down
#restore the old broken handle
#so that future recovery attempts have a shot
#a broken db handle we can recover, no db handle we cannot
$::XCAT_DBHS->{$dbindex} = $oldhandle;
return undef;
}
$dbobjsforhandle->{$::XCAT_DBHS->{$dbindex}} = $dbobjsforhandle->{$oldhandle}; #Move the map of depenednt objects to the new handle
foreach (@afflictedobjs) { #migrate afflicted objects to the new DB handle
$$_->{dbh} = $::XCAT_DBHS->{$dbindex};