Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mqbblp::RecoveryManager: Clear sync peer promptly #589

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_clusterorchestrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ void ClusterOrchestrator::processPrimaryStatusAdvisory(
// TBD: may need to review the order of invoking these routines.

BALL_LOG_INFO << d_clusterData_p->identity().description()
<< " PartitionId [" << primaryAdv.partitionId()
<< " Partition [" << primaryAdv.partitionId()
<< "]: received primary status advisory: " << primaryAdv
<< ", from: " << source->nodeDescription();

Expand Down
15 changes: 15 additions & 0 deletions src/groups/mqb/mqbblp/mqbblp_recoverymanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,15 @@ void RecoveryManager::onPartitionPrimarySyncStatus(int partitionId, int status)
PrimarySyncContext& primarySyncCtx = d_primarySyncContexts[partitionId];
BSLS_ASSERT_SAFE(primarySyncCtx.primarySyncInProgress());

BALL_LOG_INFO << d_clusterData_p->identity().description()
<< "For Partition [" << partitionId
<< "], primary sync returned with status: " << status
<< ". Resetting primary sync peer from "
<< (primarySyncCtx.syncPeer()
? primarySyncCtx.syncPeer()->nodeDescription()
: "** null **")
<< " to ** null **.";

d_clusterData_p->scheduler().cancelEventAndWait(
&primarySyncCtx.primarySyncStatusEventHandle());

Expand All @@ -1427,6 +1436,12 @@ void RecoveryManager::onPartitionPrimarySyncStatus(int partitionId, int status)
// still mapped. It will be cleaned up when the chunk deleter
// eventually invokes 'partitionSyncCleanupDispatched' routine.

// However, we have already received all sync data chunks from the sync
// peer, so we can reset our sync peer to *null*. This prevents false
// alarm of primary sync failure if that peer happens to go down before
// 'partitionSyncCleanupDispatched' is invoked.
primarySyncCtx.setPrimarySyncPeer(0);

return; // RETURN
}

Expand Down
6 changes: 4 additions & 2 deletions src/groups/mqb/mqbblp/mqbblp_storagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,13 +796,15 @@ void StorageManager::processPartitionSyncEventDispatched(
return; // RETURN
}

if (source != d_recoveryManager_mp->primarySyncPeer(partitionId)) {
mqbnet::ClusterNode* syncPeer = d_recoveryManager_mp->primarySyncPeer(
partitionId);
if (source != syncPeer) {
BALL_LOG_ERROR << d_clusterData_p->identity().description()
<< " Partition [" << partitionId
<< "]: received a partition sync event from: "
<< source->nodeDescription()
<< ", while partition-sync peer is: "
<< source->nodeDescription();
<< syncPeer->nodeDescription();
return; // RETURN
}

Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbs/mqbs_filebackedstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ FileBackedStorage::releaseRef(const bmqt::MessageGUID& guid)

if (0 != rc) {
BMQTSK_ALARMLOG_ALARM("FILE_IO")
<< "PartitionId [" << partitionId() << "] failed to write "
<< "Partition [" << partitionId() << "] failed to write "
<< "DELETION record for GUID: " << guid << ", for queue '"
<< d_queueUri << "', queueKey '" << d_queueKey
<< "' while attempting to purge the message, rc: " << rc
Expand Down
4 changes: 2 additions & 2 deletions src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ VirtualStorageCatalog::removeAll(const mqbu::StorageKey& appKey)
else {
if (result == mqbi::StorageResult::e_GUID_NOT_FOUND) {
BALL_LOG_WARN
<< "#STORAGE_PURGE_ERROR " << "PartitionId ["
<< "#STORAGE_PURGE_ERROR " << "Partition ["
<< d_storage_p->partitionId() << "]"
<< ": Attempting to purge GUID '" << itData->first
<< "' from virtual storage with appId '"
Expand All @@ -359,7 +359,7 @@ VirtualStorageCatalog::removeAll(const mqbu::StorageKey& appKey)
}
else {
BMQTSK_ALARMLOG_ALARM("STORAGE_PURGE_ERROR")
<< "PartitionId [" << d_storage_p->partitionId() << "]"
<< "Partition [" << d_storage_p->partitionId() << "]"
<< ": Attempting to purge GUID '" << itData->first
<< "' from virtual storage with appId '"
<< itVs->value()->appId() << "' & appKey '" << appKey
Expand Down
Loading