MCPcopy Create free account
hub / github.com/apple/foundationdb / checkAtomicSwitchOverConfig

Function checkAtomicSwitchOverConfig

fdbclient/DatabaseBackupAgent.actor.cpp:2377–2415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2375}
2376
2377void checkAtomicSwitchOverConfig(StatusObjectReader srcStatus, StatusObjectReader destStatus, Key tagName) {
2378
2379 try {
2380 // Check if src is unlocked and dest is locked
2381 if (getLockedStatus(srcStatus) != false) {
2382 TraceEvent(SevWarn, "DBA_AtomicSwitchOverSrcLocked").log();
2383 throw backup_error();
2384 }
2385 if (getLockedStatus(destStatus) != true) {
2386 TraceEvent(SevWarn, "DBA_AtomicSwitchOverDestUnlocked").log();
2387 throw backup_error();
2388 }
2389 // Check if mutation-stream-id matches
2390 if (getDRMutationStreamId(srcStatus, "dr_backup", tagName) !=
2391 getDRMutationStreamId(destStatus, "dr_backup_dest", tagName)) {
2392 TraceEvent(SevWarn, "DBA_AtomicSwitchOverMutationIdMismatch")
2393 .detail("SourceMutationId", getDRMutationStreamId(srcStatus, "dr_backup", tagName))
2394 .detail("DestMutationId", getDRMutationStreamId(destStatus, "dr_back_dest", tagName));
2395 throw backup_error();
2396 }
2397 // Check if there are agents set up with src as its destination cluster and dest as its source cluster
2398 auto srcDRAgents = getDRAgentsIds(srcStatus, "dr_backup_dest");
2399 auto destDRAgents = getDRAgentsIds(destStatus, "dr_backup");
2400 std::set<std::string> intersectingAgents;
2401 std::set_intersection(srcDRAgents.begin(),
2402 srcDRAgents.end(),
2403 destDRAgents.begin(),
2404 destDRAgents.end(),
2405 std::inserter(intersectingAgents, intersectingAgents.begin()));
2406 if (intersectingAgents.empty()) {
2407 TraceEvent(SevWarn, "DBA_SwitchOverPossibleDRAgentsIncorrectSetup").log();
2408 throw backup_error();
2409 }
2410 } catch (std::runtime_error& e) {
2411 TraceEvent(SevWarn, "DBA_UnableToCheckAtomicSwitchOverConfig").detail("RunTimeError", e.what());
2412 throw backup_error();
2413 }
2414 return;
2415}
2416
2417class DatabaseBackupAgentImpl {
2418public:

Callers 1

Calls 10

getLockedStatusFunction · 0.85
TraceEventClass · 0.85
getDRMutationStreamIdFunction · 0.85
getDRAgentsIdsFunction · 0.85
detailMethod · 0.80
logMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected