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

Function waitBackup

fdbclient/DatabaseBackupAgent.actor.cpp:2417–2495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2415}
2416
2417class DatabaseBackupAgentImpl {
2418public:
2419 static constexpr int MAX_RESTORABLE_FILE_METASECTION_BYTES = 1024 * 8;
2420
2421 ACTOR static Future<Void> waitUpgradeToLatestDrVersion(DatabaseBackupAgent* backupAgent, Database cx, Key tagName) {
2422 state UID logUid = wait(backupAgent->getLogUid(cx, tagName));
2423 state Key drVersionKey = backupAgent->config.get(BinaryWriter::toValue(logUid, Unversioned()))
2424 .pack(DatabaseBackupAgent::keyDrVersion);
2425
2426 TraceEvent("DRU_WatchLatestDrVersion")
2427 .detail("DrVersionKey", drVersionKey.printable())
2428 .detail("LogUid", BinaryWriter::toValue(logUid, Unversioned()).printable());
2429
2430 loop {
2431 state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
2432
2433 loop {
2434 try {
2435 tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
2436 tr->setOption(FDBTransactionOptions::LOCK_AWARE);
2437 Optional<Value> drVersion = wait(tr->get(drVersionKey));
2438
2439 TraceEvent("DRU_VersionCheck")
2440 .detail("Current",
2441 drVersion.present() ? BinaryReader::fromStringRef<int>(drVersion.get(), Unversioned())
2442 : -1)
2443 .detail("Expected", DatabaseBackupAgent::LATEST_DR_VERSION)
2444 .detail("LogUid", BinaryWriter::toValue(logUid, Unversioned()).printable());
2445 if (drVersion.present() && BinaryReader::fromStringRef<int>(drVersion.get(), Unversioned()) ==
2446 DatabaseBackupAgent::LATEST_DR_VERSION) {
2447 return Void();
2448 }
2449
2450 state Future<Void> watchDrVersionFuture = tr->watch(drVersionKey);
2451 wait(tr->commit());
2452 wait(watchDrVersionFuture);
2453 break;
2454 } catch (Error& e) {
2455 wait(tr->onError(e));
2456 }
2457 }
2458 }
2459 }
2460
2461 // This method will return the final status of the backup
2462 ACTOR static Future<EBackupState> waitBackup(DatabaseBackupAgent* backupAgent,
2463 Database cx,
2464 Key tagName,
2465 StopWhenDone stopWhenDone) {
2466 state std::string backTrace;
2467 state UID logUid = wait(backupAgent->getLogUid(cx, tagName));
2468 state Key statusKey = backupAgent->states.get(BinaryWriter::toValue(logUid, Unversioned()))
2469 .pack(DatabaseBackupAgent::keyStateStatus);
2470
2471 loop {
2472 state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
2473 tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
2474 tr->setOption(FDBTransactionOptions::LOCK_AWARE);

Callers 4

mainFunction · 0.85
waitBackupMethod · 0.85
waitBackupMethod · 0.85

Calls 9

UnversionedFunction · 0.85
getMethod · 0.65
setOptionMethod · 0.65
watchMethod · 0.65
commitMethod · 0.65
onErrorMethod · 0.65
getLogUidMethod · 0.45
packMethod · 0.45
getStateValueMethod · 0.45

Tested by

no test coverage detected