| 207 | } |
| 208 | |
| 209 | ACTOR static Future<Void> _execute(Database cx, |
| 210 | Reference<TaskBucket> taskBucket, |
| 211 | Reference<FutureBucket> futureBucket, |
| 212 | Reference<Task> task) { |
| 213 | state Reference<FlowLock> lock(new FlowLock(CLIENT_KNOBS->BACKUP_LOCK_BYTES)); |
| 214 | state Subspace conf = Subspace(databaseBackupPrefixRange.begin) |
| 215 | .get(BackupAgentBase::keyConfig) |
| 216 | .get(task->params[BackupAgentBase::keyConfigLogUid]); |
| 217 | |
| 218 | wait(checkTaskVersion(cx, task, BackupRangeTaskFunc::name, BackupRangeTaskFunc::version)); |
| 219 | // Find out if there is a shard boundary in(beginKey, endKey) |
| 220 | Standalone<VectorRef<KeyRef>> keys = |
| 221 | wait(runRYWTransaction(taskBucket->src, [=](Reference<ReadYourWritesTransaction> tr) { |
| 222 | return getBlockOfShards(tr, |
| 223 | task->params[DatabaseBackupAgent::keyBeginKey], |
| 224 | task->params[DatabaseBackupAgent::keyEndKey], |
| 225 | CLIENT_KNOBS->BACKUP_SHARD_TASK_LIMIT); |
| 226 | })); |
| 227 | if (keys.size() > 0) { |
| 228 | task->params[BackupRangeTaskFunc::keyAddBackupRangeTasks] = BinaryWriter::toValue(keys, IncludeVersion()); |
| 229 | return Void(); |
| 230 | } |
| 231 | |
| 232 | // Read everything from beginKey to endKey, write it to an output file, run the output file processor, and |
| 233 | // then set on_done.If we are still writing after X seconds, end the output file and insert a new backup_range |
| 234 | // task for the remainder. |
| 235 | state double timeout = now() + CLIENT_KNOBS->BACKUP_RANGE_TIMEOUT; |
| 236 | state Key addPrefix = task->params[DatabaseBackupAgent::keyAddPrefix]; |
| 237 | state Key removePrefix = task->params[DatabaseBackupAgent::keyRemovePrefix]; |
| 238 | |
| 239 | state KeyRange range( |
| 240 | KeyRangeRef(task->params[BackupAgentBase::keyBeginKey], task->params[BackupAgentBase::keyEndKey])); |
| 241 | |
| 242 | // retrieve kvData |
| 243 | state PromiseStream<RangeResultWithVersion> results; |
| 244 | |
| 245 | state Future<Void> rc = readCommitted( |
| 246 | taskBucket->src, results, lock, range, Terminator::True, AccessSystemKeys::True, LockAware::True); |
| 247 | state Key rangeBegin = range.begin; |
| 248 | state Key rangeEnd; |
| 249 | state bool endOfStream = false; |
| 250 | state RangeResultWithVersion nextValues; |
| 251 | state int64_t nextValuesSize = 0; |
| 252 | nextValues.second = invalidVersion; |
| 253 | loop { |
| 254 | if (endOfStream && nextValues.second == invalidVersion) { |
| 255 | return Void(); |
| 256 | } |
| 257 | state RangeResultWithVersion values = std::move(nextValues); |
| 258 | state int64_t valuesSize = nextValuesSize; |
| 259 | nextValues = RangeResultWithVersion(); |
nothing calls this directly
no test coverage detected