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

Class StartFullBackupTaskFunc

fdbclient/FileBackupAgent.actor.cpp:2707–2800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2705}
2706
2707struct StartFullBackupTaskFunc : BackupTaskFuncBase {
2708 static StringRef name;
2709 static constexpr uint32_t version = 1;
2710
2711 static struct {
2712 static TaskParam<Version> beginVersion() { return LiteralStringRef(__FUNCTION__); }
2713 } Params;
2714
2715 ACTOR static Future<Void> _execute(Database cx,
2716 Reference<TaskBucket> taskBucket,
2717 Reference<FutureBucket> futureBucket,
2718 Reference<Task> task) {
2719 wait(checkTaskVersion(cx, task, StartFullBackupTaskFunc::name, StartFullBackupTaskFunc::version));
2720
2721 state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
2722 state BackupConfig config(task);
2723 state Future<Optional<bool>> partitionedLog;
2724 loop {
2725 try {
2726 tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
2727 tr->setOption(FDBTransactionOptions::LOCK_AWARE);
2728 partitionedLog = config.partitionedLogEnabled().get(tr);
2729 state Future<Version> startVersionFuture = tr->getReadVersion();
2730 wait(success(partitionedLog) && success(startVersionFuture));
2731
2732 Params.beginVersion().set(task, startVersionFuture.get());
2733 break;
2734 } catch (Error& e) {
2735 wait(tr->onError(e));
2736 }
2737 }
2738
2739 // Check if backup worker is enabled
2740 DatabaseConfiguration dbConfig = wait(getDatabaseConfiguration(cx));
2741 state bool backupWorkerEnabled = dbConfig.backupWorkerEnabled;
2742 if (!backupWorkerEnabled && partitionedLog.get().present() && partitionedLog.get().get()) {
2743 // Change configuration only when we set to use partitioned logs and
2744 // the flag was not set before.
2745 wait(success(ManagementAPI::changeConfig(cx.getReference(), "backup_worker_enabled:=1", true)));
2746 backupWorkerEnabled = true;
2747 }
2748
2749 // Set the "backupStartedKey" and wait for all backup worker started
2750 tr->reset();
2751 loop {
2752 state Future<Void> watchFuture;
2753 try {
2754 tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
2755 tr->setOption(FDBTransactionOptions::LOCK_AWARE);
2756 state Future<Void> keepRunning = taskBucket->keepRunning(tr, task);
2757
2758 state Future<Optional<Value>> started = tr->get(backupStartedKey);
2759 state Future<Optional<Value>> taskStarted = tr->get(config.allWorkerStarted().key);
2760 partitionedLog = config.partitionedLogEnabled().get(tr);
2761 wait(success(started) && success(taskStarted) && success(partitionedLog));
2762
2763 if (!partitionedLog.get().present() || !partitionedLog.get().get()) {
2764 return Void(); // Skip if not using partitioned logs

Callers

nothing calls this directly

Calls 15

changeConfigFunction · 0.85
decodeBackupStartedValueFunction · 0.85
encodeBackupStartedValueFunction · 0.85
keepRunningMethod · 0.80
allWorkerStartedMethod · 0.80
partitionedLogEnabledMethod · 0.80
emplace_backMethod · 0.80
backupWorkerEnabledMethod · 0.80
setOptionMethod · 0.65
getMethod · 0.65
setMethod · 0.65
watchMethod · 0.65

Tested by

no test coverage detected