| 4026 | } |
| 4027 | |
| 4028 | struct StartFullRestoreTaskFunc : RestoreTaskFuncBase { |
| 4029 | static StringRef name; |
| 4030 | static constexpr uint32_t version = 1; |
| 4031 | |
| 4032 | static struct { |
| 4033 | static TaskParam<Version> firstVersion() { return LiteralStringRef(__FUNCTION__); } |
| 4034 | } Params; |
| 4035 | |
| 4036 | // Find all files needed for the restore and save them in the RestoreConfig for the task. |
| 4037 | // Update the total number of files and blocks and change state to starting. |
| 4038 | ACTOR static Future<Void> _execute(Database cx, |
| 4039 | Reference<TaskBucket> taskBucket, |
| 4040 | Reference<FutureBucket> futureBucket, |
| 4041 | Reference<Task> task) { |
| 4042 | state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx)); |
| 4043 | state RestoreConfig restore(task); |
| 4044 | state Version restoreVersion; |
| 4045 | state Version beginVersion; |
| 4046 | state Reference<IBackupContainer> bc; |
| 4047 | state std::vector<KeyRange> ranges; |
| 4048 | state bool logsOnly; |
| 4049 | state bool inconsistentSnapshotOnly; |
| 4050 | |
| 4051 | loop { |
| 4052 | try { |
| 4053 | tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); |
| 4054 | tr->setOption(FDBTransactionOptions::LOCK_AWARE); |
| 4055 | |
| 4056 | wait(checkTaskVersion(tr->getDatabase(), task, name, version)); |
| 4057 | wait(store(beginVersion, restore.beginVersion().getD(tr, Snapshot::False, ::invalidVersion))); |
| 4058 | |
| 4059 | wait(store(restoreVersion, restore.restoreVersion().getOrThrow(tr))); |
| 4060 | wait(store(ranges, restore.getRestoreRangesOrDefault(tr))); |
| 4061 | wait(store(logsOnly, restore.onlyApplyMutationLogs().getD(tr, Snapshot::False, false))); |
| 4062 | wait(store(inconsistentSnapshotOnly, |
| 4063 | restore.inconsistentSnapshotOnly().getD(tr, Snapshot::False, false))); |
| 4064 | |
| 4065 | wait(taskBucket->keepRunning(tr, task)); |
| 4066 | |
| 4067 | ERestoreState oldState = wait(restore.stateEnum().getD(tr)); |
| 4068 | if (oldState != ERestoreState::QUEUED && oldState != ERestoreState::STARTING) { |
| 4069 | wait(restore.logError(cx, |
| 4070 | restore_error(), |
| 4071 | format("StartFullRestore: Encountered unexpected state(%d)", oldState), |
| 4072 | THIS)); |
| 4073 | return Void(); |
| 4074 | } |
| 4075 | restore.stateEnum().set(tr, ERestoreState::STARTING); |
| 4076 | restore.fileSet().clear(tr); |
| 4077 | restore.fileBlockCount().clear(tr); |
| 4078 | restore.fileCount().clear(tr); |
| 4079 | Reference<IBackupContainer> _bc = wait(restore.sourceContainer().getOrThrow(tr)); |
| 4080 | bc = _bc; |
| 4081 | |
| 4082 | wait(tr->commit()); |
| 4083 | break; |
| 4084 | } catch (Error& e) { |
| 4085 | wait(tr->onError(e)); |
nothing calls this directly
no test coverage detected