Skip to content

Commit ca78516

Browse files
authored
Fix[mqb]: to roll back, call release instead of drop (#1182)
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
1 parent 3525c06 commit ca78516

3 files changed

Lines changed: 42 additions & 22 deletions

File tree

src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ void ClusterQueueHelper::finishOpening(
224224
BSLS_ASSERT_SAFE(openQueueContext_sp);
225225
BSLS_ASSERT_SAFE(openQueueContext_sp->d_queueContext_p);
226226

227+
// First step in this routine is to update the cookie with the queue handle
228+
// if 'confirmationCookie' is valid. If this open-queue request has
229+
// succeeded, this object should eventually set 'confirmationCookie' to 0
230+
// (see 'onGetQueueHandleDispatched'). Note that this also applies to the
231+
// 'mqba::ClientSession' case ('onQueueOpenCb'). The rough equivalent
232+
// of a client session here is the cluster node session represented by
233+
// 'requester'.
234+
235+
if (confirmationCookie) {
236+
confirmationCookie->d_handle = queueHandle;
237+
}
238+
227239
const OpenQueueContext& openQueueContext = *openQueueContext_sp;
228240

229241
openQueueContext.d_callback(status,
@@ -1408,7 +1420,7 @@ void ClusterQueueHelper::onOpenQueueResponse(
14081420
}
14091421

14101422
// 'createQueue' always calls 'onGetQueueHandle' which calls
1411-
// 'finishOpenQueueRequest'.
1423+
// 'finishOpening'.
14121424
return; // RETURN
14131425
}
14141426

@@ -2097,14 +2109,18 @@ void ClusterQueueHelper::onOpenQueueConfirmationCookieReleased(
20972109
// in); but upstream was a success, so we need to rollback and issue a
20982110
// closeQueue.
20992111

2100-
BMQ_LOGTHROTTLE_WARN
2112+
BMQ_LOGTHROTTLE_ERROR
21012113
<< d_cluster_p->description()
21022114
<< ": OpenQueueConfirmationCookie released without "
21032115
<< "successful processing from the requester. Queue handle "
21042116
<< "ptr [" << handle << "], client ptr [" << handle->client()
21052117
<< "], handle parameters: " << handleParameters << ".";
2106-
handle->clearClient(false);
2107-
handle->drop();
2118+
2119+
// Roll back exactly 'handleParameters'.
2120+
// Cannot drop the handle as it can have other substreams.
2121+
handle->release(handleParameters,
2122+
false,
2123+
mqbi::QueueHandle::HandleReleasedCallback());
21082124
}
21092125

21102126
bool ClusterQueueHelper::createQueue(
@@ -2766,18 +2782,6 @@ void ClusterQueueHelper::onGetQueueHandle(
27662782

27672783
BSLS_ASSERT_SAFE(context);
27682784

2769-
// First step in this routine is to update the cookie with the queue handle
2770-
// if 'confirmationCookie' is valid. If this open-queue request has
2771-
// succeeded, this object should eventually set 'confirmationCookie' to 0
2772-
// (see 'onGetQueueHandleDispatched'). Note that this also applies to the
2773-
// 'mqba::ClientSession' case ('onQueueOpenCb'). The rough equivalent
2774-
// of a client session here is the cluster node session represented by
2775-
// 'requester'.
2776-
2777-
if (confirmationCookie) {
2778-
confirmationCookie->d_handle = queueHandle;
2779-
}
2780-
27812785
d_cluster_p->dispatcher()->execute(
27822786
bdlf::BindUtil::bindS(d_allocator_p,
27832787
&ClusterQueueHelper::finishOpening,

src/groups/mqb/mqbblp/mqbblp_queue.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,13 @@ void Queue::dropHandleDispatched(mqbi::QueueHandle* handle, bool doDeconfigure)
299299
isFinal = ((++citer) == handle->subStreamInfos().end());
300300
totalReadCount -= consumerHandleParams.readCount();
301301

302-
BALL_LOG_INFO << "For queue [" << handle->queue()->description()
303-
<< "] and handle [" << handle->client() << ":"
304-
<< handle->id() << "] " << "having [handleParamerers: "
305-
<< handle->handleParameters() << "], dropping subStream "
306-
<< "[" << subStreamInfo << "] having [streamParameters: "
307-
<< info.d_streamParameters << "].";
302+
BALL_LOG_INFO << "Dropping subStream for queue ["
303+
<< handle->queue()->description() << "] and handle ["
304+
<< handle->client() << ":" << handle->id()
305+
<< "] handleParamerers [" << handle->handleParameters()
306+
<< "], subStreamInfo [" << subStreamInfo
307+
<< "], streamParameters [" << info.d_streamParameters
308+
<< "].";
308309

309310
if (doDeconfigure) {
310311
bmqp_ctrlmsg::StreamParameters nullStreamParameters;

src/groups/mqb/mqbblp/mqbblp_queuesessionmanager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ void handleHolderDummy(BSLA_MAYBE_UNUSED const bsl::shared_ptr<void>& handle)
7777
// NOTHING
7878
}
7979

80+
void clearClient(mqbi::QueueHandle* queueHandle)
81+
{
82+
if (queueHandle) {
83+
queueHandle->clearClient(false);
84+
}
85+
}
86+
8087
} // close unnamed namespace
8188

8289
// -------------------------
@@ -230,6 +237,8 @@ void QueueSessionManager::onQueueOpenCb(
230237
{
231238
// executed by *ANY* thread
232239

240+
bdlb::ScopeExitAny cleaner(bdlf::BindUtil::bind(clearClient, queueHandle));
241+
233242
bmqu::AtomicValidatorGuard guard(validator.get());
234243
if (!guard.isValid()) {
235244
// The session was destroyed before we received the response (see
@@ -253,6 +262,8 @@ void QueueSessionManager::onQueueOpenCb(
253262
responseCallback,
254263
request),
255264
d_dispatcherClient_p);
265+
266+
cleaner.release();
256267
}
257268

258269
void QueueSessionManager::onQueueOpenCbDispatched(
@@ -269,6 +280,8 @@ void QueueSessionManager::onQueueOpenCbDispatched(
269280
BSLS_ASSERT_SAFE(d_dispatcherClient_p->inDispatcherThread());
270281
BSLS_ASSERT_SAFE(request.choice().isOpenQueueValue());
271282

283+
bdlb::ScopeExitAny cleaner(bdlf::BindUtil::bind(clearClient, queueHandle));
284+
272285
if (d_shutdownInProgress) {
273286
return; // RETURN
274287
}
@@ -330,6 +343,8 @@ void QueueSessionManager::onQueueOpenCbDispatched(
330343
cluster,
331344
queueFlags);
332345
}
346+
347+
cleaner.release();
333348
}
334349

335350
responseCallback(status, queueHandle, openQueueResponse);

0 commit comments

Comments
 (0)