2019-05-01 11:55:31 +08:00
|
|
|
/*
|
|
|
|
* RestoreCommon.actor.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-05-13 12:53:09 +08:00
|
|
|
// This file includes the code copied from the old restore in FDB 5.2
|
2019-08-02 08:00:13 +08:00
|
|
|
// The functions and structure declared in this file can be shared by
|
2019-05-13 12:53:09 +08:00
|
|
|
// the old restore and the new performant restore systems
|
|
|
|
|
2019-05-01 11:55:31 +08:00
|
|
|
#pragma once
|
|
|
|
#if defined(NO_INTELLISENSE) && !defined(FDBSERVER_RESTORECOMMON_ACTOR_G_H)
|
2019-08-02 08:00:13 +08:00
|
|
|
#define FDBSERVER_RESTORECOMMON_ACTOR_G_H
|
|
|
|
#include "fdbserver/RestoreCommon.actor.g.h"
|
2019-05-01 11:55:31 +08:00
|
|
|
#elif !defined(FDBSERVER_RESTORECOMMON_ACTOR_H)
|
2019-08-02 08:00:13 +08:00
|
|
|
#define FDBSERVER_RESTORECOMMON_ACTOR_H
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
#include "flow/flow.h"
|
2019-05-13 12:53:09 +08:00
|
|
|
#include "flow/genericactors.actor.h"
|
|
|
|
#include "fdbclient/Tuple.h"
|
2019-05-01 11:55:31 +08:00
|
|
|
#include "fdbclient/NativeAPI.actor.h"
|
|
|
|
#include "fdbrpc/IAsyncFile.h"
|
|
|
|
#include "fdbclient/BackupAgent.actor.h"
|
2021-05-31 02:51:47 +08:00
|
|
|
#include "fdbserver/Knobs.h"
|
2019-05-10 11:55:44 +08:00
|
|
|
|
2019-05-12 13:48:39 +08:00
|
|
|
#include "flow/actorcompiler.h" // has to be last include
|
|
|
|
|
2019-05-01 11:55:31 +08:00
|
|
|
// RestoreConfig copied from FileBackupAgent.actor.cpp
|
2021-03-11 02:06:03 +08:00
|
|
|
// We copy RestoreConfig instead of using (and potentially changing) it in place
|
2019-08-03 07:09:38 +08:00
|
|
|
// to avoid conflict with the existing code.
|
|
|
|
// We also made minor changes to allow RestoreConfig to be ReferenceCounted
|
2019-05-01 11:55:31 +08:00
|
|
|
// TODO: Merge this RestoreConfig with the original RestoreConfig in FileBackupAgent.actor.cpp
|
2019-08-03 07:09:38 +08:00
|
|
|
// For convenience
|
2019-05-01 11:55:31 +08:00
|
|
|
typedef FileBackupAgent::ERestoreState ERestoreState;
|
2019-08-03 07:09:38 +08:00
|
|
|
|
2019-05-01 11:55:31 +08:00
|
|
|
struct RestoreFileFR;
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
// We copy RestoreConfig copied from FileBackupAgent.actor.cpp instead of using (and potentially changing) it in place
|
|
|
|
// to avoid conflict with the existing code Split RestoreConfig defined in FileBackupAgent.actor.cpp to declaration in
|
|
|
|
// Restore.actor.h and implementation in RestoreCommon.actor.cpp, so that we can use in both the existing restore and
|
2019-08-03 07:09:38 +08:00
|
|
|
// the new fast restore subsystems. We use RestoreConfig as a Reference<RestoreConfig>, which leads to some
|
2019-08-02 08:00:13 +08:00
|
|
|
// non-functional changes in RestoreConfig
|
2019-08-03 07:09:38 +08:00
|
|
|
class RestoreConfigFR : public KeyBackedConfig, public ReferenceCounted<RestoreConfigFR> {
|
2019-05-01 11:55:31 +08:00
|
|
|
public:
|
2019-08-03 07:09:38 +08:00
|
|
|
RestoreConfigFR(UID uid = UID()) : KeyBackedConfig(fileRestorePrefixRange.begin, uid) {}
|
|
|
|
RestoreConfigFR(Reference<Task> task) : KeyBackedConfig(fileRestorePrefixRange.begin, task) {}
|
2019-05-01 11:55:31 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
KeyBackedProperty<ERestoreState> stateEnum();
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
Future<StringRef> stateText(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
|
|
|
KeyBackedProperty<Key> addPrefix();
|
|
|
|
|
|
|
|
KeyBackedProperty<Key> removePrefix();
|
|
|
|
|
|
|
|
// XXX: Remove restoreRange() once it is safe to remove. It has been changed to restoreRanges
|
|
|
|
KeyBackedProperty<KeyRange> restoreRange();
|
|
|
|
|
|
|
|
KeyBackedProperty<std::vector<KeyRange>> restoreRanges();
|
|
|
|
|
|
|
|
KeyBackedProperty<Key> batchFuture();
|
|
|
|
|
|
|
|
KeyBackedProperty<Version> restoreVersion();
|
|
|
|
|
|
|
|
KeyBackedProperty<Reference<IBackupContainer>> sourceContainer();
|
|
|
|
|
|
|
|
// Get the source container as a bare URL, without creating a container instance
|
|
|
|
KeyBackedProperty<Value> sourceContainerURL();
|
|
|
|
|
|
|
|
// Total bytes written by all log and range restore tasks.
|
|
|
|
KeyBackedBinaryValue<int64_t> bytesWritten();
|
|
|
|
|
|
|
|
// File blocks that have had tasks created for them by the Dispatch task
|
|
|
|
KeyBackedBinaryValue<int64_t> filesBlocksDispatched();
|
|
|
|
|
|
|
|
// File blocks whose tasks have finished
|
|
|
|
KeyBackedBinaryValue<int64_t> fileBlocksFinished();
|
|
|
|
|
|
|
|
// Total number of files in the fileMap
|
|
|
|
KeyBackedBinaryValue<int64_t> fileCount();
|
|
|
|
|
|
|
|
// Total number of file blocks in the fileMap
|
|
|
|
KeyBackedBinaryValue<int64_t> fileBlockCount();
|
|
|
|
|
|
|
|
Future<std::vector<KeyRange>> getRestoreRangesOrDefault(Reference<ReadYourWritesTransaction> tr);
|
2019-08-03 07:09:38 +08:00
|
|
|
ACTOR static Future<std::vector<KeyRange>> getRestoreRangesOrDefault_impl(RestoreConfigFR* self,
|
2019-08-02 08:00:13 +08:00
|
|
|
Reference<ReadYourWritesTransaction> tr);
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
// Describes a file to load blocks from during restore. Ordered by version and then fileName to enable
|
|
|
|
// incrementally advancing through the map, saving the version and path of the next starting point.
|
|
|
|
struct RestoreFile {
|
|
|
|
Version version;
|
|
|
|
std::string fileName;
|
2019-08-02 08:00:13 +08:00
|
|
|
bool isRange; // false for log file
|
2019-05-01 11:55:31 +08:00
|
|
|
int64_t blockSize;
|
|
|
|
int64_t fileSize;
|
2019-08-02 08:00:13 +08:00
|
|
|
Version endVersion; // not meaningful for range files
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
Tuple pack() const {
|
2019-08-02 08:00:13 +08:00
|
|
|
// fprintf(stderr, "Filename:%s\n", fileName.c_str());
|
2019-05-01 11:55:31 +08:00
|
|
|
return Tuple()
|
2019-08-02 08:00:13 +08:00
|
|
|
.append(version)
|
|
|
|
.append(StringRef(fileName))
|
|
|
|
.append(isRange)
|
|
|
|
.append(fileSize)
|
|
|
|
.append(blockSize)
|
|
|
|
.append(endVersion);
|
2019-05-01 11:55:31 +08:00
|
|
|
}
|
2019-08-02 08:00:13 +08:00
|
|
|
static RestoreFile unpack(Tuple const& t) {
|
2019-05-01 11:55:31 +08:00
|
|
|
RestoreFile r;
|
|
|
|
int i = 0;
|
|
|
|
r.version = t.getInt(i++);
|
|
|
|
r.fileName = t.getString(i++).toString();
|
|
|
|
r.isRange = t.getInt(i++) != 0;
|
|
|
|
r.fileSize = t.getInt(i++);
|
|
|
|
r.blockSize = t.getInt(i++);
|
|
|
|
r.endVersion = t.getInt(i++);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
// typedef KeyBackedSet<RestoreFile> FileSetT;
|
2019-05-01 11:55:31 +08:00
|
|
|
KeyBackedSet<RestoreFile> fileSet();
|
|
|
|
|
|
|
|
Future<bool> isRunnable(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
Future<Void> logError(Database cx, Error e, std::string const& details, void* taskInstance = nullptr);
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
Key mutationLogPrefix();
|
|
|
|
|
|
|
|
Key applyMutationsMapPrefix();
|
|
|
|
|
|
|
|
ACTOR Future<int64_t> getApplyVersionLag_impl(Reference<ReadYourWritesTransaction> tr, UID uid);
|
|
|
|
|
|
|
|
Future<int64_t> getApplyVersionLag(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
|
|
|
void initApplyMutations(Reference<ReadYourWritesTransaction> tr, Key addPrefix, Key removePrefix);
|
|
|
|
|
|
|
|
void clearApplyMutationsKeys(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
|
|
|
void setApplyBeginVersion(Reference<ReadYourWritesTransaction> tr, Version ver);
|
|
|
|
|
|
|
|
void setApplyEndVersion(Reference<ReadYourWritesTransaction> tr, Version ver);
|
|
|
|
|
|
|
|
Future<Version> getApplyEndVersion(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
2019-08-03 07:09:38 +08:00
|
|
|
ACTOR static Future<std::string> getProgress_impl(Reference<RestoreConfigFR> restore,
|
2019-08-02 08:00:13 +08:00
|
|
|
Reference<ReadYourWritesTransaction> tr);
|
2019-05-01 11:55:31 +08:00
|
|
|
Future<std::string> getProgress(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
2019-08-03 07:09:38 +08:00
|
|
|
ACTOR static Future<std::string> getFullStatus_impl(Reference<RestoreConfigFR> restore,
|
2019-08-02 08:00:13 +08:00
|
|
|
Reference<ReadYourWritesTransaction> tr);
|
2019-05-01 11:55:31 +08:00
|
|
|
Future<std::string> getFullStatus(Reference<ReadYourWritesTransaction> tr);
|
|
|
|
|
|
|
|
std::string toString(); // Added by Meng
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// typedef RestoreConfigFR::RestoreFile RestoreFile;
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
// Describes a file to load blocks from during restore. Ordered by version and then fileName to enable
|
|
|
|
// incrementally advancing through the map, saving the version and path of the next starting point.
|
2019-08-02 08:00:13 +08:00
|
|
|
// NOTE: The struct RestoreFileFR can NOT be named RestoreFile, because compiler will get confused in linking which
|
|
|
|
// RestoreFile should be used. If we use RestoreFile, compilation succeeds, but weird segmentation fault will happen.
|
2019-05-01 11:55:31 +08:00
|
|
|
struct RestoreFileFR {
|
|
|
|
Version version;
|
|
|
|
std::string fileName;
|
2019-08-02 08:00:13 +08:00
|
|
|
bool isRange; // false for log file
|
2019-05-01 11:55:31 +08:00
|
|
|
int64_t blockSize;
|
|
|
|
int64_t fileSize;
|
2019-08-02 08:00:13 +08:00
|
|
|
Version endVersion; // not meaningful for range files
|
|
|
|
Version beginVersion; // range file's beginVersion == endVersion; log file contains mutations in version
|
|
|
|
// [beginVersion, endVersion)
|
|
|
|
int64_t cursor; // The start block location to be restored. All blocks before cursor have been scheduled to load and
|
|
|
|
// restore
|
2019-10-17 02:31:30 +08:00
|
|
|
int fileIndex; // index of backup file. Must be identical per file.
|
2020-02-18 06:36:09 +08:00
|
|
|
int partitionId = -1; // Partition ID (Log Router Tag ID) for mutation files.
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
Tuple pack() const {
|
|
|
|
return Tuple()
|
2019-08-02 08:00:13 +08:00
|
|
|
.append(version)
|
|
|
|
.append(StringRef(fileName))
|
|
|
|
.append(isRange)
|
|
|
|
.append(fileSize)
|
|
|
|
.append(blockSize)
|
|
|
|
.append(endVersion)
|
|
|
|
.append(beginVersion)
|
2019-10-17 02:31:30 +08:00
|
|
|
.append(cursor)
|
2020-02-18 06:36:09 +08:00
|
|
|
.append(fileIndex)
|
|
|
|
.append(partitionId);
|
2019-05-01 11:55:31 +08:00
|
|
|
}
|
2019-08-02 08:00:13 +08:00
|
|
|
static RestoreFileFR unpack(Tuple const& t) {
|
2019-05-01 11:55:31 +08:00
|
|
|
RestoreFileFR r;
|
|
|
|
int i = 0;
|
|
|
|
r.version = t.getInt(i++);
|
|
|
|
r.fileName = t.getString(i++).toString();
|
|
|
|
r.isRange = t.getInt(i++) != 0;
|
|
|
|
r.fileSize = t.getInt(i++);
|
|
|
|
r.blockSize = t.getInt(i++);
|
|
|
|
r.endVersion = t.getInt(i++);
|
|
|
|
r.beginVersion = t.getInt(i++);
|
|
|
|
r.cursor = t.getInt(i++);
|
2019-10-17 02:31:30 +08:00
|
|
|
r.fileIndex = t.getInt(i++);
|
2020-02-18 06:36:09 +08:00
|
|
|
r.partitionId = t.getInt(i++);
|
2019-05-01 11:55:31 +08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2019-10-17 02:31:30 +08:00
|
|
|
bool operator<(const RestoreFileFR& rhs) const {
|
2020-01-28 10:13:20 +08:00
|
|
|
return std::tie(beginVersion, endVersion, fileIndex, fileName) <
|
|
|
|
std::tie(rhs.beginVersion, rhs.endVersion, rhs.fileIndex, rhs.fileName);
|
2019-10-17 02:31:30 +08:00
|
|
|
}
|
2019-05-01 11:55:31 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
RestoreFileFR()
|
|
|
|
: version(invalidVersion), isRange(false), blockSize(0), fileSize(0), endVersion(invalidVersion),
|
2019-10-17 02:31:30 +08:00
|
|
|
beginVersion(invalidVersion), cursor(0), fileIndex(0) {}
|
2019-05-01 11:55:31 +08:00
|
|
|
|
2020-02-18 06:36:09 +08:00
|
|
|
explicit RestoreFileFR(const RangeFile& f)
|
|
|
|
: version(f.version), fileName(f.fileName), isRange(true), blockSize(f.blockSize), fileSize(f.fileSize),
|
|
|
|
endVersion(f.version), beginVersion(f.version), cursor(0), fileIndex(0) {}
|
|
|
|
|
|
|
|
explicit RestoreFileFR(const LogFile& f)
|
|
|
|
: version(f.beginVersion), fileName(f.fileName), isRange(false), blockSize(f.blockSize), fileSize(f.fileSize),
|
|
|
|
endVersion(f.endVersion), beginVersion(f.beginVersion), cursor(0), fileIndex(0), partitionId(f.tagId) {}
|
2019-05-01 11:55:31 +08:00
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
std::stringstream ss;
|
2021-03-11 02:06:03 +08:00
|
|
|
ss << "version:" << version << " fileName:" << fileName << " isRange:" << isRange << " blockSize:" << blockSize
|
|
|
|
<< " fileSize:" << fileSize << " endVersion:" << endVersion << " beginVersion:" << beginVersion
|
|
|
|
<< " cursor:" << cursor << " fileIndex:" << fileIndex << " partitionId:" << partitionId;
|
2019-05-01 11:55:31 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace parallelFileRestore {
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Standalone<VectorRef<KeyValueRef>>> decodeLogFileBlock(Reference<IAsyncFile> file,
|
|
|
|
int64_t offset,
|
2019-08-02 08:00:13 +08:00
|
|
|
int len);
|
|
|
|
} // namespace parallelFileRestore
|
2019-05-01 11:55:31 +08:00
|
|
|
|
2019-08-02 09:20:42 +08:00
|
|
|
// Send each request in requests via channel of the request's interface.
|
2020-03-02 12:39:56 +08:00
|
|
|
// Save replies to replies if replies != nullptr
|
2019-08-02 09:20:42 +08:00
|
|
|
// The UID in a request is the UID of the interface to handle the request
|
|
|
|
ACTOR template <class Interface, class Request>
|
2021-03-11 02:06:03 +08:00
|
|
|
Future<Void> getBatchReplies(RequestStream<Request> Interface::*channel,
|
|
|
|
std::map<UID, Interface> interfaces,
|
|
|
|
std::vector<std::pair<UID, Request>> requests,
|
|
|
|
std::vector<REPLY_TYPE(Request)>* replies,
|
|
|
|
TaskPriority taskID = TaskPriority::Low,
|
|
|
|
bool trackRequestLatency = true) {
|
2020-02-22 07:19:58 +08:00
|
|
|
if (requests.empty()) {
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
state double start = now();
|
|
|
|
state int oustandingReplies = requests.size();
|
|
|
|
loop {
|
|
|
|
try {
|
|
|
|
state std::vector<Future<REPLY_TYPE(Request)>> cmdReplies;
|
|
|
|
state std::vector<std::tuple<UID, Request, double>> replyDurations; // double is end time of the request
|
|
|
|
for (auto& request : requests) {
|
|
|
|
RequestStream<Request> const* stream = &(interfaces[request.first].*channel);
|
|
|
|
cmdReplies.push_back(stream->getReply(request.second, taskID));
|
|
|
|
replyDurations.emplace_back(request.first, request.second, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
state std::vector<Future<REPLY_TYPE(Request)>> ongoingReplies;
|
|
|
|
state std::vector<int> ongoingRepliesIndex;
|
|
|
|
loop {
|
|
|
|
ongoingReplies.clear();
|
|
|
|
ongoingRepliesIndex.clear();
|
|
|
|
for (int i = 0; i < cmdReplies.size(); ++i) {
|
2020-05-05 11:12:59 +08:00
|
|
|
if (SERVER_KNOBS->FASTRESTORE_REQBATCH_LOG) {
|
|
|
|
TraceEvent(SevInfo, "FastRestoreGetBatchReplies")
|
2020-05-06 10:12:15 +08:00
|
|
|
.suppressFor(1.0)
|
2020-05-05 11:12:59 +08:00
|
|
|
.detail("Requests", requests.size())
|
|
|
|
.detail("OutstandingReplies", oustandingReplies)
|
|
|
|
.detail("ReplyIndex", i)
|
|
|
|
.detail("ReplyIsReady", cmdReplies[i].isReady())
|
|
|
|
.detail("ReplyIsError", cmdReplies[i].isError())
|
|
|
|
.detail("RequestNode", requests[i].first)
|
|
|
|
.detail("Request", requests[i].second.toString());
|
|
|
|
}
|
2020-02-22 07:19:58 +08:00
|
|
|
if (!cmdReplies[i].isReady()) { // still wait for reply
|
|
|
|
ongoingReplies.push_back(cmdReplies[i]);
|
|
|
|
ongoingRepliesIndex.push_back(i);
|
|
|
|
}
|
|
|
|
}
|
2020-05-06 10:12:15 +08:00
|
|
|
ASSERT(ongoingReplies.size() == oustandingReplies);
|
2020-02-22 07:19:58 +08:00
|
|
|
if (ongoingReplies.empty()) {
|
|
|
|
break;
|
|
|
|
} else {
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(
|
|
|
|
quorum(ongoingReplies,
|
|
|
|
std::min((int)SERVER_KNOBS->FASTRESTORE_REQBATCH_PARALLEL, (int)ongoingReplies.size())));
|
2020-02-22 06:10:10 +08:00
|
|
|
}
|
2020-02-22 07:19:58 +08:00
|
|
|
// At least one reply is received; Calculate the reply duration
|
|
|
|
for (int j = 0; j < ongoingReplies.size(); ++j) {
|
|
|
|
if (ongoingReplies[j].isReady()) {
|
|
|
|
std::get<2>(replyDurations[ongoingRepliesIndex[j]]) = now();
|
|
|
|
--oustandingReplies;
|
2020-09-09 22:23:18 +08:00
|
|
|
} else if (ongoingReplies[j].isError()) {
|
|
|
|
// When this happens,
|
|
|
|
// the above assertion ASSERT(ongoingReplies.size() == oustandingReplies) will fail
|
|
|
|
TraceEvent(SevError, "FastRestoreGetBatchRepliesReplyError")
|
|
|
|
.detail("OngoingReplyIndex", j)
|
|
|
|
.detail("FutureError", ongoingReplies[j].getError().what());
|
2020-02-22 07:19:58 +08:00
|
|
|
}
|
2020-02-22 06:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
2020-02-22 07:19:58 +08:00
|
|
|
ASSERT(oustandingReplies == 0);
|
|
|
|
if (trackRequestLatency && SERVER_KNOBS->FASTRESTORE_TRACK_REQUEST_LATENCY) {
|
|
|
|
// Calculate the latest end time for each interface
|
|
|
|
std::map<UID, double> maxEndTime;
|
|
|
|
UID bathcID = deterministicRandom()->randomUniqueID();
|
|
|
|
for (int i = 0; i < replyDurations.size(); ++i) {
|
|
|
|
double endTime = std::get<2>(replyDurations[i]);
|
|
|
|
TraceEvent(SevInfo, "ProfileSendRequestBatchLatency", bathcID)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Node", std::get<0>(replyDurations[i]))
|
|
|
|
.detail("Request", std::get<1>(replyDurations[i]).toString())
|
|
|
|
.detail("Duration", endTime - start);
|
2020-02-22 07:19:58 +08:00
|
|
|
auto item = maxEndTime.emplace(std::get<0>(replyDurations[i]), endTime);
|
|
|
|
item.first->second = std::max(item.first->second, endTime);
|
|
|
|
}
|
|
|
|
// Check the time gap between the earliest and latest node
|
|
|
|
double earliest = std::numeric_limits<double>::max();
|
|
|
|
double latest = std::numeric_limits<double>::min();
|
|
|
|
UID earliestNode, latestNode;
|
|
|
|
|
|
|
|
for (auto& endTime : maxEndTime) {
|
|
|
|
if (earliest > endTime.second) {
|
|
|
|
earliest = endTime.second;
|
|
|
|
earliestNode = endTime.first;
|
|
|
|
}
|
|
|
|
if (latest < endTime.second) {
|
|
|
|
latest = endTime.second;
|
|
|
|
latestNode = endTime.first;
|
|
|
|
}
|
|
|
|
}
|
2020-03-03 02:52:44 +08:00
|
|
|
if (latest - earliest > SERVER_KNOBS->FASTRESTORE_STRAGGLER_THRESHOLD_SECONDS) {
|
2020-02-22 07:19:58 +08:00
|
|
|
TraceEvent(SevWarn, "ProfileSendRequestBatchLatencyFoundStraggler", bathcID)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("SlowestNode", latestNode)
|
|
|
|
.detail("FatestNode", earliestNode)
|
|
|
|
.detail("EarliestEndtime", earliest)
|
|
|
|
.detail("LagTime", latest - earliest);
|
2020-02-22 07:19:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Update replies
|
2020-03-02 12:39:56 +08:00
|
|
|
if (replies != nullptr) {
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int i = 0; i < cmdReplies.size(); ++i) {
|
2020-02-22 07:19:58 +08:00
|
|
|
replies->emplace_back(cmdReplies[i].get());
|
|
|
|
}
|
2020-02-22 06:10:10 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
} catch (Error& e) {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (e.code() == error_code_operation_cancelled)
|
|
|
|
break;
|
2020-04-26 08:21:17 +08:00
|
|
|
// fprintf(stdout, "sendBatchRequests Error code:%d, error message:%s\n", e.code(), e.what());
|
2020-05-02 04:35:13 +08:00
|
|
|
TraceEvent(SevWarn, "FastRestoreSendBatchRequests").error(e);
|
2020-02-22 06:10:10 +08:00
|
|
|
for (auto& request : requests) {
|
2020-05-06 10:12:15 +08:00
|
|
|
TraceEvent(SevWarn, "FastRestoreSendBatchRequests")
|
2020-02-22 06:10:10 +08:00
|
|
|
.detail("SendBatchRequests", requests.size())
|
|
|
|
.detail("RequestID", request.first)
|
|
|
|
.detail("Request", request.second.toString());
|
2020-04-24 11:32:50 +08:00
|
|
|
resetReply(request.second);
|
2020-02-22 06:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2020-02-22 08:15:01 +08:00
|
|
|
// Similar to getBatchReplies except that the caller does not expect to process the reply info.
|
2019-08-02 09:20:42 +08:00
|
|
|
ACTOR template <class Interface, class Request>
|
2021-03-11 02:06:03 +08:00
|
|
|
Future<Void> sendBatchRequests(RequestStream<Request> Interface::*channel,
|
|
|
|
std::map<UID, Interface> interfaces,
|
|
|
|
std::vector<std::pair<UID, Request>> requests,
|
|
|
|
TaskPriority taskID = TaskPriority::Low,
|
2020-02-22 08:15:01 +08:00
|
|
|
bool trackRequestLatency = true) {
|
2020-03-02 12:39:56 +08:00
|
|
|
wait(getBatchReplies(channel, interfaces, requests, nullptr, taskID, trackRequestLatency));
|
2019-08-02 09:20:42 +08:00
|
|
|
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:55:31 +08:00
|
|
|
#include "flow/unactorcompiler.h"
|
2021-05-31 02:51:47 +08:00
|
|
|
#endif // FDBSERVER_RESTORECOMMON_ACTOR_H
|