Skip to content

Commit feea9a5

Browse files
authored
Cleanup Partition FSM: Trimming unnecessary logic (#905)
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
1 parent 493cdc1 commit feea9a5

File tree

4 files changed

+46
-39
lines changed

4 files changed

+46
-39
lines changed

src/groups/mqb/mqbc/mqbc_partitionstatetable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ PartitionStateTableEvent::toAscii(PartitionStateTableEvent::Enum value)
125125
CASE(RECOVERY_DATA)
126126
CASE(LIVE_DATA)
127127
CASE(QUORUM_REPLICA_DATA_RSPN)
128-
CASE(PUT)
129128
CASE(ISSUE_LIVESTREAM)
130129
CASE(QUORUM_REPLICA_SEQ)
131130
CASE(SELF_HIGHEST_SEQ)

src/groups/mqb/mqbc/mqbc_partitionstatetable.h

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,12 @@ struct PartitionStateTableEvent {
130130
e_RECOVERY_DATA = 23,
131131
e_LIVE_DATA = 24,
132132
e_QUORUM_REPLICA_DATA_RSPN = 25,
133-
e_PUT = 26,
134-
e_ISSUE_LIVESTREAM = 27,
135-
e_QUORUM_REPLICA_SEQ = 28,
136-
e_SELF_HIGHEST_SEQ = 29,
137-
e_REPLICA_HIGHEST_SEQ = 30,
138-
e_WATCH_DOG = 31,
139-
e_NUM_EVENTS = 32
133+
e_ISSUE_LIVESTREAM = 26,
134+
e_QUORUM_REPLICA_SEQ = 27,
135+
e_SELF_HIGHEST_SEQ = 28,
136+
e_REPLICA_HIGHEST_SEQ = 29,
137+
e_WATCH_DOG = 30,
138+
e_NUM_EVENTS = 31
140139
};
141140

142141
// CLASS METHODS
@@ -253,10 +252,6 @@ class PartitionStateTableActions {
253252

254253
virtual void do_processLiveData(const ARGS& args) = 0;
255254

256-
virtual void do_processPut(const ARGS& args) = 0;
257-
258-
virtual void do_nackPut(const ARGS& args) = 0;
259-
260255
virtual void do_cleanupMetadata(const ARGS& args) = 0;
261256

262257
virtual void do_startSendDataChunks(const ARGS& args) = 0;
@@ -289,6 +284,8 @@ class PartitionStateTableActions {
289284

290285
virtual void do_reapplyDetectSelfReplica(const ARGS& args) = 0;
291286

287+
virtual void do_unsupportedPrimaryDowngrade(const ARGS& args) = 0;
288+
292289
void
293290
do_startWatchDog_storePartitionInfo_openRecoveryFileSet_storeSelfSeq_replicaStateRequest_checkQuorumSeq(
294291
const ARGS& args);
@@ -336,8 +333,7 @@ class PartitionStateTableActions {
336333
do_resetReceiveDataCtx_closeRecoveryFileSet_storeSelfSeq_attemptOpenStorage_replicaDataRequestPush_replicaDataRequestDrop_startSendDataChunks_incrementNumRplcaDataRspn_checkQuorumRplcaDataRspn(
337334
const ARGS& args);
338335

339-
void
340-
do_processPut_stopWatchDog_transitionToActivePrimary(const ARGS& args);
336+
void do_stopWatchDog_transitionToActivePrimary(const ARGS& args);
341337

342338
void do_replicaStateResponse_storePrimarySeq(const ARGS& args);
343339

@@ -434,7 +430,6 @@ class PartitionStateTable
434430
DETECT_SELF_REPLICA,
435431
startWatchDog_storePartitionInfo_openRecoveryFileSet_storeSelfSeq_primaryStateRequest,
436432
REPLICA_HEALING);
437-
PST_CFG(UNKNOWN, PUT, nackPut, UNKNOWN);
438433
PST_CFG(PRIMARY_HEALING_STG1,
439434
DETECT_SELF_REPLICA,
440435
cleanupMetadata_clearPartitionInfo_stopWatchDog_reapplyEvent,
@@ -455,7 +450,6 @@ class PartitionStateTable
455450
PRIMARY_STATE_RQST,
456451
storeReplicaSeq_primaryStateResponse_checkQuorumSeq,
457452
PRIMARY_HEALING_STG1);
458-
PST_CFG(PRIMARY_HEALING_STG1, PUT, nackPut, PRIMARY_HEALING_STG1);
459453
PST_CFG(PRIMARY_HEALING_STG1,
460454
QUORUM_REPLICA_SEQ,
461455
findHighestSeq,
@@ -520,9 +514,8 @@ class PartitionStateTable
520514
PRIMARY_HEALING_STG2);
521515
PST_CFG(PRIMARY_HEALING_STG2,
522516
QUORUM_REPLICA_DATA_RSPN,
523-
processPut_stopWatchDog_transitionToActivePrimary,
517+
stopWatchDog_transitionToActivePrimary,
524518
PRIMARY_HEALED);
525-
PST_CFG(PRIMARY_HEALING_STG2, PUT, nackPut, PRIMARY_HEALING_STG2);
526519
PST_CFG(
527520
PRIMARY_HEALING_STG2,
528521
RST_UNKNOWN,
@@ -593,7 +586,6 @@ class PartitionStateTable
593586
failureReplicaDataResponsePush_cleanupMetadata_closeRecoveryFileSet_stopWatchDog_reapplyDetectSelfReplica,
594587
UNKNOWN);
595588
PST_CFG(REPLICA_HEALING, LIVE_DATA, bufferLiveData, REPLICA_HEALING);
596-
PST_CFG(REPLICA_HEALING, PUT, nackPut, REPLICA_HEALING);
597589
PST_CFG(
598590
REPLICA_HEALING,
599591
RST_UNKNOWN,
@@ -620,7 +612,6 @@ class PartitionStateTable
620612
replicaDataResponsePush,
621613
REPLICA_HEALED);
622614
PST_CFG(REPLICA_HEALED, LIVE_DATA, processLiveData, REPLICA_HEALED);
623-
PST_CFG(REPLICA_HEALED, PUT, processPut, REPLICA_HEALED);
624615
PST_CFG(REPLICA_HEALED,
625616
ISSUE_LIVESTREAM,
626617
cleanupMetadata_reapplyDetectSelfReplica,
@@ -631,7 +622,7 @@ class PartitionStateTable
631622
UNKNOWN);
632623
PST_CFG(PRIMARY_HEALED,
633624
DETECT_SELF_REPLICA,
634-
cleanupMetadata_clearPartitionInfo_reapplyEvent,
625+
unsupportedPrimaryDowngrade,
635626
UNKNOWN);
636627
PST_CFG(
637628
PRIMARY_HEALED,
@@ -643,7 +634,6 @@ class PartitionStateTable
643634
PRIMARY_STATE_RQST,
644635
storeSelfSeq_storeReplicaSeq_primaryStateResponse_replicaDataRequestPush_replicaDataRequestDrop_startSendDataChunks,
645636
PRIMARY_HEALED);
646-
PST_CFG(PRIMARY_HEALED, PUT, processPut, PRIMARY_HEALED);
647637
PST_CFG(PRIMARY_HEALED,
648638
RST_UNKNOWN,
649639
cleanupMetadata_clearPartitionInfo,
@@ -846,10 +836,9 @@ void PartitionStateTableActions<ARGS>::
846836
}
847837

848838
template <typename ARGS>
849-
void PartitionStateTableActions<ARGS>::
850-
do_processPut_stopWatchDog_transitionToActivePrimary(const ARGS& args)
839+
void PartitionStateTableActions<
840+
ARGS>::do_stopWatchDog_transitionToActivePrimary(const ARGS& args)
851841
{
852-
do_processPut(args);
853842
do_stopWatchDog(args);
854843
do_transitionToActivePrimary(args);
855844
}

src/groups/mqb/mqbc/mqbc_storagemanager.cpp

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// limitations under the License.
1515

1616
// mqbc_storagemanager.cpp -*-C++-*-
17+
#include "mqbc_partitionstatetable.h"
1718
#include <ball_log.h>
1819
#include <bsls_assert.h>
1920
#include <mqbc_storagemanager.h>
@@ -2626,16 +2627,6 @@ void StorageManager::do_processLiveData(const PartitionFSMArgsSp& args)
26262627
source);
26272628
}
26282629

2629-
void StorageManager::do_processPut(const BSLA_UNUSED PartitionFSMArgsSp& args)
2630-
{
2631-
// TODO: Complete Impl
2632-
}
2633-
2634-
void StorageManager::do_nackPut(const BSLA_UNUSED PartitionFSMArgsSp& args)
2635-
{
2636-
// TODO: Complete Impl
2637-
}
2638-
26392630
void StorageManager::do_cleanupMetadata(const PartitionFSMArgsSp& args)
26402631
{
26412632
// executed by the *QUEUE DISPATCHER* thread associated with the paritionId
@@ -3410,6 +3401,35 @@ void StorageManager::do_reapplyDetectSelfReplica(
34103401
eventDataVecOut);
34113402
}
34123403

3404+
void StorageManager::do_unsupportedPrimaryDowngrade(
3405+
const PartitionFSMArgsSp& args)
3406+
{
3407+
// executed by the *QUEUE DISPATCHER* thread associated with the
3408+
// paritionId contained in 'args'
3409+
3410+
// PRECONDITIONS
3411+
BSLS_ASSERT_SAFE(!args->eventsQueue()->empty());
3412+
3413+
const PartitionFSM::EventWithData& eventWithData =
3414+
args->eventsQueue()->front();
3415+
const EventData& eventDataVec = eventWithData.second;
3416+
BSLS_ASSERT_SAFE(eventDataVec.size() == 1);
3417+
const int partitionId = eventDataVec[0].partitionId();
3418+
BSLS_ASSERT_SAFE(0 <= partitionId &&
3419+
partitionId < static_cast<int>(d_fileStores.size()));
3420+
3421+
BSLS_ASSERT_SAFE(d_partitionFSMVec[partitionId]->isSelfPrimary());
3422+
BSLS_ASSERT_SAFE(eventWithData.first ==
3423+
PartitionFSM::Event::e_DETECT_SELF_REPLICA);
3424+
3425+
BMQTSK_ALARMLOG_ALARM("CLUSTER")
3426+
<< d_clusterData_p->identity().description() << " Partition ["
3427+
<< partitionId << "]: "
3428+
<< "Downgrade from primary to replica is **UNSUPPORTED**. Terminating "
3429+
<< "broker." << BMQTSK_ALARMLOG_END;
3430+
mqbu::ExitUtil::terminate(mqbu::ExitCode::e_UNSUPPORTED_SCENARIO); // EXIT
3431+
}
3432+
34133433
// PRIVATE ACCESSORS
34143434
bool StorageManager::allPartitionsAvailable() const
34153435
{

src/groups/mqb/mqbc/mqbc_storagemanager.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,6 @@ class StorageManager BSLS_KEYWORD_FINAL
637637
void
638638
do_processLiveData(const PartitionFSMArgsSp& args) BSLS_KEYWORD_OVERRIDE;
639639

640-
void do_processPut(const PartitionFSMArgsSp& args) BSLS_KEYWORD_OVERRIDE;
641-
642-
void do_nackPut(const PartitionFSMArgsSp& args) BSLS_KEYWORD_OVERRIDE;
643-
644640
void
645641
do_cleanupMetadata(const PartitionFSMArgsSp& args) BSLS_KEYWORD_OVERRIDE;
646642

@@ -688,6 +684,9 @@ class StorageManager BSLS_KEYWORD_FINAL
688684
void do_reapplyDetectSelfReplica(const PartitionFSMArgsSp& args)
689685
BSLS_KEYWORD_OVERRIDE;
690686

687+
void do_unsupportedPrimaryDowngrade(const PartitionFSMArgsSp& args)
688+
BSLS_KEYWORD_OVERRIDE;
689+
691690
// PRIVATE ACCESSORS
692691

693692
/// Return true if all partitions are fully healed and have an active

0 commit comments

Comments
 (0)