Fix[mqb]: revisiting open queue failures handling - #1175
Conversation
aea57d5 to
eca0625
Compare
| // Do retry if the state is k_OPEN && isQueuePrimaryAvailable | ||
| bool retryNow = subQueueContext.d_state == SubQueueContext::k_OPEN | ||
| ? isQueuePrimaryAvailable(*qcontext, otherThan) | ||
| : false; |
There was a problem hiding this comment.
| // Do retry if the state is k_OPEN && isQueuePrimaryAvailable | |
| bool retryNow = subQueueContext.d_state == SubQueueContext::k_OPEN | |
| ? isQueuePrimaryAvailable(*qcontext, otherThan) | |
| : false; | |
| bool retryNow = (subQueueContext.d_state == SubQueueContext::k_OPEN) | |
| && isQueuePrimaryAvailable(*qcontext, otherThan); |
Possible to replace ternary operator with operations mentioned in the comment.
This way, the code becomes self-explanatory, and the comment duplicating behaviour can be removed.
2baa5da to
e2eb738
Compare
e2eb738 to
92bb647
Compare
92bb647 to
b00775c
Compare
| for (ReopenCycles::const_iterator cit = d_reopenCycles.begin(); | ||
| cit != d_reopenCycles.end(); | ||
| ++cit) { | ||
| sum += cit->second.use_count(); |
There was a problem hiding this comment.
To be precise, use_count only shows the number of shared_ptr copies, not the number of pending requests. This might be misleading during debug.
For example, there might be 1 shared_ptr with 3 copies, numPendingReopenQueueRequests() == 3 which is not true. We might spend time investigating "where are these 3 reopen requests?", when in reality we only have 1.
Binary +1 or +0 makes more sense here:
| sum += cit->second.use_count(); | |
| sum += static_cast<int>(cit->second.use_count() > 0); |
or
| sum += cit->second.use_count(); | |
| sum += static_cast<int>(!cit->second.expired()); |
There was a problem hiding this comment.
Using cit->second.use_count() > 0) would return number of partitions being reopened.
The use_count can have the error margin of +1 - upon reopen response we may bind the cycle to reconfigure or retry callback before releasing. It is like having two requests for the same queue - one is completing and another is starting.
But. Since numPendingReopenQueueRequests() is executed in the cluster thread - where we process reopen responses - the "completing" count should be gone and the number should be precise.
| BSLS_ASSERT_SAFE(cycle); | ||
|
|
||
| if (cycle->isSuccess()) { | ||
| d_reopenCycles.erase(cycle->partitionId()); |
There was a problem hiding this comment.
I think that we should also check that the current d_reopenCycle[partitionId] has the same primary lease id as cycle before deleting.
What if we free the last PartitionReopenCycle from the previous primary at the time when we have a new primary and another partition cycle for the same partition id?
There was a problem hiding this comment.
This runs in the cluster thread only. We setAsFailure if generationCounts mismatch). Not sure about checking generationCount - 1) there is no shared_ptr anymore; 2) the actual ClusterStatePartitionInfo::primaryLeaseId() could change before we start new cycle.
There was a problem hiding this comment.
If it runs on cluster thread, let's add a comment
// Thread: CLUSTER dispatcher
And add a precondition
BSLS_ASSERT_SAFE(d_cluster_p->inDispatcherThread());
b00775c to
361c84e
Compare
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
Signed-off-by: dorjesinpo <129227380+dorjesinpo@users.noreply.github.com>
361c84e to
6bb2388
Compare
| cycle.reset(new (*d_allocator_p) | ||
| PartitionReopenCycle(this, generationCount, partitionId), | ||
| d_allocator_p); |
There was a problem hiding this comment.
| cycle.reset(new (*d_allocator_p) | |
| PartitionReopenCycle(this, generationCount, partitionId), | |
| d_allocator_p); | |
| cycle = bsl::allocate_shared<PartitionReopenCycle>(d_allocator_p, this, generationCount, partitionId); |
Upon open queue failure, either buffer the request or retry immediately, or respond