Skip to content

Commit 8bb019e

Browse files
logging
1 parent ef7448b commit 8bb019e

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

fdbclient/ServerKnobs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi
629629
init( SHARDED_ROCKSDB_HISTOGRAMS_SAMPLE_RATE, 0.001 ); if( isSimulated ) SHARDED_ROCKSDB_HISTOGRAMS_SAMPLE_RATE = deterministicRandom()->random01();
630630
init( SHARDED_ROCKSDB_USE_DIRECT_IO, false ); if (isSimulated) SHARDED_ROCKSDB_USE_DIRECT_IO = deterministicRandom()->coinflip();
631631
init( SHARDED_ROCKSDB_FLUSH_PERIOD, 0.0 ); if (isSimulated) SHARDED_ROCKSDB_FLUSH_PERIOD = deterministicRandom()->randomInt(100, 1000);
632+
init( SHARDED_ROCKSDB_DETAILED_STATS, false ); if (isSimulated) SHARDED_ROCKSDB_DETAILED_STATS = deterministicRandom()->coinflip();
632633

633634

634635
// Leader election

fdbclient/include/fdbclient/ServerKnobs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ class ServerKnobs : public KnobsImpl<ServerKnobs> {
597597
double SHARDED_ROCKSDB_HISTOGRAMS_SAMPLE_RATE;
598598
bool SHARDED_ROCKSDB_USE_DIRECT_IO;
599599
double SHARDED_ROCKSDB_FLUSH_PERIOD;
600+
bool SHARDED_ROCKSDB_DETAILED_STATS;
600601

601602
// Leader election
602603
int MAX_NOTIFICATIONS;

fdbserver/DDTeamCollection.actor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,6 +3639,8 @@ class DDTeamCollectionImpl {
36393639
}
36403640
}
36413641

3642+
self->shardsAffectedByTeamFailure->traceTeamShardMapping();
3643+
36423644
// TODO: re-enable the following logging or remove them.
36433645
// TraceEvent("LocalityRecordKeyName", self->getDistributorId())
36443646
// .detail("Size", internedLocalityRecordKeyNameStrings.size())
@@ -4942,6 +4944,7 @@ void DDTeamCollection::traceAllInfo(bool shouldPrint) const {
49424944
traceMachineTeamInfo();
49434945
traceLocalityArrayIndexName();
49444946
traceMachineLocalityMap();
4947+
shardsAffectedByTeamFailure->traceTeamShardMapping();
49454948
}
49464949

49474950
void DDTeamCollection::rebuildMachineLocalityMap() {

fdbserver/KeyValueStoreShardedRocksDB.actor.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,12 +1298,18 @@ class ShardManager {
12981298
int numLevels = 0;
12991299
for (auto it = cfMetadata.levels.begin(); it != cfMetadata.levels.end(); ++it) {
13001300
std::string propValue = "";
1301-
ASSERT(shard->db->GetProperty(shard->cf,
1302-
rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix +
1303-
std::to_string(it->level),
1304-
&propValue));
1305-
e.detail("Level" + std::to_string(it->level),
1306-
std::to_string(it->size) + " " + propValue + " " + std::to_string(it->files.size()));
1301+
if (SERVER_KNOBS->SHARDED_ROCKSDB_DETAILED_STATS) {
1302+
ASSERT(shard->db->GetProperty(shard->cf,
1303+
rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix +
1304+
std::to_string(it->level),
1305+
&propValue));
1306+
e.detail("Level" + std::to_string(it->level),
1307+
std::to_string(it->size) + " " + propValue + " " +
1308+
std::to_string(it->files.size()));
1309+
}
1310+
if (it->level == 0) {
1311+
e.detail("Level0Files", it->files.size());
1312+
}
13071313
if (it->size > 0) {
13081314
++numLevels;
13091315
}

fdbserver/ShardsAffectedByTeamFailure.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,34 @@ void ShardsAffectedByTeamFailure::setCheckMode(CheckMode mode) {
196196
checkMode = mode;
197197
}
198198

199+
void ShardsAffectedByTeamFailure::traceTeamShardMapping() const {
200+
Team prevTeam;
201+
int count = 0;
202+
int teamCount;
203+
for (auto it = team_shards.begin(); it != team_shards.end(); ++it) {
204+
if (it->first != prevTeam) {
205+
if (count > 0) {
206+
TraceEvent("DDTeamShardCount")
207+
.detail("IsPrimary", prevTeam.primary)
208+
.detail("Team", prevTeam.toString())
209+
.detail("Shards", count);
210+
}
211+
count = 1;
212+
prevTeam = it->first;
213+
++teamCount;
214+
} else {
215+
++count;
216+
}
217+
}
218+
if (count > 0) {
219+
TraceEvent("DDTeamShardCount")
220+
.detail("IsPrimary", prevTeam.primary)
221+
.detail("Team", prevTeam.toString())
222+
.detail("Shards", count);
223+
}
224+
TraceEvent("DDTeamShardStats").detail("TotalShards", team_shards.size()).detail("TotalTeams", teamCount);
225+
}
226+
199227
void ShardsAffectedByTeamFailure::check() const {
200228
if (checkMode == CheckMode::ForceNoCheck)
201229
return;

fdbserver/include/fdbserver/ShardsAffectedByTeamFailure.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class ShardsAffectedByTeamFailure : public ReferenceCounted<ShardsAffectedByTeam
106106
void assignRangeToTeams(KeyRangeRef keys, const std::vector<Team>& destinationTeam);
107107
void check() const;
108108
void setCheckMode(CheckMode);
109+
// Prints the team shard mapping as trace events.
110+
void traceTeamShardMapping() const;
109111

110112
PromiseStream<KeyRange> restartShardTracker;
111113

0 commit comments

Comments
 (0)