Skip to content

Commit 5893962

Browse files
rm physical shard
1 parent 8b7ac8a commit 5893962

File tree

6 files changed

+193
-63
lines changed

6 files changed

+193
-63
lines changed

fdbclient/ServerKnobs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,9 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi
11181118
init( FETCH_SHARD_BUFFER_BYTE_LIMIT, 20e6 ); if( randomize && BUGGIFY ) FETCH_SHARD_BUFFER_BYTE_LIMIT = 1;
11191119
init( FETCH_SHARD_UPDATES_BYTE_LIMIT, 2500000 ); if( randomize && BUGGIFY ) FETCH_SHARD_UPDATES_BYTE_LIMIT = 100;
11201120

1121+
// Storage Server with Physical Shard
1122+
init( SS_GET_DATA_MOVE_ID, false); if ( isSimulated ) SS_GET_DATA_MOVE_ID = SHARD_ENCODE_LOCATION_METADATA;
1123+
11211124
//Wait Failure
11221125
init( MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS, 250 ); if( randomize && BUGGIFY ) MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS = 2;
11231126
init( WAIT_FAILURE_DELAY_LIMIT, 1.0 ); if( randomize && BUGGIFY ) WAIT_FAILURE_DELAY_LIMIT = 5.0;

fdbclient/include/fdbclient/ServerKnobs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,9 @@ class SWIFT_CXX_IMMORTAL_SINGLETON_TYPE ServerKnobs : public KnobsImpl<ServerKno
11571157
int FETCH_SHARD_BUFFER_BYTE_LIMIT;
11581158
int FETCH_SHARD_UPDATES_BYTE_LIMIT;
11591159

1160+
// Storage Server with Physical Shard
1161+
bool SS_GET_DATA_MOVE_ID;
1162+
11601163
// Wait Failure
11611164
int MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS;
11621165
double WAIT_FAILURE_DELAY_LIMIT;

fdbclient/include/fdbclient/StorageCheckpoint.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ struct DataMoveMetaData {
175175
int16_t phase; // DataMoveMetaData::Phase.
176176
int8_t mode;
177177
Optional<BulkLoadTaskState> bulkLoadTaskState; // set if the data move is a bulk load data move
178+
Optional<std::unordered_map<std::string, std::string>> dcTeamIds; // map of dcId to teamId
178179

179180
DataMoveMetaData() = default;
180181
DataMoveMetaData(UID id, Version version, KeyRange range) : id(id), version(version), priority(0), mode(0) {
@@ -202,7 +203,8 @@ struct DataMoveMetaData {
202203

203204
template <class Ar>
204205
void serialize(Ar& ar) {
205-
serializer(ar, id, version, ranges, priority, src, dest, checkpoints, phase, mode, bulkLoadTaskState);
206+
serializer(
207+
ar, id, version, ranges, priority, src, dest, checkpoints, phase, mode, bulkLoadTaskState, dcTeamIds);
206208
}
207209
};
208210

fdbclient/include/fdbclient/StorageServerShard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct StorageServerShard {
104104
uint64_t desiredId; // The intended shard ID.
105105
int8_t shardState;
106106
Optional<UID> moveInShardId; // If present, it is the associated MoveInShardMetaData.
107+
UID teamId;
107108
};
108109

109110
#endif

fdbserver/MoveKeys.actor.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ ACTOR static Future<Void> startMoveShards(Database occ,
17121712
serverListEntries.push_back(tr.get(serverListKeyFor(servers[s])));
17131713
}
17141714
std::vector<Optional<Value>> serverListValues = wait(getAll(serverListEntries));
1715-
1715+
state std::unordered_map<std::string, std::vector<std::string>> dcServers;
17161716
for (int s = 0; s < serverListValues.size(); s++) {
17171717
if (!serverListValues[s].present()) {
17181718
// Attempt to move onto a server that isn't in serverList (removed or never added to the
@@ -1721,6 +1721,13 @@ ACTOR static Future<Void> startMoveShards(Database occ,
17211721
// TODO(psm): Mark the data move as 'deleting'.
17221722
throw move_to_removed_server();
17231723
}
1724+
auto si = decodeServerListValue(serverListValues[s].get());
1725+
ASSERT(si.id() == servers[s]);
1726+
auto it = dcServers.find(si.locality.describeDcId());
1727+
if (it == dcServers.end()) {
1728+
dcServers[si.locality.describeDcId()] = std::vector<std::string>();
1729+
}
1730+
dcServers[si.locality.describeDcId()].push_back(si.id().shortString());
17241731
}
17251732

17261733
currentKeys = KeyRangeRef(begin, keys.end);
@@ -1733,6 +1740,15 @@ ACTOR static Future<Void> startMoveShards(Database occ,
17331740
state Key endKey = old.back().key;
17341741
currentKeys = KeyRangeRef(currentKeys.begin, endKey);
17351742

1743+
if (ranges.front() != currentKeys) {
1744+
TraceEvent("MoveShardsPartialRange")
1745+
.detail("ExpectedRange", ranges.front())
1746+
.detail("ActualRange", currentKeys)
1747+
.detail("DataMoveId", dataMoveId)
1748+
.detail("RowLimit", SERVER_KNOBS->MOVE_SHARD_KRM_ROW_LIMIT)
1749+
.detail("ByteLimit", SERVER_KNOBS->MOVE_SHARD_KRM_BYTE_LIMIT);
1750+
}
1751+
17361752
// Check that enough servers for each shard are in the correct state
17371753
state RangeResult UIDtoTagMap = wait(tr.getRange(serverTagKeys, CLIENT_KNOBS->TOO_MANY));
17381754
ASSERT(!UIDtoTagMap.more && UIDtoTagMap.size() < CLIENT_KNOBS->TOO_MANY);
@@ -1806,6 +1822,7 @@ ACTOR static Future<Void> startMoveShards(Database occ,
18061822
TraceEvent(
18071823
SevWarn, "StartMoveShardsCancelConflictingDataMove", relocationIntervalId)
18081824
.detail("Range", rangeIntersectKeys)
1825+
.detail("CurrentDataMoveRange", ranges[0])
18091826
.detail("DataMoveID", dataMoveId.toString())
18101827
.detail("ExistingDataMoveID", destId.toString());
18111828
wait(cleanUpDataMove(occ, destId, lock, startMoveKeysLock, keys, ddEnabledState));
@@ -1868,6 +1885,16 @@ ACTOR static Future<Void> startMoveShards(Database occ,
18681885
dataMove.ranges.clear();
18691886
dataMove.ranges.push_back(KeyRangeRef(keys.begin, currentKeys.end));
18701887
dataMove.dest.insert(servers.begin(), servers.end());
1888+
dataMove.dcTeamIds = std::unordered_map<std::string, std::string>();
1889+
for (auto& [dc, serverIds] : dcServers) {
1890+
std::sort(serverIds.begin(), serverIds.end());
1891+
std::string teamId;
1892+
for (const auto& serverId : serverIds) {
1893+
teamId += serverId;
1894+
}
1895+
// Use the concatenated server ids as the team id to avoid conflicts.
1896+
dataMove.dcTeamIds.get()[dc] = teamId;
1897+
}
18711898
}
18721899

18731900
if (currentKeys.end == keys.end) {

0 commit comments

Comments
 (0)