| 1147 | REGISTER_TASKFUNC(CopyLogsTaskFunc); |
| 1148 | |
| 1149 | struct FinishedFullBackupTaskFunc : TaskFuncBase { |
| 1150 | static StringRef name; |
| 1151 | static constexpr uint32_t version = 1; |
| 1152 | static const Key keyInsertTask; |
| 1153 | |
| 1154 | StringRef getName() const override { return name; }; |
| 1155 | |
| 1156 | ACTOR static Future<Void> _execute(Database cx, |
| 1157 | Reference<TaskBucket> taskBucket, |
| 1158 | Reference<FutureBucket> futureBucket, |
| 1159 | Reference<Task> task) { |
| 1160 | state Subspace sourceStates = Subspace(databaseBackupPrefixRange.begin) |
| 1161 | .get(BackupAgentBase::keySourceStates) |
| 1162 | .get(task->params[BackupAgentBase::keyConfigLogUid]); |
| 1163 | |
| 1164 | wait(checkTaskVersion(cx, task, FinishedFullBackupTaskFunc::name, FinishedFullBackupTaskFunc::version)); |
| 1165 | |
| 1166 | state Transaction tr2(cx); |
| 1167 | loop { |
| 1168 | try { |
| 1169 | tr2.setOption(FDBTransactionOptions::LOCK_AWARE); |
| 1170 | Optional<Value> beginValue = wait( |
| 1171 | tr2.get(task->params[BackupAgentBase::keyConfigLogUid].withPrefix(applyMutationsBeginRange.begin))); |
| 1172 | state Version appliedVersion = |
| 1173 | beginValue.present() ? BinaryReader::fromStringRef<Version>(beginValue.get(), Unversioned()) : -1; |
| 1174 | Optional<Value> endValue = wait( |
| 1175 | tr2.get(task->params[BackupAgentBase::keyConfigLogUid].withPrefix(applyMutationsEndRange.begin))); |
| 1176 | Version endVersion = |
| 1177 | endValue.present() ? BinaryReader::fromStringRef<Version>(endValue.get(), Unversioned()) : -1; |
| 1178 | |
| 1179 | //TraceEvent("DBA_FinishedFullBackup").detail("Applied", appliedVersion).detail("EndVer", endVersion); |
| 1180 | if (appliedVersion < endVersion) { |
| 1181 | wait(delay(FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY)); |
| 1182 | task->params[FinishedFullBackupTaskFunc::keyInsertTask] = StringRef(); |
| 1183 | return Void(); |
| 1184 | } |
| 1185 | break; |
| 1186 | } catch (Error& e) { |
| 1187 | wait(tr2.onError(e)); |
| 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(taskBucket->src)); |
| 1192 | state Key logUidValue = task->params[DatabaseBackupAgent::keyConfigLogUid]; |
| 1193 | state Key destUidValue = task->params[BackupAgentBase::destUid]; |
| 1194 | state Version backupUid = |
| 1195 | BinaryReader::fromStringRef<Version>(task->params[BackupAgentBase::keyFolderId], Unversioned()); |
| 1196 | |
| 1197 | loop { |
| 1198 | try { |
| 1199 | tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); |
| 1200 | tr->setOption(FDBTransactionOptions::LOCK_AWARE); |
| 1201 | Optional<Value> v = wait(tr->get(sourceStates.pack(DatabaseBackupAgent::keyFolderId))); |
| 1202 | if (v.present() && BinaryReader::fromStringRef<Version>(v.get(), Unversioned()) > |
| 1203 | BinaryReader::fromStringRef<Version>( |
| 1204 | task->params[DatabaseBackupAgent::keyFolderId], Unversioned())) |
| 1205 | return Void(); |
| 1206 |
nothing calls this directly
no test coverage detected