mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-02 19:25:52 +08:00
FastRestore:Add nodeIndex to CMDUID
This avoids the duplicate cmdIDs from different loaders.
This commit is contained in:
parent
8e5c7e4b22
commit
5344e3faf7
@ -297,13 +297,13 @@ ACTOR Future<Void> handleRecruitRoleRequest(RestoreRecruitRoleRequest req, Refer
|
||||
ASSERT( !self->loaderInterf.present() );
|
||||
self->loaderInterf = RestoreLoaderInterface();
|
||||
self->loaderInterf.get().initEndpoints();
|
||||
self->loaderData = Reference<RestoreLoaderData>(new RestoreLoaderData(self->loaderInterf.get().id()));
|
||||
self->loaderData = Reference<RestoreLoaderData>( new RestoreLoaderData(self->loaderInterf.get().id(), req.nodeIndex) );
|
||||
actors->add( restoreLoaderCore(self->loaderData, self->loaderInterf.get(), cx) );
|
||||
} else if (req.role == RestoreRole::Applier) {
|
||||
ASSERT( !self->applierInterf.present() );
|
||||
self->applierInterf = RestoreApplierInterface();
|
||||
self->applierInterf.get().initEndpoints();
|
||||
self->applierData = Reference<RestoreApplierData>( new RestoreApplierData(self->applierInterf.get().id()) );
|
||||
self->applierData = Reference<RestoreApplierData>( new RestoreApplierData(self->applierInterf.get().id(), req.nodeIndex) );
|
||||
actors->add( restoreApplierCore(self->applierData, self->applierInterf.get(), cx) );
|
||||
} else {
|
||||
TraceEvent(SevError, "FastRestore").detail("HandleRecruitRoleRequest", "UnknownRole"); //.detail("Request", req.printable());
|
||||
|
@ -60,9 +60,9 @@ struct RestoreApplierData : RestoreRoleData, public ReferenceCounted<RestoreAppl
|
||||
void addref() { return ReferenceCounted<RestoreApplierData>::addref(); }
|
||||
void delref() { return ReferenceCounted<RestoreApplierData>::delref(); }
|
||||
|
||||
explicit RestoreApplierData(UID applierInterfID) {
|
||||
explicit RestoreApplierData(UID applierInterfID, int assignedIndex) {
|
||||
nodeID = applierInterfID;
|
||||
nodeIndex = 0;
|
||||
nodeIndex = assignedIndex;
|
||||
|
||||
role = RestoreRole::Applier;
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ public:
|
||||
void addref() { return ReferenceCounted<RestoreLoaderData>::addref(); }
|
||||
void delref() { return ReferenceCounted<RestoreLoaderData>::delref(); }
|
||||
|
||||
explicit RestoreLoaderData(UID loaderInterfID) {
|
||||
explicit RestoreLoaderData(UID loaderInterfID, int assignedIndex) {
|
||||
nodeID = loaderInterfID;
|
||||
nodeIndex = 0;
|
||||
|
||||
nodeIndex = assignedIndex;
|
||||
role = RestoreRole::Loader;
|
||||
cmdID.nodeIndex = nodeIndex;
|
||||
}
|
||||
|
||||
~RestoreLoaderData() {}
|
||||
|
@ -78,6 +78,7 @@ struct RestoreMasterData : RestoreRoleData, public ReferenceCounted<RestoreMast
|
||||
nodeID = UID();
|
||||
|
||||
cmdID = CMDUID();
|
||||
cmdID.nodeIndex = -1; // uint16_t maximum value
|
||||
|
||||
batchIndex = 0;
|
||||
curWorkloadSize = 0;
|
||||
|
@ -108,8 +108,8 @@ struct StringRefReaderMX {
|
||||
struct RestoreRoleData : NonCopyable, public ReferenceCounted<RestoreRoleData> {
|
||||
public:
|
||||
RestoreRole role;
|
||||
UID nodeID; // RestoreLoader role ID
|
||||
int nodeIndex; // RestoreLoader role index, which is continuous and easy for debuggging
|
||||
UID nodeID; //
|
||||
int nodeIndex; // The index (starts from 0) of each role should be unique. We use nodeIndex to ensure cmdID is not duplicate across loaders
|
||||
|
||||
std::map<UID, RestoreLoaderInterface> loadersInterf;
|
||||
std::map<UID, RestoreApplierInterface> appliersInterf;
|
||||
|
@ -61,12 +61,13 @@ std::string getRoleStr(RestoreRole role);
|
||||
// TODO: Add another field to indicate version-batch round
|
||||
class CMDUID {
|
||||
public:
|
||||
uint16_t nodeIndex;
|
||||
uint16_t batch;
|
||||
uint16_t phase;
|
||||
uint64_t cmdID;
|
||||
CMDUID() : batch(0), phase(0), cmdID(0) { }
|
||||
CMDUID( uint16_t a, uint64_t b ) { batch = 0; phase=a; cmdID=b; }
|
||||
CMDUID(const CMDUID &cmd) { batch = cmd.batch; phase = cmd.phase; cmdID = cmd.cmdID; }
|
||||
CMDUID() : nodeIndex(0), batch(0), phase(0), cmdID(0) { }
|
||||
CMDUID( uint16_t a, uint64_t b ) { nodeIndex = 0, batch = 0; phase=a; cmdID=b; }
|
||||
CMDUID(const CMDUID &cmd) { nodeIndex = cmd.nodeIndex; batch = cmd.batch; phase = cmd.phase; cmdID = cmd.cmdID; }
|
||||
|
||||
void initPhase(RestoreCommandEnum phase);
|
||||
|
||||
@ -82,9 +83,14 @@ public:
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
bool operator == ( const CMDUID& r ) const { return batch == r.batch && phase == r.phase && cmdID == r.cmdID; }
|
||||
bool operator != ( const CMDUID& r ) const { return batch != r.batch || phase != r.phase || cmdID != r.cmdID; }
|
||||
bool operator < ( const CMDUID& r ) const { return batch < r.batch || (batch == r.batch && phase < r.phase) || (batch == r.batch && phase == r.phase && cmdID < r.cmdID); }
|
||||
bool operator == ( const CMDUID& r ) const { return nodeIndex == r.nodeIndex && batch == r.batch && phase == r.phase && cmdID == r.cmdID; }
|
||||
bool operator != ( const CMDUID& r ) const { return nodeIndex != r.nodeIndex || batch != r.batch || phase != r.phase || cmdID != r.cmdID; }
|
||||
bool operator < ( const CMDUID& r ) const {
|
||||
return (nodeIndex < r.nodeIndex) ||
|
||||
(nodeIndex == r.nodeIndex && batch < r.batch) ||
|
||||
(nodeIndex == r.nodeIndex && batch == r.batch && phase < r.phase)
|
||||
|| (nodeIndex == r.nodeIndex && batch == r.batch && phase == r.phase && cmdID < r.cmdID);
|
||||
}
|
||||
|
||||
//uint64_t hash() const { return first(); }
|
||||
//uint64_t first() const { return part[0]; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user