From 38000643066ef75bf0ab10e42989a25fa2ccbccd Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 10 Dec 2013 14:11:36 +0000 Subject: QPID-5404: HA broker message duplication when deleting a queue with an alt-exchange The old code ran auto-delete on the backup on disconnect. This reroutes messages onto the alt queue with incorrect replication IDs from the original queue, and then replicates duplicate rerouted messages from the primary. The solution is to process auto deletes on the new primary and let them replicate to the backups. - Move all auto-delete logic into QueueReplicator - Primary process auto-delete on QueueReplicator as part of promotion. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1549844 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/ha/BrokerReplicator.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'cpp/src/qpid/ha/BrokerReplicator.cpp') diff --git a/cpp/src/qpid/ha/BrokerReplicator.cpp b/cpp/src/qpid/ha/BrokerReplicator.cpp index 5e8da17a1b..1587b5b33f 100644 --- a/cpp/src/qpid/ha/BrokerReplicator.cpp +++ b/cpp/src/qpid/ha/BrokerReplicator.cpp @@ -865,27 +865,14 @@ bool BrokerReplicator::hasBindings() { return false; } string BrokerReplicator::getType() const { return QPID_CONFIGURATION_REPLICATOR; } -void BrokerReplicator::disconnectedExchange(boost::shared_ptr ex) { +void BrokerReplicator::disconnectedQueueReplicator(boost::shared_ptr ex) { boost::shared_ptr qr(boost::dynamic_pointer_cast(ex)); - // FIXME aconway 2013-11-01: move logic with releaseFromUse to QueueReplicator if (qr) { qr->disconnect(); if (TxReplicator::isTxQueue(qr->getQueue()->getName())) { // Transactions are aborted on failover so clean up tx-queues deleteQueue(qr->getQueue()->getName()); } - else if (qr->getQueue()->isAutoDelete() && qr->isSubscribed()) { - if (qr->getQueue()->getSettings().autoDeleteDelay) { - // Start the auto-delete timer - qr->getQueue()->releaseFromUse(); - qr->getQueue()->scheduleAutoDelete(); - } - else { - // Delete immediately. Don't purge, the primary is gone so we need - // to reroute the deleted messages. - deleteQueue(qr->getQueue()->getName(), false); - } - } } } @@ -893,9 +880,9 @@ typedef vector > ExchangeVector; // Callback function for accumulating exchange candidates namespace { - void exchangeAccumulatorCallback(ExchangeVector& ev, const Exchange::shared_ptr& i) { - ev.push_back(i); - } +void exchangeAccumulatorCallback(ExchangeVector& ev, const Exchange::shared_ptr& i) { + ev.push_back(i); +} } // Called by ConnectionObserver::disconnected, disconnected from the network side. @@ -907,7 +894,7 @@ void BrokerReplicator::disconnected() { ExchangeVector exs; exchanges.eachExchange(boost::bind(&exchangeAccumulatorCallback, boost::ref(exs), _1)); for_each(exs.begin(), exs.end(), - boost::bind(&BrokerReplicator::disconnectedExchange, this, _1)); + boost::bind(&BrokerReplicator::disconnectedQueueReplicator, this, _1)); } void BrokerReplicator::setMembership(const Variant::List& brokers) { -- cgit v1.2.1