From 1731c3ba99577fa515985609a675afd89e5c91e4 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 29 Oct 2013 15:23:49 +0000 Subject: QPID-5139: HA transactions block a thread, can deadlock the broker PrimaryTxObserver::prepare used to block pending responses from each backup. With concurrent transactions this can deadlock the broker: once all worker threads are blocked in prepare, responses from backups cannot be received. This commit generalizes the async completion mechanism for messages to allow async completion of arbitrary commands. It leaves the special-case code for messages undisturbed but adds a second path (starting from SessionState::handleCommand) for async completion of other commands. In particular it implements tx.commit to allow async completion. TxBuffer is now an AsyncCompletion and commitLocal() is split into - startCommit() called by SemanticState::commit() - endCommit() called when the commit command completes TxAccept no longer holds pre-computed ranges, compute fresh each time. - Avoid range iterators going out of date during a delayed commit. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1536754 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/TxBufferTest.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/TxBufferTest.cpp') diff --git a/qpid/cpp/src/tests/TxBufferTest.cpp b/qpid/cpp/src/tests/TxBufferTest.cpp index 4807026ab7..3f052d213e 100644 --- a/qpid/cpp/src/tests/TxBufferTest.cpp +++ b/qpid/cpp/src/tests/TxBufferTest.cpp @@ -20,6 +20,7 @@ */ #include "qpid/broker/TxBuffer.h" #include "unit_test.h" +#include "test_tools.h" #include #include #include "TxMocks.h" @@ -50,7 +51,8 @@ QPID_AUTO_TEST_CASE(testCommitLocal) buffer.enlist(static_pointer_cast(opB));//opB enlisted twice buffer.enlist(static_pointer_cast(opC)); - BOOST_CHECK(buffer.commitLocal(&store)); + buffer.startCommit(&store); + buffer.endCommit(&store); store.check(); BOOST_CHECK(store.isCommitted()); opA->check(); @@ -75,7 +77,12 @@ QPID_AUTO_TEST_CASE(testFailOnCommitLocal) buffer.enlist(static_pointer_cast(opB)); buffer.enlist(static_pointer_cast(opC)); - BOOST_CHECK(!buffer.commitLocal(&store)); + try { + ScopedSuppressLogging sl; // Suppress messages for expected error. + buffer.startCommit(&store); + buffer.endCommit(&store); + BOOST_FAIL("Expected exception"); + } catch (...) {} BOOST_CHECK(store.isAborted()); store.check(); opA->check(); -- cgit v1.2.1