Repository: qpid-cpp Updated Branches: refs/heads/master 3475d7e3b -> 57e8b4a6b
QPID-7357: c++ HA Backup crash during re-connect in failover The problem: A backup creates an UpdateTracker to delete non-existent queues at the end of an update, in the UpdateTracker destructor. However if an update is interrupted, it can leave a partially-used UpdateTracker behind. When the next update starts this can incorrectly delete queues at a sensitive moment and cause a crash, or could cause queues to be removed incorrectly. The fix is to move queue deletion out of the destructor so it is only run at the end of a successful update. Project: http://git-wip-us.apache.org/repos/asf/qpid-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-cpp/commit/57e8b4a6 Tree: http://git-wip-us.apache.org/repos/asf/qpid-cpp/tree/57e8b4a6 Diff: http://git-wip-us.apache.org/repos/asf/qpid-cpp/diff/57e8b4a6 Branch: refs/heads/master Commit: 57e8b4a6bb2da5701804d988b875f335f64c64a5 Parents: 3475d7e Author: Alan Conway <[email protected]> Authored: Thu Jul 14 20:10:44 2016 -0400 Committer: Alan Conway <[email protected]> Committed: Mon Jul 18 12:59:58 2016 -0400 ---------------------------------------------------------------------- src/qpid/ha/BrokerReplicator.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-cpp/blob/57e8b4a6/src/qpid/ha/BrokerReplicator.cpp ---------------------------------------------------------------------- diff --git a/src/qpid/ha/BrokerReplicator.cpp b/src/qpid/ha/BrokerReplicator.cpp index d664f13..2863c0f 100644 --- a/src/qpid/ha/BrokerReplicator.cpp +++ b/src/qpid/ha/BrokerReplicator.cpp @@ -214,16 +214,10 @@ class BrokerReplicator::UpdateTracker { const LogPrefix& lp) : type(type_), cleanFn(f), logPrefix(lp) {} - /** Destructor cleans up remaining initial queues. */ - ~UpdateTracker() { - // Don't throw in a destructor. - try { - for_each(initial.begin(), initial.end(), - boost::bind(&UpdateTracker::clean, this, _1)); - } - catch (const std::exception& e) { - QPID_LOG(error, logPrefix << "Error in cleanup of lost objects: " << e.what()); - } + /** Clean up remaining initial queues. */ + void done() { + for_each(initial.begin(), initial.end(), + boost::bind(&UpdateTracker::clean, this, _1)); } /** Add an exchange name */ @@ -471,16 +465,17 @@ void BrokerReplicator::route(Deliverable& msg) { } if (MessageTransfer::isLastQMFResponse(msg.getMessage(), EXCHANGE)) { QPID_LOG(debug, logPrefix << "All exchange responses received.") - exchangeTracker.reset(); // Clean up exchanges that no longer exist in the primary + exchangeTracker->done(); // Clean up exchanges that no longer exist in the primary + exchangeTracker.reset(); alternates.clear(); } if (MessageTransfer::isLastQMFResponse(msg.getMessage(), QUEUE)) { QPID_LOG(debug, logPrefix << "All queue responses received."); - queueTracker.reset(); // Clean up queues that no longer exist in the primary + queueTracker->done(); // Clean up queues that no longer exist in the primary + queueTracker.reset(); } } } catch (const std::exception& e) { -; haBroker.shutdown( QPID_MSG(logPrefix << "Configuration replication failed: " << e.what() << ": while handling: " << list)); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
