From bc757f3e4b3708f6057c97fba034a2ce2c4c876e Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:14:54 -0800 Subject: [PATCH 001/225] basic framework for range feed support --- fdbcli/fdbcli.actor.cpp | 38 ++++++++++++++++++++ fdbclient/DatabaseContext.h | 2 ++ fdbclient/NativeAPI.actor.cpp | 49 ++++++++++++++++++++++++++ fdbclient/NativeAPI.actor.h | 2 ++ fdbclient/StorageServerInterface.h | 39 +++++++++++++++++++++ fdbclient/SystemData.cpp | 19 ++++++++++ fdbclient/SystemData.h | 6 ++++ fdbserver/ApplyMetadataMutation.cpp | 22 ++++++++++++ fdbserver/storageserver.actor.cpp | 54 ++++++++++++++++++++++++++--- flow/ProtocolVersion.h | 1 + 10 files changed, 228 insertions(+), 4 deletions(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 12a6a0a11d..1d7689bc10 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -617,6 +617,10 @@ void initHelp() { helpMap["triggerddteaminfolog"] = CommandHelp("triggerddteaminfolog", "trigger the data distributor teams logging", "Trigger the data distributor to log detailed information about its teams."); + helpMap["rangefeed"] = CommandHelp( + "rangefeed ", + "", + ""); hiddenCommands.insert("expensive_data_check"); hiddenCommands.insert("datadistribution"); @@ -3267,6 +3271,40 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { continue; } + if (tokencmp(tokens[0], "rangefeed")) { + if(tokens.size() == 1) { + printUsage(tokens[0]); + is_error = true; + continue; + } + if(tokencmp(tokens[1], "register")) { + if(tokens.size() != 5) { + printUsage(tokens[0]); + is_error = true; + continue; + } + state Transaction trx(db); + loop { + try { + wait(trx.registerRangeFeed(tokens[2], KeyRangeRef(tokens[3], tokens[4]))); + wait(trx.commit()); + } catch( Error &e ) { + wait(trx.onError(e)); + } + } + } else if(tokencmp(tokens[1], "get")) { + if(tokens.size() != 3) { + printUsage(tokens[0]); + is_error = true; + continue; + } + Standalone res = wait(db->getRangeFeedMutations(tokens[2])); + for(auto& it : res) { + printf("%lld %s\n", it.version, it.mutation.toString().c_str()); + } + } + } + if (tokencmp(tokens[0], "configure")) { bool err = wait(configure(db, tokens, db->getConnectionFile(), &linenoise, warn)); if (err) is_error = true; diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index 831bf5d80a..dd4ae2d186 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -236,6 +236,8 @@ public: // Management API, create snapshot Future createSnapshot(StringRef uid, StringRef snapshot_command); + Future> getRangeFeedMutations(StringRef rangeID); + //private: explicit DatabaseContext( Reference>> connectionFile, Reference> clientDBInfo, Future clientInfoMonitor, TaskPriority taskID, LocalityData const& clientLocality, diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 32e6df4acf..20294fe4bd 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -3093,6 +3093,24 @@ Future< Standalone< VectorRef< const char*>>> Transaction::getAddressesForKey( c return getAddressesForKeyActor(key, ver, cx, info, options); } +ACTOR Future registerRangeFeedActor(StringRef rangeID, KeyRangeRef range, Future ver, Database cx, + TransactionInfo info, + TransactionOptions options) { + state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); + Optional val = wait( getValue(ver, rangeIDKey, cx, info, trLogInfo, options.readTags) ); + if(!val.present()) { + set(rangeIDKey, rangeFeedValue(range)); + } else if(decodeRangeFeedValue(val.get()) != range) { + throw unsupported_operation(); + } + return Void(); +} + +Future Transaction::registerRangeFeed( const StringRef& rangeID, const KeyRangeRef& range ) { + auto ver = getReadVersion(); + return registerRangeFeedActor(rangeID, range, ver, cx, info, options); +} + ACTOR Future< Key > getKeyAndConflictRange( Database cx, KeySelector k, Future version, Promise> conflictRange, TransactionInfo info, TagSet tags) { @@ -5025,3 +5043,34 @@ Future DatabaseContext::createSnapshot(StringRef uid, } return createSnapshotActor(this, UID::fromString(uid_str), snapshot_command); } + +ACTOR Future>> getRangeFeedMutationsActor(Reference db, StringRef rangeID) { + state Database cx(db); + state Transaction tr(cx); + state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); + state Span span("NAPI:GetRangeFeedMutations"_loc); + Optional val = wait( tr.get(rangeIDKey) ); + if(!val.present()) { + throw unsupported_operation(); + } + KeyRange keys = decodeRangeFeedValue(val.get()); + state vector< pair> > locations = wait( getKeyRangeLocations( cx, keys, 100, + false, &StorageServerInterface::rangeFeed, TransactionInfo(TaskPriority::DefaultEndpoint, span.context) ) ); + + if(locations.size() > 1) { + throw unsupported_operation(); + } + + state RangeFeedRequest req; + req.rangeID = rangeID; + + RangeFeedReply rep = + wait(loadBalance(cx.getPtr(), locations[0].second, &StorageServerInterface::rangeFeed, req, + TaskPriority::DefaultPromiseEndpoint, false, + cx->enableLocalityLoadBalance ? &cx->queueModel : nullptr)); + return Standalone>(rep.mutations, rep.arena); +} + +Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID) { + return getRangeFeedMutationsActor(Reference::addRef(this), rangeID); +} diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h index 1be191e16c..385f106ca3 100644 --- a/fdbclient/NativeAPI.actor.h +++ b/fdbclient/NativeAPI.actor.h @@ -255,6 +255,8 @@ public: [[nodiscard]] Future>> getAddressesForKey(const Key& key); + Future registerRangeFeed(const Key& rangeID, const KeyRange& range); + void enableCheckWrites(); void addReadConflictRange( KeyRangeRef const& keys ); void addWriteConflictRange( KeyRangeRef const& keys ); diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index e6a4e18f89..8c74e554e3 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -73,6 +73,7 @@ struct StorageServerInterface { RequestStream watchValue; RequestStream getReadHotRanges; RequestStream getRangeSplitPoints; + RequestStream rangeFeed; explicit StorageServerInterface(UID uid) : uniqueID( uid ) {} StorageServerInterface() : uniqueID( deterministicRandom()->randomUniqueID() ) {} @@ -101,6 +102,7 @@ struct StorageServerInterface { watchValue = RequestStream( getValue.getEndpoint().getAdjustedEndpoint(10) ); getReadHotRanges = RequestStream( getValue.getEndpoint().getAdjustedEndpoint(11) ); getRangeSplitPoints = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(12)); + rangeFeed = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(13)); } } else { ASSERT(Ar::isDeserializing); @@ -129,6 +131,7 @@ struct StorageServerInterface { streams.push_back(watchValue.getReceiver()); streams.push_back(getReadHotRanges.getReceiver()); streams.push_back(getRangeSplitPoints.getReceiver()); + streams.push_back(rangeFeed.getReceiver()); FlowTransport::transport().addEndpoints(streams); } }; @@ -516,6 +519,42 @@ struct SplitRangeRequest { } }; +struct MutationRefAndVersion { + MutationRef mutation; + Version version; + + MutationRefAndVersion(MutationRef mutation, Version version, Arena arena) : mutation(mutation), version(version) {} + + template + void serialize(Ar& ar) { + serializer(ar, mutation, version); + } +}; + +struct RangeFeedReply { + constexpr static FileIdentifier file_identifier = 11815134; + VectorRef mutations; + Arena arena; + + template + void serialize(Ar& ar) { + serializer(ar, mutations, arena); + } +}; +struct RangeFeedRequest { + constexpr static FileIdentifier file_identifier = 10726174; + Key rangeID; + ReplyPromise reply; + + RangeFeedRequest() {} + RangeFeedRequest(Key const& rangeID) : rangeID(rangeID) {} + + template + void serialize(Ar& ar) { + serializer(ar, rangeID, reply); + } +}; + struct GetStorageMetricsReply { constexpr static FileIdentifier file_identifier = 15491478; StorageMetrics load; diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 54bb0003e4..94f8e3293b 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -1062,3 +1062,22 @@ const KeyRangeRef testOnlyTxnStateStorePrefixRange( const KeyRef writeRecoveryKey = LiteralStringRef("\xff/writeRecovery"); const ValueRef writeRecoveryKeyTrue = LiteralStringRef("1"); const KeyRef snapshotEndVersionKey = LiteralStringRef("\xff/snapshotEndVersion"); + +const KeyRangeRef rangeFeedKeys( + LiteralStringRef("\xff\x02/feed/"), + LiteralStringRef("\xff\x02/feed0") +); +const KeyRef rangeFeedPrefix = rangeFeedKeys.begin; +const KeyRef rangeFeedPrivatePrefix = LiteralStringRef("\xff\xff\x02/feed/"); + +const Value rangeFeedValue( KeyRangeRef const& range ) { + BinaryWriter wr(IncludeVersion(ProtocolVersion::withRangeFeed())); + wr << range; + return wr.toValue(); +} +KeyRange decodeFeedValue( ValueRef const& value ) { + KeyRange range; + BinaryReader reader( value, IncludeVersion() ); + reader >> range; + return range; +} diff --git a/fdbclient/SystemData.h b/fdbclient/SystemData.h index 4a5c5c5a19..89e8ff3bf0 100644 --- a/fdbclient/SystemData.h +++ b/fdbclient/SystemData.h @@ -461,6 +461,12 @@ extern const ValueRef writeRecoveryKeyTrue; // Allows incremental restore to read and set starting version for consistency. extern const KeyRef snapshotEndVersionKey; +extern const KeyRangeRef rangeFeedKeys; +const Value rangeFeedValue( KeyRangeRef const& range ); +KeyRange decodeRangeFeedValue( ValueRef const& value ); +extern const KeyRef rangeFeedPrefix; +extern const KeyRef rangeFeedPrivatePrefix; + #pragma clang diagnostic pop #endif diff --git a/fdbserver/ApplyMetadataMutation.cpp b/fdbserver/ApplyMetadataMutation.cpp index e6cabc8d1a..cf804870af 100644 --- a/fdbserver/ApplyMetadataMutation.cpp +++ b/fdbserver/ApplyMetadataMutation.cpp @@ -308,6 +308,28 @@ void applyMetadataMutations(SpanID const& spanContext, UID const& dbgid, Arena& TraceEvent("WriteRecoveryKeySet", dbgid); if (!initialCommit) txnStateStore->set(KeyValueRef(m.param1, m.param2)); TEST(true); // Snapshot created, setting writeRecoveryKey in txnStateStore + } else if (m.param1.startsWith(rangeFeedPrefix)) { + if(toCommit && keyInfo) { + KeyRange r = decodeRangeFeedValue( m.param2 ); + MutationRef privatized = m; + privatized.param1 = m.param1.withPrefix(systemKeys.begin, arena); + auto ranges = keyInfo->intersectingRanges(r); + auto firstRange = ranges.begin(); + ++firstRange; + if (firstRange == ranges.end()) { + ranges.begin().value().populateTags(); + toCommit->addTags(ranges.begin().value().tags); + } + else { + std::set allSources; + for (auto r : ranges) { + r.value().populateTags(); + allSources.insert(r.value().tags.begin(), r.value().tags.end()); + } + toCommit->addTags(allSources); + } + toCommit->writeTypedMessage(privatized); + } } } else if (m.param2.size() > 1 && m.param2[0] == systemKeys.begin[0] && m.type == MutationRef::ClearRange) { KeyRangeRef range(m.param1, m.param2); diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index d111ef076e..70b08a594c 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -259,6 +259,12 @@ struct FetchInjectionInfo { vector changes; }; +struct RangeFeedInfo : ReferenceCounted { + std::deque mutations; + KeyRange range; + Key id; +}; + struct StorageServer { typedef VersionedMap VersionedData; @@ -436,7 +442,9 @@ public: KeyRangeMap< Reference > shards; uint64_t shardChangeCounter; // max( shards->changecounter ) - KeyRangeMap cachedRangeMap; // indicates if a key-range is being cached + KeyRangeMap cachedRangeMap; // indicates if a key-range is being cached + KeyRangeMap>> keyRangeFeed; + std::unordered_map> uidRangeFeed; // newestAvailableVersion[k] // == invalidVersion -> k is unavailable at all versions @@ -492,7 +500,6 @@ public: FlowLock durableVersionLock; FlowLock fetchKeysParallelismLock; vector< Promise > readyFetchKeys; - int64_t instanceID; Promise otherError; @@ -1206,6 +1213,16 @@ ACTOR Future watchValueQ( StorageServer* data, WatchValueRequest req ) { } } +ACTOR Future rangeFeedQ( StorageServer* data, RangeFeedRequest req ) { + wait(delay(0)); + RangeFeedReply reply; + for(auto& it : data->uidRangeFeed[req.rangeID]->mutations) { + reply.mutations.push_back(reply.arena, it); + } + req.reply.send(reply); + return Void(); +} + ACTOR Future getShardState_impl( StorageServer* data, GetShardStateRequest req ) { ASSERT( req.mode != GetShardStateRequest::NO_WAIT ); @@ -2001,7 +2018,7 @@ bool expandMutation( MutationRef& m, StorageServer::VersionedData const& data, U return true; } -void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, StorageServer::VersionedData &data ) { +void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, StorageServer::VersionedData &data, Version version ) { // m is expected to be in arena already // Clear split keys are added to arena StorageMetrics metrics; @@ -2027,12 +2044,21 @@ void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, Sto } data.insert( m.param1, ValueOrClearToRef::value(m.param2) ); self->watches.trigger( m.param1 ); + + for(auto& it : self->keyRangeFeed[m.param1]) { + it->mutations.emplace_back(m,version); + } } else if (m.type == MutationRef::ClearRange) { data.erase( m.param1, m.param2 ); ASSERT( m.param2 > m.param1 ); ASSERT( !data.isClearContaining( data.atLatest(), m.param1 ) ); data.insert( m.param1, ValueOrClearToRef::clearTo(m.param2) ); self->watches.triggerRange( m.param1, m.param2 ); + + auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); + for(auto &it : ranges) { + it.value()->mutations.emplace_back(m,version); + } } } @@ -2720,7 +2746,7 @@ void StorageServer::addMutation(Version version, MutationRef const& mutation, Ke } expanded = addMutationToMutationLog(mLog, expanded); DEBUG_MUTATION("applyMutation", version, expanded).detail("UID", thisServerID).detail("ShardBegin", shard.begin).detail("ShardEnd", shard.end); - applyMutation( this, expanded, mLog.arena(), mutableData() ); + applyMutation( this, expanded, mLog.arena(), mutableData(), version ); //printf("\nSSUpdate: Printing versioned tree after applying mutation\n"); //mutableData().printTree(version); } @@ -2850,6 +2876,18 @@ private: data->primaryLocality = BinaryReader::fromStringRef(m.param2, Unversioned()); auto& mLV = data->addVersionToMutationLog( data->data().getLatestVersion() ); data->addMutationToMutationLog( mLV, MutationRef(MutationRef::SetValue, persistPrimaryLocality, m.param2) ); + } else if (m.type == MutationRef::SetValue && m.param1.startsWith(rangeFeedPrivatePrefix)) { + Key rangeFeedId = m.param1.removePrefix(rangeFeedPrivatePrefix); + KeyRange rangeFeedRange = decodeRangeFeedValue( m.param2 ); + Reference rangeFeedInfo( new RangeFeedInfo() ); + rangeFeedInfo->range = rangeFeedRange; + rangeFeedInfo->id = rangeFeedId; + data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; + auto rs = data->keyRangeFeed.modify( rangeFeedRange ); + for(auto r = rs.begin(); r != rs.end(); ++r) { + r->value().push_back( rangeFeedInfo ); + } + data->uidRangeFeed.coalesce( rangeFeedRange ); } else { ASSERT(false); // Unknown private mutation } @@ -3900,6 +3938,13 @@ ACTOR Future serveWatchValueRequests( StorageServer* self, FutureStream serveRangeFeedRequests( StorageServer* self, FutureStream rangeFeed ) { + loop { + RangeFeedRequest req = waitNext(rangeFeed); + self->actors.add(self->readGuard(req, rangeFeedQ)); + } +} + ACTOR Future reportStorageServerState(StorageServer* self) { if (!SERVER_KNOBS->REPORT_DD_METRICS) { return Void(); @@ -3948,6 +3993,7 @@ ACTOR Future storageServerCore( StorageServer* self, StorageServerInterfac self->actors.add(serveGetKeyValuesRequests(self, ssi.getKeyValues.getFuture())); self->actors.add(serveGetKeyRequests(self, ssi.getKey.getFuture())); self->actors.add(serveWatchValueRequests(self, ssi.watchValue.getFuture())); + self->actors.add(serveRangeFeedRequests(self, ssi.rangeFeed.getFuture())); self->actors.add(traceRole(Role::STORAGE_SERVER, ssi.id())); self->actors.add(reportStorageServerState(self)); diff --git a/flow/ProtocolVersion.h b/flow/ProtocolVersion.h index 3ee31959ab..4578f40d39 100644 --- a/flow/ProtocolVersion.h +++ b/flow/ProtocolVersion.h @@ -132,6 +132,7 @@ public: // introduced features PROTOCOL_VERSION_FEATURE(0x0FDB00B070010000LL, StableInterfaces); PROTOCOL_VERSION_FEATURE(0x0FDB00B070010001LL, TagThrottleValueReason); PROTOCOL_VERSION_FEATURE(0x0FDB00B070010001LL, SpanContext); + PROTOCOL_VERSION_FEATURE(0x0FDB00B070010001LL, RangeFeed); }; // These impact both communications and the deserialization of certain database and IKeyValueStore keys. From 7c3403c3dd622f4222619bbebf13f8af8ec7cb05 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:29:18 -0800 Subject: [PATCH 002/225] added missing include --- fdbclient/StorageServerInterface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 8c74e554e3..25b067cb8a 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -30,6 +30,7 @@ #include "fdbrpc/Stats.h" #include "fdbrpc/TimedRequest.h" #include "fdbclient/TagThrottle.h" +#include "fdbclient/CommitTransaction.h" // Dead code, removed in the next protocol version struct VersionReply { From bfc5ec92419afd6ead5992db9bc2def8993280a9 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:32:16 -0800 Subject: [PATCH 003/225] fixed mutationRefAnfVersion constructor --- fdbclient/StorageServerInterface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 25b067cb8a..d128cdf45f 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -524,7 +524,8 @@ struct MutationRefAndVersion { MutationRef mutation; Version version; - MutationRefAndVersion(MutationRef mutation, Version version, Arena arena) : mutation(mutation), version(version) {} + MutationRefAndVersion() {} + MutationRefAndVersion(MutationRef mutation, Version version) : mutation(mutation), version(version) {} template void serialize(Ar& ar) { From 77769aabee9013386d0e67986efd9593b4b7beb3 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:33:32 -0800 Subject: [PATCH 004/225] fixed compile error --- fdbclient/DatabaseContext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index dd4ae2d186..863c382dcd 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -236,7 +236,7 @@ public: // Management API, create snapshot Future createSnapshot(StringRef uid, StringRef snapshot_command); - Future> getRangeFeedMutations(StringRef rangeID); + Future>> getRangeFeedMutations(StringRef rangeID); //private: explicit DatabaseContext( Reference>> connectionFile, Reference> clientDBInfo, From adaa67df6317af9fdb81aa1172d83a609a5239f0 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:42:36 -0800 Subject: [PATCH 005/225] fix registerRangeFeedActor --- fdbclient/NativeAPI.actor.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 20294fe4bd..c6354b1fc3 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -3093,13 +3093,11 @@ Future< Standalone< VectorRef< const char*>>> Transaction::getAddressesForKey( c return getAddressesForKeyActor(key, ver, cx, info, options); } -ACTOR Future registerRangeFeedActor(StringRef rangeID, KeyRangeRef range, Future ver, Database cx, - TransactionInfo info, - TransactionOptions options) { +ACTOR Future registerRangeFeedActor(Transaction *tr, StringRef rangeID, KeyRangeRef range) { state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); - Optional val = wait( getValue(ver, rangeIDKey, cx, info, trLogInfo, options.readTags) ); + Optional val = wait( tr->get(rangeIDKey) ); if(!val.present()) { - set(rangeIDKey, rangeFeedValue(range)); + tr->set(rangeIDKey, rangeFeedValue(range)); } else if(decodeRangeFeedValue(val.get()) != range) { throw unsupported_operation(); } @@ -3107,8 +3105,7 @@ ACTOR Future registerRangeFeedActor(StringRef rangeID, KeyRangeRef range, } Future Transaction::registerRangeFeed( const StringRef& rangeID, const KeyRangeRef& range ) { - auto ver = getReadVersion(); - return registerRangeFeedActor(rangeID, range, ver, cx, info, options); + return registerRangeFeedActor(this, rangeID, range); } ACTOR Future< Key > getKeyAndConflictRange( From 21822e49498d9aee2f30c43149b60cafc59cb537 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:46:32 -0800 Subject: [PATCH 006/225] more fixes --- fdbclient/NativeAPI.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index c6354b1fc3..13a06e25bd 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -3093,7 +3093,7 @@ Future< Standalone< VectorRef< const char*>>> Transaction::getAddressesForKey( c return getAddressesForKeyActor(key, ver, cx, info, options); } -ACTOR Future registerRangeFeedActor(Transaction *tr, StringRef rangeID, KeyRangeRef range) { +ACTOR Future registerRangeFeedActor(Transaction *tr, Key rangeID, KeyRange range) { state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); Optional val = wait( tr->get(rangeIDKey) ); if(!val.present()) { @@ -3104,7 +3104,7 @@ ACTOR Future registerRangeFeedActor(Transaction *tr, StringRef rangeID, Ke return Void(); } -Future Transaction::registerRangeFeed( const StringRef& rangeID, const KeyRangeRef& range ) { +Future Transaction::registerRangeFeed( const Key& rangeID, const KeyRange& range ) { return registerRangeFeedActor(this, rangeID, range); } From 83187f9c0e43c7379ae5803dcc22a134a7cd275e Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:48:48 -0800 Subject: [PATCH 007/225] rangeID is a key --- fdbserver/storageserver.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 70b08a594c..4ea7f3f902 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -444,7 +444,7 @@ public: KeyRangeMap cachedRangeMap; // indicates if a key-range is being cached KeyRangeMap>> keyRangeFeed; - std::unordered_map> uidRangeFeed; + std::unordered_map> uidRangeFeed; // newestAvailableVersion[k] // == invalidVersion -> k is unavailable at all versions From d071f4871682a708c51822f25ee84125b09e4e49 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:53:24 -0800 Subject: [PATCH 008/225] added missing load balance field --- fdbclient/StorageServerInterface.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index d128cdf45f..2fdaeaf080 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -536,8 +536,11 @@ struct MutationRefAndVersion { struct RangeFeedReply { constexpr static FileIdentifier file_identifier = 11815134; VectorRef mutations; + bool cached; Arena arena; + RangeFeedReply() : cached(false) {} + template void serialize(Ar& ar) { serializer(ar, mutations, arena); From b7df90ec66987d9f05b8eb923f7508253bf84e9b Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 19:57:33 -0800 Subject: [PATCH 009/225] change to an ordered map for now --- fdbserver/storageserver.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 4ea7f3f902..63a9b58870 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -444,7 +444,7 @@ public: KeyRangeMap cachedRangeMap; // indicates if a key-range is being cached KeyRangeMap>> keyRangeFeed; - std::unordered_map> uidRangeFeed; + std::map> uidRangeFeed; // newestAvailableVersion[k] // == invalidVersion -> k is unavailable at all versions From 14ea90b34b39eff7f21f667e80393ffd594f34ee Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 20:04:37 -0800 Subject: [PATCH 010/225] more compile fixes --- fdbserver/storageserver.actor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 63a9b58870..49155ed637 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -2056,8 +2056,10 @@ void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, Sto self->watches.triggerRange( m.param1, m.param2 ); auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); - for(auto &it : ranges) { - it.value()->mutations.emplace_back(m,version); + for(auto &r : ranges) { + for(auto& it : r.value()) { + it->mutations.emplace_back(m,version); + } } } @@ -2887,7 +2889,7 @@ private: for(auto r = rs.begin(); r != rs.end(); ++r) { r->value().push_back( rangeFeedInfo ); } - data->uidRangeFeed.coalesce( rangeFeedRange ); + data->keyRangeFeed.coalesce( rangeFeedRange ); } else { ASSERT(false); // Unknown private mutation } From 371f11861d8327364cd9217ea9eb59082ef946bb Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 20:11:22 -0800 Subject: [PATCH 011/225] compile fixes --- fdbserver/storageserver.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 49155ed637..5a6b07e379 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -2889,7 +2889,7 @@ private: for(auto r = rs.begin(); r != rs.end(); ++r) { r->value().push_back( rangeFeedInfo ); } - data->keyRangeFeed.coalesce( rangeFeedRange ); + data->keyRangeFeed.coalesce( rangeFeedRange.contents() ); } else { ASSERT(false); // Unknown private mutation } From 0c72e5a9cb9186ac9baa3c34cec5bed6878d77b8 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 20:22:42 -0800 Subject: [PATCH 012/225] fixed name of function --- fdbclient/SystemData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 94f8e3293b..9495bd6207 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -1075,7 +1075,7 @@ const Value rangeFeedValue( KeyRangeRef const& range ) { wr << range; return wr.toValue(); } -KeyRange decodeFeedValue( ValueRef const& value ) { +KeyRange decodeRangeFeedValue( ValueRef const& value ) { KeyRange range; BinaryReader reader( value, IncludeVersion() ); reader >> range; From 7d0a86395dbafdf48f6e4fb3563eb6e7a1fd6c35 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 20:31:16 -0800 Subject: [PATCH 013/225] compile fix --- fdbcli/fdbcli.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 1d7689bc10..1872c0f160 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3298,7 +3298,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { is_error = true; continue; } - Standalone res = wait(db->getRangeFeedMutations(tokens[2])); + Standalone> res = wait(db->getRangeFeedMutations(tokens[2])); for(auto& it : res) { printf("%lld %s\n", it.version, it.mutation.toString().c_str()); } From fa39ea35b4f24c7ce5822c950238aea4e2a2a5f4 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 20:42:32 -0800 Subject: [PATCH 014/225] added missing break --- fdbcli/fdbcli.actor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 1872c0f160..0555849784 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3288,6 +3288,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { try { wait(trx.registerRangeFeed(tokens[2], KeyRangeRef(tokens[3], tokens[4]))); wait(trx.commit()); + break; } catch( Error &e ) { wait(trx.onError(e)); } From 78a74aab8ee10580f3d6f9084f891193af9db0fa Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 21:17:29 -0800 Subject: [PATCH 015/225] added logging --- fdbserver/storageserver.actor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 5a6b07e379..74540ff442 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -1219,6 +1219,7 @@ ACTOR Future rangeFeedQ( StorageServer* data, RangeFeedRequest req ) { for(auto& it : data->uidRangeFeed[req.rangeID]->mutations) { reply.mutations.push_back(reply.arena, it); } + TraceEvent("RangeFeedQuery", data->thisServerID).detail("RangeID", req.rangeID.printable()).detail("Mutations", reply.mutations.size()); req.reply.send(reply); return Void(); } @@ -2890,6 +2891,7 @@ private: r->value().push_back( rangeFeedInfo ); } data->keyRangeFeed.coalesce( rangeFeedRange.contents() ); + TraceEvent("AddingRangeFeed", data->thisServerID).detail("RangeID", rangeFeedId.printable()).detail("Range", rangeFeedRange.toString()); } else { ASSERT(false); // Unknown private mutation } From e25aac49880a5e00d0d563fc328789f284bb74bb Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 21:31:21 -0800 Subject: [PATCH 016/225] added missing continue --- fdbcli/fdbcli.actor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 0555849784..4ae1be7715 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3304,6 +3304,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { printf("%lld %s\n", it.version, it.mutation.toString().c_str()); } } + continue; } if (tokencmp(tokens[0], "configure")) { From 4a7358b0c4c083a15b409f02f18862229c5df46b Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 21:44:02 -0800 Subject: [PATCH 017/225] disable range feeds temporarily --- fdbserver/storageserver.actor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 74540ff442..ebbf4e68de 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -2882,6 +2882,8 @@ private: } else if (m.type == MutationRef::SetValue && m.param1.startsWith(rangeFeedPrivatePrefix)) { Key rangeFeedId = m.param1.removePrefix(rangeFeedPrivatePrefix); KeyRange rangeFeedRange = decodeRangeFeedValue( m.param2 ); + TraceEvent("AddingRangeFeed", data->thisServerID).detail("RangeID", rangeFeedId.printable()).detail("Range", rangeFeedRange.toString()); + /* Reference rangeFeedInfo( new RangeFeedInfo() ); rangeFeedInfo->range = rangeFeedRange; rangeFeedInfo->id = rangeFeedId; @@ -2891,7 +2893,7 @@ private: r->value().push_back( rangeFeedInfo ); } data->keyRangeFeed.coalesce( rangeFeedRange.contents() ); - TraceEvent("AddingRangeFeed", data->thisServerID).detail("RangeID", rangeFeedId.printable()).detail("Range", rangeFeedRange.toString()); + */ } else { ASSERT(false); // Unknown private mutation } From 077d5cb7744068ebd82d98f642660a52485d7dce Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 22:05:00 -0800 Subject: [PATCH 018/225] more logging --- fdbserver/ApplyMetadataMutation.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fdbserver/ApplyMetadataMutation.cpp b/fdbserver/ApplyMetadataMutation.cpp index cf804870af..1bfb29bb57 100644 --- a/fdbserver/ApplyMetadataMutation.cpp +++ b/fdbserver/ApplyMetadataMutation.cpp @@ -318,7 +318,8 @@ void applyMetadataMutations(SpanID const& spanContext, UID const& dbgid, Arena& ++firstRange; if (firstRange == ranges.end()) { ranges.begin().value().populateTags(); - toCommit->addTags(ranges.begin().value().tags); + TraceEvent("RangeFeedTags1").detail("Tags", describe(ranges.begin().value().tags)); + //toCommit->addTags(ranges.begin().value().tags); } else { std::set allSources; @@ -326,9 +327,10 @@ void applyMetadataMutations(SpanID const& spanContext, UID const& dbgid, Arena& r.value().populateTags(); allSources.insert(r.value().tags.begin(), r.value().tags.end()); } - toCommit->addTags(allSources); + TraceEvent("RangeFeedTags2").detail("Tags", describe(allSources)); + //toCommit->addTags(allSources); } - toCommit->writeTypedMessage(privatized); + //toCommit->writeTypedMessage(privatized); } } } else if (m.param2.size() > 1 && m.param2[0] == systemKeys.begin[0] && m.type == MutationRef::ClearRange) { From fcdfb608c3982ed16a994f9c72af8f95d00c5326 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 22:45:58 -0800 Subject: [PATCH 019/225] re-enabled range feeds --- fdbserver/ApplyMetadataMutation.cpp | 6 +++--- fdbserver/storageserver.actor.cpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fdbserver/ApplyMetadataMutation.cpp b/fdbserver/ApplyMetadataMutation.cpp index 1bfb29bb57..2ab63d9413 100644 --- a/fdbserver/ApplyMetadataMutation.cpp +++ b/fdbserver/ApplyMetadataMutation.cpp @@ -319,7 +319,7 @@ void applyMetadataMutations(SpanID const& spanContext, UID const& dbgid, Arena& if (firstRange == ranges.end()) { ranges.begin().value().populateTags(); TraceEvent("RangeFeedTags1").detail("Tags", describe(ranges.begin().value().tags)); - //toCommit->addTags(ranges.begin().value().tags); + toCommit->addTags(ranges.begin().value().tags); } else { std::set allSources; @@ -328,9 +328,9 @@ void applyMetadataMutations(SpanID const& spanContext, UID const& dbgid, Arena& allSources.insert(r.value().tags.begin(), r.value().tags.end()); } TraceEvent("RangeFeedTags2").detail("Tags", describe(allSources)); - //toCommit->addTags(allSources); + toCommit->addTags(allSources); } - //toCommit->writeTypedMessage(privatized); + toCommit->writeTypedMessage(privatized); } } } else if (m.param2.size() > 1 && m.param2[0] == systemKeys.begin[0] && m.type == MutationRef::ClearRange) { diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index ebbf4e68de..7f6e5dd9d2 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -2883,7 +2883,6 @@ private: Key rangeFeedId = m.param1.removePrefix(rangeFeedPrivatePrefix); KeyRange rangeFeedRange = decodeRangeFeedValue( m.param2 ); TraceEvent("AddingRangeFeed", data->thisServerID).detail("RangeID", rangeFeedId.printable()).detail("Range", rangeFeedRange.toString()); - /* Reference rangeFeedInfo( new RangeFeedInfo() ); rangeFeedInfo->range = rangeFeedRange; rangeFeedInfo->id = rangeFeedId; @@ -2893,7 +2892,6 @@ private: r->value().push_back( rangeFeedInfo ); } data->keyRangeFeed.coalesce( rangeFeedRange.contents() ); - */ } else { ASSERT(false); // Unknown private mutation } From 0865b1c70c80166884b31f86682a1060fa06cd2a Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 23:27:49 -0800 Subject: [PATCH 020/225] prevent pointing to released memory --- fdbserver/storageserver.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 7f6e5dd9d2..a827d60765 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -260,7 +260,7 @@ struct FetchInjectionInfo { }; struct RangeFeedInfo : ReferenceCounted { - std::deque mutations; + std::deque> mutations; KeyRange range; Key id; }; From 6d1878113220befa3be4389e0f2f5ff5fb2166e3 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 23:30:26 -0800 Subject: [PATCH 021/225] fix compile error --- fdbserver/storageserver.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index a827d60765..d13f751817 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -2047,7 +2047,7 @@ void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, Sto self->watches.trigger( m.param1 ); for(auto& it : self->keyRangeFeed[m.param1]) { - it->mutations.emplace_back(m,version); + it->mutations.push_back(MutationRefAndVersion(m,version)); } } else if (m.type == MutationRef::ClearRange) { data.erase( m.param1, m.param2 ); @@ -2059,7 +2059,7 @@ void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, Sto auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); for(auto &r : ranges) { for(auto& it : r.value()) { - it->mutations.emplace_back(m,version); + it->mutations.push_back(MutationRefAndVersion(m,version)); } } } From a6c9b75aa5d508b1b01cd6bcbaf2abe0013f4914 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 4 Mar 2021 23:36:41 -0800 Subject: [PATCH 022/225] add Standalone support for MutationRefAndVersion --- fdbclient/StorageServerInterface.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 2fdaeaf080..ee3b445185 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -526,6 +526,9 @@ struct MutationRefAndVersion { MutationRefAndVersion() {} MutationRefAndVersion(MutationRef mutation, Version version) : mutation(mutation), version(version) {} + MutationRefAndVersion( Arena& to, MutationRef mutation, Version version ) : mutation(to, mutation), version(version) {} + MutationRefAndVersion( Arena& to, const MutationRefAndVersion& from ) : mutation(to, from.mutation), version(from.version) {} + int expectedSize() const { return mutation.expectedSize(); } template void serialize(Ar& ar) { From 6cfba6e54be22b63590edfa91bdba2f0eff80e05 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 5 Mar 2021 11:46:33 -0800 Subject: [PATCH 023/225] added support for popping rangefeeds --- fdbcli/fdbcli.actor.cpp | 16 +++++++++++++++- fdbclient/DatabaseContext.h | 1 + fdbclient/NativeAPI.actor.cpp | 29 +++++++++++++++++++++++++++++ fdbclient/StorageServerInterface.h | 18 ++++++++++++++++++ fdbserver/storageserver.actor.cpp | 12 ++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 4ae1be7715..a351eda2fb 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -618,7 +618,7 @@ void initHelp() { CommandHelp("triggerddteaminfolog", "trigger the data distributor teams logging", "Trigger the data distributor to log detailed information about its teams."); helpMap["rangefeed"] = CommandHelp( - "rangefeed ", + "rangefeed ", "", ""); @@ -3303,6 +3303,20 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { for(auto& it : res) { printf("%lld %s\n", it.version, it.mutation.toString().c_str()); } + } else if(tokencmp(tokens[1], "pop")) { + if(tokens.size() != 4) { + printUsage(tokens[0]); + is_error = true; + continue; + } + Version v; + int n = 0; + if (sscanf(tokens[3].toString().c_str(), "%ld%n", &v, &n) != 1 || n != tokens[3].size()) { + printUsage(tokens[0]); + is_error = true; + } else { + wait(db->popRangeFeedMutations(tokens[2], v)); + } } continue; } diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index 863c382dcd..412915589c 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -237,6 +237,7 @@ public: Future createSnapshot(StringRef uid, StringRef snapshot_command); Future>> getRangeFeedMutations(StringRef rangeID); + Future popRangeFeedMutations(StringRef rangeID, Version version); //private: explicit DatabaseContext( Reference>> connectionFile, Reference> clientDBInfo, diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 13a06e25bd..6d7fe8a99c 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -5071,3 +5071,32 @@ ACTOR Future>> getRangeFeedMutations Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID) { return getRangeFeedMutationsActor(Reference::addRef(this), rangeID); } + +ACTOR Future popRangeFeedMutationsActor(Reference db, StringRef rangeID, Version version) { + state Database cx(db); + state Transaction tr(cx); + state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); + state Span span("NAPI:PopRangeFeedMutations"_loc); + Optional val = wait( tr.get(rangeIDKey) ); + if(!val.present()) { + throw unsupported_operation(); + } + KeyRange keys = decodeRangeFeedValue(val.get()); + state vector< pair> > locations = wait( getKeyRangeLocations( cx, keys, 100, + false, &StorageServerInterface::rangeFeed, TransactionInfo(TaskPriority::DefaultEndpoint, span.context) ) ); + + if(locations.size() > 1) { + throw unsupported_operation(); + } + + state std::vector> popRequests; + for(int i = 0; i < locations[0].second->size(); i++) { + popRequests.push_back(locations[0].second->getInterface(i).rangeFeedPop.getReply(RangeFeedPopRequest(rangeID, version))); + } + wait(waitForAll(popRequests)); + return Void(); +} + +Future DatabaseContext::popRangeFeedMutations(StringRef rangeID, Version version) { + return popRangeFeedMutationsActor(Reference::addRef(this), rangeID, version); +} \ No newline at end of file diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index ee3b445185..eed882dc22 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -75,6 +75,7 @@ struct StorageServerInterface { RequestStream getReadHotRanges; RequestStream getRangeSplitPoints; RequestStream rangeFeed; + RequestStream rangeFeedPop; explicit StorageServerInterface(UID uid) : uniqueID( uid ) {} StorageServerInterface() : uniqueID( deterministicRandom()->randomUniqueID() ) {} @@ -104,6 +105,7 @@ struct StorageServerInterface { getReadHotRanges = RequestStream( getValue.getEndpoint().getAdjustedEndpoint(11) ); getRangeSplitPoints = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(12)); rangeFeed = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(13)); + rangeFeedPop = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(14)); } } else { ASSERT(Ar::isDeserializing); @@ -133,6 +135,7 @@ struct StorageServerInterface { streams.push_back(getReadHotRanges.getReceiver()); streams.push_back(getRangeSplitPoints.getReceiver()); streams.push_back(rangeFeed.getReceiver()); + streams.push_back(rangeFeedPop.getReceiver()); FlowTransport::transport().addEndpoints(streams); } }; @@ -563,6 +566,21 @@ struct RangeFeedRequest { } }; +struct RangeFeedPopRequest { + constexpr static FileIdentifier file_identifier = 10726174; + Key rangeID; + Version version; + ReplyPromise reply; + + RangeFeedPopRequest() {} + RangeFeedPopRequest(Key const& rangeID, Version version) : rangeID(rangeID), version(version) {} + + template + void serialize(Ar& ar) { + serializer(ar, rangeID, version, reply); + } +}; + struct GetStorageMetricsReply { constexpr static FileIdentifier file_identifier = 15491478; StorageMetrics load; diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index d13f751817..25bfec2922 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -3949,6 +3949,17 @@ ACTOR Future serveRangeFeedRequests( StorageServer* self, FutureStream serveRangeFeedPopRequests( StorageServer* self, FutureStream rangeFeedPops ) { + loop { + RangeFeedPopRequest req = waitNext(rangeFeedPops); + while(data->uidRangeFeed[req.rangeID]->mutations.front().version < req.version) { + data->uidRangeFeed[req.rangeID]->mutations.pop_front(); + } + TraceEvent("RangeFeedPopQuery", data->thisServerID).detail("RangeID", req.rangeID.printable()).detail("Version", req.version); + req.reply.send(Void()); + } +} + ACTOR Future reportStorageServerState(StorageServer* self) { if (!SERVER_KNOBS->REPORT_DD_METRICS) { return Void(); @@ -3998,6 +4009,7 @@ ACTOR Future storageServerCore( StorageServer* self, StorageServerInterfac self->actors.add(serveGetKeyRequests(self, ssi.getKey.getFuture())); self->actors.add(serveWatchValueRequests(self, ssi.watchValue.getFuture())); self->actors.add(serveRangeFeedRequests(self, ssi.rangeFeed.getFuture())); + self->actors.add(serveRangeFeedPopRequests(self, ssi.rangeFeedPop.getFuture())); self->actors.add(traceRole(Role::STORAGE_SERVER, ssi.id())); self->actors.add(reportStorageServerState(self)); From 163e44b6b0b635ef63901f9457988084beba6c56 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 5 Mar 2021 11:50:08 -0800 Subject: [PATCH 024/225] rename data to self --- fdbserver/storageserver.actor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 25bfec2922..ed77fe7882 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -3952,10 +3952,10 @@ ACTOR Future serveRangeFeedRequests( StorageServer* self, FutureStream serveRangeFeedPopRequests( StorageServer* self, FutureStream rangeFeedPops ) { loop { RangeFeedPopRequest req = waitNext(rangeFeedPops); - while(data->uidRangeFeed[req.rangeID]->mutations.front().version < req.version) { - data->uidRangeFeed[req.rangeID]->mutations.pop_front(); + while(self->uidRangeFeed[req.rangeID]->mutations.front().version < req.version) { + self->uidRangeFeed[req.rangeID]->mutations.pop_front(); } - TraceEvent("RangeFeedPopQuery", data->thisServerID).detail("RangeID", req.rangeID.printable()).detail("Version", req.version); + TraceEvent("RangeFeedPopQuery", self->thisServerID).detail("RangeID", req.rangeID.printable()).detail("Version", req.version); req.reply.send(Void()); } } From 2621c7153a244e21fdbb949bc4e2a82439f5c466 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 30 Apr 2021 10:41:35 -0700 Subject: [PATCH 025/225] clang format PR --- documentation/tutorial/tutorial.actor.cpp | 36 +++++----- fdbclient/NativeAPI.actor.cpp | 67 ++++++++++++------- fdbclient/StorageServerInterface.h | 9 ++- fdbrpc/FlowTransport.actor.cpp | 2 +- fdbserver/storageserver.actor.cpp | 81 +++++++++++++---------- 5 files changed, 114 insertions(+), 81 deletions(-) diff --git a/documentation/tutorial/tutorial.actor.cpp b/documentation/tutorial/tutorial.actor.cpp index 5ec749b1cb..dfc684e922 100644 --- a/documentation/tutorial/tutorial.actor.cpp +++ b/documentation/tutorial/tutorial.actor.cpp @@ -1,23 +1,23 @@ /* - * tutorial.actor.cpp +* tutorial.actor.cpp - * - * 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. - */ +* +* 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. +*/ #include "flow/flow.h" #include "flow/Platform.h" diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index b96b60da96..c95ed7ba29 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -1054,14 +1054,16 @@ DatabaseContext::DatabaseContext(Reference( KeyRangeRef(LiteralStringRef("profiling/"), LiteralStringRef("profiling0")) - .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::MANAGEMENT).begin))); + .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::MANAGEMENT).begin))); registerSpecialKeySpaceModule( - SpecialKeySpace::MODULE::MANAGEMENT, SpecialKeySpace::IMPLTYPE::READWRITE, + SpecialKeySpace::MODULE::MANAGEMENT, + SpecialKeySpace::IMPLTYPE::READWRITE, std::make_unique( KeyRangeRef(LiteralStringRef("maintenance/"), LiteralStringRef("maintenance0")) .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::MANAGEMENT).begin))); registerSpecialKeySpaceModule( - SpecialKeySpace::MODULE::MANAGEMENT, SpecialKeySpace::IMPLTYPE::READWRITE, + SpecialKeySpace::MODULE::MANAGEMENT, + SpecialKeySpace::IMPLTYPE::READWRITE, std::make_unique( KeyRangeRef(LiteralStringRef("data_distribution/"), LiteralStringRef("data_distribution0")) .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::MANAGEMENT).begin))); @@ -3531,18 +3533,18 @@ Future>> Transaction::getAddressesForKey(const return getAddressesForKeyActor(key, ver, cx, info, options); } -ACTOR Future registerRangeFeedActor(Transaction *tr, Key rangeID, KeyRange range) { +ACTOR Future registerRangeFeedActor(Transaction* tr, Key rangeID, KeyRange range) { state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); - Optional val = wait( tr->get(rangeIDKey) ); - if(!val.present()) { + Optional val = wait(tr->get(rangeIDKey)); + if (!val.present()) { tr->set(rangeIDKey, rangeFeedValue(range)); - } else if(decodeRangeFeedValue(val.get()) != range) { + } else if (decodeRangeFeedValue(val.get()) != range) { throw unsupported_operation(); } return Void(); } -Future Transaction::registerRangeFeed( const Key& rangeID, const KeyRange& range ) { +Future Transaction::registerRangeFeed(const Key& rangeID, const KeyRange& range) { return registerRangeFeedActor(this, rangeID, range); } @@ -5678,30 +5680,39 @@ Future DatabaseContext::createSnapshot(StringRef uid, StringRef snapshot_c return createSnapshotActor(this, UID::fromString(uid_str), snapshot_command); } -ACTOR Future>> getRangeFeedMutationsActor(Reference db, StringRef rangeID) { +ACTOR Future>> getRangeFeedMutationsActor(Reference db, + StringRef rangeID) { state Database cx(db); state Transaction tr(cx); state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); state Span span("NAPI:GetRangeFeedMutations"_loc); - Optional val = wait( tr.get(rangeIDKey) ); - if(!val.present()) { + Optional val = wait(tr.get(rangeIDKey)); + if (!val.present()) { throw unsupported_operation(); } KeyRange keys = decodeRangeFeedValue(val.get()); - state vector< pair> > locations = wait( getKeyRangeLocations( cx, keys, 100, - false, &StorageServerInterface::rangeFeed, TransactionInfo(TaskPriority::DefaultEndpoint, span.context) ) ); + state vector>> locations = + wait(getKeyRangeLocations(cx, + keys, + 100, + false, + &StorageServerInterface::rangeFeed, + TransactionInfo(TaskPriority::DefaultEndpoint, span.context))); - if(locations.size() > 1) { + if (locations.size() > 1) { throw unsupported_operation(); } state RangeFeedRequest req; req.rangeID = rangeID; - RangeFeedReply rep = - wait(loadBalance(cx.getPtr(), locations[0].second, &StorageServerInterface::rangeFeed, req, - TaskPriority::DefaultPromiseEndpoint, false, - cx->enableLocalityLoadBalance ? &cx->queueModel : nullptr)); + RangeFeedReply rep = wait(loadBalance(cx.getPtr(), + locations[0].second, + &StorageServerInterface::rangeFeed, + req, + TaskPriority::DefaultPromiseEndpoint, + false, + cx->enableLocalityLoadBalance ? &cx->queueModel : nullptr)); return Standalone>(rep.mutations, rep.arena); } @@ -5714,21 +5725,27 @@ ACTOR Future popRangeFeedMutationsActor(Reference db, Str state Transaction tr(cx); state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); state Span span("NAPI:PopRangeFeedMutations"_loc); - Optional val = wait( tr.get(rangeIDKey) ); - if(!val.present()) { + Optional val = wait(tr.get(rangeIDKey)); + if (!val.present()) { throw unsupported_operation(); } KeyRange keys = decodeRangeFeedValue(val.get()); - state vector< pair> > locations = wait( getKeyRangeLocations( cx, keys, 100, - false, &StorageServerInterface::rangeFeed, TransactionInfo(TaskPriority::DefaultEndpoint, span.context) ) ); + state vector>> locations = + wait(getKeyRangeLocations(cx, + keys, + 100, + false, + &StorageServerInterface::rangeFeed, + TransactionInfo(TaskPriority::DefaultEndpoint, span.context))); - if(locations.size() > 1) { + if (locations.size() > 1) { throw unsupported_operation(); } state std::vector> popRequests; - for(int i = 0; i < locations[0].second->size(); i++) { - popRequests.push_back(locations[0].second->getInterface(i).rangeFeedPop.getReply(RangeFeedPopRequest(rangeID, version))); + for (int i = 0; i < locations[0].second->size(); i++) { + popRequests.push_back( + locations[0].second->getInterface(i).rangeFeedPop.getReply(RangeFeedPopRequest(rangeID, version))); } wait(waitForAll(popRequests)); return Void(); diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 566908e63c..84c2e6c14f 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -112,7 +112,8 @@ struct StorageServerInterface { getRangeSplitPoints = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(12)); rangeFeed = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(13)); - rangeFeedPop = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(14)); + rangeFeedPop = + RequestStream(getValue.getEndpoint().getAdjustedEndpoint(14)); } } else { ASSERT(Ar::isDeserializing); @@ -576,8 +577,10 @@ struct MutationRefAndVersion { MutationRefAndVersion() {} MutationRefAndVersion(MutationRef mutation, Version version) : mutation(mutation), version(version) {} - MutationRefAndVersion( Arena& to, MutationRef mutation, Version version ) : mutation(to, mutation), version(version) {} - MutationRefAndVersion( Arena& to, const MutationRefAndVersion& from ) : mutation(to, from.mutation), version(from.version) {} + MutationRefAndVersion(Arena& to, MutationRef mutation, Version version) + : mutation(to, mutation), version(version) {} + MutationRefAndVersion(Arena& to, const MutationRefAndVersion& from) + : mutation(to, from.mutation), version(from.version) {} int expectedSize() const { return mutation.expectedSize(); } template diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index 8cc9d0d8e6..bf119496cf 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -1215,7 +1215,7 @@ ACTOR static Future connectionReader(TransportData* transport, } compatible = false; if (!protocolVersion.hasInexpensiveMultiVersionClient()) { - if(peer) { + if (peer) { peer->protocolVersion->set(protocolVersion); } diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 811d24f22b..a7d9191fac 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -522,7 +522,7 @@ public: uint64_t shardChangeCounter; // max( shards->changecounter ) KeyRangeMap cachedRangeMap; // indicates if a key-range is being cached - + KeyRangeMap>> keyRangeFeed; std::map> uidRangeFeed; @@ -1394,13 +1394,15 @@ ACTOR Future watchValueSendReply(StorageServer* data, } } -ACTOR Future rangeFeedQ( StorageServer* data, RangeFeedRequest req ) { +ACTOR Future rangeFeedQ(StorageServer* data, RangeFeedRequest req) { wait(delay(0)); RangeFeedReply reply; - for(auto& it : data->uidRangeFeed[req.rangeID]->mutations) { + for (auto& it : data->uidRangeFeed[req.rangeID]->mutations) { reply.mutations.push_back(reply.arena, it); } - TraceEvent("RangeFeedQuery", data->thisServerID).detail("RangeID", req.rangeID.printable()).detail("Mutations", reply.mutations.size()); + TraceEvent("RangeFeedQuery", data->thisServerID) + .detail("RangeID", req.rangeID.printable()) + .detail("Mutations", reply.mutations.size()); req.reply.send(reply); return Void(); } @@ -2292,7 +2294,11 @@ bool expandMutation(MutationRef& m, return true; } -void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, StorageServer::VersionedData &data, Version version ) { +void applyMutation(StorageServer* self, + MutationRef const& m, + Arena& arena, + StorageServer::VersionedData& data, + Version version) { // m is expected to be in arena already // Clear split keys are added to arena StorageMetrics metrics; @@ -2321,23 +2327,23 @@ void applyMutation( StorageServer *self, MutationRef const& m, Arena& arena, Sto data.insert(nextKey, ValueOrClearToRef::clearTo(KeyRef(arena, end))); } } - data.insert( m.param1, ValueOrClearToRef::value(m.param2) ); - self->watches.trigger( m.param1 ); + data.insert(m.param1, ValueOrClearToRef::value(m.param2)); + self->watches.trigger(m.param1); - for(auto& it : self->keyRangeFeed[m.param1]) { - it->mutations.push_back(MutationRefAndVersion(m,version)); + for (auto& it : self->keyRangeFeed[m.param1]) { + it->mutations.push_back(MutationRefAndVersion(m, version)); } } else if (m.type == MutationRef::ClearRange) { - data.erase( m.param1, m.param2 ); - ASSERT( m.param2 > m.param1 ); - ASSERT( !data.isClearContaining( data.atLatest(), m.param1 ) ); - data.insert( m.param1, ValueOrClearToRef::clearTo(m.param2) ); - self->watches.triggerRange( m.param1, m.param2 ); + data.erase(m.param1, m.param2); + ASSERT(m.param2 > m.param1); + ASSERT(!data.isClearContaining(data.atLatest(), m.param1)); + data.insert(m.param1, ValueOrClearToRef::clearTo(m.param2)); + self->watches.triggerRange(m.param1, m.param2); auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); - for(auto &r : ranges) { - for(auto& it : r.value()) { - it->mutations.push_back(MutationRefAndVersion(m,version)); + for (auto& r : ranges) { + for (auto& it : r.value()) { + it->mutations.push_back(MutationRefAndVersion(m, version)); } } } @@ -3106,10 +3112,13 @@ void StorageServer::addMutation(Version version, return; } expanded = addMutationToMutationLog(mLog, expanded); - DEBUG_MUTATION("applyMutation", version, expanded).detail("UID", thisServerID).detail("ShardBegin", shard.begin).detail("ShardEnd", shard.end); - applyMutation( this, expanded, mLog.arena(), mutableData(), version ); - //printf("\nSSUpdate: Printing versioned tree after applying mutation\n"); - //mutableData().printTree(version); + DEBUG_MUTATION("applyMutation", version, expanded) + .detail("UID", thisServerID) + .detail("ShardBegin", shard.begin) + .detail("ShardEnd", shard.end); + applyMutation(this, expanded, mLog.arena(), mutableData(), version); + // printf("\nSSUpdate: Printing versioned tree after applying mutation\n"); + // mutableData().printTree(version); } struct OrderByVersion { @@ -3256,21 +3265,23 @@ private: .detail("RebootAfterDurableVersion", data->rebootAfterDurableVersion); } else if (m.type == MutationRef::SetValue && m.param1 == primaryLocalityPrivateKey) { data->primaryLocality = BinaryReader::fromStringRef(m.param2, Unversioned()); - auto& mLV = data->addVersionToMutationLog( data->data().getLatestVersion() ); - data->addMutationToMutationLog( mLV, MutationRef(MutationRef::SetValue, persistPrimaryLocality, m.param2) ); + auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); + data->addMutationToMutationLog(mLV, MutationRef(MutationRef::SetValue, persistPrimaryLocality, m.param2)); } else if (m.type == MutationRef::SetValue && m.param1.startsWith(rangeFeedPrivatePrefix)) { Key rangeFeedId = m.param1.removePrefix(rangeFeedPrivatePrefix); - KeyRange rangeFeedRange = decodeRangeFeedValue( m.param2 ); - TraceEvent("AddingRangeFeed", data->thisServerID).detail("RangeID", rangeFeedId.printable()).detail("Range", rangeFeedRange.toString()); - Reference rangeFeedInfo( new RangeFeedInfo() ); + KeyRange rangeFeedRange = decodeRangeFeedValue(m.param2); + TraceEvent("AddingRangeFeed", data->thisServerID) + .detail("RangeID", rangeFeedId.printable()) + .detail("Range", rangeFeedRange.toString()); + Reference rangeFeedInfo(new RangeFeedInfo()); rangeFeedInfo->range = rangeFeedRange; rangeFeedInfo->id = rangeFeedId; data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; - auto rs = data->keyRangeFeed.modify( rangeFeedRange ); - for(auto r = rs.begin(); r != rs.end(); ++r) { - r->value().push_back( rangeFeedInfo ); + auto rs = data->keyRangeFeed.modify(rangeFeedRange); + for (auto r = rs.begin(); r != rs.end(); ++r) { + r->value().push_back(rangeFeedInfo); } - data->keyRangeFeed.coalesce( rangeFeedRange.contents() ); + data->keyRangeFeed.coalesce(rangeFeedRange.contents()); } else { ASSERT(false); // Unknown private mutation } @@ -4508,20 +4519,22 @@ ACTOR Future serveWatchValueRequests(StorageServer* self, FutureStream serveRangeFeedRequests( StorageServer* self, FutureStream rangeFeed ) { +ACTOR Future serveRangeFeedRequests(StorageServer* self, FutureStream rangeFeed) { loop { RangeFeedRequest req = waitNext(rangeFeed); self->actors.add(self->readGuard(req, rangeFeedQ)); } } -ACTOR Future serveRangeFeedPopRequests( StorageServer* self, FutureStream rangeFeedPops ) { +ACTOR Future serveRangeFeedPopRequests(StorageServer* self, FutureStream rangeFeedPops) { loop { RangeFeedPopRequest req = waitNext(rangeFeedPops); - while(self->uidRangeFeed[req.rangeID]->mutations.front().version < req.version) { + while (self->uidRangeFeed[req.rangeID]->mutations.front().version < req.version) { self->uidRangeFeed[req.rangeID]->mutations.pop_front(); } - TraceEvent("RangeFeedPopQuery", self->thisServerID).detail("RangeID", req.rangeID.printable()).detail("Version", req.version); + TraceEvent("RangeFeedPopQuery", self->thisServerID) + .detail("RangeID", req.rangeID.printable()) + .detail("Version", req.version); req.reply.send(Void()); } } From 78697003ea290dbcb60063efb32e52aa862ccf31 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 30 Apr 2021 10:51:35 -0700 Subject: [PATCH 026/225] more formatting --- fdbcli/fdbcli.actor.cpp | 23 ++++++++++------------- fdbclient/SystemData.cpp | 19 +++++++++---------- fdbclient/SystemData.h | 4 ++-- fdbserver/ApplyMetadataMutation.cpp | 7 +++---- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 930eeaf639..9eb5f974a4 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -678,10 +678,7 @@ void initHelp() { CommandHelp("triggerddteaminfolog", "trigger the data distributor teams logging", "Trigger the data distributor to log detailed information about its teams."); - helpMap["rangefeed"] = CommandHelp( - "rangefeed ", - "", - ""); + helpMap["rangefeed"] = CommandHelp("rangefeed ", "", ""); hiddenCommands.insert("expensive_data_check"); hiddenCommands.insert("datadistribution"); @@ -3398,13 +3395,13 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { } if (tokencmp(tokens[0], "rangefeed")) { - if(tokens.size() == 1) { + if (tokens.size() == 1) { printUsage(tokens[0]); is_error = true; continue; } - if(tokencmp(tokens[1], "register")) { - if(tokens.size() != 5) { + if (tokencmp(tokens[1], "register")) { + if (tokens.size() != 5) { printUsage(tokens[0]); is_error = true; continue; @@ -3415,22 +3412,22 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { wait(trx.registerRangeFeed(tokens[2], KeyRangeRef(tokens[3], tokens[4]))); wait(trx.commit()); break; - } catch( Error &e ) { + } catch (Error& e) { wait(trx.onError(e)); } } - } else if(tokencmp(tokens[1], "get")) { - if(tokens.size() != 3) { + } else if (tokencmp(tokens[1], "get")) { + if (tokens.size() != 3) { printUsage(tokens[0]); is_error = true; continue; } Standalone> res = wait(db->getRangeFeedMutations(tokens[2])); - for(auto& it : res) { + for (auto& it : res) { printf("%lld %s\n", it.version, it.mutation.toString().c_str()); } - } else if(tokencmp(tokens[1], "pop")) { - if(tokens.size() != 4) { + } else if (tokencmp(tokens[1], "pop")) { + if (tokens.size() != 4) { printUsage(tokens[0]); is_error = true; continue; diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 3a8646d486..734728d331 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -635,15 +635,17 @@ std::string encodeFailedServersKey(AddressExclusion const& addr) { // const KeyRangeRef globalConfigKeys( LiteralStringRef("\xff/globalConfig/"), LiteralStringRef("\xff/globalConfig0") ); // const KeyRef globalConfigPrefix = globalConfigKeys.begin; -const KeyRangeRef globalConfigDataKeys( LiteralStringRef("\xff/globalConfig/k/"), LiteralStringRef("\xff/globalConfig/k0") ); +const KeyRangeRef globalConfigDataKeys(LiteralStringRef("\xff/globalConfig/k/"), + LiteralStringRef("\xff/globalConfig/k0")); const KeyRef globalConfigKeysPrefix = globalConfigDataKeys.begin; -const KeyRangeRef globalConfigHistoryKeys( LiteralStringRef("\xff/globalConfig/h/"), LiteralStringRef("\xff/globalConfig/h0") ); +const KeyRangeRef globalConfigHistoryKeys(LiteralStringRef("\xff/globalConfig/h/"), + LiteralStringRef("\xff/globalConfig/h0")); const KeyRef globalConfigHistoryPrefix = globalConfigHistoryKeys.begin; const KeyRef globalConfigVersionKey = LiteralStringRef("\xff/globalConfig/v"); -const KeyRangeRef workerListKeys( LiteralStringRef("\xff/worker/"), LiteralStringRef("\xff/worker0") ); +const KeyRangeRef workerListKeys(LiteralStringRef("\xff/worker/"), LiteralStringRef("\xff/worker0")); const KeyRef workerListPrefix = workerListKeys.begin; const Key workerListKeyFor(StringRef processID) { @@ -1085,21 +1087,18 @@ const KeyRef writeRecoveryKey = LiteralStringRef("\xff/writeRecovery"); const ValueRef writeRecoveryKeyTrue = LiteralStringRef("1"); const KeyRef snapshotEndVersionKey = LiteralStringRef("\xff/snapshotEndVersion"); -const KeyRangeRef rangeFeedKeys( - LiteralStringRef("\xff\x02/feed/"), - LiteralStringRef("\xff\x02/feed0") -); +const KeyRangeRef rangeFeedKeys(LiteralStringRef("\xff\x02/feed/"), LiteralStringRef("\xff\x02/feed0")); const KeyRef rangeFeedPrefix = rangeFeedKeys.begin; const KeyRef rangeFeedPrivatePrefix = LiteralStringRef("\xff\xff\x02/feed/"); -const Value rangeFeedValue( KeyRangeRef const& range ) { +const Value rangeFeedValue(KeyRangeRef const& range) { BinaryWriter wr(IncludeVersion(ProtocolVersion::withRangeFeed())); wr << range; return wr.toValue(); } -KeyRange decodeRangeFeedValue( ValueRef const& value ) { +KeyRange decodeRangeFeedValue(ValueRef const& value) { KeyRange range; - BinaryReader reader( value, IncludeVersion() ); + BinaryReader reader(value, IncludeVersion()); reader >> range; return range; } diff --git a/fdbclient/SystemData.h b/fdbclient/SystemData.h index 9f061963ac..d948ea4da3 100644 --- a/fdbclient/SystemData.h +++ b/fdbclient/SystemData.h @@ -492,8 +492,8 @@ extern const ValueRef writeRecoveryKeyTrue; extern const KeyRef snapshotEndVersionKey; extern const KeyRangeRef rangeFeedKeys; -const Value rangeFeedValue( KeyRangeRef const& range ); -KeyRange decodeRangeFeedValue( ValueRef const& value ); +const Value rangeFeedValue(KeyRangeRef const& range); +KeyRange decodeRangeFeedValue(ValueRef const& value); extern const KeyRef rangeFeedPrefix; extern const KeyRef rangeFeedPrivatePrefix; diff --git a/fdbserver/ApplyMetadataMutation.cpp b/fdbserver/ApplyMetadataMutation.cpp index 3879339074..aa4f4cec93 100644 --- a/fdbserver/ApplyMetadataMutation.cpp +++ b/fdbserver/ApplyMetadataMutation.cpp @@ -353,8 +353,8 @@ void applyMetadataMutations(SpanID const& spanContext, txnStateStore->set(KeyValueRef(m.param1, m.param2)); TEST(true); // Snapshot created, setting writeRecoveryKey in txnStateStore } else if (m.param1.startsWith(rangeFeedPrefix)) { - if(toCommit && keyInfo) { - KeyRange r = decodeRangeFeedValue( m.param2 ); + if (toCommit && keyInfo) { + KeyRange r = decodeRangeFeedValue(m.param2); MutationRef privatized = m; privatized.param1 = m.param1.withPrefix(systemKeys.begin, arena); auto ranges = keyInfo->intersectingRanges(r); @@ -364,8 +364,7 @@ void applyMetadataMutations(SpanID const& spanContext, ranges.begin().value().populateTags(); TraceEvent("RangeFeedTags1").detail("Tags", describe(ranges.begin().value().tags)); toCommit->addTags(ranges.begin().value().tags); - } - else { + } else { std::set allSources; for (auto r : ranges) { r.value().populateTags(); From 6c1d913ab8614cfafed4c687576bc1bb3dc08208 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 21:11:21 -0700 Subject: [PATCH 027/225] Prevent masterServer from modifying db --- fdbclient/GlobalConfig.actor.h | 2 +- fdbclient/NativeAPI.actor.cpp | 3 ++- fdbserver/WorkerInterface.actor.h | 4 ++-- fdbserver/masterserver.actor.cpp | 6 +++--- fdbserver/worker.actor.cpp | 4 ++-- flow/genericactors.actor.h | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/fdbclient/GlobalConfig.actor.h b/fdbclient/GlobalConfig.actor.h index 2d63d8de60..444f1ab697 100644 --- a/fdbclient/GlobalConfig.actor.h +++ b/fdbclient/GlobalConfig.actor.h @@ -72,7 +72,7 @@ public: // to allow global configuration to run transactions on the latest // database. template - static void create(Database& cx, Reference> db, const ClientDBInfo* dbInfo) { + static void create(Database& cx, Reference const> db, const ClientDBInfo* dbInfo) { if (g_network->global(INetwork::enGlobalConfig) == nullptr) { auto config = new GlobalConfig{ cx }; g_network->setGlobal(INetwork::enGlobalConfig, config); diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 5419ae825e..84faf6ffec 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -1756,7 +1756,8 @@ Database Database::createDatabase(Reference connFile, } auto database = Database(db); - GlobalConfig::create(database, clientInfo, std::addressof(clientInfo->get())); + GlobalConfig::create( + database, Reference const>(clientInfo), std::addressof(clientInfo->get())); return database; } diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index e642d015dd..3fedfe1c8f 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -831,7 +831,7 @@ ACTOR Future traceRole(Role role, UID roleId); struct ServerDBInfo; -class Database openDBOnServer(Reference> const& db, +class Database openDBOnServer(Reference const> const& db, TaskPriority taskID = TaskPriority::DefaultEndpoint, LockAware = LockAware::FALSE, EnableLocalityLoadBalance = EnableLocalityLoadBalance::TRUE); @@ -879,7 +879,7 @@ ACTOR Future storageServer( Reference connFile); // changes pssi->id() to be the recovered ID); // changes pssi->id() to be the recovered ID ACTOR Future masterServer(MasterInterface mi, - Reference> db, + Reference const> db, Reference>> ccInterface, ServerCoordinators serverCoordinators, LifetimeToken lifetime, diff --git a/fdbserver/masterserver.actor.cpp b/fdbserver/masterserver.actor.cpp index ea93b35f7f..b6bf046991 100644 --- a/fdbserver/masterserver.actor.cpp +++ b/fdbserver/masterserver.actor.cpp @@ -228,7 +228,7 @@ struct MasterData : NonCopyable, ReferenceCounted { ReusableCoordinatedState cstate; Promise cstateUpdated; - Reference> dbInfo; + Reference const> dbInfo; int64_t registrationCount; // Number of different MasterRegistrationRequests sent to clusterController RecoveryState recoveryState; @@ -255,7 +255,7 @@ struct MasterData : NonCopyable, ReferenceCounted { Future logger; - MasterData(Reference> const& dbInfo, + MasterData(Reference const> const& dbInfo, MasterInterface const& myInterface, ServerCoordinators const& coordinators, ClusterControllerFullInterface const& clusterController, @@ -1978,7 +1978,7 @@ ACTOR Future masterCore(Reference self) { } ACTOR Future masterServer(MasterInterface mi, - Reference> db, + Reference const> db, Reference>> ccInterface, ServerCoordinators coordinators, LifetimeToken lifetime, diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index dafcfba2e3..2ff5252320 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -122,7 +122,7 @@ ACTOR Future> broadcastDBInfoRequest(UpdateServerDBInfoReq return notUpdated; } -ACTOR static Future extractClientInfo(Reference> db, +ACTOR static Future extractClientInfo(Reference const> db, Reference> info) { state std::vector lastCommitProxyUIDs; state std::vector lastCommitProxies; @@ -136,7 +136,7 @@ ACTOR static Future extractClientInfo(Reference> db } } -Database openDBOnServer(Reference> const& db, +Database openDBOnServer(Reference const> const& db, TaskPriority taskID, LockAware lockAware, EnableLocalityLoadBalance enableLocalityLoadBalance) { diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index d04a0478f8..5cb0344ffb 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -700,7 +700,7 @@ private: // Binds an AsyncTrigger object to an AsyncVar, so when the AsyncVar changes // the AsyncTrigger is triggered. ACTOR template -void forward(Reference> from, AsyncTrigger* to) { +void forward(Reference const> from, AsyncTrigger* to) { loop { wait(from->onChange()); to->trigger(); From 8a212862f0fb11705d7d11731962f81f5256f498 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 22:04:38 -0700 Subject: [PATCH 028/225] Prevent dataDistributor from modifying ServerDBInfo object --- fdbserver/DataDistribution.actor.cpp | 20 ++++++++--------- fdbserver/QuietDatabase.actor.cpp | 31 +++++++++++++++------------ fdbserver/QuietDatabase.h | 21 +++++++++--------- fdbserver/WorkerInterface.actor.h | 2 +- fdbserver/workloads/workloads.actor.h | 2 +- 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 3829d11d2f..b0e579ff84 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -5202,7 +5202,7 @@ ACTOR Future initializeStorage(DDTeamCollection* self, } ACTOR Future storageRecruiter(DDTeamCollection* self, - Reference> db, + Reference const> db, const DDEnabledState* ddEnabledState) { state Future fCandidateWorker; state RecruitStorageRequest lastRequest; @@ -5474,7 +5474,7 @@ ACTOR Future serverGetTeamRequests(TeamCollectionInterface tci, DDTeamColl } } -ACTOR Future remoteRecovered(Reference> db) { +ACTOR Future remoteRecovered(Reference const> db) { TraceEvent("DDTrackerStarting"); while (db->get().recoveryState < RecoveryState::ALL_LOGS_RECRUITED) { TraceEvent("DDTrackerStarting").detail("RecoveryState", (int)db->get().recoveryState); @@ -5500,8 +5500,8 @@ ACTOR Future monitorHealthyTeams(DDTeamCollection* self) { ACTOR Future dataDistributionTeamCollection(Reference teamCollection, Reference initData, TeamCollectionInterface tci, - Reference> db, - const DDEnabledState* ddEnabledState) { + Reference const> db, + DDEnabledState const* ddEnabledState) { state DDTeamCollection* self = teamCollection.getPtr(); state Future loggingTrigger = Void(); state PromiseStream serverRemoved; @@ -5728,16 +5728,16 @@ ACTOR Future pollMoveKeysLock(Database cx, MoveKeysLock lock, const DDEnab } struct DataDistributorData : NonCopyable, ReferenceCounted { - Reference> dbInfo; + Reference const> dbInfo; UID ddId; PromiseStream> addActor; DDTeamCollection* teamCollection; - DataDistributorData(Reference> const& db, UID id) + DataDistributorData(Reference const> const& db, UID id) : dbInfo(db), ddId(id), teamCollection(nullptr) {} }; -ACTOR Future monitorBatchLimitedTime(Reference> db, double* lastLimited) { +ACTOR Future monitorBatchLimitedTime(Reference const> db, double* lastLimited) { loop { wait(delay(SERVER_KNOBS->METRIC_UPDATE_RATE)); @@ -6105,7 +6105,7 @@ static std::set const& normalDataDistributorErrors() { return s; } -ACTOR Future ddSnapCreateCore(DistributorSnapRequest snapReq, Reference> db) { +ACTOR Future ddSnapCreateCore(DistributorSnapRequest snapReq, Reference const> db) { state Database cx = openDBOnServer(db, TaskPriority::DefaultDelay, LockAware::TRUE); state ReadYourWritesTransaction tr(cx); loop { @@ -6249,7 +6249,7 @@ ACTOR Future ddSnapCreateCore(DistributorSnapRequest snapReq, Reference ddSnapCreate(DistributorSnapRequest snapReq, - Reference> db, + Reference const> db, DDEnabledState* ddEnabledState) { state Future dbInfoChange = db->onChange(); if (!ddEnabledState->setDDEnabled(false, snapReq.snapUID)) { @@ -6443,7 +6443,7 @@ ACTOR Future ddGetMetrics(GetDataDistributorMetricsRequest req, return Void(); } -ACTOR Future dataDistributor(DataDistributorInterface di, Reference> db) { +ACTOR Future dataDistributor(DataDistributorInterface di, Reference const> db) { state Reference self(new DataDistributorData(db, di.id())); state Future collection = actorCollection(self->addActor.getFuture()); state PromiseStream getShardMetricsList; diff --git a/fdbserver/QuietDatabase.actor.cpp b/fdbserver/QuietDatabase.actor.cpp index 47b9a9f2f3..e0915c3366 100644 --- a/fdbserver/QuietDatabase.actor.cpp +++ b/fdbserver/QuietDatabase.actor.cpp @@ -35,7 +35,7 @@ #include #include "flow/actorcompiler.h" // This must be the last #include. -ACTOR Future> getWorkers(Reference> dbInfo, int flags = 0) { +ACTOR Future> getWorkers(Reference const> dbInfo, int flags = 0) { loop { choose { when(vector w = wait(brokenPromiseToNever( @@ -48,7 +48,7 @@ ACTOR Future> getWorkers(Reference> } // Gets the WorkerInterface representing the Master server. -ACTOR Future getMasterWorker(Database cx, Reference> dbInfo) { +ACTOR Future getMasterWorker(Database cx, Reference const> dbInfo) { TraceEvent("GetMasterWorker").detail("Stage", "GettingWorkers"); loop { @@ -75,7 +75,7 @@ ACTOR Future getMasterWorker(Database cx, Reference getDataDistributorWorker(Database cx, Reference> dbInfo) { +ACTOR Future getDataDistributorWorker(Database cx, Reference const> dbInfo) { TraceEvent("GetDataDistributorWorker").detail("Stage", "GettingWorkers"); loop { @@ -118,7 +118,7 @@ ACTOR Future getDataInFlight(Database cx, WorkerInterface distributorWo } // Gets the number of bytes in flight from the data distributor. -ACTOR Future getDataInFlight(Database cx, Reference> dbInfo) { +ACTOR Future getDataInFlight(Database cx, Reference const> dbInfo) { WorkerInterface distributorInterf = wait(getDataDistributorWorker(cx, dbInfo)); int64_t dataInFlight = wait(getDataInFlight(cx, distributorInterf)); return dataInFlight; @@ -144,7 +144,7 @@ int64_t getPoppedVersionLag(const TraceEventFields& md) { return persistentDataDurableVersion - queuePoppedVersion; } -ACTOR Future> getCoordWorkers(Database cx, Reference> dbInfo) { +ACTOR Future> getCoordWorkers(Database cx, Reference const> dbInfo) { state std::vector workers = wait(getWorkers(dbInfo)); Optional coordinators = @@ -177,7 +177,8 @@ ACTOR Future> getCoordWorkers(Database cx, Reference> getTLogQueueInfo(Database cx, Reference> dbInfo) { +ACTOR Future> getTLogQueueInfo(Database cx, + Reference const> dbInfo) { TraceEvent("MaxTLogQueueSize").detail("Stage", "ContactingLogs"); state std::vector workers = wait(getWorkers(dbInfo)); @@ -245,7 +246,7 @@ ACTOR Future> getStorageServers(Database cx, bool } ACTOR Future> getStorageWorkers(Database cx, - Reference> dbInfo, + Reference const> dbInfo, bool localOnly) { state std::vector servers = wait(getStorageServers(cx)); state std::map workersMap; @@ -335,7 +336,7 @@ ACTOR Future getStorageMetricsTimeout(UID storage, WorkerInter }; // Gets the maximum size of all the storage server queues -ACTOR Future getMaxStorageServerQueueSize(Database cx, Reference> dbInfo) { +ACTOR Future getMaxStorageServerQueueSize(Database cx, Reference const> dbInfo) { TraceEvent("MaxStorageServerQueueSize").detail("Stage", "ContactingStorageServers"); Future> serversFuture = getStorageServers(cx); @@ -399,7 +400,7 @@ ACTOR Future getDataDistributionQueueSize(Database cx, // Gets the size of the data distribution queue. If reportInFlight is true, then data in flight is considered part of // the queue Convenience method that first finds the master worker from a zookeeper interface ACTOR Future getDataDistributionQueueSize(Database cx, - Reference> dbInfo, + Reference const> dbInfo, bool reportInFlight) { WorkerInterface distributorInterf = wait(getDataDistributorWorker(cx, dbInfo)); int64_t inQueue = wait(getDataDistributionQueueSize(cx, distributorInterf, reportInFlight)); @@ -516,7 +517,7 @@ ACTOR Future getTeamCollectionValid(Database cx, WorkerInterface dataDistr // Gets if the number of process and machine teams does not exceed the maximum allowed number of teams // Convenience method that first finds the master worker from a zookeeper interface -ACTOR Future getTeamCollectionValid(Database cx, Reference> dbInfo) { +ACTOR Future getTeamCollectionValid(Database cx, Reference const> dbInfo) { WorkerInterface dataDistributorWorker = wait(getDataDistributorWorker(cx, dbInfo)); bool valid = wait(getTeamCollectionValid(cx, dataDistributorWorker)); return valid; @@ -565,7 +566,9 @@ ACTOR Future getStorageServersRecruiting(Database cx, WorkerInterface dist } } -ACTOR Future repairDeadDatacenter(Database cx, Reference> dbInfo, std::string context) { +ACTOR Future repairDeadDatacenter(Database cx, + Reference const> dbInfo, + std::string context) { if (g_network->isSimulated() && g_simulator.usableRegions > 1) { bool primaryDead = g_simulator.datacenterDead(g_simulator.primaryDcId); bool remoteDead = g_simulator.datacenterDead(g_simulator.remoteDcId); @@ -601,7 +604,7 @@ ACTOR Future repairDeadDatacenter(Database cx, Reference reconfigureAfter(Database cx, double time, - Reference> dbInfo, + Reference const> dbInfo, std::string context) { wait(delay(time)); wait(repairDeadDatacenter(cx, dbInfo, context)); @@ -611,7 +614,7 @@ ACTOR Future reconfigureAfter(Database cx, // Waits until a database quiets down (no data in flight, small tlog queue, low SQ, no active data distribution). This // requires the database to be available and healthy in order to succeed. ACTOR Future waitForQuietDatabase(Database cx, - Reference> dbInfo, + Reference const> dbInfo, std::string phase, int64_t dataInFlightGate = 2e6, int64_t maxTLogQueueGate = 5e6, @@ -747,7 +750,7 @@ ACTOR Future waitForQuietDatabase(Database cx, } Future quietDatabase(Database const& cx, - Reference> const& dbInfo, + Reference const> const& dbInfo, std::string phase, int64_t dataInFlightGate, int64_t maxTLogQueueGate, diff --git a/fdbserver/QuietDatabase.h b/fdbserver/QuietDatabase.h index 37897e63fe..6a7ddc6d5e 100644 --- a/fdbserver/QuietDatabase.h +++ b/fdbserver/QuietDatabase.h @@ -28,25 +28,26 @@ #include "fdbserver/WorkerInterface.actor.h" #include "flow/actorcompiler.h" -Future getDataInFlight(Database const& cx, Reference> const&); +Future getDataInFlight(Database const& cx, Reference const> const&); Future> getTLogQueueInfo(Database const& cx, - Reference> const&); -Future getMaxStorageServerQueueSize(Database const& cx, Reference> const&); + Reference const> const&); +Future getMaxStorageServerQueueSize(Database const& cx, Reference const> const&); Future getDataDistributionQueueSize(Database const& cx, - Reference> const&, + Reference const> const&, bool const& reportInFlight); Future getTeamCollectionValid(Database const& cx, WorkerInterface const&); -Future getTeamCollectionValid(Database const& cx, Reference> const&); +Future getTeamCollectionValid(Database const& cx, Reference const> const&); Future> getStorageServers(Database const& cx, bool const& use_system_priority = false); -Future> getWorkers(Reference> const& dbInfo, int const& flags = 0); -Future getMasterWorker(Database const& cx, Reference> const& dbInfo); +Future> getWorkers(Reference const> const& dbInfo, int const& flags = 0); +Future getMasterWorker(Database const& cx, Reference const> const& dbInfo); Future repairDeadDatacenter(Database const& cx, - Reference> const& dbInfo, + Reference const> const& dbInfo, std::string const& context); Future> getStorageWorkers(Database const& cx, - Reference> const& dbInfo, + Reference const> const& dbInfo, bool const& localOnly); -Future> getCoordWorkers(Database const& cx, Reference> const& dbInfo); +Future> getCoordWorkers(Database const& cx, + Reference const> const& dbInfo); #include "flow/unactorcompiler.h" #endif diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index 3fedfe1c8f..5937855574 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -910,7 +910,7 @@ ACTOR Future resolver(ResolverInterface resolver, ACTOR Future logRouter(TLogInterface interf, InitializeLogRouterRequest req, Reference> db); -ACTOR Future dataDistributor(DataDistributorInterface ddi, Reference> db); +ACTOR Future dataDistributor(DataDistributorInterface ddi, Reference const> db); ACTOR Future ratekeeper(RatekeeperInterface rki, Reference> db); ACTOR Future storageCacheServer(StorageServerInterface interf, uint16_t id, Reference> db); ACTOR Future backupWorker(BackupInterface bi, InitializeBackupRequest req, Reference> db); diff --git a/fdbserver/workloads/workloads.actor.h b/fdbserver/workloads/workloads.actor.h index fa3fb62571..ad89b1cce5 100644 --- a/fdbserver/workloads/workloads.actor.h +++ b/fdbserver/workloads/workloads.actor.h @@ -223,7 +223,7 @@ double testKeyToDouble(const KeyRef& p, const KeyRef& prefix); ACTOR Future databaseWarmer(Database cx); Future quietDatabase(Database const& cx, - Reference> const&, + Reference const> const&, std::string phase, int64_t dataInFlightGate = 2e6, int64_t maxTLogQueueGate = 5e6, From edbac4a26a569b41f077e8a49dbceb003750ec79 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 21:14:38 -0700 Subject: [PATCH 029/225] Prevent storageServer from modifying ServerDBInfo object --- fdbserver/WorkerInterface.actor.h | 4 ++-- fdbserver/storageserver.actor.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index 5937855574..20ac496c2a 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -868,12 +868,12 @@ ACTOR Future storageServer(IKeyValueStore* persistentData, Tag seedTag, Version tssSeedVersion, ReplyPromise recruitReply, - Reference> db, + Reference const> db, std::string folder); ACTOR Future storageServer( IKeyValueStore* persistentData, StorageServerInterface ssi, - Reference> db, + Reference const> db, std::string folder, Promise recovered, Reference diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index e9a23ab309..078b2b1a66 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -614,7 +614,7 @@ public: bool tssInQuarantine; Key sk; - Reference> db; + Reference const> db; Database cx; ActorCollection actors; @@ -806,7 +806,7 @@ public: } counters; StorageServer(IKeyValueStore* storage, - Reference> const& db, + Reference const> const& db, StorageServerInterface const& ssi) : fetchKeysHistograms(), instanceID(deterministicRandom()->randomUniqueID().first()), storage(this, storage), db(db), actors(false), lastTLogVersion(0), lastVersionWithData(0), restoredVersion(0), @@ -5134,7 +5134,7 @@ ACTOR Future storageServer(IKeyValueStore* persistentData, Tag seedTag, Version tssSeedVersion, ReplyPromise recruitReply, - Reference> db, + Reference const> db, std::string folder) { state StorageServer self(persistentData, db, ssi); if (ssi.isTss()) { @@ -5328,7 +5328,7 @@ ACTOR Future replaceTSSInterface(StorageServer* self, StorageServerInterfa // for recovering an existing storage server ACTOR Future storageServer(IKeyValueStore* persistentData, StorageServerInterface ssi, - Reference> db, + Reference const> db, std::string folder, Promise recovered, Reference connFile) { From 7cfa37a731d535ba9e883355acf5381f5f036cd4 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 21:18:09 -0700 Subject: [PATCH 030/225] Prevent storageCacheServer from modifying ServerDBInfo object --- fdbserver/StorageCache.actor.cpp | 8 +++++--- fdbserver/WorkerInterface.actor.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fdbserver/StorageCache.actor.cpp b/fdbserver/StorageCache.actor.cpp index 888c94c3b3..e62e80e5ed 100644 --- a/fdbserver/StorageCache.actor.cpp +++ b/fdbserver/StorageCache.actor.cpp @@ -162,7 +162,7 @@ public: ProtocolVersion logProtocol; Reference logSystem; Key ck; // cacheKey - Reference> const& db; + Reference const> db; Database cx; StorageCacheUpdater* updater; @@ -238,7 +238,7 @@ public: } } counters; - explicit StorageCacheData(UID thisServerID, uint16_t index, Reference> const& db) + explicit StorageCacheData(UID thisServerID, uint16_t index, Reference const> const& db) : /*versionedData(FastAllocPTree{std::make_shared(0)}), */ thisServerID(thisServerID), index(index), logProtocol(0), db(db), cacheRangeChangeCounter(0), lastTLogVersion(0), lastVersionWithData(0), peekVersion(0), compactionInProgress(Void()), @@ -2165,7 +2165,9 @@ ACTOR Future watchInterface(StorageCacheData* self, StorageServerInterface } } -ACTOR Future storageCacheServer(StorageServerInterface ssi, uint16_t id, Reference> db) { +ACTOR Future storageCacheServer(StorageServerInterface ssi, + uint16_t id, + Reference const> db) { state StorageCacheData self(ssi.id(), id, db); state ActorCollection actors(false); state Future dbInfoChange = Void(); diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index 20ac496c2a..45332ac0b4 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -912,7 +912,9 @@ ACTOR Future logRouter(TLogInterface interf, Reference> db); ACTOR Future dataDistributor(DataDistributorInterface ddi, Reference const> db); ACTOR Future ratekeeper(RatekeeperInterface rki, Reference> db); -ACTOR Future storageCacheServer(StorageServerInterface interf, uint16_t id, Reference> db); +ACTOR Future storageCacheServer(StorageServerInterface interf, + uint16_t id, + Reference const> db); ACTOR Future backupWorker(BackupInterface bi, InitializeBackupRequest req, Reference> db); void registerThreadForProfiling(); From fe03cead964e33e3e48b3db0fb1d573e612aa8bb Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 21:26:47 -0700 Subject: [PATCH 031/225] Prevent resolver from modifying ServerDBInfo object --- fdbserver/Resolver.actor.cpp | 4 ++-- fdbserver/WorkerInterface.actor.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fdbserver/Resolver.actor.cpp b/fdbserver/Resolver.actor.cpp index 351439a947..ff09179bf1 100644 --- a/fdbserver/Resolver.actor.cpp +++ b/fdbserver/Resolver.actor.cpp @@ -354,7 +354,7 @@ ACTOR Future resolverCore(ResolverInterface resolver, InitializeResolverRe } } -ACTOR Future checkRemoved(Reference> db, +ACTOR Future checkRemoved(Reference const> db, uint64_t recoveryCount, ResolverInterface myInterface) { loop { @@ -367,7 +367,7 @@ ACTOR Future checkRemoved(Reference> db, ACTOR Future resolver(ResolverInterface resolver, InitializeResolverRequest initReq, - Reference> db) { + Reference const> db) { try { state Future core = resolverCore(resolver, initReq); loop choose { diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index 45332ac0b4..f7c71cddc9 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -906,7 +906,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, Reference> activeSharedTLog); ACTOR Future resolver(ResolverInterface resolver, InitializeResolverRequest initReq, - Reference> db); + Reference const> db); ACTOR Future logRouter(TLogInterface interf, InitializeLogRouterRequest req, Reference> db); From a106d40012bb667bbb1c977e732b804f6cb5e29f Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 22:05:26 -0700 Subject: [PATCH 032/225] Prevent logRouter from modifying ServerDBInfo object --- fdbserver/LogRouter.actor.cpp | 6 +++--- fdbserver/WorkerInterface.actor.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fdbserver/LogRouter.actor.cpp b/fdbserver/LogRouter.actor.cpp index ec0ec6a416..5b0aa75ad7 100644 --- a/fdbserver/LogRouter.actor.cpp +++ b/fdbserver/LogRouter.actor.cpp @@ -625,7 +625,7 @@ ACTOR Future logRouterPop(LogRouterData* self, TLogPopRequest req) { ACTOR Future logRouterCore(TLogInterface interf, InitializeLogRouterRequest req, - Reference> db) { + Reference const> db) { state LogRouterData logRouterData(interf.id(), req); state PromiseStream> addActor; state Future error = actorCollection(addActor.getFuture()); @@ -653,7 +653,7 @@ ACTOR Future logRouterCore(TLogInterface interf, } } -ACTOR Future checkRemoved(Reference> db, +ACTOR Future checkRemoved(Reference const> db, uint64_t recoveryCount, TLogInterface myInterface) { loop { @@ -670,7 +670,7 @@ ACTOR Future checkRemoved(Reference> db, ACTOR Future logRouter(TLogInterface interf, InitializeLogRouterRequest req, - Reference> db) { + Reference const> db) { try { TraceEvent("LogRouterStart", interf.id()) .detail("Start", req.startVersion) diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index f7c71cddc9..4d1877268a 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -909,7 +909,7 @@ ACTOR Future resolver(ResolverInterface resolver, Reference const> db); ACTOR Future logRouter(TLogInterface interf, InitializeLogRouterRequest req, - Reference> db); + Reference const> db); ACTOR Future dataDistributor(DataDistributorInterface ddi, Reference const> db); ACTOR Future ratekeeper(RatekeeperInterface rki, Reference> db); ACTOR Future storageCacheServer(StorageServerInterface interf, From 1a20cf9579081c3dd63a05fd65699464f13f7d71 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 22:17:09 -0700 Subject: [PATCH 033/225] Prevent commitProxyServer from modifying ServerDBInfo object --- fdbserver/CommitProxyServer.actor.cpp | 13 +++++++------ fdbserver/ProxyCommitData.actor.h | 4 ++-- fdbserver/WorkerInterface.actor.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/fdbserver/CommitProxyServer.actor.cpp b/fdbserver/CommitProxyServer.actor.cpp index 337a24e956..71316dcdb7 100644 --- a/fdbserver/CommitProxyServer.actor.cpp +++ b/fdbserver/CommitProxyServer.actor.cpp @@ -1596,7 +1596,7 @@ ACTOR static Future rejoinServer(CommitProxyInterface proxy, ProxyCommitDa } } -ACTOR Future ddMetricsRequestServer(CommitProxyInterface proxy, Reference> db) { +ACTOR Future ddMetricsRequestServer(CommitProxyInterface proxy, Reference const> db) { loop { choose { when(state GetDDMetricsRequest req = waitNext(proxy.getDDMetrics.getFuture())) { @@ -1754,7 +1754,8 @@ ACTOR Future proxySnapCreate(ProxySnapRequest snapReq, ProxyCommitData* co return Void(); } -ACTOR Future proxyCheckSafeExclusion(Reference> db, ExclusionSafetyCheckRequest req) { +ACTOR Future proxyCheckSafeExclusion(Reference const> db, + ExclusionSafetyCheckRequest req) { TraceEvent("SafetyCheckCommitProxyBegin"); state ExclusionSafetyCheckReply reply(false); if (!db->get().distributor.present()) { @@ -1783,7 +1784,7 @@ ACTOR Future proxyCheckSafeExclusion(Reference> db, } ACTOR Future reportTxnTagCommitCost(UID myID, - Reference> db, + Reference const> db, UIDTransactionTagMap* ssTrTagCommitCost) { state Future nextRequestTimer = Never(); state Future nextReply = Never(); @@ -1818,7 +1819,7 @@ ACTOR Future reportTxnTagCommitCost(UID myID, ACTOR Future commitProxyServerCore(CommitProxyInterface proxy, MasterInterface master, - Reference> db, + Reference const> db, LogEpoch epoch, Version recoveryTransactionVersion, bool firstProxy, @@ -2037,7 +2038,7 @@ ACTOR Future commitProxyServerCore(CommitProxyInterface proxy, } } -ACTOR Future checkRemoved(Reference> db, +ACTOR Future checkRemoved(Reference const> db, uint64_t recoveryCount, CommitProxyInterface myInterface) { loop { @@ -2051,7 +2052,7 @@ ACTOR Future checkRemoved(Reference> db, ACTOR Future commitProxyServer(CommitProxyInterface proxy, InitializeCommitProxyRequest req, - Reference> db, + Reference const> db, std::string whitelistBinPaths) { try { state Future core = commitProxyServerCore(proxy, diff --git a/fdbserver/ProxyCommitData.actor.h b/fdbserver/ProxyCommitData.actor.h index 7a2960022e..a8896b768c 100644 --- a/fdbserver/ProxyCommitData.actor.h +++ b/fdbserver/ProxyCommitData.actor.h @@ -161,7 +161,7 @@ struct ProxyCommitData { RequestStream getConsistentReadVersion; RequestStream commit; Database cx; - Reference> db; + Reference const> db; EventMetricHandle singleKeyMutationEvent; std::map> storageCache; @@ -239,7 +239,7 @@ struct ProxyCommitData { RequestStream getConsistentReadVersion, Version recoveryTransactionVersion, RequestStream commit, - Reference> db, + Reference const> db, bool firstProxy) : dbgid(dbgid), stats(dbgid, &version, &committedVersion, &commitBatchesMemBytesCount), master(master), logAdapter(nullptr), txnStateStore(nullptr), popRemoteTxs(false), committedVersion(recoveryTransactionVersion), diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index 4d1877268a..e77c79d341 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -886,7 +886,7 @@ ACTOR Future masterServer(MasterInterface mi, bool forceRecovery); ACTOR Future commitProxyServer(CommitProxyInterface proxy, InitializeCommitProxyRequest req, - Reference> db, + Reference const> db, std::string whitelistBinPaths); ACTOR Future grvProxyServer(GrvProxyInterface proxy, InitializeGrvProxyRequest req, From b2bbdf0d7f9cfca42b16e4b054a527065b438491 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 22:19:18 -0700 Subject: [PATCH 034/225] Prevent grvProxyServer from modifying ServerDBInfo object --- fdbserver/GrvProxyServer.actor.cpp | 18 +++++++++--------- fdbserver/WorkerInterface.actor.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fdbserver/GrvProxyServer.actor.cpp b/fdbserver/GrvProxyServer.actor.cpp index 0a7614a52c..56251976ab 100644 --- a/fdbserver/GrvProxyServer.actor.cpp +++ b/fdbserver/GrvProxyServer.actor.cpp @@ -222,7 +222,7 @@ struct GrvProxyData { Reference logSystem; Database cx; - Reference> db; + Reference const> db; Optional latencyBandConfig; double lastStartCommit; @@ -251,7 +251,7 @@ struct GrvProxyData { GrvProxyData(UID dbgid, MasterInterface master, RequestStream getConsistentReadVersion, - Reference> db) + Reference const> db) : dbgid(dbgid), stats(dbgid), master(master), getConsistentReadVersion(getConsistentReadVersion), cx(openDBOnServer(db, TaskPriority::DefaultEndpoint, LockAware::TRUE)), db(db), lastStartCommit(0), lastCommitLatency(SERVER_KNOBS->REQUIRED_MIN_RECOVERY_DURATION), updateCommitRequests(0), lastCommitTime(0), @@ -275,7 +275,7 @@ ACTOR Future healthMetricsRequestServer(GrvProxyInterface grvProxy, // Get transaction rate info from RateKeeper. ACTOR Future getRate(UID myID, - Reference> db, + Reference const> db, int64_t* inTransactionCount, int64_t* inBatchTransactionCount, GrvTransactionRateInfo* transactionRateInfo, @@ -375,7 +375,7 @@ void dropRequestFromQueue(Deque* queue, GrvProxyStats* st } // Put a GetReadVersion request into the queue corresponding to its priority. -ACTOR Future queueGetReadVersionRequests(Reference> db, +ACTOR Future queueGetReadVersionRequests(Reference const> db, SpannedDeque* systemQueue, SpannedDeque* defaultQueue, SpannedDeque* batchQueue, @@ -634,7 +634,7 @@ ACTOR Future sendGrvReplies(Future replyFuture, return Void(); } -ACTOR Future monitorDDMetricsChanges(int64_t* midShardSize, Reference> db) { +ACTOR Future monitorDDMetricsChanges(int64_t* midShardSize, Reference const> db) { state Future nextRequestTimer = Never(); state Future nextReply = Never(); @@ -680,7 +680,7 @@ ACTOR Future monitorDDMetricsChanges(int64_t* midShardSize, Reference transactionStarter(GrvProxyInterface proxy, - Reference> db, + Reference const> db, PromiseStream> addActor, GrvProxyData* grvProxyData, GetHealthMetricsReply* healthMetricsReply, @@ -898,7 +898,7 @@ ACTOR static Future transactionStarter(GrvProxyInterface proxy, ACTOR Future grvProxyServerCore(GrvProxyInterface proxy, MasterInterface master, - Reference> db) { + Reference const> db) { state GrvProxyData grvProxyData(proxy.id(), master, proxy.getConsistentReadVersion, db); state PromiseStream> addActor; @@ -945,7 +945,7 @@ ACTOR Future grvProxyServerCore(GrvProxyInterface proxy, } } -ACTOR Future checkRemoved(Reference> db, +ACTOR Future checkRemoved(Reference const> db, uint64_t recoveryCount, GrvProxyInterface myInterface) { loop { @@ -959,7 +959,7 @@ ACTOR Future checkRemoved(Reference> db, ACTOR Future grvProxyServer(GrvProxyInterface proxy, InitializeGrvProxyRequest req, - Reference> db) { + Reference const> db) { try { state Future core = grvProxyServerCore(proxy, req.master, db); wait(core || checkRemoved(db, req.recoveryCount, proxy)); diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index e77c79d341..a9a7a6dcb8 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -890,7 +890,7 @@ ACTOR Future commitProxyServer(CommitProxyInterface proxy, std::string whitelistBinPaths); ACTOR Future grvProxyServer(GrvProxyInterface proxy, InitializeGrvProxyRequest req, - Reference> db); + Reference const> db); ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, Reference> db, From 84f6b55e6c3368ca685fed48d6f73aeb17bda9f8 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 22:25:40 -0700 Subject: [PATCH 035/225] Prevent tLog from modifying ServerDBInfo object --- fdbserver/OldTLogServer_4_6.actor.cpp | 6 +++--- fdbserver/OldTLogServer_6_0.actor.cpp | 6 +++--- fdbserver/OldTLogServer_6_2.actor.cpp | 6 +++--- fdbserver/TLogServer.actor.cpp | 6 +++--- fdbserver/WorkerInterface.actor.h | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fdbserver/OldTLogServer_4_6.actor.cpp b/fdbserver/OldTLogServer_4_6.actor.cpp index d8d6755910..ce291e644c 100644 --- a/fdbserver/OldTLogServer_4_6.actor.cpp +++ b/fdbserver/OldTLogServer_4_6.actor.cpp @@ -291,7 +291,7 @@ struct TLogData : NonCopyable { AsyncVar largeDiskQueueCommitBytes; // becomes true when diskQueueCommitBytes is greater than MAX_QUEUE_COMMIT_BYTES - Reference> dbInfo; + Reference const> dbInfo; NotifiedVersion queueCommitEnd; Version queueCommitBegin; @@ -321,7 +321,7 @@ struct TLogData : NonCopyable { UID workerID, IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> const& dbInfo) + Reference const> const& dbInfo) : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), persistentData(persistentData), rawPersistentQueue(persistentQueue), persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), queueCommitBegin(0), queueCommitEnd(0), @@ -1568,7 +1568,7 @@ ACTOR Future restorePersistentState(TLogData* self, LocalityData locality) ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, UID tlogId, UID workerID) { diff --git a/fdbserver/OldTLogServer_6_0.actor.cpp b/fdbserver/OldTLogServer_6_0.actor.cpp index 24c97f741c..dfa3a94a34 100644 --- a/fdbserver/OldTLogServer_6_0.actor.cpp +++ b/fdbserver/OldTLogServer_6_0.actor.cpp @@ -264,7 +264,7 @@ struct TLogData : NonCopyable { AsyncVar largeDiskQueueCommitBytes; // becomes true when diskQueueCommitBytes is greater than MAX_QUEUE_COMMIT_BYTES - Reference> dbInfo; + Reference const> dbInfo; Database cx; NotifiedVersion queueCommitEnd; @@ -301,7 +301,7 @@ struct TLogData : NonCopyable { UID workerID, IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> dbInfo, + Reference const> dbInfo, Reference> degraded, std::string folder) : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), @@ -2716,7 +2716,7 @@ ACTOR Future startSpillingInTenSeconds(TLogData* self, UID tlogId, Referen // New tLog (if !recoverFrom.size()) or restore from network ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, PromiseStream tlogRequests, UID tlogId, diff --git a/fdbserver/OldTLogServer_6_2.actor.cpp b/fdbserver/OldTLogServer_6_2.actor.cpp index 68c125858f..4fa793c74b 100644 --- a/fdbserver/OldTLogServer_6_2.actor.cpp +++ b/fdbserver/OldTLogServer_6_2.actor.cpp @@ -327,7 +327,7 @@ struct TLogData : NonCopyable { AsyncVar largeDiskQueueCommitBytes; // becomes true when diskQueueCommitBytes is greater than MAX_QUEUE_COMMIT_BYTES - Reference> dbInfo; + Reference const> dbInfo; Database cx; NotifiedVersion queueCommitEnd; @@ -364,7 +364,7 @@ struct TLogData : NonCopyable { UID workerID, IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> dbInfo, + Reference const> dbInfo, Reference> degraded, std::string folder) : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), @@ -3205,7 +3205,7 @@ ACTOR Future startSpillingInTenSeconds(TLogData* self, UID tlogId, Referen // New tLog (if !recoverFrom.size()) or restore from network ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, PromiseStream tlogRequests, UID tlogId, diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index a948ecefb2..15074905da 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -329,7 +329,7 @@ struct TLogData : NonCopyable { AsyncVar largeDiskQueueCommitBytes; // becomes true when diskQueueCommitBytes is greater than MAX_QUEUE_COMMIT_BYTES - Reference> dbInfo; + Reference const> dbInfo; Database cx; NotifiedVersion queueCommitEnd; @@ -372,7 +372,7 @@ struct TLogData : NonCopyable { UID workerID, IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> dbInfo, + Reference const> dbInfo, Reference> degraded, std::string folder) : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), @@ -3280,7 +3280,7 @@ ACTOR Future startSpillingInTenSeconds(TLogData* self, UID tlogId, Referen // New tLog (if !recoverFrom.size()) or restore from network ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, PromiseStream tlogRequests, UID tlogId, diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index a9a7a6dcb8..1e32cc55db 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -893,7 +893,7 @@ ACTOR Future grvProxyServer(GrvProxyInterface proxy, Reference const> db); ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, PromiseStream tlogRequests, UID tlogId, @@ -923,7 +923,7 @@ void updateCpuProfiler(ProfilerRequest req); namespace oldTLog_4_6 { ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, UID tlogId, UID workerID); @@ -931,7 +931,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, namespace oldTLog_6_0 { ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, PromiseStream tlogRequests, UID tlogId, @@ -946,7 +946,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, namespace oldTLog_6_2 { ACTOR Future tLog(IKeyValueStore* persistentData, IDiskQueue* persistentQueue, - Reference> db, + Reference const> db, LocalityData locality, PromiseStream tlogRequests, UID tlogId, From ca3f0152724fb5ee6af5e5835cfb6c86e00931b0 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 21:52:55 -0700 Subject: [PATCH 036/225] Prevent ratekeeper from modifying ServerDBInfo object --- fdbserver/Ratekeeper.actor.cpp | 2 +- fdbserver/WorkerInterface.actor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbserver/Ratekeeper.actor.cpp b/fdbserver/Ratekeeper.actor.cpp index 77bda2577b..83f25160cf 100644 --- a/fdbserver/Ratekeeper.actor.cpp +++ b/fdbserver/Ratekeeper.actor.cpp @@ -1408,7 +1408,7 @@ ACTOR Future configurationMonitor(RatekeeperData* self) { } } -ACTOR Future ratekeeper(RatekeeperInterface rkInterf, Reference> dbInfo) { +ACTOR Future ratekeeper(RatekeeperInterface rkInterf, Reference const> dbInfo) { state RatekeeperData self(rkInterf.id(), openDBOnServer(dbInfo, TaskPriority::DefaultEndpoint, LockAware::TRUE)); state Future timeout = Void(); state std::vector> tlogTrackers; diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index 1e32cc55db..d63c22c586 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -911,7 +911,7 @@ ACTOR Future logRouter(TLogInterface interf, InitializeLogRouterRequest req, Reference const> db); ACTOR Future dataDistributor(DataDistributorInterface ddi, Reference const> db); -ACTOR Future ratekeeper(RatekeeperInterface rki, Reference> db); +ACTOR Future ratekeeper(RatekeeperInterface rki, Reference const> db); ACTOR Future storageCacheServer(StorageServerInterface interf, uint16_t id, Reference const> db); From 0e1d5c34e6dbb57ba2cbc920fa309dafcf999c63 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 21:54:36 -0700 Subject: [PATCH 037/225] Prevent backupWorker from modifying ServerDBInfo object --- fdbserver/BackupWorker.actor.cpp | 6 +++--- fdbserver/WorkerInterface.actor.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fdbserver/BackupWorker.actor.cpp b/fdbserver/BackupWorker.actor.cpp index 8a1f2c952a..4e40ea1c47 100644 --- a/fdbserver/BackupWorker.actor.cpp +++ b/fdbserver/BackupWorker.actor.cpp @@ -237,7 +237,7 @@ struct BackupData { CounterCollection cc; Future logger; - explicit BackupData(UID id, Reference> db, const InitializeBackupRequest& req) + explicit BackupData(UID id, Reference const> db, const InitializeBackupRequest& req) : myId(id), tag(req.routerTag), totalTags(req.totalTags), startVersion(req.startVersion), endVersion(req.endVersion), recruitedEpoch(req.recruitedEpoch), backupEpoch(req.backupEpoch), minKnownCommittedVersion(invalidVersion), savedVersion(req.startVersion - 1), popVersion(req.startVersion - 1), @@ -987,7 +987,7 @@ ACTOR Future monitorBackupKeyOrPullData(BackupData* self, bool keyPresent) } } -ACTOR Future checkRemoved(Reference> db, LogEpoch recoveryCount, BackupData* self) { +ACTOR Future checkRemoved(Reference const> db, LogEpoch recoveryCount, BackupData* self) { loop { bool isDisplaced = db->get().recoveryCount > recoveryCount && db->get().recoveryState != RecoveryState::UNINITIALIZED; @@ -1033,7 +1033,7 @@ ACTOR static Future monitorWorkerPause(BackupData* self) { ACTOR Future backupWorker(BackupInterface interf, InitializeBackupRequest req, - Reference> db) { + Reference const> db) { state BackupData self(interf.id(), db, req); state PromiseStream> addActor; state Future error = actorCollection(addActor.getFuture()); diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index d63c22c586..9e155756f0 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -915,7 +915,9 @@ ACTOR Future ratekeeper(RatekeeperInterface rki, Reference storageCacheServer(StorageServerInterface interf, uint16_t id, Reference const> db); -ACTOR Future backupWorker(BackupInterface bi, InitializeBackupRequest req, Reference> db); +ACTOR Future backupWorker(BackupInterface bi, + InitializeBackupRequest req, + Reference const> db); void registerThreadForProfiling(); void updateCpuProfiler(ProfilerRequest req); From 77cbc1aa81bd4fb561cd74b76f6bfb3b9970dca3 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 11 Jul 2021 11:54:04 -0700 Subject: [PATCH 038/225] s/IDependentAsyncVar/IAsyncListener --- fdbclient/MonitorLeader.h | 2 +- fdbserver/ConfigDatabaseUnitTests.actor.cpp | 8 +++---- fdbserver/LocalConfiguration.actor.cpp | 9 ++++---- fdbserver/LocalConfiguration.h | 2 +- fdbserver/worker.actor.cpp | 7 +++---- flow/genericactors.actor.cpp | 8 +++---- flow/genericactors.actor.h | 23 ++++++++++----------- 7 files changed, 28 insertions(+), 31 deletions(-) diff --git a/fdbclient/MonitorLeader.h b/fdbclient/MonitorLeader.h index b9b195a9da..22ef1a5300 100644 --- a/fdbclient/MonitorLeader.h +++ b/fdbclient/MonitorLeader.h @@ -49,7 +49,7 @@ struct ClientData { OpenDatabaseRequest getRequest(); - ClientData() : clientInfo(new AsyncVar>(CachedSerialization())) {} + ClientData() : clientInfo(makeReference>>()) {} }; struct MonitorLeaderInfo { diff --git a/fdbserver/ConfigDatabaseUnitTests.actor.cpp b/fdbserver/ConfigDatabaseUnitTests.actor.cpp index e315156da0..aa57ae9db3 100644 --- a/fdbserver/ConfigDatabaseUnitTests.actor.cpp +++ b/fdbserver/ConfigDatabaseUnitTests.actor.cpp @@ -126,7 +126,7 @@ class ReadFromLocalConfigEnvironment { UID id; std::string dataDir; LocalConfiguration localConfiguration; - Reference const> cbfi; + Reference const> cbfi; Future consumer; ACTOR static Future checkEventually(LocalConfiguration const* localConfiguration, @@ -168,7 +168,7 @@ public: return setup(); } - void connectToBroadcaster(Reference const> const& cbfi) { + void connectToBroadcaster(Reference const> const& cbfi) { ASSERT(!this->cbfi); this->cbfi = cbfi; consumer = localConfiguration.consume(cbfi); @@ -228,7 +228,7 @@ class BroadcasterToLocalConfigEnvironment { ACTOR static Future setup(BroadcasterToLocalConfigEnvironment* self) { wait(self->readFrom.setup()); - self->readFrom.connectToBroadcaster(IDependentAsyncVar::create(self->cbfi)); + self->readFrom.connectToBroadcaster(IAsyncListener::create(self->cbfi)); self->broadcastServer = self->broadcaster.serve(self->cbfi->get()); return Void(); } @@ -364,7 +364,7 @@ class TransactionToLocalConfigEnvironment { ACTOR static Future setup(TransactionToLocalConfigEnvironment* self) { wait(self->readFrom.setup()); - self->readFrom.connectToBroadcaster(IDependentAsyncVar::create(self->cbfi)); + self->readFrom.connectToBroadcaster(IAsyncListener::create(self->cbfi)); self->broadcastServer = self->broadcaster.serve(self->cbfi->get()); return Void(); } diff --git a/fdbserver/LocalConfiguration.actor.cpp b/fdbserver/LocalConfiguration.actor.cpp index 30974a2d19..3fd55141a3 100644 --- a/fdbserver/LocalConfiguration.actor.cpp +++ b/fdbserver/LocalConfiguration.actor.cpp @@ -309,9 +309,8 @@ class LocalConfigurationImpl { } } - ACTOR static Future consume( - LocalConfigurationImpl* self, - Reference const> broadcaster) { + ACTOR static Future consume(LocalConfigurationImpl* self, + Reference const> broadcaster) { ASSERT(self->initFuture.isValid() && self->initFuture.isReady()); loop { choose { @@ -371,7 +370,7 @@ public: return getKnobs().getTestKnobs(); } - Future consume(Reference const> const& broadcaster) { + Future consume(Reference const> const& broadcaster) { return consume(this, broadcaster); } @@ -453,7 +452,7 @@ TestKnobs const& LocalConfiguration::getTestKnobs() const { } Future LocalConfiguration::consume( - Reference const> const& broadcaster) { + Reference const> const& broadcaster) { return impl().consume(broadcaster); } diff --git a/fdbserver/LocalConfiguration.h b/fdbserver/LocalConfiguration.h index 6f9ecabc8f..e5e212b83e 100644 --- a/fdbserver/LocalConfiguration.h +++ b/fdbserver/LocalConfiguration.h @@ -60,7 +60,7 @@ public: ClientKnobs const& getClientKnobs() const; ServerKnobs const& getServerKnobs() const; TestKnobs const& getTestKnobs() const; - Future consume(Reference const> const& broadcaster); + Future consume(Reference const> const& broadcaster); UID getID() const; public: // Testing diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index 2ff5252320..d14e1b21e1 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -2303,10 +2303,9 @@ ACTOR Future fdbd(Reference connFile, auto dbInfo = makeReference>(); if (useConfigDB != UseConfigDB::DISABLED) { - actors.push_back( - reportErrors(localConfig.consume(IDependentAsyncVar::create( - dbInfo, [](auto const& info) { return info.configBroadcaster; })), - "LocalConfiguration")); + actors.push_back(reportErrors(localConfig.consume(IAsyncListener::create( + dbInfo, [](auto const& info) { return info.configBroadcaster; })), + "LocalConfiguration")); } actors.push_back(reportErrors(monitorAndWriteCCPriorityInfo(fitnessFilePath, asyncPriorityInfo), "MonitorAndWriteCCPriorityInfo")); diff --git a/flow/genericactors.actor.cpp b/flow/genericactors.actor.cpp index b199175af7..9b7f906713 100644 --- a/flow/genericactors.actor.cpp +++ b/flow/genericactors.actor.cpp @@ -158,7 +158,7 @@ ACTOR Future testPublisher(Reference> input) { return Void(); } -ACTOR Future testSubscriber(Reference> output, Optional expected) { +ACTOR Future testSubscriber(Reference> output, Optional expected) { loop { wait(output->onChange()); ASSERT(expected.present()); @@ -170,12 +170,12 @@ ACTOR Future testSubscriber(Reference> output, Opt } // namespace -TEST_CASE("/flow/genericactors/DependentAsyncVar") { +TEST_CASE("/flow/genericactors/AsyncListener") { auto input = makeReference>(); state Future subscriber1 = - testSubscriber(IDependentAsyncVar::create(input, [](auto const& var) { return var.changed; }), 100); + testSubscriber(IAsyncListener::create(input, [](auto const& var) { return var.changed; }), 100); state Future subscriber2 = - testSubscriber(IDependentAsyncVar::create(input, [](auto const& var) { return var.unchanged; }), {}); + testSubscriber(IAsyncListener::create(input, [](auto const& var) { return var.unchanged; }), {}); wait(subscriber1 && testPublisher(input)); ASSERT(!subscriber2.isReady()); return Void(); diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index 5cb0344ffb..bffee8bdfa 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -1957,22 +1957,22 @@ Future operator>>(Future const& lhs, Future const& rhs) { } /* - * IDependentAsyncVar is similar to AsyncVar, but it decouples the input and output, so the translation unit + * IAsyncListener is similar to AsyncVar, but it decouples the input and output, so the translation unit * responsible for handling the output does not need to have knowledge of how the output is generated */ template -class IDependentAsyncVar : public ReferenceCounted> { +class IAsyncListener : public ReferenceCounted> { public: - virtual ~IDependentAsyncVar() = default; + virtual ~IAsyncListener() = default; virtual Output const& get() const = 0; virtual Future onChange() const = 0; template - static Reference create(Reference> const& input, F const& f); - static Reference create(Reference> const& output); + static Reference create(Reference> const& input, F const& f); + static Reference create(Reference> const& output); }; template -class DependentAsyncVar final : public IDependentAsyncVar { +class AsyncListener final : public IAsyncListener { Reference> output; Future monitorActor; ACTOR static Future monitor(Reference> input, Reference> output, F f) { @@ -1983,7 +1983,7 @@ class DependentAsyncVar final : public IDependentAsyncVar { } public: - DependentAsyncVar(Reference> const& input, F const& f) + AsyncListener(Reference> const& input, F const& f) : output(makeReference>(f(input->get()))), monitorActor(monitor(input, output, f)) {} Output const& get() const override { return output->get(); } Future onChange() const override { return output->onChange(); } @@ -1991,15 +1991,14 @@ public: template template -Reference> IDependentAsyncVar::create(Reference> const& input, - F const& f) { - return makeReference>(input, f); +Reference> IAsyncListener::create(Reference> const& input, F const& f) { + return makeReference>(input, f); } template -Reference> IDependentAsyncVar::create(Reference> const& input) { +Reference> IAsyncListener::create(Reference> const& input) { auto identity = [](const auto& x) { return x; }; - return makeReference>(input, identity); + return makeReference>(input, identity); } // A weak reference type to wrap a future Reference object. From 95d86a1d1e13531ce32de4f75ae6c61e22c227d3 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 12 Jul 2021 16:30:27 -0700 Subject: [PATCH 039/225] Put IAsyncListener implementation in its own namespace --- flow/genericactors.actor.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index bffee8bdfa..b83c3f90be 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -1971,11 +1971,14 @@ public: static Reference create(Reference> const& output); }; +namespace IAsyncListenerImpl { + template class AsyncListener final : public IAsyncListener { - Reference> output; + // Order matters here, output must outlive monitorActor + AsyncVar output; Future monitorActor; - ACTOR static Future monitor(Reference> input, Reference> output, F f) { + ACTOR static Future monitor(Reference const> input, AsyncVar* output, F f) { loop { wait(input->onChange()); output->set(f(input->get())); @@ -1983,22 +1986,24 @@ class AsyncListener final : public IAsyncListener { } public: - AsyncListener(Reference> const& input, F const& f) - : output(makeReference>(f(input->get()))), monitorActor(monitor(input, output, f)) {} - Output const& get() const override { return output->get(); } - Future onChange() const override { return output->onChange(); } + AsyncListener(Reference const> const& input, F const& f) + : output(f(input->get())), monitorActor(monitor(input, &output, f)) {} + Output const& get() const override { return output.get(); } + Future onChange() const override { return output.onChange(); } }; +} // namespace IAsyncListenerImpl + template template Reference> IAsyncListener::create(Reference> const& input, F const& f) { - return makeReference>(input, f); + return makeReference>(input, f); } template Reference> IAsyncListener::create(Reference> const& input) { auto identity = [](const auto& x) { return x; }; - return makeReference>(input, identity); + return makeReference>(input, identity); } // A weak reference type to wrap a future Reference object. From 03949f2bf9583aef9fbab4469836341e5f292766 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 12 Jul 2021 16:53:52 -0700 Subject: [PATCH 040/225] Improve const-correctness of registrationClient arguments --- fdbserver/worker.actor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index d14e1b21e1..bdbb2ac7e7 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -502,15 +502,15 @@ std::vector getDiskStores(std::string folder) { // Register the worker interf to cluster controller (cc) and // re-register the worker when key roles interface, e.g., cc, dd, ratekeeper, change. -ACTOR Future registrationClient(Reference>> ccInterface, +ACTOR Future registrationClient(Reference> const> ccInterface, WorkerInterface interf, Reference> asyncPriorityInfo, ProcessClass initialClass, - Reference>> ddInterf, - Reference>> rkInterf, - Reference> degraded, + Reference> const> ddInterf, + Reference> const> rkInterf, + Reference const> degraded, Reference connFile, - Reference>> issues) { + Reference> const> issues) { // Keeps the cluster controller (as it may be re-elected) informed that this worker exists // The cluster controller uses waitFailureClient to find out if we die, and returns from registrationReply // (requiring us to re-register) The registration request piggybacks optional distributor interface if it exists. From 4f853b19a6f1387ee2e6a59a5815ec576d16065b Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 12 Jul 2021 21:28:38 -0700 Subject: [PATCH 041/225] More const-correctness improvements for Reference> objects --- fdbclient/DatabaseContext.h | 12 +++++++----- fdbclient/NativeAPI.actor.cpp | 12 ++++++------ fdbrpc/FlowTransport.actor.cpp | 4 ++-- fdbrpc/FlowTransport.h | 2 +- flow/genericactors.actor.h | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index d95ca71c32..a1d33d6781 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -196,7 +196,7 @@ public: Reference getCommitProxies(bool useProvisionalProxies); Future> getCommitProxiesFuture(bool useProvisionalProxies); Reference getGrvProxies(bool useProvisionalProxies); - Future onProxiesChanged(); + Future onProxiesChanged() const; Future getHealthMetrics(bool detailed); // Returns the protocol version reported by the coordinator this client is connected to @@ -255,7 +255,7 @@ public: // private: explicit DatabaseContext(Reference>> connectionFile, Reference> clientDBInfo, - Reference>> coordinator, + Reference> const> coordinator, Future clientInfoMonitor, TaskPriority taskID, LocalityData const& clientLocality, @@ -307,7 +307,7 @@ public: // trust that the read version (possibly set manually by the application) is actually from the correct cluster. // Updated everytime we get a GRV response Version minAcceptableReadVersion = std::numeric_limits::max(); - void validateVersion(Version); + void validateVersion(Version) const; // Client status updater struct ClientStatusUpdater { @@ -399,7 +399,7 @@ public: Future connected; // An AsyncVar that reports the coordinator this DatabaseContext is interacting with - Reference>> coordinator; + Reference> const> coordinator; Reference>> statusClusterInterface; Future statusLeaderMon; @@ -428,7 +428,6 @@ public: static bool debugUseTags; static const std::vector debugTransactionTagChoices; - std::unordered_map> watchMap; // Adds or updates the specified (SS, TSS) pair in the TSS mapping (if not already present). // Requests to the storage server will be duplicated to the TSS. @@ -437,6 +436,9 @@ public: // Removes the storage server and its TSS pair from the TSS mapping (if present). // Requests to the storage server will no longer be duplicated to its pair TSS. void removeTssMapping(StorageServerInterface const& ssi); + +private: + std::unordered_map> watchMap; }; #endif diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 8fa167694e..dcae7caa9c 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -285,7 +285,7 @@ std::string unprintable(std::string const& val) { return s; } -void DatabaseContext::validateVersion(Version version) { +void DatabaseContext::validateVersion(Version version) const { // Version could be 0 if the INITIALIZE_NEW_DATABASE option is set. In that case, it is illegal to perform any // reads. We throw client_invalid_operation because the caller didn't directly set the version, so the // version_invalid error might be confusing. @@ -650,7 +650,7 @@ ACTOR static Future clientStatusUpdateActor(DatabaseContext* cx) { } } -ACTOR static Future monitorProxiesChange(Reference> clientDBInfo, +ACTOR static Future monitorProxiesChange(Reference const> clientDBInfo, AsyncTrigger* triggerVar) { state vector curCommitProxies; state vector curGrvProxies; @@ -1085,7 +1085,7 @@ Future HealthMetricsRangeImpl::getRange(ReadYourWritesTransaction* DatabaseContext::DatabaseContext(Reference>> connectionFile, Reference> clientInfo, - Reference>> coordinator, + Reference> const> coordinator, Future clientInfoMonitor, TaskPriority taskID, LocalityData const& clientLocality, @@ -1482,7 +1482,7 @@ void DatabaseContext::invalidateCache(const KeyRangeRef& keys) { locationCache.insert(KeyRangeRef(begin, end), Reference()); } -Future DatabaseContext::onProxiesChanged() { +Future DatabaseContext::onProxiesChanged() const { return this->proxiesChangeTrigger.onTrigger(); } @@ -5761,7 +5761,7 @@ ACTOR Future> getCoordinatorProtocolFromConnectPacket( NetworkAddress coordinatorAddress, Optional expectedVersion) { - state Reference>> protocolVersion = + state Reference> const> protocolVersion = FlowTransport::transport().getPeerProtocolAsyncVar(coordinatorAddress); loop { @@ -5786,7 +5786,7 @@ ACTOR Future> getCoordinatorProtocolFromConnectPacket( // Returns the protocol version reported by the given coordinator // If an expected version is given, the future won't return until the protocol version is different than expected ACTOR Future getClusterProtocolImpl( - Reference>> coordinator, + Reference> const> coordinator, Optional expectedVersion) { state bool needToConnect = true; diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index e16264591f..5b08069fc7 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -1698,7 +1698,7 @@ Reference> FlowTransport::getDegraded() { // // Note that this function does not establish a connection to the peer. In order to obtain a peer's protocol // version, some other mechanism should be used to connect to that peer. -Reference>> FlowTransport::getPeerProtocolAsyncVar(NetworkAddress addr) { +Reference> const> FlowTransport::getPeerProtocolAsyncVar(NetworkAddress addr) { return self->peers.at(addr)->protocolVersion; } @@ -1723,4 +1723,4 @@ void FlowTransport::createInstance(bool isClient, uint64_t transportId) { HealthMonitor* FlowTransport::healthMonitor() { return &self->healthMonitor; -} \ No newline at end of file +} diff --git a/fdbrpc/FlowTransport.h b/fdbrpc/FlowTransport.h index 7ae82b8ef7..0ba5a605aa 100644 --- a/fdbrpc/FlowTransport.h +++ b/fdbrpc/FlowTransport.h @@ -252,7 +252,7 @@ public: // // Note that this function does not establish a connection to the peer. In order to obtain a peer's protocol // version, some other mechanism should be used to connect to that peer. - Reference>> getPeerProtocolAsyncVar(NetworkAddress addr); + Reference> const> getPeerProtocolAsyncVar(NetworkAddress addr); static FlowTransport& transport() { return *static_cast((void*)g_network->global(INetwork::enFlowTransport)); diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index b83c3f90be..30794d9791 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -690,7 +690,7 @@ public: AsyncTrigger() {} AsyncTrigger(AsyncTrigger&& at) : v(std::move(at.v)) {} void operator=(AsyncTrigger&& at) { v = std::move(at.v); } - Future onTrigger() { return v.onChange(); } + Future onTrigger() const { return v.onChange(); } void trigger() { v.trigger(); } private: From 9379bab04e808ce49c039f860dd3e7dccb785f82 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 13 Jul 2021 14:28:46 -0700 Subject: [PATCH 042/225] Move trim to anonymous namespace --- fdbclient/MonitorLeader.actor.cpp | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/fdbclient/MonitorLeader.actor.cpp b/fdbclient/MonitorLeader.actor.cpp index 22bbbfc4b7..920a09e247 100644 --- a/fdbclient/MonitorLeader.actor.cpp +++ b/fdbclient/MonitorLeader.actor.cpp @@ -26,6 +26,28 @@ #include "flow/Platform.h" #include "flow/actorcompiler.h" // has to be last include +namespace { + +std::string trim(std::string const& connectionString) { + // Strip out whitespace + // Strip out characters between a # and a newline + std::string trimmed; + auto end = connectionString.end(); + for (auto c = connectionString.begin(); c != end; ++c) { + if (*c == '#') { + ++c; + while (c != end && *c != '\n' && *c != '\r') + ++c; + if (c == end) + break; + } else if (*c != ' ' && *c != '\n' && *c != '\r' && *c != '\t') + trimmed += *c; + } + return trimmed; +} + +} // namespace + std::pair ClusterConnectionFile::lookupClusterFileName(std::string const& filename) { if (filename.length()) return std::make_pair(filename, false); @@ -154,24 +176,6 @@ std::string ClusterConnectionString::getErrorString(std::string const& source, E } } -std::string trim(std::string const& connectionString) { - // Strip out whitespace - // Strip out characters between a # and a newline - std::string trimmed; - auto end = connectionString.end(); - for (auto c = connectionString.begin(); c != end; ++c) { - if (*c == '#') { - ++c; - while (c != end && *c != '\n' && *c != '\r') - ++c; - if (c == end) - break; - } else if (*c != ' ' && *c != '\n' && *c != '\r' && *c != '\t') - trimmed += *c; - } - return trimmed; -} - ClusterConnectionString::ClusterConnectionString(std::string const& connectionString) { auto trimmed = trim(connectionString); From 3c1cabf04125e80d0f8ad3aef9e910b2854790e7 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 13 Jul 2021 16:43:09 -0700 Subject: [PATCH 043/225] Coordinator lets client know if it cannot communicate with cluster controller --- fdbclient/MonitorLeader.actor.cpp | 1 + fdbrpc/fdbrpc.h | 8 +++++ fdbserver/Coordination.actor.cpp | 54 +++++++++++++++++++++++++------ flow/error_definitions.h | 1 + 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/fdbclient/MonitorLeader.actor.cpp b/fdbclient/MonitorLeader.actor.cpp index 920a09e247..f8c1769384 100644 --- a/fdbclient/MonitorLeader.actor.cpp +++ b/fdbclient/MonitorLeader.actor.cpp @@ -842,6 +842,7 @@ ACTOR Future monitorProxiesOneGeneration( clientInfo->set(ni); successIdx = idx; } else { + TEST(rep.getError().code() == error_code_failed_to_progress); // Coordinator cannot talk to cluster controller idx = (idx + 1) % addrs.size(); if (idx == successIdx) { wait(delay(CLIENT_KNOBS->COORDINATOR_RECONNECTION_DELAY)); diff --git a/fdbrpc/fdbrpc.h b/fdbrpc/fdbrpc.h index df13a7fa0c..53eb6b13d5 100644 --- a/fdbrpc/fdbrpc.h +++ b/fdbrpc/fdbrpc.h @@ -123,6 +123,14 @@ public: void sendError(const E& exc) const { sav->sendError(exc); } + template + void sendErrorOr(U&& value) const { + if (value.present()) { + sav->send(std::forward(value).get()); + } else { + sav->sendError(value.getError()); + } + } Future getFuture() const { sav->addFutureRef(); diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index eeffd7b4d7..c284c2eabd 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -37,6 +37,30 @@ // This module implements coordinationServer() and the interfaces in CoordinationInterface.h +namespace { + +class LivenessChecker { + double threshold; + AsyncVar lastTime; + ACTOR static Future checkStuck(LivenessChecker const* self) { + loop { + choose { + when(wait(delayUntil(self->lastTime.get() + self->threshold))) { return Void(); } + when(wait(self->lastTime.onChange())) {} + } + } + } + +public: + explicit LivenessChecker(double threshold) : threshold(threshold), lastTime(now()) {} + + void confirmLiveness() { lastTime.set(now()); } + + Future checkStuck() const { return checkStuck(this); } +}; + +} // namespace + struct GenerationRegVal { UniqueGeneration readGen, writeGen; Optional val; @@ -179,7 +203,10 @@ TEST_CASE("/fdbserver/Coordination/localGenerationReg/simple") { ACTOR Future openDatabase(ClientData* db, int* clientCount, Reference> hasConnectedClients, - OpenDatabaseCoordRequest req) { + OpenDatabaseCoordRequest req, + Future checkStuck) { + state ErrorOr> replyContents; + ++(*clientCount); hasConnectedClients->set(true); @@ -191,18 +218,22 @@ ACTOR Future openDatabase(ClientData* db, while (db->clientInfo->get().read().id == req.knownClientInfoID && !db->clientInfo->get().read().forward.present()) { choose { + when(wait(checkStuck)) { + replyContents = failed_to_progress(); + break; + } when(wait(yieldedFuture(db->clientInfo->onChange()))) {} when(wait(delayJittered(SERVER_KNOBS->CLIENT_REGISTER_INTERVAL))) { + if (req.supportedVersions.size() > 0) { + db->clientStatusInfoMap.erase(req.reply.getEndpoint().getPrimaryAddress()); + } + replyContents = db->clientInfo->get(); break; } // The client might be long gone! } } - if (req.supportedVersions.size() > 0) { - db->clientStatusInfoMap.erase(req.reply.getEndpoint().getPrimaryAddress()); - } - - req.reply.send(db->clientInfo->get()); + req.reply.sendErrorOr(replyContents); if (--(*clientCount) == 0) { hasConnectedClients->set(false); @@ -255,6 +286,7 @@ ACTOR Future leaderRegister(LeaderElectionRegInterface interf, Key key) { state AsyncVar leaderInterface; state Reference>> currentElectedLeader = makeReference>>(); + state LivenessChecker canConnectToLeader(20.0); loop choose { when(OpenDatabaseCoordRequest req = waitNext(interf.openDatabase.getFuture())) { @@ -266,7 +298,8 @@ ACTOR Future leaderRegister(LeaderElectionRegInterface interf, Key key) { leaderMon = monitorLeaderForProxies(req.clusterKey, req.coordinators, &clientData, currentElectedLeader); } - actors.add(openDatabase(&clientData, &clientCount, hasConnectedClients, req)); + actors.add( + openDatabase(&clientData, &clientCount, hasConnectedClients, req, canConnectToLeader.checkStuck())); } } when(ElectionResultRequest req = waitNext(interf.electionResult.getFuture())) { @@ -320,8 +353,11 @@ ACTOR Future leaderRegister(LeaderElectionRegInterface interf, Key key) { // TODO: use notify to only send a heartbeat once per interval availableLeaders.erase(LeaderInfo(req.prevChangeID)); availableLeaders.insert(req.myInfo); - req.reply.send( - LeaderHeartbeatReply{ currentNominee.present() && currentNominee.get().equalInternalId(req.myInfo) }); + bool const isCurrentLeader = currentNominee.present() && currentNominee.get().equalInternalId(req.myInfo); + if (isCurrentLeader) { + canConnectToLeader.confirmLiveness(); + } + req.reply.send(LeaderHeartbeatReply{ isCurrentLeader }); } when(ForwardRequest req = waitNext(interf.forward.getFuture())) { LeaderInfo newInfo; diff --git a/flow/error_definitions.h b/flow/error_definitions.h index 8ffb54f290..b69801cfd7 100755 --- a/flow/error_definitions.h +++ b/flow/error_definitions.h @@ -99,6 +99,7 @@ ERROR( master_backup_worker_failed, 1212, "Master terminating because a backup w ERROR( tag_throttled, 1213, "Transaction tag is being throttled" ) ERROR( grv_proxy_failed, 1214, "Master terminating because a GRV CommitProxy failed" ) ERROR( dd_tracker_cancelled, 1215, "The data distribution tracker has been cancelled" ) +ERROR( failed_to_progress, 1216, "Process has failed to make sufficient progress" ) // 15xx Platform errors ERROR( platform_error, 1500, "Platform error" ) From a87e2b3019a86b7f21a156e02ad649b152ff9a48 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 17 Jul 2021 16:44:03 -0700 Subject: [PATCH 044/225] Fix build with -DBUILD_AZURE_BACKUP=ON --- .../BackupContainerAzureBlobStore.actor.cpp | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 4ee3a7ebf5..184971ed8a 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -42,7 +42,7 @@ public: void addref() override { ReferenceCounted::addref(); } void delref() override { ReferenceCounted::delref(); } - Future read(void* data, int length, int64_t offset) { + Future read(void* data, int length, int64_t offset) override { return asyncTaskThread.execAsync([client = this->client, containerName = this->containerName, blobName = this->blobName, @@ -171,7 +171,7 @@ public: Reference f = makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); if (self->usesEncryption()) { - f = makeReference(f, false); + f = makeReference(f, AsyncFileEncrypted::Mode::READ_ONLY); } return f; } @@ -182,9 +182,10 @@ public: auto outcome = client->create_append_blob(containerName, fileName).get(); return Void(); })); - auto f = makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); + Reference f = + makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); if (self->usesEncryption()) { - f = makeReference(f, true); + f = makeReference(f, AsyncFileEncrypted::Mode::APPEND_ONLY); } return makeReference(fileName, f); } @@ -220,15 +221,6 @@ public: return Void(); } - ACTOR static Future create(BackupContainerAzureBlobStore* self) { - state Future f1 = - self->asyncTaskThread.execAsync([containerName = self->containerName, client = self->client.get()] { - client->create_container(containerName).wait(); - return Void(); - }); - state Future f2 = self->usesEncryption() ? self->encryptionSetupComplete() : Void(); - return f1 && f2; - } }; Future BackupContainerAzureBlobStore::blobExists(const std::string& fileName) { @@ -261,7 +253,13 @@ void BackupContainerAzureBlobStore::delref() { } Future BackupContainerAzureBlobStore::create() { - return BackupContainerAzureBlobStoreImpl::create(this); + Future createContainerFuture = + asyncTaskThread.execAsync([containerName = this->containerName, client = this->client.get()] { + client->create_container(containerName).wait(); + return Void(); + }); + Future encryptionSetupFuture = usesEncryption() ? encryptionSetupComplete() : Void(); + return createContainerFuture && encryptionSetupFuture; } Future BackupContainerAzureBlobStore::exists() { return asyncTaskThread.execAsync([containerName = this->containerName, client = this->client.get()] { From 87f46fa0af34586645fcc470066cd8ec4c2030a8 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 17 Jul 2021 17:00:36 -0700 Subject: [PATCH 045/225] Use std::unique_ptr for AsyncTaskThread::queue elements --- fdbclient/AsyncTaskThread.actor.cpp | 4 ++-- fdbclient/AsyncTaskThread.h | 4 ++-- fdbclient/SimpleConfigTransaction.actor.cpp | 2 +- flow/Arena.h | 1 + flow/ThreadSafeQueue.h | 7 ++++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fdbclient/AsyncTaskThread.actor.cpp b/fdbclient/AsyncTaskThread.actor.cpp index 050af68c29..aad2470ed1 100644 --- a/fdbclient/AsyncTaskThread.actor.cpp +++ b/fdbclient/AsyncTaskThread.actor.cpp @@ -51,7 +51,7 @@ AsyncTaskThread::~AsyncTaskThread() { bool wakeUp = false; { std::lock_guard g(m); - wakeUp = queue.push(std::make_shared()); + wakeUp = queue.push(std::make_unique()); } if (wakeUp) { cv.notify_one(); @@ -61,7 +61,7 @@ AsyncTaskThread::~AsyncTaskThread() { void AsyncTaskThread::run(AsyncTaskThread* self) { while (true) { - std::shared_ptr task; + std::unique_ptr task; { std::unique_lock lk(self->m); self->cv.wait(lk, [self] { return !self->queue.canSleep(); }); diff --git a/fdbclient/AsyncTaskThread.h b/fdbclient/AsyncTaskThread.h index e7ea8b3cf2..5ec22eb26c 100644 --- a/fdbclient/AsyncTaskThread.h +++ b/fdbclient/AsyncTaskThread.h @@ -48,7 +48,7 @@ public: }; class AsyncTaskThread { - ThreadSafeQueue> queue; + ThreadSafeQueue> queue; std::condition_variable cv; std::mutex m; std::thread thread; @@ -60,7 +60,7 @@ class AsyncTaskThread { bool wakeUp = false; { std::lock_guard g(m); - wakeUp = queue.push(std::make_shared>(func)); + wakeUp = queue.push(std::make_unique>(func)); } if (wakeUp) { cv.notify_one(); diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index 453cf26ae0..42b16e2456 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -70,7 +70,7 @@ class SimpleConfigTransactionImpl { if (reply.value.present()) { return reply.value.get().toValue(); } else { - return {}; + return Optional{}; } } diff --git a/flow/Arena.h b/flow/Arena.h index d752baedf0..b8df3360ab 100644 --- a/flow/Arena.h +++ b/flow/Arena.h @@ -219,6 +219,7 @@ public: template Optional(const U& t) : impl(std::in_place, t) {} + Optional(T&& t) : impl(std::in_place, std::move(t)) {} /* This conversion constructor was nice, but combined with the prior constructor it means that Optional can be converted to Optional> in the wrong way (a non-present Optional converts to a non-present diff --git a/flow/ThreadSafeQueue.h b/flow/ThreadSafeQueue.h index 0f489bd08a..b49a7b22d0 100644 --- a/flow/ThreadSafeQueue.h +++ b/flow/ThreadSafeQueue.h @@ -52,6 +52,7 @@ class ThreadSafeQueue : NonCopyable { struct Node : BaseNode, FastAllocated { T data; Node(T const& data) : data(data) {} + Node(T&& data) : data(std::move(data)) {} }; std::atomic head; BaseNode* tail; @@ -131,9 +132,9 @@ public: } // If push() returns true, the consumer may be sleeping and should be woken - bool push(T const& data) { - Node* n = new Node(data); - n->data = data; + template + bool push(U&& data) { + Node* n = new Node(std::forward(data)); return pushNode(n) == &sleeping; } From 15545bd9b010d16da80c1c8aa3dd5ca775b34cdc Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 17 Jul 2021 18:02:26 -0700 Subject: [PATCH 046/225] Added /asynctaskthread/error unit test --- fdbclient/AsyncTaskThread.actor.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fdbclient/AsyncTaskThread.actor.cpp b/fdbclient/AsyncTaskThread.actor.cpp index aad2470ed1..def8b5398c 100644 --- a/fdbclient/AsyncTaskThread.actor.cpp +++ b/fdbclient/AsyncTaskThread.actor.cpp @@ -86,3 +86,17 @@ TEST_CASE("/asynctaskthread/add") { ASSERT_EQ(sum, 1000); return Void(); } + +TEST_CASE("/asynctaskthread/error") { + state AsyncTaskThread asyncTaskThread; + try { + wait(asyncTaskThread.execAsync([]{ + throw operation_failed(); + return Void(); + })); + ASSERT(false); + } catch (Error &e) { + ASSERT_EQ(e.code(), error_code_operation_failed); + } + return Void(); +} From e8f0c3c98a52313114094ef27709cc3ddfe39bcc Mon Sep 17 00:00:00 2001 From: hao fu Date: Sat, 17 Jul 2021 15:56:03 -0700 Subject: [PATCH 047/225] Add RepeatableReadMultiThreadClientTest Add RepeatableReadMultiThreadClientTest to verify transactions have repeatable read. --- .../RepeatableReadMultiThreadClientTest.java | 188 ++++++++++++++++++ bindings/java/src/tests.cmake | 1 + 2 files changed, 189 insertions(+) create mode 100644 bindings/java/src/integration/com/apple/foundationdb/RepeatableReadMultiThreadClientTest.java diff --git a/bindings/java/src/integration/com/apple/foundationdb/RepeatableReadMultiThreadClientTest.java b/bindings/java/src/integration/com/apple/foundationdb/RepeatableReadMultiThreadClientTest.java new file mode 100644 index 0000000000..3358c9e760 --- /dev/null +++ b/bindings/java/src/integration/com/apple/foundationdb/RepeatableReadMultiThreadClientTest.java @@ -0,0 +1,188 @@ +/* + * RepeatableReadMultiThreadClientTest + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2021 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. + */ +package com.apple.foundationdb; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import com.apple.foundationdb.tuple.Tuple; + +import org.junit.jupiter.api.Assertions; + +/** + * This test verify transcations have repeatable read. + * 1 First set initialValue to key. + * 2 Have transactions to read the key and verify the initialValue in a loop, if it does not + * see the initialValue as the value, it set the flag to false. + * + * 3 Then have new transactions set the value and then read to verify the new value is set, + * if it does not read the new value, set the flag to false. + * + * 4 Verify that old transactions have not finished when new transactions have finished, + * then verify old transactions does not have false flag -- it means that old transactions + * are still seeting the initialValue even after new transactions set them to a new value. + */ +public class RepeatableReadMultiThreadClientTest { + public static final MultiClientHelper clientHelper = new MultiClientHelper(); + + private static final int oldValueReadCount = 30; + private static final int threadPerDB = 5; + + private static final String key = "foo"; + private static final String initialValue = "bar"; + private static final String newValue = "cool"; + private static final Map threadToOldValueReaders = new HashMap<>(); + + public static void main(String[] args) throws Exception { + FDB fdb = FDB.selectAPIVersion(710); + setupThreads(fdb); + Collection dbs = clientHelper.openDatabases(fdb); // the clientHelper will close the databases for us + System.out.println("Starting tests"); + setup(dbs); + System.out.println("Start processing and validating"); + readOldValue(dbs); + setNewValueAndRead(dbs); + System.out.println("Test finished"); + } + + private static synchronized void setupThreads(FDB fdb) { + int clientThreadsPerVersion = clientHelper.readClusterFromEnv().length; + fdb.options().setClientThreadsPerVersion(clientThreadsPerVersion); + System.out.printf("thread per version is %d\n", clientThreadsPerVersion); + fdb.options().setExternalClientDirectory("/var/dynamic-conf/lib"); + fdb.options().setTraceEnable("/tmp"); + fdb.options().setKnob("min_trace_severity=5"); + } + + private static void setup(Collection dbs) { + // 0 -> 1 -> 2 -> 3 -> 0 + for (Database db : dbs) { + db.run(tr -> { + tr.set(Tuple.from(key).pack(), Tuple.from(initialValue).pack()); + return null; + }); + } + } + + private static void readOldValue(Collection dbs) throws InterruptedException { + for (Database db : dbs) { + for (int i = 0; i < threadPerDB; i++) { + final OldValueReader oldValueReader = new OldValueReader(db); + final Thread thread = new Thread(OldValueReader.create(db)); + thread.start(); + threadToOldValueReaders.put(thread, oldValueReader); + } + } + } + + private static void setNewValueAndRead(Collection dbs) throws InterruptedException { + // threads running NewValueReader need to wait for threads to start first who run OldValueReader + Thread.sleep(1000); + final Map threads = new HashMap<>(); + for (Database db : dbs) { + for (int i = 0; i < threadPerDB; i++) { + final NewValueReader newValueReader = new NewValueReader(db); + final Thread thread = new Thread(NewValueReader.create(db)); + thread.start(); + threads.put(thread, newValueReader); + } + } + + for (Map.Entry entry : threads.entrySet()) { + entry.getKey().join(); + Assertions.assertTrue(entry.getValue().succeed, "new value reader failed to read the correct value"); + } + + for (Map.Entry entry : threadToOldValueReaders.entrySet()) { + Assertions.assertTrue(entry.getKey().isAlive(), "Old value reader finished too soon, cannot verify repeatable read, succeed is " + entry.getValue().succeed); + } + + for (Map.Entry entry : threadToOldValueReaders.entrySet()) { + entry.getKey().join(); + Assertions.assertTrue(entry.getValue().succeed, "old value reader failed to read the correct value"); + } + } + + public static class OldValueReader implements Runnable { + + private final Database db; + private boolean succeed; + + private OldValueReader(Database db) { + this.db = db; + this.succeed = true; + } + + public static OldValueReader create(Database db) { + return new OldValueReader(db); + } + + @Override + public void run() { + db.run(tr -> { + try { + for (int i = 0; i < oldValueReadCount; i++) { + byte[] result = tr.get(Tuple.from(key).pack()).join(); + String value = Tuple.fromBytes(result).getString(0); + if (!initialValue.equals(value)) { + succeed = false; + break; + } + Thread.sleep(100); + } + } + catch (Exception e) { + succeed = false; + } + return null; + }); + } + } + + public static class NewValueReader implements Runnable { + private final Database db; + private boolean succeed; + + public NewValueReader(Database db) { + this.db = db; + this.succeed = true; + } + + public static NewValueReader create(Database db) { + return new NewValueReader(db); + } + + @Override + public void run() { + db.run(tr -> { + tr.set(Tuple.from(key).pack(), Tuple.from(newValue).pack()); + return null; + }); + String value = db.run(tr -> { + byte[] result = tr.get(Tuple.from(key).pack()).join(); + return Tuple.fromBytes(result).getString(0); + }); + if (!newValue.equals(value)) { + succeed = false; + } + } + } +} diff --git a/bindings/java/src/tests.cmake b/bindings/java/src/tests.cmake index 63fb18322d..3e9dce6657 100644 --- a/bindings/java/src/tests.cmake +++ b/bindings/java/src/tests.cmake @@ -51,6 +51,7 @@ set(JAVA_INTEGRATION_TESTS src/integration/com/apple/foundationdb/BasicMultiClientIntegrationTest.java src/integration/com/apple/foundationdb/CycleMultiClientIntegrationTest.java src/integration/com/apple/foundationdb/SidebandMultiThreadClientTest.java + src/integration/com/apple/foundationdb/RepeatableReadMultiThreadClientTest.java ) # Resources that are used in integration testing, but are not explicitly test files (JUnit rules, From 127d488b6836f7efc649977fd1d13c097546a91b Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 17 Jul 2021 20:00:38 -0700 Subject: [PATCH 048/225] Strengthen /asynctaskthread/add unit test --- fdbclient/AsyncTaskThread.actor.cpp | 27 ++++++++++++++++++++------- fdbclient/AsyncTaskThread.h | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/fdbclient/AsyncTaskThread.actor.cpp b/fdbclient/AsyncTaskThread.actor.cpp index def8b5398c..b63a731045 100644 --- a/fdbclient/AsyncTaskThread.actor.cpp +++ b/fdbclient/AsyncTaskThread.actor.cpp @@ -18,6 +18,8 @@ * limitations under the License. */ +#include + #include "fdbclient/AsyncTaskThread.h" #include "flow/UnitTest.h" #include "flow/actorcompiler.h" // This must be the last #include. @@ -30,13 +32,22 @@ public: bool isTerminate() const override { return true; } }; -ACTOR Future asyncTaskThreadClient(AsyncTaskThread* asyncTaskThread, int* sum, int count) { +ACTOR Future asyncTaskThreadClient(AsyncTaskThread* asyncTaskThread, std::atomic *sum, int count, int clientId, double meanSleep) { state int i = 0; + state double randomSleep = 0.0; for (; i < count; ++i) { + randomSleep = deterministicRandom()->random01() * 2 * meanSleep; + wait(delay(randomSleep)); wait(asyncTaskThread->execAsync([sum = sum] { - ++(*sum); + sum->fetch_add(1); return Void(); })); + TraceEvent("AsyncTaskThreadIncrementedSum") + .detail("Index", i) + .detail("Sum", sum->load()) + .detail("ClientId", clientId) + .detail("RandomSleep", randomSleep) + .detail("MeanSleep", meanSleep); } return Void(); } @@ -75,15 +86,17 @@ void AsyncTaskThread::run(AsyncTaskThread* self) { } TEST_CASE("/asynctaskthread/add") { - state int sum = 0; + state std::atomic sum = 0; state AsyncTaskThread asyncTaskThread; + state int numClients = 10; + state int incrementsPerClient = 100; std::vector> clients; - clients.reserve(10); - for (int i = 0; i < 10; ++i) { - clients.push_back(asyncTaskThreadClient(&asyncTaskThread, &sum, 100)); + clients.reserve(numClients); + for (int clientId = 0; clientId < numClients; ++clientId) { + clients.push_back(asyncTaskThreadClient(&asyncTaskThread, &sum, incrementsPerClient, clientId, deterministicRandom()->random01() * 0.01)); } wait(waitForAll(clients)); - ASSERT_EQ(sum, 1000); + ASSERT_EQ(sum.load(), numClients * incrementsPerClient); return Void(); } diff --git a/fdbclient/AsyncTaskThread.h b/fdbclient/AsyncTaskThread.h index 5ec22eb26c..223a434257 100644 --- a/fdbclient/AsyncTaskThread.h +++ b/fdbclient/AsyncTaskThread.h @@ -88,6 +88,7 @@ public: auto funcResult = func(); onMainThreadVoid([promise, funcResult] { promise.send(funcResult); }, nullptr, priority); } catch (Error& e) { + TraceEvent("ErrorExecutingAsyncTask").error(e); onMainThreadVoid([promise, e] { promise.sendError(e); }, nullptr, priority); } }); From 54fb0cbe85a5966c99797d637abb4c583ba7347e Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 12:23:34 -0700 Subject: [PATCH 049/225] Use full generation in ConfigTransactionInterface --- fdbclient/ConfigTransactionInterface.cpp | 14 +++- fdbclient/ConfigTransactionInterface.h | 73 ++++++++--------- fdbclient/CoordinationInterface.h | 2 +- fdbclient/SimpleConfigTransaction.actor.cpp | 59 +++++++------- fdbserver/SimpleConfigDatabaseNode.actor.cpp | 82 +++++++++----------- 5 files changed, 117 insertions(+), 113 deletions(-) diff --git a/fdbclient/ConfigTransactionInterface.cpp b/fdbclient/ConfigTransactionInterface.cpp index c912668aff..838e69e091 100644 --- a/fdbclient/ConfigTransactionInterface.cpp +++ b/fdbclient/ConfigTransactionInterface.cpp @@ -25,7 +25,7 @@ ConfigTransactionInterface::ConfigTransactionInterface() : _id(deterministicRandom()->randomUniqueID()) {} void ConfigTransactionInterface::setupWellKnownEndpoints() { - getVersion.makeWellKnownEndpoint(WLTOKEN_CONFIGTXN_GETVERSION, TaskPriority::Coordination); + getGeneration.makeWellKnownEndpoint(WLTOKEN_CONFIGTXN_GETGENERATION, TaskPriority::Coordination); get.makeWellKnownEndpoint(WLTOKEN_CONFIGTXN_GET, TaskPriority::Coordination); getClasses.makeWellKnownEndpoint(WLTOKEN_CONFIGTXN_GETCLASSES, TaskPriority::Coordination); getKnobs.makeWellKnownEndpoint(WLTOKEN_CONFIGTXN_GETKNOBS, TaskPriority::Coordination); @@ -33,8 +33,8 @@ void ConfigTransactionInterface::setupWellKnownEndpoints() { } ConfigTransactionInterface::ConfigTransactionInterface(NetworkAddress const& remote) - : getVersion(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GETVERSION)), get(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GET)), - getClasses(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GETCLASSES)), + : getGeneration(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GETGENERATION)), + get(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GET)), getClasses(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GETCLASSES)), getKnobs(Endpoint({ remote }, WLTOKEN_CONFIGTXN_GETKNOBS)), commit(Endpoint({ remote }, WLTOKEN_CONFIGTXN_COMMIT)) { } @@ -45,3 +45,11 @@ bool ConfigTransactionInterface::operator==(ConfigTransactionInterface const& rh bool ConfigTransactionInterface::operator!=(ConfigTransactionInterface const& rhs) const { return !(*this == rhs); } + +bool ConfigGeneration::operator==(ConfigGeneration const& rhs) const { + return liveVersion == rhs.liveVersion && committedVersion == rhs.committedVersion; +} + +bool ConfigGeneration::operator!=(ConfigGeneration const& rhs) const { + return !(*this == rhs); +} diff --git a/fdbclient/ConfigTransactionInterface.h b/fdbclient/ConfigTransactionInterface.h index 6b6173cada..b5a6437378 100644 --- a/fdbclient/ConfigTransactionInterface.h +++ b/fdbclient/ConfigTransactionInterface.h @@ -27,22 +27,35 @@ #include "fdbrpc/fdbrpc.h" #include "flow/flow.h" -struct ConfigTransactionGetVersionReply { - static constexpr FileIdentifier file_identifier = 2934851; - ConfigTransactionGetVersionReply() = default; - explicit ConfigTransactionGetVersionReply(Version version) : version(version) {} - Version version; +struct ConfigGeneration { + Version liveVersion{ 0 }; + Version committedVersion{ 0 }; + + bool operator==(ConfigGeneration const&) const; + bool operator!=(ConfigGeneration const&) const; template void serialize(Ar& ar) { - serializer(ar, version); + serializer(ar, liveVersion, committedVersion); } }; -struct ConfigTransactionGetVersionRequest { +struct ConfigTransactionGetGenerationReply { + static constexpr FileIdentifier file_identifier = 2934851; + ConfigTransactionGetGenerationReply() = default; + explicit ConfigTransactionGetGenerationReply(ConfigGeneration generation) : generation(generation) {} + ConfigGeneration generation; + + template + void serialize(Ar& ar) { + serializer(ar, generation); + } +}; + +struct ConfigTransactionGetGenerationRequest { static constexpr FileIdentifier file_identifier = 138941; - ReplyPromise reply; - ConfigTransactionGetVersionRequest() = default; + ReplyPromise reply; + ConfigTransactionGetGenerationRequest() = default; template void serialize(Ar& ar) { @@ -64,23 +77,24 @@ struct ConfigTransactionGetReply { struct ConfigTransactionGetRequest { static constexpr FileIdentifier file_identifier = 923040; - Version version; + ConfigGeneration generation; ConfigKey key; ReplyPromise reply; ConfigTransactionGetRequest() = default; - explicit ConfigTransactionGetRequest(Version version, ConfigKey key) : version(version), key(key) {} + explicit ConfigTransactionGetRequest(ConfigGeneration generation, ConfigKey key) + : generation(generation), key(key) {} template void serialize(Ar& ar) { - serializer(ar, version, key, reply); + serializer(ar, generation, key, reply); } }; struct ConfigTransactionCommitRequest { static constexpr FileIdentifier file_identifier = 103841; Arena arena; - Version version{ ::invalidVersion }; + ConfigGeneration generation{ ::invalidVersion, ::invalidVersion }; VectorRef mutations; ConfigCommitAnnotationRef annotation; ReplyPromise reply; @@ -89,20 +103,7 @@ struct ConfigTransactionCommitRequest { template void serialize(Ar& ar) { - serializer(ar, arena, version, mutations, annotation, reply); - } -}; - -struct ConfigTransactionGetRangeReply { - static constexpr FileIdentifier file_identifier = 430263; - Standalone range; - - ConfigTransactionGetRangeReply() = default; - explicit ConfigTransactionGetRangeReply(Standalone range) : range(range) {} - - template - void serialize(Ar& ar) { - serializer(ar, range); + serializer(ar, arena, generation, mutations, annotation, reply); } }; @@ -122,15 +123,15 @@ struct ConfigTransactionGetConfigClassesReply { struct ConfigTransactionGetConfigClassesRequest { static constexpr FileIdentifier file_identifier = 7163400; - Version version; + ConfigGeneration generation; ReplyPromise reply; ConfigTransactionGetConfigClassesRequest() = default; - explicit ConfigTransactionGetConfigClassesRequest(Version version) : version(version) {} + explicit ConfigTransactionGetConfigClassesRequest(ConfigGeneration generation) : generation(generation) {} template void serialize(Ar& ar) { - serializer(ar, version); + serializer(ar, generation); } }; @@ -149,17 +150,17 @@ struct ConfigTransactionGetKnobsReply { struct ConfigTransactionGetKnobsRequest { static constexpr FileIdentifier file_identifier = 987410; - Version version; + ConfigGeneration generation; Optional configClass; ReplyPromise reply; ConfigTransactionGetKnobsRequest() = default; - explicit ConfigTransactionGetKnobsRequest(Version version, Optional configClass) - : version(version), configClass(configClass) {} + explicit ConfigTransactionGetKnobsRequest(ConfigGeneration generation, Optional configClass) + : generation(generation), configClass(configClass) {} template void serialize(Ar& ar) { - serializer(ar, version, configClass, reply); + serializer(ar, generation, configClass, reply); } }; @@ -172,7 +173,7 @@ struct ConfigTransactionInterface { public: static constexpr FileIdentifier file_identifier = 982485; - struct RequestStream getVersion; + struct RequestStream getGeneration; struct RequestStream get; struct RequestStream getClasses; struct RequestStream getKnobs; @@ -188,6 +189,6 @@ public: template void serialize(Ar& ar) { - serializer(ar, getVersion, get, getClasses, getKnobs, commit); + serializer(ar, getGeneration, get, getClasses, getKnobs, commit); } }; diff --git a/fdbclient/CoordinationInterface.h b/fdbclient/CoordinationInterface.h index 2c80899aae..a2abfa87db 100644 --- a/fdbclient/CoordinationInterface.h +++ b/fdbclient/CoordinationInterface.h @@ -38,7 +38,7 @@ constexpr UID WLTOKEN_CLIENTLEADERREG_OPENDATABASE(-1, 3); constexpr UID WLTOKEN_PROTOCOL_INFO(-1, 10); constexpr UID WLTOKEN_CLIENTLEADERREG_DESCRIPTOR_MUTABLE(-1, 11); -constexpr UID WLTOKEN_CONFIGTXN_GETVERSION(-1, 12); +constexpr UID WLTOKEN_CONFIGTXN_GETGENERATION(-1, 12); constexpr UID WLTOKEN_CONFIGTXN_GET(-1, 13); constexpr UID WLTOKEN_CONFIGTXN_GETCLASSES(-1, 14); constexpr UID WLTOKEN_CONFIGTXN_GETKNOBS(-1, 15); diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index 453cf26ae0..70e8ec7b0d 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -30,39 +30,40 @@ class SimpleConfigTransactionImpl { ConfigTransactionCommitRequest toCommit; - Future getVersionFuture; + Future getGenerationFuture; ConfigTransactionInterface cti; int numRetries{ 0 }; bool committed{ false }; Optional dID; Database cx; - ACTOR static Future getReadVersion(SimpleConfigTransactionImpl* self) { + ACTOR static Future getGeneration(SimpleConfigTransactionImpl* self) { if (self->dID.present()) { TraceEvent("SimpleConfigTransactionGettingReadVersion", self->dID.get()); } - ConfigTransactionGetVersionRequest req; - ConfigTransactionGetVersionReply reply = - wait(self->cti.getVersion.getReply(ConfigTransactionGetVersionRequest{})); + ConfigTransactionGetGenerationRequest req; + ConfigTransactionGetGenerationReply reply = + wait(self->cti.getGeneration.getReply(ConfigTransactionGetGenerationRequest{})); if (self->dID.present()) { - TraceEvent("SimpleConfigTransactionGotReadVersion", self->dID.get()).detail("Version", reply.version); + TraceEvent("SimpleConfigTransactionGotReadVersion", self->dID.get()) + .detail("Version", reply.generation.liveVersion); } - return reply.version; + return reply.generation; } ACTOR static Future> get(SimpleConfigTransactionImpl* self, KeyRef key) { - if (!self->getVersionFuture.isValid()) { - self->getVersionFuture = getReadVersion(self); + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); } state ConfigKey configKey = ConfigKey::decodeKey(key); - Version version = wait(self->getVersionFuture); + ConfigGeneration generation = wait(self->getGenerationFuture); if (self->dID.present()) { TraceEvent("SimpleConfigTransactionGettingValue", self->dID.get()) .detail("ConfigClass", configKey.configClass) .detail("KnobName", configKey.knobName); } ConfigTransactionGetReply reply = - wait(self->cti.get.getReply(ConfigTransactionGetRequest{ version, configKey })); + wait(self->cti.get.getReply(ConfigTransactionGetRequest{ generation, configKey })); if (self->dID.present()) { TraceEvent("SimpleConfigTransactionGotValue", self->dID.get()) .detail("Value", reply.value.get().toString()); @@ -75,12 +76,12 @@ class SimpleConfigTransactionImpl { } ACTOR static Future> getConfigClasses(SimpleConfigTransactionImpl* self) { - if (!self->getVersionFuture.isValid()) { - self->getVersionFuture = getReadVersion(self); + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); } - Version version = wait(self->getVersionFuture); + ConfigGeneration generation = wait(self->getGenerationFuture); ConfigTransactionGetConfigClassesReply reply = - wait(self->cti.getClasses.getReply(ConfigTransactionGetConfigClassesRequest{ version })); + wait(self->cti.getClasses.getReply(ConfigTransactionGetConfigClassesRequest{ generation })); Standalone result; for (const auto& configClass : reply.configClasses) { result.push_back_deep(result.arena(), KeyValueRef(configClass, ""_sr)); @@ -90,12 +91,12 @@ class SimpleConfigTransactionImpl { ACTOR static Future> getKnobs(SimpleConfigTransactionImpl* self, Optional configClass) { - if (!self->getVersionFuture.isValid()) { - self->getVersionFuture = getReadVersion(self); + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); } - Version version = wait(self->getVersionFuture); + ConfigGeneration generation = wait(self->getGenerationFuture); ConfigTransactionGetKnobsReply reply = - wait(self->cti.getKnobs.getReply(ConfigTransactionGetKnobsRequest{ version, configClass })); + wait(self->cti.getKnobs.getReply(ConfigTransactionGetKnobsRequest{ generation, configClass })); Standalone result; for (const auto& knobName : reply.knobNames) { result.push_back_deep(result.arena(), KeyValueRef(knobName, ""_sr)); @@ -104,10 +105,10 @@ class SimpleConfigTransactionImpl { } ACTOR static Future commit(SimpleConfigTransactionImpl* self) { - if (!self->getVersionFuture.isValid()) { - self->getVersionFuture = getReadVersion(self); + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); } - wait(store(self->toCommit.version, self->getVersionFuture)); + wait(store(self->toCommit.generation, self->getGenerationFuture)); self->toCommit.annotation.timestamp = now(); wait(self->cti.commit.getReply(self->toCommit)); self->committed = true; @@ -170,23 +171,23 @@ public: } Future getReadVersion() { - if (!getVersionFuture.isValid()) - getVersionFuture = getReadVersion(this); - return getVersionFuture; + if (!getGenerationFuture.isValid()) + getGenerationFuture = getGeneration(this); + return map(getGenerationFuture, [](auto const& gen) { return gen.committedVersion; }); } Optional getCachedReadVersion() const { - if (getVersionFuture.isValid() && getVersionFuture.isReady() && !getVersionFuture.isError()) { - return getVersionFuture.get(); + if (getGenerationFuture.isValid() && getGenerationFuture.isReady() && !getGenerationFuture.isError()) { + return getGenerationFuture.get().liveVersion; } else { return {}; } } - Version getCommittedVersion() const { return committed ? getVersionFuture.get() : ::invalidVersion; } + Version getCommittedVersion() const { return committed ? getGenerationFuture.get().liveVersion : ::invalidVersion; } void reset() { - getVersionFuture = Future{}; + getGenerationFuture = Future{}; toCommit = {}; committed = false; } diff --git a/fdbserver/SimpleConfigDatabaseNode.actor.cpp b/fdbserver/SimpleConfigDatabaseNode.actor.cpp index 9fb14498c9..4e12adb4cd 100644 --- a/fdbserver/SimpleConfigDatabaseNode.actor.cpp +++ b/fdbserver/SimpleConfigDatabaseNode.actor.cpp @@ -33,8 +33,7 @@ namespace { const KeyRef lastCompactedVersionKey = "lastCompactedVersion"_sr; -const KeyRef liveTransactionVersionKey = "liveTransactionVersion"_sr; -const KeyRef committedVersionKey = "committedVersion"_sr; +const KeyRef currentGenerationKey = "currentGeneration"_sr; const KeyRangeRef kvKeys = KeyRangeRef("kv/"_sr, "kv0"_sr); const KeyRangeRef mutationKeys = KeyRangeRef("mutation/"_sr, "mutation0"_sr); const KeyRangeRef annotationKeys = KeyRangeRef("annotation/"_sr, "annotation0"_sr); @@ -114,28 +113,16 @@ class SimpleConfigDatabaseNodeImpl { Counter newVersionRequests; Future logger; - ACTOR static Future getLiveTransactionVersion(SimpleConfigDatabaseNodeImpl *self) { - Optional value = wait(self->kvStore->readValue(liveTransactionVersionKey)); - state Version liveTransactionVersion = 0; + ACTOR static Future getGeneration(SimpleConfigDatabaseNodeImpl* self) { + state ConfigGeneration generation; + Optional value = wait(self->kvStore->readValue(currentGenerationKey)); if (value.present()) { - liveTransactionVersion = BinaryReader::fromStringRef(value.get(), IncludeVersion()); + generation = BinaryReader::fromStringRef(value.get(), IncludeVersion()); } else { - self->kvStore->set(KeyValueRef(liveTransactionVersionKey, BinaryWriter::toValue(liveTransactionVersion, IncludeVersion()))); + self->kvStore->set(KeyValueRef(currentGenerationKey, BinaryWriter::toValue(generation, IncludeVersion()))); wait(self->kvStore->commit()); } - return liveTransactionVersion; - } - - ACTOR static Future getCommittedVersion(SimpleConfigDatabaseNodeImpl *self) { - Optional value = wait(self->kvStore->readValue(committedVersionKey)); - state Version committedVersion = 0; - if (value.present()) { - committedVersion = BinaryReader::fromStringRef(value.get(), IncludeVersion()); - } else { - self->kvStore->set(KeyValueRef(committedVersionKey, BinaryWriter::toValue(committedVersion, IncludeVersion()))); - wait(self->kvStore->commit()); - } - return committedVersion; + return generation; } ACTOR static Future getLastCompactedVersion(SimpleConfigDatabaseNodeImpl* self) { @@ -192,7 +179,8 @@ class SimpleConfigDatabaseNodeImpl { req.reply.sendError(version_already_compacted()); return Void(); } - state Version committedVersion = wait(getCommittedVersion(self)); + state Version committedVersion = + wait(map(getGeneration(self), [](auto const& gen) { return gen.committedVersion; })); state Standalone> versionedMutations = wait(getMutations(self, req.lastSeenVersion + 1, committedVersion)); state Standalone> versionedAnnotations = @@ -209,17 +197,20 @@ class SimpleConfigDatabaseNodeImpl { // New transactions increment the database's current live version. This effectively serves as a lock, providing // serializability - ACTOR static Future getNewVersion(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionGetVersionRequest req) { - state Version currentVersion = wait(getLiveTransactionVersion(self)); - self->kvStore->set(KeyValueRef(liveTransactionVersionKey, BinaryWriter::toValue(++currentVersion, IncludeVersion()))); + ACTOR static Future getNewGeneration(SimpleConfigDatabaseNodeImpl* self, + ConfigTransactionGetGenerationRequest req) { + state ConfigGeneration generation = wait(getGeneration(self)); + ++generation.liveVersion; + self->kvStore->set(KeyValueRef(currentGenerationKey, BinaryWriter::toValue(generation, IncludeVersion()))); wait(self->kvStore->commit()); - req.reply.send(ConfigTransactionGetVersionReply(currentVersion)); + req.reply.send(ConfigTransactionGetGenerationReply{ generation }); return Void(); } ACTOR static Future get(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionGetRequest req) { - Version currentVersion = wait(getLiveTransactionVersion(self)); - if (req.version != currentVersion) { + ConfigGeneration currentGeneration = wait(getGeneration(self)); + if (req.generation != currentGeneration) { + // TODO: Also send information about highest seen version req.reply.sendError(transaction_too_old()); return Void(); } @@ -229,7 +220,8 @@ class SimpleConfigDatabaseNodeImpl { if (serializedValue.present()) { value = ObjectReader::fromStringRef(serializedValue.get(), IncludeVersion()); } - Standalone> versionedMutations = wait(getMutations(self, 0, req.version)); + Standalone> versionedMutations = + wait(getMutations(self, 0, req.generation.committedVersion)); for (const auto &versionedMutation : versionedMutations) { const auto &mutation = versionedMutation.mutation; if (mutation.getKey() == req.key) { @@ -249,8 +241,8 @@ class SimpleConfigDatabaseNodeImpl { // may want to fix this to clean up the contract ACTOR static Future getConfigClasses(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionGetConfigClassesRequest req) { - Version currentVersion = wait(getLiveTransactionVersion(self)); - if (req.version != currentVersion) { + ConfigGeneration currentGeneration = wait(getGeneration(self)); + if (req.generation != currentGeneration) { req.reply.sendError(transaction_too_old()); return Void(); } @@ -265,7 +257,7 @@ class SimpleConfigDatabaseNodeImpl { } state Version lastCompactedVersion = wait(getLastCompactedVersion(self)); state Standalone> mutations = - wait(getMutations(self, lastCompactedVersion + 1, req.version)); + wait(getMutations(self, lastCompactedVersion + 1, req.generation.committedVersion)); for (const auto& versionedMutation : mutations) { auto configClass = versionedMutation.mutation.getConfigClass(); if (configClass.present()) { @@ -282,8 +274,8 @@ class SimpleConfigDatabaseNodeImpl { // Retrieve all knobs explicitly defined for the specified configuration class ACTOR static Future getKnobs(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionGetKnobsRequest req) { - Version currentVersion = wait(getLiveTransactionVersion(self)); - if (req.version != currentVersion) { + ConfigGeneration currentGeneration = wait(getGeneration(self)); + if (req.generation != currentGeneration) { req.reply.sendError(transaction_too_old()); return Void(); } @@ -299,7 +291,7 @@ class SimpleConfigDatabaseNodeImpl { } state Version lastCompactedVersion = wait(getLastCompactedVersion(self)); state Standalone> mutations = - wait(getMutations(self, lastCompactedVersion + 1, req.version)); + wait(getMutations(self, lastCompactedVersion + 1, req.generation.committedVersion)); for (const auto& versionedMutation : mutations) { if (versionedMutation.mutation.getConfigClass().template castTo() == req.configClass) { if (versionedMutation.mutation.isSet()) { @@ -318,31 +310,32 @@ class SimpleConfigDatabaseNodeImpl { } ACTOR static Future commit(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionCommitRequest req) { - Version currentVersion = wait(getLiveTransactionVersion(self)); - if (req.version != currentVersion) { + ConfigGeneration currentGeneration = wait(getGeneration(self)); + if (req.generation != currentGeneration) { ++self->failedCommits; req.reply.sendError(transaction_too_old()); return Void(); } int index = 0; for (const auto &mutation : req.mutations) { - Key key = versionedMutationKey(req.version, index++); + Key key = versionedMutationKey(req.generation.liveVersion, index++); Value value = ObjectWriter::toValue(mutation, IncludeVersion()); if (mutation.isSet()) { TraceEvent("SimpleConfigDatabaseNodeSetting") .detail("ConfigClass", mutation.getConfigClass()) .detail("KnobName", mutation.getKnobName()) .detail("Value", mutation.getValue().toString()) - .detail("Version", req.version); + .detail("Version", req.generation.liveVersion); ++self->setMutations; } else { ++self->clearMutations; } self->kvStore->set(KeyValueRef(key, value)); } - self->kvStore->set( - KeyValueRef(versionedAnnotationKey(req.version), BinaryWriter::toValue(req.annotation, IncludeVersion()))); - self->kvStore->set(KeyValueRef(committedVersionKey, BinaryWriter::toValue(req.version, IncludeVersion()))); + self->kvStore->set(KeyValueRef(versionedAnnotationKey(req.generation.liveVersion), + BinaryWriter::toValue(req.annotation, IncludeVersion()))); + ConfigGeneration newGeneration = { req.generation.liveVersion, req.generation.liveVersion }; + self->kvStore->set(KeyValueRef(currentGenerationKey, BinaryWriter::toValue(newGeneration, IncludeVersion()))); wait(self->kvStore->commit()); ++self->successfulCommits; req.reply.send(Void()); @@ -352,9 +345,9 @@ class SimpleConfigDatabaseNodeImpl { ACTOR static Future serve(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionInterface const* cti) { loop { choose { - when(ConfigTransactionGetVersionRequest req = waitNext(cti->getVersion.getFuture())) { + when(ConfigTransactionGetGenerationRequest req = waitNext(cti->getGeneration.getFuture())) { ++self->newVersionRequests; - wait(getNewVersion(self, req)); + wait(getNewGeneration(self, req)); } when(ConfigTransactionGetRequest req = waitNext(cti->get.getFuture())) { ++self->getValueRequests; @@ -384,7 +377,8 @@ class SimpleConfigDatabaseNodeImpl { ObjectReader::fromStringRef(kv.value, IncludeVersion()); } wait(store(reply.snapshotVersion, getLastCompactedVersion(self))); - wait(store(reply.changesVersion, getCommittedVersion(self))); + wait(store(reply.changesVersion, + map(getGeneration(self), [](auto const& gen) { return gen.committedVersion; }))); wait(store(reply.changes, getMutations(self, reply.snapshotVersion + 1, reply.changesVersion))); wait(store(reply.annotations, getAnnotations(self, reply.snapshotVersion + 1, reply.changesVersion))); TraceEvent(SevDebug, "ConfigDatabaseNodeGettingSnapshot", self->id) From de871da75f453cfb6c2ba8061cf1f7e6c7f5a57b Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 14:02:45 -0700 Subject: [PATCH 050/225] Add some simple implementations to PaxosConfigTransaction methods --- fdbclient/ConfigTransactionInterface.cpp | 20 +++ fdbclient/ConfigTransactionInterface.h | 3 + fdbclient/PaxosConfigTransaction.actor.cpp | 165 +++++++++++++++----- fdbclient/PaxosConfigTransaction.h | 1 + fdbclient/SimpleConfigTransaction.actor.cpp | 20 +-- 5 files changed, 152 insertions(+), 57 deletions(-) diff --git a/fdbclient/ConfigTransactionInterface.cpp b/fdbclient/ConfigTransactionInterface.cpp index 838e69e091..66618e01d7 100644 --- a/fdbclient/ConfigTransactionInterface.cpp +++ b/fdbclient/ConfigTransactionInterface.cpp @@ -20,6 +20,7 @@ #include "fdbclient/ConfigTransactionInterface.h" #include "fdbclient/CoordinationInterface.h" +#include "fdbclient/SystemData.h" #include "flow/IRandom.h" ConfigTransactionInterface::ConfigTransactionInterface() : _id(deterministicRandom()->randomUniqueID()) {} @@ -53,3 +54,22 @@ bool ConfigGeneration::operator==(ConfigGeneration const& rhs) const { bool ConfigGeneration::operator!=(ConfigGeneration const& rhs) const { return !(*this == rhs); } + +void ConfigTransactionCommitRequest::set(KeyRef key, ValueRef value) { + if (key == configTransactionDescriptionKey) { + annotation.description = KeyRef(arena, value); + } else { + ConfigKey configKey = ConfigKeyRef::decodeKey(key); + auto knobValue = IKnobCollection::parseKnobValue( + configKey.knobName.toString(), value.toString(), IKnobCollection::Type::TEST); + mutations.emplace_back_deep(arena, configKey, knobValue.contents()); + } +} + +void ConfigTransactionCommitRequest::clear(KeyRef key) { + if (key == configTransactionDescriptionKey) { + annotation.description = ""_sr; + } else { + mutations.emplace_back_deep(arena, ConfigKeyRef::decodeKey(key), Optional{}); + } +} diff --git a/fdbclient/ConfigTransactionInterface.h b/fdbclient/ConfigTransactionInterface.h index b5a6437378..d2e19ad0ab 100644 --- a/fdbclient/ConfigTransactionInterface.h +++ b/fdbclient/ConfigTransactionInterface.h @@ -101,6 +101,9 @@ struct ConfigTransactionCommitRequest { size_t expectedSize() const { return mutations.expectedSize() + annotation.expectedSize(); } + void set(KeyRef key, ValueRef value); + void clear(KeyRef key); + template void serialize(Ar& ar) { serializer(ar, arena, generation, mutations, annotation, reply); diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index f6ac8b69e9..ac94b70b1b 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -18,24 +18,125 @@ * limitations under the License. */ +#include "fdbclient/DatabaseContext.h" #include "fdbclient/PaxosConfigTransaction.h" #include "flow/actorcompiler.h" // must be last include -class PaxosConfigTransactionImpl {}; +class PaxosConfigTransactionImpl { + ConfigTransactionCommitRequest toCommit; + Future getGenerationFuture; + std::vector ctis; + int numRetries{ 0 }; + bool committed{ false }; + Optional dID; + Database cx; + + ACTOR static Future getGeneration(PaxosConfigTransactionImpl* self) { + state std::vector> getGenerationFutures; + getGenerationFutures.reserve(self->ctis.size()); + for (auto const& cti : self->ctis) { + getGenerationFutures.push_back(cti.getGeneration.getReply(ConfigTransactionGetGenerationRequest{})); + } + // FIXME: Must tolerate failures and disagreement + wait(waitForAll(getGenerationFutures)); + return getGenerationFutures[0].get().generation; + } + + ACTOR static Future> get(PaxosConfigTransactionImpl* self, Key key) { + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); + } + state ConfigKey configKey = ConfigKey::decodeKey(key); + ConfigGeneration generation = wait(self->getGenerationFuture); + // TODO: Load balance + ConfigTransactionGetReply reply = + wait(self->ctis[0].get.getReply(ConfigTransactionGetRequest{ generation, configKey })); + if (reply.value.present()) { + return reply.value.get().toValue(); + } else { + return Optional{}; + } + } + +public: + Future getReadVersion() { + if (!getGenerationFuture.isValid()) { + getGenerationFuture = getGeneration(this); + } + return map(getGenerationFuture, [](auto const& gen) { return gen.committedVersion; }); + } + + Optional getCachedReadVersion() const { + if (getGenerationFuture.isValid() && getGenerationFuture.isReady() && !getGenerationFuture.isError()) { + return getGenerationFuture.get().liveVersion; + } else { + return {}; + } + } + + Version getCommittedVersion() const { return committed ? getGenerationFuture.get().liveVersion : ::invalidVersion; } + + int64_t getApproximateSize() const { return toCommit.expectedSize(); } + + void set(KeyRef key, ValueRef value) { toCommit.set(key, value); } + + void clear(KeyRef key) { toCommit.clear(key); } + + Future> get(Key const& key) { return get(this, key); } + + Future onError(Error const& e) { + // TODO: Improve this: + if (e.code() == error_code_transaction_too_old) { + reset(); + return delay((1 << numRetries++) * 0.01 * deterministicRandom()->random01()); + } + throw e; + } + + void debugTransaction(UID dID) { this->dID = dID; } + + void reset() { + getGenerationFuture = Future{}; + toCommit = {}; + committed = false; + } + + void fullReset() { + numRetries = 0; + dID = {}; + reset(); + } + + void checkDeferredError(Error const& deferredError) const { + if (deferredError.code() != invalid_error_code) { + throw deferredError; + } + if (cx.getPtr()) { + cx->checkDeferredError(); + } + } + + PaxosConfigTransactionImpl(Database const& cx) : cx(cx) { + auto coordinators = cx->getConnectionFile()->getConnectionString().coordinators(); + ctis.reserve(coordinators.size()); + for (const auto& coordinator : coordinators) { + ctis.emplace_back(coordinator); + } + } + + PaxosConfigTransactionImpl(std::vector const& ctis) : ctis(ctis) {} +}; Future PaxosConfigTransaction::getReadVersion() { - // TODO: Implement - return ::invalidVersion; + return impl().getReadVersion(); } Optional PaxosConfigTransaction::getCachedReadVersion() const { - // TODO: Implement - return ::invalidVersion; + return impl().getCachedReadVersion(); } -Future> PaxosConfigTransaction::get(Key const& key, Snapshot snapshot) { - // TODO: Implement - return Optional{}; +Future> PaxosConfigTransaction::get(Key const& key, Snapshot) { + return impl().get(key); } Future> PaxosConfigTransaction::getRange(KeySelector const& begin, @@ -59,13 +160,11 @@ Future> PaxosConfigTransaction::getRange(KeySelector } void PaxosConfigTransaction::set(KeyRef const& key, ValueRef const& value) { - // TODO: Implememnt - ASSERT(false); + return impl().set(key, value); } void PaxosConfigTransaction::clear(KeyRef const& key) { - // TODO: Implememnt - ASSERT(false); + return impl().clear(key); } Future PaxosConfigTransaction::commit() { @@ -75,61 +174,49 @@ Future PaxosConfigTransaction::commit() { } Version PaxosConfigTransaction::getCommittedVersion() const { - // TODO: Implement - ASSERT(false); - return ::invalidVersion; + return impl().getCommittedVersion(); } int64_t PaxosConfigTransaction::getApproximateSize() const { - // TODO: Implement - ASSERT(false); - return 0; + return impl().getApproximateSize(); } void PaxosConfigTransaction::setOption(FDBTransactionOptions::Option option, Optional value) { - // TODO: Implement - ASSERT(false); + // TODO: Support using this option to determine atomicity } Future PaxosConfigTransaction::onError(Error const& e) { - // TODO: Implement - ASSERT(false); - return Void(); + return impl().onError(e); } void PaxosConfigTransaction::cancel() { - // TODO: Implement - ASSERT(false); + // TODO: Implement someday + throw client_invalid_operation(); } void PaxosConfigTransaction::reset() { - // TODO: Implement - ASSERT(false); + impl().reset(); } void PaxosConfigTransaction::fullReset() { - // TODO: Implement - ASSERT(false); + impl().fullReset(); } void PaxosConfigTransaction::debugTransaction(UID dID) { - // TODO: Implement - ASSERT(false); + impl().debugTransaction(dID); } void PaxosConfigTransaction::checkDeferredError() const { - // TODO: Implement - ASSERT(false); + impl().checkDeferredError(deferredError); } -PaxosConfigTransaction::PaxosConfigTransaction() { - // TODO: Implement - ASSERT(false); -} +PaxosConfigTransaction::PaxosConfigTransaction(std::vector const& ctis) + : _impl(std::make_unique(ctis)) {} + +PaxosConfigTransaction::PaxosConfigTransaction() = default; PaxosConfigTransaction::~PaxosConfigTransaction() = default; void PaxosConfigTransaction::setDatabase(Database const& cx) { - // TODO: Implement - ASSERT(false); + _impl = std::make_unique(cx); } diff --git a/fdbclient/PaxosConfigTransaction.h b/fdbclient/PaxosConfigTransaction.h index 7c68fcba05..8a9bdd7ebe 100644 --- a/fdbclient/PaxosConfigTransaction.h +++ b/fdbclient/PaxosConfigTransaction.h @@ -33,6 +33,7 @@ class PaxosConfigTransaction final : public IConfigTransaction, public FastAlloc PaxosConfigTransactionImpl& impl() { return *_impl; } public: + PaxosConfigTransaction(std::vector const&); PaxosConfigTransaction(); ~PaxosConfigTransaction(); void setDatabase(Database const&) override; diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index 70e8ec7b0d..8511716e04 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -124,25 +124,9 @@ public: SimpleConfigTransactionImpl(ConfigTransactionInterface const& cti) : cti(cti) {} - void set(KeyRef key, ValueRef value) { - if (key == configTransactionDescriptionKey) { - toCommit.annotation.description = KeyRef(toCommit.arena, value); - } else { - ConfigKey configKey = ConfigKeyRef::decodeKey(key); - auto knobValue = IKnobCollection::parseKnobValue( - configKey.knobName.toString(), value.toString(), IKnobCollection::Type::TEST); - toCommit.mutations.emplace_back_deep(toCommit.arena, configKey, knobValue.contents()); - } - } + void set(KeyRef key, ValueRef value) { toCommit.set(key, value); } - void clear(KeyRef key) { - if (key == configTransactionDescriptionKey) { - toCommit.annotation.description = ""_sr; - } else { - toCommit.mutations.emplace_back_deep( - toCommit.arena, ConfigKeyRef::decodeKey(key), Optional{}); - } - } + void clear(KeyRef key) { toCommit.clear(key); } Future> get(KeyRef key) { return get(this, key); } From 91e6b7d83de8083302332372620ea8386e0be288 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 14:21:21 -0700 Subject: [PATCH 051/225] Implement several more PaxosConfigTransaction methods --- fdbclient/PaxosConfigTransaction.actor.cpp | 70 +++++++++++++++++---- fdbclient/SimpleConfigTransaction.actor.cpp | 6 ++ 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index ac94b70b1b..0f56b8e60b 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -58,6 +58,39 @@ class PaxosConfigTransactionImpl { } } + ACTOR static Future getConfigClasses(PaxosConfigTransactionImpl* self) { + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); + } + ConfigGeneration generation = wait(self->getGenerationFuture); + // TODO: Load balance + ConfigTransactionGetConfigClassesReply reply = + wait(self->ctis[0].getClasses.getReply(ConfigTransactionGetConfigClassesRequest{ generation })); + RangeResult result; + result.reserve(result.arena(), reply.configClasses.size()); + for (const auto& configClass : reply.configClasses) { + result.push_back_deep(result.arena(), KeyValueRef(configClass, ""_sr)); + } + return result; + } + + ACTOR static Future> getKnobs(PaxosConfigTransactionImpl* self, + Optional configClass) { + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); + } + ConfigGeneration generation = wait(self->getGenerationFuture); + // TODO: Load balance + ConfigTransactionGetKnobsReply reply = + wait(self->ctis[0].getKnobs.getReply(ConfigTransactionGetKnobsRequest{ generation, configClass })); + RangeResult result; + result.reserve(result.arena(), reply.knobNames.size()); + for (const auto& knobName : reply.knobNames) { + result.push_back_deep(result.arena(), KeyValueRef(knobName, ""_sr)); + } + return result; + } + public: Future getReadVersion() { if (!getGenerationFuture.isValid()) { @@ -84,6 +117,19 @@ public: Future> get(Key const& key) { return get(this, key); } + Future getRange(KeyRangeRef keys) { + if (keys == configClassKeys) { + return getConfigClasses(this); + } else if (keys == globalConfigKnobKeys) { + return getKnobs(this, {}); + } else if (configKnobKeys.contains(keys) && keys.singleKeyRange()) { + const auto configClass = keys.begin.removePrefix(configKnobKeys.begin); + return getKnobs(this, configClass); + } else { + throw invalid_config_db_range_read(); + } + } + Future onError(Error const& e) { // TODO: Improve this: if (e.code() == error_code_transaction_too_old) { @@ -139,14 +185,15 @@ Future> PaxosConfigTransaction::get(Key const& key, Snapshot) { return impl().get(key); } -Future> PaxosConfigTransaction::getRange(KeySelector const& begin, - KeySelector const& end, - int limit, - Snapshot snapshot, - Reverse reverse) { - // TODO: Implement - ASSERT(false); - return Standalone{}; +Future PaxosConfigTransaction::getRange(KeySelector const& begin, + KeySelector const& end, + int limit, + Snapshot snapshot, + Reverse reverse) { + if (reverse) { + throw client_invalid_operation(); + } + return impl().getRange(KeyRangeRef(begin.getKey(), end.getKey())); } Future> PaxosConfigTransaction::getRange(KeySelector begin, @@ -154,9 +201,10 @@ Future> PaxosConfigTransaction::getRange(KeySelector GetRangeLimits limits, Snapshot snapshot, Reverse reverse) { - // TODO: Implement - ASSERT(false); - return Standalone{}; + if (reverse) { + throw client_invalid_operation(); + } + return impl().getRange(KeyRangeRef(begin.getKey(), end.getKey())); } void PaxosConfigTransaction::set(KeyRef const& key, ValueRef const& value) { diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index 8511716e04..943ce5357c 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -215,6 +215,9 @@ Future> SimpleConfigTransaction::getRange(KeySelector int limit, Snapshot snapshot, Reverse reverse) { + if (reverse) { + throw client_invalid_operation(); + } return impl().getRange(KeyRangeRef(begin.getKey(), end.getKey())); } @@ -223,6 +226,9 @@ Future> SimpleConfigTransaction::getRange(KeySelector GetRangeLimits limits, Snapshot snapshot, Reverse reverse) { + if (reverse) { + throw client_invalid_operation(); + } return impl().getRange(KeyRangeRef(begin.getKey(), end.getKey())); } From b24b46c8629e3137af9e90f05e7a93b46eeaccdb Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 14:26:15 -0700 Subject: [PATCH 052/225] Replace Standalone with RangeResult in configuration database code --- fdbclient/ISingleThreadTransaction.h | 20 ++++++------- fdbclient/PaxosConfigTransaction.actor.cpp | 13 ++++---- fdbclient/PaxosConfigTransaction.h | 20 ++++++------- fdbclient/ReadYourWrites.h | 28 +++++++++--------- fdbclient/SimpleConfigTransaction.actor.cpp | 31 ++++++++++---------- fdbclient/SimpleConfigTransaction.h | 20 ++++++------- fdbserver/ConfigDatabaseUnitTests.actor.cpp | 4 +-- fdbserver/LocalConfiguration.actor.cpp | 2 +- fdbserver/SimpleConfigDatabaseNode.actor.cpp | 10 +++---- 9 files changed, 73 insertions(+), 75 deletions(-) diff --git a/fdbclient/ISingleThreadTransaction.h b/fdbclient/ISingleThreadTransaction.h index 950e723e11..e1c9aa9575 100644 --- a/fdbclient/ISingleThreadTransaction.h +++ b/fdbclient/ISingleThreadTransaction.h @@ -52,16 +52,16 @@ public: virtual Optional getCachedReadVersion() const = 0; virtual Future> get(const Key& key, Snapshot = Snapshot::False) = 0; virtual Future getKey(const KeySelector& key, Snapshot = Snapshot::False) = 0; - virtual Future> getRange(const KeySelector& begin, - const KeySelector& end, - int limit, - Snapshot = Snapshot::False, - Reverse = Reverse::False) = 0; - virtual Future> getRange(KeySelector begin, - KeySelector end, - GetRangeLimits limits, - Snapshot = Snapshot::False, - Reverse = Reverse::False) = 0; + virtual Future getRange(const KeySelector& begin, + const KeySelector& end, + int limit, + Snapshot = Snapshot::False, + Reverse = Reverse::False) = 0; + virtual Future getRange(KeySelector begin, + KeySelector end, + GetRangeLimits limits, + Snapshot = Snapshot::False, + Reverse = Reverse::False) = 0; virtual Future>> getAddressesForKey(Key const& key) = 0; virtual Future>> getRangeSplitPoints(KeyRange const& range, int64_t chunkSize) = 0; virtual Future getEstimatedRangeSizeBytes(KeyRange const& keys) = 0; diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index 0f56b8e60b..29d88cc519 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -74,8 +74,7 @@ class PaxosConfigTransactionImpl { return result; } - ACTOR static Future> getKnobs(PaxosConfigTransactionImpl* self, - Optional configClass) { + ACTOR static Future getKnobs(PaxosConfigTransactionImpl* self, Optional configClass) { if (!self->getGenerationFuture.isValid()) { self->getGenerationFuture = getGeneration(self); } @@ -196,11 +195,11 @@ Future PaxosConfigTransaction::getRange(KeySelector const& begin, return impl().getRange(KeyRangeRef(begin.getKey(), end.getKey())); } -Future> PaxosConfigTransaction::getRange(KeySelector begin, - KeySelector end, - GetRangeLimits limits, - Snapshot snapshot, - Reverse reverse) { +Future PaxosConfigTransaction::getRange(KeySelector begin, + KeySelector end, + GetRangeLimits limits, + Snapshot snapshot, + Reverse reverse) { if (reverse) { throw client_invalid_operation(); } diff --git a/fdbclient/PaxosConfigTransaction.h b/fdbclient/PaxosConfigTransaction.h index 8a9bdd7ebe..758507b7ec 100644 --- a/fdbclient/PaxosConfigTransaction.h +++ b/fdbclient/PaxosConfigTransaction.h @@ -41,16 +41,16 @@ public: Optional getCachedReadVersion() const override; Future> get(Key const& key, Snapshot = Snapshot::False) override; - Future> getRange(KeySelector const& begin, - KeySelector const& end, - int limit, - Snapshot = Snapshot::False, - Reverse = Reverse::False) override; - Future> getRange(KeySelector begin, - KeySelector end, - GetRangeLimits limits, - Snapshot = Snapshot::False, - Reverse = Reverse::False) override; + Future getRange(KeySelector const& begin, + KeySelector const& end, + int limit, + Snapshot = Snapshot::False, + Reverse = Reverse::False) override; + Future getRange(KeySelector begin, + KeySelector end, + GetRangeLimits limits, + Snapshot = Snapshot::False, + Reverse = Reverse::False) override; void set(KeyRef const& key, ValueRef const& value) override; void clear(KeyRangeRef const&) override { throw client_invalid_operation(); } void clear(KeyRef const&) override; diff --git a/fdbclient/ReadYourWrites.h b/fdbclient/ReadYourWrites.h index 092a67793e..53431e00ed 100644 --- a/fdbclient/ReadYourWrites.h +++ b/fdbclient/ReadYourWrites.h @@ -74,20 +74,20 @@ public: Optional getCachedReadVersion() const override { return tr.getCachedReadVersion(); } Future> get(const Key& key, Snapshot = Snapshot::False) override; Future getKey(const KeySelector& key, Snapshot = Snapshot::False) override; - Future> getRange(const KeySelector& begin, - const KeySelector& end, - int limit, - Snapshot = Snapshot::False, - Reverse = Reverse::False) override; - Future> getRange(KeySelector begin, - KeySelector end, - GetRangeLimits limits, - Snapshot = Snapshot::False, - Reverse = Reverse::False) override; - Future> getRange(const KeyRange& keys, - int limit, - Snapshot snapshot = Snapshot::False, - Reverse reverse = Reverse::False) { + Future getRange(const KeySelector& begin, + const KeySelector& end, + int limit, + Snapshot = Snapshot::False, + Reverse = Reverse::False) override; + Future getRange(KeySelector begin, + KeySelector end, + GetRangeLimits limits, + Snapshot = Snapshot::False, + Reverse = Reverse::False) override; + Future getRange(const KeyRange& keys, + int limit, + Snapshot snapshot = Snapshot::False, + Reverse reverse = Reverse::False) { return getRange(KeySelector(firstGreaterOrEqual(keys.begin), keys.arena()), KeySelector(firstGreaterOrEqual(keys.end), keys.arena()), limit, diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index 943ce5357c..f9e0872e76 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -75,29 +75,28 @@ class SimpleConfigTransactionImpl { } } - ACTOR static Future> getConfigClasses(SimpleConfigTransactionImpl* self) { + ACTOR static Future getConfigClasses(SimpleConfigTransactionImpl* self) { if (!self->getGenerationFuture.isValid()) { self->getGenerationFuture = getGeneration(self); } ConfigGeneration generation = wait(self->getGenerationFuture); ConfigTransactionGetConfigClassesReply reply = wait(self->cti.getClasses.getReply(ConfigTransactionGetConfigClassesRequest{ generation })); - Standalone result; + RangeResult result; for (const auto& configClass : reply.configClasses) { result.push_back_deep(result.arena(), KeyValueRef(configClass, ""_sr)); } return result; } - ACTOR static Future> getKnobs(SimpleConfigTransactionImpl* self, - Optional configClass) { + ACTOR static Future getKnobs(SimpleConfigTransactionImpl* self, Optional configClass) { if (!self->getGenerationFuture.isValid()) { self->getGenerationFuture = getGeneration(self); } ConfigGeneration generation = wait(self->getGenerationFuture); ConfigTransactionGetKnobsReply reply = wait(self->cti.getKnobs.getReply(ConfigTransactionGetKnobsRequest{ generation, configClass })); - Standalone result; + RangeResult result; for (const auto& knobName : reply.knobNames) { result.push_back_deep(result.arena(), KeyValueRef(knobName, ""_sr)); } @@ -130,7 +129,7 @@ public: Future> get(KeyRef key) { return get(this, key); } - Future> getRange(KeyRangeRef keys) { + Future getRange(KeyRangeRef keys) { if (keys == configClassKeys) { return getConfigClasses(this); } else if (keys == globalConfigKnobKeys) { @@ -210,22 +209,22 @@ Future> SimpleConfigTransaction::get(Key const& key, Snapshot sn return impl().get(key); } -Future> SimpleConfigTransaction::getRange(KeySelector const& begin, - KeySelector const& end, - int limit, - Snapshot snapshot, - Reverse reverse) { +Future SimpleConfigTransaction::getRange(KeySelector const& begin, + KeySelector const& end, + int limit, + Snapshot snapshot, + Reverse reverse) { if (reverse) { throw client_invalid_operation(); } return impl().getRange(KeyRangeRef(begin.getKey(), end.getKey())); } -Future> SimpleConfigTransaction::getRange(KeySelector begin, - KeySelector end, - GetRangeLimits limits, - Snapshot snapshot, - Reverse reverse) { +Future SimpleConfigTransaction::getRange(KeySelector begin, + KeySelector end, + GetRangeLimits limits, + Snapshot snapshot, + Reverse reverse) { if (reverse) { throw client_invalid_operation(); } diff --git a/fdbclient/SimpleConfigTransaction.h b/fdbclient/SimpleConfigTransaction.h index faecd2f8b0..8190123271 100644 --- a/fdbclient/SimpleConfigTransaction.h +++ b/fdbclient/SimpleConfigTransaction.h @@ -50,16 +50,16 @@ public: Optional getCachedReadVersion() const override; Future> get(Key const& key, Snapshot = Snapshot::False) override; - Future> getRange(KeySelector const& begin, - KeySelector const& end, - int limit, - Snapshot = Snapshot::False, - Reverse = Reverse::False) override; - Future> getRange(KeySelector begin, - KeySelector end, - GetRangeLimits limits, - Snapshot = Snapshot::False, - Reverse = Reverse::False) override; + Future getRange(KeySelector const& begin, + KeySelector const& end, + int limit, + Snapshot = Snapshot::False, + Reverse = Reverse::False) override; + Future getRange(KeySelector begin, + KeySelector end, + GetRangeLimits limits, + Snapshot = Snapshot::False, + Reverse = Reverse::False) override; Future commit() override; Version getCommittedVersion() const override; void setOption(FDBTransactionOptions::Option option, Optional value = Optional()) override; diff --git a/fdbserver/ConfigDatabaseUnitTests.actor.cpp b/fdbserver/ConfigDatabaseUnitTests.actor.cpp index a99f4560cd..9ecd617980 100644 --- a/fdbserver/ConfigDatabaseUnitTests.actor.cpp +++ b/fdbserver/ConfigDatabaseUnitTests.actor.cpp @@ -293,7 +293,7 @@ class TransactionEnvironment { IConfigTransaction::createTestSimple(self->writeTo.getTransactionInterface()); state KeySelector begin = firstGreaterOrEqual(configClassKeys.begin); state KeySelector end = firstGreaterOrEqual(configClassKeys.end); - Standalone range = wait(tr->getRange(begin, end, 1000)); + RangeResult range = wait(tr->getRange(begin, end, 1000)); Standalone> result; for (const auto& kv : range) { result.push_back_deep(result.arena(), kv.key); @@ -312,7 +312,7 @@ class TransactionEnvironment { } KeySelector begin = firstGreaterOrEqual(keys.begin); KeySelector end = firstGreaterOrEqual(keys.end); - Standalone range = wait(tr->getRange(begin, end, 1000)); + RangeResult range = wait(tr->getRange(begin, end, 1000)); Standalone> result; for (const auto& kv : range) { result.push_back_deep(result.arena(), kv.key); diff --git a/fdbserver/LocalConfiguration.actor.cpp b/fdbserver/LocalConfiguration.actor.cpp index b522ca1fca..97ab6baf80 100644 --- a/fdbserver/LocalConfiguration.actor.cpp +++ b/fdbserver/LocalConfiguration.actor.cpp @@ -215,7 +215,7 @@ class LocalConfigurationImpl { self->updateInMemoryState(lastSeenVersion); return Void(); } - Standalone range = wait(self->kvStore->readRange(knobOverrideKeys)); + RangeResult range = wait(self->kvStore->readRange(knobOverrideKeys)); for (const auto& kv : range) { auto configKey = BinaryReader::fromStringRef(kv.key.removePrefix(knobOverrideKeys.begin), IncludeVersion()); diff --git a/fdbserver/SimpleConfigDatabaseNode.actor.cpp b/fdbserver/SimpleConfigDatabaseNode.actor.cpp index 4e12adb4cd..65bedd0f1b 100644 --- a/fdbserver/SimpleConfigDatabaseNode.actor.cpp +++ b/fdbserver/SimpleConfigDatabaseNode.actor.cpp @@ -144,7 +144,7 @@ class SimpleConfigDatabaseNodeImpl { Key startKey = versionedAnnotationKey(startVersion); Key endKey = versionedAnnotationKey(endVersion + 1); state KeyRangeRef keys(startKey, endKey); - Standalone range = wait(self->kvStore->readRange(keys)); + RangeResult range = wait(self->kvStore->readRange(keys)); Standalone> result; for (const auto& kv : range) { auto version = getVersionFromVersionedAnnotationKey(kv.key); @@ -161,7 +161,7 @@ class SimpleConfigDatabaseNodeImpl { Key startKey = versionedMutationKey(startVersion, 0); Key endKey = versionedMutationKey(endVersion + 1, 0); state KeyRangeRef keys(startKey, endKey); - Standalone range = wait(self->kvStore->readRange(keys)); + RangeResult range = wait(self->kvStore->readRange(keys)); Standalone> result; for (const auto &kv : range) { auto version = getVersionFromVersionedMutationKey(kv.key); @@ -246,7 +246,7 @@ class SimpleConfigDatabaseNodeImpl { req.reply.sendError(transaction_too_old()); return Void(); } - state Standalone snapshot = wait(self->kvStore->readRange(kvKeys)); + state RangeResult snapshot = wait(self->kvStore->readRange(kvKeys)); state std::set configClassesSet; for (const auto& kv : snapshot) { auto configKey = @@ -280,7 +280,7 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } // FIXME: Filtering after reading from disk is very inefficient - state Standalone snapshot = wait(self->kvStore->readRange(kvKeys)); + state RangeResult snapshot = wait(self->kvStore->readRange(kvKeys)); state std::set knobSet; for (const auto& kv : snapshot) { auto configKey = @@ -370,7 +370,7 @@ class SimpleConfigDatabaseNodeImpl { ACTOR static Future getSnapshotAndChanges(SimpleConfigDatabaseNodeImpl* self, ConfigFollowerGetSnapshotAndChangesRequest req) { state ConfigFollowerGetSnapshotAndChangesReply reply; - Standalone data = wait(self->kvStore->readRange(kvKeys)); + RangeResult data = wait(self->kvStore->readRange(kvKeys)); for (const auto& kv : data) { reply .snapshot[BinaryReader::fromStringRef(kv.key.removePrefix(kvKeys.begin), IncludeVersion())] = From 7de573faf817fcc7998854588653b3a01e74d69e Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 14:43:58 -0700 Subject: [PATCH 053/225] Add simple PaxosConfigTransaction::commit implementation --- fdbclient/PaxosConfigTransaction.actor.cpp | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index 29d88cc519..4c10ec534e 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -90,6 +90,23 @@ class PaxosConfigTransactionImpl { return result; } + ACTOR static Future commit(PaxosConfigTransactionImpl* self) { + if (!self->getGenerationFuture.isValid()) { + self->getGenerationFuture = getGeneration(self); + } + wait(store(self->toCommit.generation, self->getGenerationFuture)); + self->toCommit.annotation.timestamp = now(); + std::vector> commitFutures; + commitFutures.reserve(self->ctis.size()); + for (const auto& cti : self->ctis) { + commitFutures.push_back(cti.commit.getReply(self->toCommit)); + } + // FIXME: Must tolerate failures and disagreement + wait(quorum(commitFutures, commitFutures.size() / 2 + 1)); + self->committed = true; + return Void(); + } + public: Future getReadVersion() { if (!getGenerationFuture.isValid()) { @@ -161,6 +178,8 @@ public: } } + Future commit() { return commit(this); } + PaxosConfigTransactionImpl(Database const& cx) : cx(cx) { auto coordinators = cx->getConnectionFile()->getConnectionString().coordinators(); ctis.reserve(coordinators.size()); @@ -215,9 +234,7 @@ void PaxosConfigTransaction::clear(KeyRef const& key) { } Future PaxosConfigTransaction::commit() { - // TODO: Implememnt - ASSERT(false); - return Void(); + return impl().commit(); } Version PaxosConfigTransaction::getCommittedVersion() const { From 9cfd6ed955645f1e4ce04ad03de5badea3c35023 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 17:07:10 -0700 Subject: [PATCH 054/225] Add simple implementation to PaxosConfigConsumer --- fdbrpc/FlowTransport.actor.cpp | 4 +- fdbserver/ConfigFollowerInterface.cpp | 4 +- fdbserver/ConfigFollowerInterface.h | 50 +++++-- fdbserver/CoordinationInterface.h | 1 + fdbserver/PaxosConfigConsumer.actor.cpp | 132 +++++++++++++++++-- fdbserver/PaxosConfigConsumer.h | 9 +- fdbserver/SimpleConfigConsumer.actor.cpp | 55 ++++---- fdbserver/SimpleConfigDatabaseNode.actor.cpp | 7 +- 8 files changed, 204 insertions(+), 58 deletions(-) diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index 8a6b32df56..26473b1aa0 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -51,7 +51,7 @@ constexpr UID WLTOKEN_PING_PACKET(-1, 1); constexpr int PACKET_LEN_WIDTH = sizeof(uint32_t); const uint64_t TOKEN_STREAM_FLAG = 1; -static constexpr int WLTOKEN_COUNTS = 20; // number of wellKnownEndpoints +static constexpr int WLTOKEN_COUNTS = 21; // number of wellKnownEndpoints class EndpointMap : NonCopyable { public: @@ -1723,4 +1723,4 @@ void FlowTransport::createInstance(bool isClient, uint64_t transportId) { HealthMonitor* FlowTransport::healthMonitor() { return &self->healthMonitor; -} \ No newline at end of file +} diff --git a/fdbserver/ConfigFollowerInterface.cpp b/fdbserver/ConfigFollowerInterface.cpp index 47c18e8c9c..b78afa091a 100644 --- a/fdbserver/ConfigFollowerInterface.cpp +++ b/fdbserver/ConfigFollowerInterface.cpp @@ -27,6 +27,7 @@ void ConfigFollowerInterface::setupWellKnownEndpoints() { TaskPriority::Coordination); getChanges.makeWellKnownEndpoint(WLTOKEN_CONFIGFOLLOWER_GETCHANGES, TaskPriority::Coordination); compact.makeWellKnownEndpoint(WLTOKEN_CONFIGFOLLOWER_COMPACT, TaskPriority::Coordination); + getCommittedVersion.makeWellKnownEndpoint(WLTOKEN_CONFIGFOLLOWER_GETCOMMITTEDVERSION, TaskPriority::Coordination); } ConfigFollowerInterface::ConfigFollowerInterface() : _id(deterministicRandom()->randomUniqueID()) {} @@ -35,7 +36,8 @@ ConfigFollowerInterface::ConfigFollowerInterface(NetworkAddress const& remote) : _id(deterministicRandom()->randomUniqueID()), getSnapshotAndChanges(Endpoint({ remote }, WLTOKEN_CONFIGFOLLOWER_GETSNAPSHOTANDCHANGES)), getChanges(Endpoint({ remote }, WLTOKEN_CONFIGFOLLOWER_GETCHANGES)), - compact(Endpoint({ remote }, WLTOKEN_CONFIGFOLLOWER_COMPACT)) {} + compact(Endpoint({ remote }, WLTOKEN_CONFIGFOLLOWER_COMPACT)), + getCommittedVersion(Endpoint({ remote }, WLTOKEN_CONFIGFOLLOWER_GETCOMMITTEDVERSION)) {} bool ConfigFollowerInterface::operator==(ConfigFollowerInterface const& rhs) const { return _id == rhs._id; diff --git a/fdbserver/ConfigFollowerInterface.h b/fdbserver/ConfigFollowerInterface.h index b93908b5fe..542bb07186 100644 --- a/fdbserver/ConfigFollowerInterface.h +++ b/fdbserver/ConfigFollowerInterface.h @@ -66,7 +66,6 @@ using VersionedConfigCommitAnnotation = Standalone snapshot; // TODO: Share arena Standalone> changes; @@ -76,24 +75,26 @@ struct ConfigFollowerGetSnapshotAndChangesReply { template explicit ConfigFollowerGetSnapshotAndChangesReply( Version snapshotVersion, - Version changesVersion, Snapshot&& snapshot, Standalone> changes, Standalone> annotations) - : snapshotVersion(snapshotVersion), changesVersion(changesVersion), snapshot(std::forward(snapshot)), - changes(changes), annotations(annotations) { - ASSERT_GE(changesVersion, snapshotVersion); - } + : snapshotVersion(snapshotVersion), snapshot(std::forward(snapshot)), changes(changes), + annotations(annotations) {} template void serialize(Ar& ar) { - serializer(ar, snapshotVersion, changesVersion, snapshot, changes); + serializer(ar, snapshotVersion, snapshot, changes); } }; struct ConfigFollowerGetSnapshotAndChangesRequest { static constexpr FileIdentifier file_identifier = 294811; ReplyPromise reply; + Version mostRecentVersion; + + ConfigFollowerGetSnapshotAndChangesRequest() = default; + explicit ConfigFollowerGetSnapshotAndChangesRequest(Version mostRecentVersion) + : mostRecentVersion(mostRecentVersion) {} template void serialize(Ar& ar) { @@ -103,30 +104,31 @@ struct ConfigFollowerGetSnapshotAndChangesRequest { struct ConfigFollowerGetChangesReply { static constexpr FileIdentifier file_identifier = 234859; - Version mostRecentVersion; // TODO: Share arena Standalone> changes; Standalone> annotations; - ConfigFollowerGetChangesReply() : mostRecentVersion(0) {} + ConfigFollowerGetChangesReply() = default; explicit ConfigFollowerGetChangesReply(Version mostRecentVersion, Standalone> const& changes, Standalone> const& annotations) - : mostRecentVersion(mostRecentVersion), changes(changes), annotations(annotations) {} + : changes(changes), annotations(annotations) {} template void serialize(Ar& ar) { - serializer(ar, mostRecentVersion, changes, annotations); + serializer(ar, changes, annotations); } }; struct ConfigFollowerGetChangesRequest { static constexpr FileIdentifier file_identifier = 178935; Version lastSeenVersion{ 0 }; + Version mostRecentVersion{ 0 }; ReplyPromise reply; ConfigFollowerGetChangesRequest() = default; - explicit ConfigFollowerGetChangesRequest(Version lastSeenVersion) : lastSeenVersion(lastSeenVersion) {} + explicit ConfigFollowerGetChangesRequest(Version lastSeenVersion, Version mostRecentVersion) + : lastSeenVersion(lastSeenVersion), mostRecentVersion(mostRecentVersion) {} template void serialize(Ar& ar) { @@ -148,6 +150,29 @@ struct ConfigFollowerCompactRequest { } }; +struct ConfigFollowerGetCommittedVersionReply { + static constexpr FileIdentifier file_identifier = 9214735; + Version version; + + ConfigFollowerGetCommittedVersionReply() = default; + explicit ConfigFollowerGetCommittedVersionReply(Version version) : version(version) {} + + template + void serialize(Ar& ar) { + serializer(ar, version); + } +}; + +struct ConfigFollowerGetCommittedVersionRequest { + static constexpr FileIdentifier file_identifier = 1093472; + ReplyPromise reply; + + template + void serialize(Ar& ar) { + serializer(ar, reply); + } +}; + /* * Configuration database nodes serve a ConfigFollowerInterface which contains well known endpoints, * used by workers to receive configuration database updates @@ -160,6 +185,7 @@ public: RequestStream getSnapshotAndChanges; RequestStream getChanges; RequestStream compact; + RequestStream getCommittedVersion; ConfigFollowerInterface(); void setupWellKnownEndpoints(); diff --git a/fdbserver/CoordinationInterface.h b/fdbserver/CoordinationInterface.h index f5c920ff61..e525263965 100644 --- a/fdbserver/CoordinationInterface.h +++ b/fdbserver/CoordinationInterface.h @@ -35,6 +35,7 @@ constexpr UID WLTOKEN_GENERATIONREG_WRITE(-1, 9); constexpr UID WLTOKEN_CONFIGFOLLOWER_GETSNAPSHOTANDCHANGES(-1, 17); constexpr UID WLTOKEN_CONFIGFOLLOWER_GETCHANGES(-1, 18); constexpr UID WLTOKEN_CONFIGFOLLOWER_COMPACT(-1, 19); +constexpr UID WLTOKEN_CONFIGFOLLOWER_GETCOMMITTEDVERSION(-1, 20); struct GenerationRegInterface { constexpr static FileIdentifier file_identifier = 16726744; diff --git a/fdbserver/PaxosConfigConsumer.actor.cpp b/fdbserver/PaxosConfigConsumer.actor.cpp index e6c6e2f2e8..23379dc57b 100644 --- a/fdbserver/PaxosConfigConsumer.actor.cpp +++ b/fdbserver/PaxosConfigConsumer.actor.cpp @@ -20,25 +20,131 @@ #include "fdbserver/PaxosConfigConsumer.h" -class PaxosConfigConsumerImpl {}; +class PaxosConfigConsumerImpl { + std::vector cfis; + Version lastSeenVersion{ 0 }; + double pollingInterval; + Optional compactionInterval; + UID id; -PaxosConfigConsumer::PaxosConfigConsumer(ServerCoordinators const& cfi, - Optional pollingInterval, - Optional compactionInterval) { - // TODO: Implement - ASSERT(false); -} + ACTOR static Future getCommittedVersion(PaxosConfigConsumerImpl* self) { + state std::vector> committedVersionFutures; + committedVersionFutures.reserve(self->cfis.size()); + for (const auto& cfi : self->cfis) { + committedVersionFutures.push_back( + cfi.getCommittedVersion.getReply(ConfigFollowerGetCommittedVersionRequest{})); + } + // FIXME: Must tolerate failure and disagreement + wait(waitForAll(committedVersionFutures)); + return committedVersionFutures[0].get().version; + } + + ACTOR static Future compactor(PaxosConfigConsumerImpl* self, ConfigBroadcaster* broadcaster) { + if (!self->compactionInterval.present()) { + wait(Never()); + return Void(); + } + loop { + state Version compactionVersion = self->lastSeenVersion; + wait(delayJittered(self->compactionInterval.get())); + std::vector> compactionRequests; + compactionRequests.reserve(compactionRequests.size()); + for (const auto& cfi : self->cfis) { + compactionRequests.push_back(cfi.compact.getReply(ConfigFollowerCompactRequest{ compactionVersion })); + } + try { + wait(timeoutError(waitForAll(compactionRequests), 1.0)); + } catch (Error& e) { + TraceEvent(SevWarn, "ErrorSendingCompactionRequest").error(e); + } + } + } + + ACTOR static Future getSnapshotAndChanges(PaxosConfigConsumerImpl* self, ConfigBroadcaster* broadcaster) { + state Version committedVersion = wait(getCommittedVersion(self)); + // TODO: Load balance + ConfigFollowerGetSnapshotAndChangesReply reply = wait(self->cfis[0].getSnapshotAndChanges.getReply( + ConfigFollowerGetSnapshotAndChangesRequest{ committedVersion })); + TraceEvent(SevDebug, "ConfigConsumerGotSnapshotAndChanges", self->id) + .detail("SnapshotVersion", reply.snapshotVersion) + .detail("SnapshotSize", reply.snapshot.size()) + .detail("ChangesVersion", committedVersion) + .detail("ChangesSize", reply.changes.size()) + .detail("AnnotationsSize", reply.annotations.size()); + ASSERT_GE(committedVersion, self->lastSeenVersion); + self->lastSeenVersion = committedVersion; + broadcaster->applySnapshotAndChanges( + std::move(reply.snapshot), reply.snapshotVersion, reply.changes, committedVersion, reply.annotations); + return Void(); + } + + ACTOR static Future fetchChanges(PaxosConfigConsumerImpl* self, ConfigBroadcaster* broadcaster) { + wait(getSnapshotAndChanges(self, broadcaster)); + loop { + try { + state Version committedVersion = wait(getCommittedVersion(self)); + ASSERT_GE(committedVersion, self->lastSeenVersion); + if (committedVersion > self->lastSeenVersion) { + // TODO: Load balance + ConfigFollowerGetChangesReply reply = wait(self->cfis[0].getChanges.getReply( + ConfigFollowerGetChangesRequest{ self->lastSeenVersion, committedVersion })); + for (const auto& versionedMutation : reply.changes) { + TraceEvent te(SevDebug, "ConsumerFetchedMutation", self->id); + te.detail("Version", versionedMutation.version) + .detail("ConfigClass", versionedMutation.mutation.getConfigClass()) + .detail("KnobName", versionedMutation.mutation.getKnobName()); + if (versionedMutation.mutation.isSet()) { + te.detail("Op", "Set") + .detail("KnobValue", versionedMutation.mutation.getValue().toString()); + } else { + te.detail("Op", "Clear"); + } + } + self->lastSeenVersion = committedVersion; + broadcaster->applyChanges(reply.changes, committedVersion, reply.annotations); + } + wait(delayJittered(self->pollingInterval)); + } catch (Error& e) { + if (e.code() == error_code_version_already_compacted) { + TEST(true); // SimpleConfigConsumer get version_already_compacted error + wait(getSnapshotAndChanges(self, broadcaster)); + } else { + throw e; + } + } + } + } + +public: + Future consume(ConfigBroadcaster& broadcaster) { + return fetchChanges(this, &broadcaster) || compactor(this, &broadcaster); + } + + UID getID() const { return id; } + + PaxosConfigConsumerImpl(std::vector const& cfis, + double pollingInterval, + Optional compactionInterval) + : cfis(cfis), pollingInterval(pollingInterval), compactionInterval(compactionInterval), + id(deterministicRandom()->randomUniqueID()) {} +}; + +PaxosConfigConsumer::PaxosConfigConsumer(std::vector const& cfis, + double pollingInterval, + Optional compactionInterval) + : _impl(std::make_unique(cfis, pollingInterval, compactionInterval)) {} + +PaxosConfigConsumer::PaxosConfigConsumer(ServerCoordinators const& coordinators, + double pollingInterval, + Optional compactionInterval) + : _impl(std::make_unique(coordinators.configServers, pollingInterval, compactionInterval)) {} PaxosConfigConsumer::~PaxosConfigConsumer() = default; Future PaxosConfigConsumer::consume(ConfigBroadcaster& broadcaster) { - // TODO: Implement - ASSERT(false); - return Void(); + return impl().consume(broadcaster); } UID PaxosConfigConsumer::getID() const { - // TODO: Implement - ASSERT(false); - return {}; + return impl().getID(); } diff --git a/fdbserver/PaxosConfigConsumer.h b/fdbserver/PaxosConfigConsumer.h index 0dcff74d0b..8e404d78a6 100644 --- a/fdbserver/PaxosConfigConsumer.h +++ b/fdbserver/PaxosConfigConsumer.h @@ -31,10 +31,15 @@ class PaxosConfigConsumer : public IConfigConsumer { PaxosConfigConsumerImpl& impl() { return *_impl; } public: - PaxosConfigConsumer(ServerCoordinators const& cfi, - Optional pollingInterval, + PaxosConfigConsumer(ServerCoordinators const& coordinators, + double pollingInterval, Optional compactionInterval); ~PaxosConfigConsumer(); Future consume(ConfigBroadcaster& broadcaster) override; UID getID() const override; + +public: // Testing + PaxosConfigConsumer(std::vector const& cfis, + double pollingInterval, + Optional compactionInterval); }; diff --git a/fdbserver/SimpleConfigConsumer.actor.cpp b/fdbserver/SimpleConfigConsumer.actor.cpp index 35b7ab76c3..70d3150632 100644 --- a/fdbserver/SimpleConfigConsumer.actor.cpp +++ b/fdbserver/SimpleConfigConsumer.actor.cpp @@ -49,28 +49,36 @@ class SimpleConfigConsumerImpl { } } + ACTOR static Future getCommittedVersion(SimpleConfigConsumerImpl* self) { + ConfigFollowerGetCommittedVersionReply committedVersionReply = + wait(self->cfi.getCommittedVersion.getReply(ConfigFollowerGetCommittedVersionRequest{})); + return committedVersionReply.version; + } + ACTOR static Future fetchChanges(SimpleConfigConsumerImpl* self, ConfigBroadcaster* broadcaster) { wait(getSnapshotAndChanges(self, broadcaster)); loop { try { - ConfigFollowerGetChangesReply reply = - wait(self->cfi.getChanges.getReply(ConfigFollowerGetChangesRequest{ self->lastSeenVersion })); - ++self->successfulChangeRequest; - for (const auto& versionedMutation : reply.changes) { - TraceEvent te(SevDebug, "ConsumerFetchedMutation", self->id); - te.detail("Version", versionedMutation.version) - .detail("ConfigClass", versionedMutation.mutation.getConfigClass()) - .detail("KnobName", versionedMutation.mutation.getKnobName()); - if (versionedMutation.mutation.isSet()) { - te.detail("Op", "Set").detail("KnobValue", versionedMutation.mutation.getValue().toString()); - } else { - te.detail("Op", "Clear"); + state Version committedVersion = wait(getCommittedVersion(self)); + ASSERT_GE(committedVersion, self->lastSeenVersion); + if (committedVersion > self->lastSeenVersion) { + ConfigFollowerGetChangesReply reply = wait(self->cfi.getChanges.getReply( + ConfigFollowerGetChangesRequest{ self->lastSeenVersion, committedVersion })); + ++self->successfulChangeRequest; + for (const auto& versionedMutation : reply.changes) { + TraceEvent te(SevDebug, "ConsumerFetchedMutation", self->id); + te.detail("Version", versionedMutation.version) + .detail("ConfigClass", versionedMutation.mutation.getConfigClass()) + .detail("KnobName", versionedMutation.mutation.getKnobName()); + if (versionedMutation.mutation.isSet()) { + te.detail("Op", "Set") + .detail("KnobValue", versionedMutation.mutation.getValue().toString()); + } else { + te.detail("Op", "Clear"); + } } - } - ASSERT_GE(reply.mostRecentVersion, self->lastSeenVersion); - if (reply.mostRecentVersion > self->lastSeenVersion) { - self->lastSeenVersion = reply.mostRecentVersion; - broadcaster->applyChanges(reply.changes, reply.mostRecentVersion, reply.annotations); + self->lastSeenVersion = committedVersion; + broadcaster->applyChanges(reply.changes, committedVersion, reply.annotations); } wait(delayJittered(self->pollingInterval)); } catch (Error& e) { @@ -86,19 +94,20 @@ class SimpleConfigConsumerImpl { } ACTOR static Future getSnapshotAndChanges(SimpleConfigConsumerImpl* self, ConfigBroadcaster* broadcaster) { - ConfigFollowerGetSnapshotAndChangesReply reply = - wait(self->cfi.getSnapshotAndChanges.getReply(ConfigFollowerGetSnapshotAndChangesRequest{})); + state Version committedVersion = wait(getCommittedVersion(self)); + ConfigFollowerGetSnapshotAndChangesReply reply = wait( + self->cfi.getSnapshotAndChanges.getReply(ConfigFollowerGetSnapshotAndChangesRequest{ committedVersion })); ++self->snapshotRequest; TraceEvent(SevDebug, "ConfigConsumerGotSnapshotAndChanges", self->id) .detail("SnapshotVersion", reply.snapshotVersion) .detail("SnapshotSize", reply.snapshot.size()) - .detail("ChangesVersion", reply.changesVersion) + .detail("ChangesVersion", committedVersion) .detail("ChangesSize", reply.changes.size()) .detail("AnnotationsSize", reply.annotations.size()); + ASSERT_GE(committedVersion, self->lastSeenVersion); + self->lastSeenVersion = committedVersion; broadcaster->applySnapshotAndChanges( - std::move(reply.snapshot), reply.snapshotVersion, reply.changes, reply.changesVersion, reply.annotations); - ASSERT_GE(reply.changesVersion, self->lastSeenVersion); - self->lastSeenVersion = reply.changesVersion; + std::move(reply.snapshot), reply.snapshotVersion, reply.changes, committedVersion, reply.annotations); return Void(); } diff --git a/fdbserver/SimpleConfigDatabaseNode.actor.cpp b/fdbserver/SimpleConfigDatabaseNode.actor.cpp index 65bedd0f1b..e07180b666 100644 --- a/fdbserver/SimpleConfigDatabaseNode.actor.cpp +++ b/fdbserver/SimpleConfigDatabaseNode.actor.cpp @@ -377,13 +377,10 @@ class SimpleConfigDatabaseNodeImpl { ObjectReader::fromStringRef(kv.value, IncludeVersion()); } wait(store(reply.snapshotVersion, getLastCompactedVersion(self))); - wait(store(reply.changesVersion, - map(getGeneration(self), [](auto const& gen) { return gen.committedVersion; }))); - wait(store(reply.changes, getMutations(self, reply.snapshotVersion + 1, reply.changesVersion))); - wait(store(reply.annotations, getAnnotations(self, reply.snapshotVersion + 1, reply.changesVersion))); + wait(store(reply.changes, getMutations(self, reply.snapshotVersion + 1, req.mostRecentVersion))); + wait(store(reply.annotations, getAnnotations(self, reply.snapshotVersion + 1, req.mostRecentVersion))); TraceEvent(SevDebug, "ConfigDatabaseNodeGettingSnapshot", self->id) .detail("SnapshotVersion", reply.snapshotVersion) - .detail("ChangesVersion", reply.changesVersion) .detail("SnapshotSize", reply.snapshot.size()) .detail("ChangesSize", reply.changes.size()) .detail("AnnotationsSize", reply.annotations.size()); From 013a3c60bf1bd22e95f9faa4ccf3930076aae447 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 17:56:44 -0700 Subject: [PATCH 055/225] Server committed version requests in SimpleConfigDatabaseNode --- fdbserver/ConfigFollowerInterface.h | 6 +++--- fdbserver/SimpleConfigDatabaseNode.actor.cpp | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/fdbserver/ConfigFollowerInterface.h b/fdbserver/ConfigFollowerInterface.h index 542bb07186..3723405d06 100644 --- a/fdbserver/ConfigFollowerInterface.h +++ b/fdbserver/ConfigFollowerInterface.h @@ -98,7 +98,7 @@ struct ConfigFollowerGetSnapshotAndChangesRequest { template void serialize(Ar& ar) { - serializer(ar, reply); + serializer(ar, reply, mostRecentVersion); } }; @@ -132,7 +132,7 @@ struct ConfigFollowerGetChangesRequest { template void serialize(Ar& ar) { - serializer(ar, lastSeenVersion, reply); + serializer(ar, lastSeenVersion, mostRecentVersion, reply); } }; @@ -196,6 +196,6 @@ public: template void serialize(Ar& ar) { - serializer(ar, _id, getSnapshotAndChanges, getChanges, compact); + serializer(ar, _id, getSnapshotAndChanges, getChanges, compact, getCommittedVersion); } }; diff --git a/fdbserver/SimpleConfigDatabaseNode.actor.cpp b/fdbserver/SimpleConfigDatabaseNode.actor.cpp index e07180b666..fca91050cb 100644 --- a/fdbserver/SimpleConfigDatabaseNode.actor.cpp +++ b/fdbserver/SimpleConfigDatabaseNode.actor.cpp @@ -103,6 +103,7 @@ class SimpleConfigDatabaseNodeImpl { Counter successfulChangeRequests; Counter failedChangeRequests; Counter snapshotRequests; + Counter getCommittedVersionRequests; // Transaction counters Counter successfulCommits; @@ -185,7 +186,7 @@ class SimpleConfigDatabaseNodeImpl { wait(getMutations(self, req.lastSeenVersion + 1, committedVersion)); state Standalone> versionedAnnotations = wait(getAnnotations(self, req.lastSeenVersion + 1, committedVersion)); - TraceEvent(SevDebug, "ConfigDatabaseNodeSendingChanges") + TraceEvent(SevDebug, "ConfigDatabaseNodeSendingChanges", self->id) .detail("ReqLastSeenVersion", req.lastSeenVersion) .detail("CommittedVersion", committedVersion) .detail("NumMutations", versionedMutations.size()) @@ -434,6 +435,13 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } + ACTOR static Future getCommittedVersion(SimpleConfigDatabaseNodeImpl* self, + ConfigFollowerGetCommittedVersionRequest req) { + ConfigGeneration generation = wait(getGeneration(self)); + req.reply.send(ConfigFollowerGetCommittedVersionReply{ generation.committedVersion }); + return Void(); + } + ACTOR static Future serve(SimpleConfigDatabaseNodeImpl* self, ConfigFollowerInterface const* cfi) { loop { choose { @@ -449,6 +457,10 @@ class SimpleConfigDatabaseNodeImpl { ++self->compactRequests; wait(compact(self, req)); } + when(ConfigFollowerGetCommittedVersionRequest req = waitNext(cfi->getCommittedVersion.getFuture())) { + ++self->getCommittedVersionRequests; + wait(getCommittedVersion(self, req)); + } when(wait(self->kvStore->getError())) { ASSERT(false); } } } @@ -459,8 +471,8 @@ public: : id(deterministicRandom()->randomUniqueID()), kvStore(folder, id, "globalconf-"), cc("ConfigDatabaseNode"), compactRequests("CompactRequests", cc), successfulChangeRequests("SuccessfulChangeRequests", cc), failedChangeRequests("FailedChangeRequests", cc), snapshotRequests("SnapshotRequests", cc), - successfulCommits("SuccessfulCommits", cc), failedCommits("FailedCommits", cc), - setMutations("SetMutations", cc), clearMutations("ClearMutations", cc), + getCommittedVersionRequests("GetCommittedVersionRequests", cc), successfulCommits("SuccessfulCommits", cc), + failedCommits("FailedCommits", cc), setMutations("SetMutations", cc), clearMutations("ClearMutations", cc), getValueRequests("GetValueRequests", cc), newVersionRequests("NewVersionRequests", cc) { logger = traceCounters( "ConfigDatabaseNodeMetrics", id, SERVER_KNOBS->WORKER_LOGGING_INTERVAL, &cc, "ConfigDatabaseNode"); From b3e2b0655360743bd0da4d6cd7e101fecba7bee2 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 18:25:06 -0700 Subject: [PATCH 056/225] Remove multiple implementations of ConfigNode --- fdbserver/CMakeLists.txt | 7 +- fdbserver/ConfigDatabaseUnitTests.actor.cpp | 8 +- ...aseNode.actor.cpp => ConfigNode.actor.cpp} | 74 +++++++++---------- .../{IConfigDatabaseNode.h => ConfigNode.h} | 24 +++--- fdbserver/Coordination.actor.cpp | 12 +-- fdbserver/IConfigDatabaseNode.cpp | 31 -------- fdbserver/PaxosConfigDatabaseNode.actor.cpp | 42 ----------- fdbserver/PaxosConfigDatabaseNode.h | 36 --------- fdbserver/SimpleConfigDatabaseNode.h | 40 ---------- 9 files changed, 57 insertions(+), 217 deletions(-) rename fdbserver/{SimpleConfigDatabaseNode.actor.cpp => ConfigNode.actor.cpp} (86%) rename fdbserver/{IConfigDatabaseNode.h => ConfigNode.h} (60%) delete mode 100644 fdbserver/IConfigDatabaseNode.cpp delete mode 100644 fdbserver/PaxosConfigDatabaseNode.actor.cpp delete mode 100644 fdbserver/PaxosConfigDatabaseNode.h delete mode 100644 fdbserver/SimpleConfigDatabaseNode.h diff --git a/fdbserver/CMakeLists.txt b/fdbserver/CMakeLists.txt index 485761ebd7..c4234f84b4 100644 --- a/fdbserver/CMakeLists.txt +++ b/fdbserver/CMakeLists.txt @@ -11,6 +11,8 @@ set(FDBSERVER_SRCS ConfigDatabaseUnitTests.actor.cpp ConfigFollowerInterface.cpp ConfigFollowerInterface.h + ConfigNode.actor.cpp + ConfigNode.h ConflictSet.h CoordinatedState.actor.cpp CoordinatedState.h @@ -28,8 +30,6 @@ set(FDBSERVER_SRCS FDBExecHelper.actor.cpp FDBExecHelper.actor.h GrvProxyServer.actor.cpp - IConfigDatabaseNode.cpp - IConfigDatabaseNode.h IConfigConsumer.cpp IConfigConsumer.h IDiskQueue.h @@ -72,8 +72,6 @@ set(FDBSERVER_SRCS OnDemandStore.h PaxosConfigConsumer.actor.cpp PaxosConfigConsumer.h - PaxosConfigDatabaseNode.actor.cpp - PaxosConfigDatabaseNode.h ProxyCommitData.actor.h pubsub.actor.cpp pubsub.h @@ -105,7 +103,6 @@ set(FDBSERVER_SRCS ServerDBInfo.h SimpleConfigConsumer.actor.cpp SimpleConfigConsumer.h - SimpleConfigDatabaseNode.actor.cpp SimulatedCluster.actor.cpp SimulatedCluster.h SkipList.cpp diff --git a/fdbserver/ConfigDatabaseUnitTests.actor.cpp b/fdbserver/ConfigDatabaseUnitTests.actor.cpp index 9ecd617980..c9d3ce679d 100644 --- a/fdbserver/ConfigDatabaseUnitTests.actor.cpp +++ b/fdbserver/ConfigDatabaseUnitTests.actor.cpp @@ -22,7 +22,7 @@ #include "fdbclient/IConfigTransaction.h" #include "fdbclient/TestKnobCollection.h" #include "fdbserver/ConfigBroadcaster.h" -#include "fdbserver/IConfigDatabaseNode.h" +#include "fdbserver/ConfigNode.h" #include "fdbserver/LocalConfiguration.h" #include "fdbclient/Tuple.h" #include "flow/UnitTest.h" @@ -55,7 +55,7 @@ class WriteToTransactionEnvironment { std::string dataDir; ConfigTransactionInterface cti; ConfigFollowerInterface cfi; - Reference node; + Reference node; Future ctiServer; Future cfiServer; Version lastWrittenVersion{ 0 }; @@ -94,7 +94,7 @@ class WriteToTransactionEnvironment { public: WriteToTransactionEnvironment(std::string const& dataDir) - : dataDir(dataDir), node(IConfigDatabaseNode::createSimple(dataDir)) { + : dataDir(dataDir), node(makeReference(dataDir)) { platform::eraseDirectoryRecursive(dataDir); setup(); } @@ -111,7 +111,7 @@ public: void restartNode() { cfiServer.cancel(); ctiServer.cancel(); - node = IConfigDatabaseNode::createSimple(dataDir); + node = makeReference(dataDir); setup(); } diff --git a/fdbserver/SimpleConfigDatabaseNode.actor.cpp b/fdbserver/ConfigNode.actor.cpp similarity index 86% rename from fdbserver/SimpleConfigDatabaseNode.actor.cpp rename to fdbserver/ConfigNode.actor.cpp index fca91050cb..3c71aa0339 100644 --- a/fdbserver/SimpleConfigDatabaseNode.actor.cpp +++ b/fdbserver/ConfigNode.actor.cpp @@ -1,5 +1,5 @@ /* - * SimpleConfigDatabaseNode.actor.cpp + * ConfigNode.actor.cpp * * This source file is part of the FoundationDB open source project * @@ -21,7 +21,7 @@ #include #include "fdbclient/SystemData.h" -#include "fdbserver/SimpleConfigDatabaseNode.h" +#include "fdbserver/ConfigNode.h" #include "fdbserver/IKeyValueStore.h" #include "fdbserver/OnDemandStore.h" #include "flow/Arena.h" @@ -64,9 +64,9 @@ Version getVersionFromVersionedMutationKey(KeyRef versionedMutationKey) { return fromBigEndian64(bigEndianResult); } -} //namespace +} // namespace -TEST_CASE("/fdbserver/ConfigDB/SimpleConfigDatabaseNode/Internal/versionedMutationKeys") { +TEST_CASE("/fdbserver/ConfigDB/ConfigNode/Internal/versionedMutationKeys") { std::vector keys; for (Version version = 0; version < 1000; ++version) { for (int index = 0; index < 5; ++index) { @@ -79,7 +79,7 @@ TEST_CASE("/fdbserver/ConfigDB/SimpleConfigDatabaseNode/Internal/versionedMutati return Void(); } -TEST_CASE("/fdbserver/ConfigDB/SimpleConfigDatabaseNode/Internal/versionedMutationKeyOrdering") { +TEST_CASE("/fdbserver/ConfigDB/ConfigNode/Internal/versionedMutationKeyOrdering") { Standalone> keys; for (Version version = 0; version < 1000; ++version) { for (auto index = 0; index < 5; ++index) { @@ -93,7 +93,7 @@ TEST_CASE("/fdbserver/ConfigDB/SimpleConfigDatabaseNode/Internal/versionedMutati return Void(); } -class SimpleConfigDatabaseNodeImpl { +class ConfigNodeImpl { UID id; OnDemandStore kvStore; CounterCollection cc; @@ -114,7 +114,7 @@ class SimpleConfigDatabaseNodeImpl { Counter newVersionRequests; Future logger; - ACTOR static Future getGeneration(SimpleConfigDatabaseNodeImpl* self) { + ACTOR static Future getGeneration(ConfigNodeImpl* self) { state ConfigGeneration generation; Optional value = wait(self->kvStore->readValue(currentGenerationKey)); if (value.present()) { @@ -126,7 +126,7 @@ class SimpleConfigDatabaseNodeImpl { return generation; } - ACTOR static Future getLastCompactedVersion(SimpleConfigDatabaseNodeImpl* self) { + ACTOR static Future getLastCompactedVersion(ConfigNodeImpl* self) { Optional value = wait(self->kvStore->readValue(lastCompactedVersionKey)); state Version lastCompactedVersion = 0; if (value.present()) { @@ -140,8 +140,9 @@ class SimpleConfigDatabaseNodeImpl { } // Returns all commit annotations between for commits with version in [startVersion, endVersion] - ACTOR static Future>> - getAnnotations(SimpleConfigDatabaseNodeImpl* self, Version startVersion, Version endVersion) { + ACTOR static Future>> getAnnotations(ConfigNodeImpl* self, + Version startVersion, + Version endVersion) { Key startKey = versionedAnnotationKey(startVersion); Key endKey = versionedAnnotationKey(endVersion + 1); state KeyRangeRef keys(startKey, endKey); @@ -157,14 +158,15 @@ class SimpleConfigDatabaseNodeImpl { } // Returns all mutations with version in [startVersion, endVersion] - ACTOR static Future>> - getMutations(SimpleConfigDatabaseNodeImpl* self, Version startVersion, Version endVersion) { + ACTOR static Future>> getMutations(ConfigNodeImpl* self, + Version startVersion, + Version endVersion) { Key startKey = versionedMutationKey(startVersion, 0); Key endKey = versionedMutationKey(endVersion + 1, 0); state KeyRangeRef keys(startKey, endKey); RangeResult range = wait(self->kvStore->readRange(keys)); Standalone> result; - for (const auto &kv : range) { + for (const auto& kv : range) { auto version = getVersionFromVersionedMutationKey(kv.key); ASSERT_LE(version, endVersion); auto mutation = ObjectReader::fromStringRef(kv.value, IncludeVersion()); @@ -173,7 +175,7 @@ class SimpleConfigDatabaseNodeImpl { return result; } - ACTOR static Future getChanges(SimpleConfigDatabaseNodeImpl *self, ConfigFollowerGetChangesRequest req) { + ACTOR static Future getChanges(ConfigNodeImpl* self, ConfigFollowerGetChangesRequest req) { Version lastCompactedVersion = wait(getLastCompactedVersion(self)); if (req.lastSeenVersion < lastCompactedVersion) { ++self->failedChangeRequests; @@ -198,8 +200,7 @@ class SimpleConfigDatabaseNodeImpl { // New transactions increment the database's current live version. This effectively serves as a lock, providing // serializability - ACTOR static Future getNewGeneration(SimpleConfigDatabaseNodeImpl* self, - ConfigTransactionGetGenerationRequest req) { + ACTOR static Future getNewGeneration(ConfigNodeImpl* self, ConfigTransactionGetGenerationRequest req) { state ConfigGeneration generation = wait(getGeneration(self)); ++generation.liveVersion; self->kvStore->set(KeyValueRef(currentGenerationKey, BinaryWriter::toValue(generation, IncludeVersion()))); @@ -208,7 +209,7 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } - ACTOR static Future get(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionGetRequest req) { + ACTOR static Future get(ConfigNodeImpl* self, ConfigTransactionGetRequest req) { ConfigGeneration currentGeneration = wait(getGeneration(self)); if (req.generation != currentGeneration) { // TODO: Also send information about highest seen version @@ -223,8 +224,8 @@ class SimpleConfigDatabaseNodeImpl { } Standalone> versionedMutations = wait(getMutations(self, 0, req.generation.committedVersion)); - for (const auto &versionedMutation : versionedMutations) { - const auto &mutation = versionedMutation.mutation; + for (const auto& versionedMutation : versionedMutations) { + const auto& mutation = versionedMutation.mutation; if (mutation.getKey() == req.key) { if (mutation.isSet()) { value = mutation.getValue(); @@ -240,8 +241,7 @@ class SimpleConfigDatabaseNodeImpl { // Retrieve all configuration classes that contain explicitly defined knobs // TODO: Currently it is possible that extra configuration classes may be returned, we // may want to fix this to clean up the contract - ACTOR static Future getConfigClasses(SimpleConfigDatabaseNodeImpl* self, - ConfigTransactionGetConfigClassesRequest req) { + ACTOR static Future getConfigClasses(ConfigNodeImpl* self, ConfigTransactionGetConfigClassesRequest req) { ConfigGeneration currentGeneration = wait(getGeneration(self)); if (req.generation != currentGeneration) { req.reply.sendError(transaction_too_old()); @@ -274,7 +274,7 @@ class SimpleConfigDatabaseNodeImpl { } // Retrieve all knobs explicitly defined for the specified configuration class - ACTOR static Future getKnobs(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionGetKnobsRequest req) { + ACTOR static Future getKnobs(ConfigNodeImpl* self, ConfigTransactionGetKnobsRequest req) { ConfigGeneration currentGeneration = wait(getGeneration(self)); if (req.generation != currentGeneration) { req.reply.sendError(transaction_too_old()); @@ -310,7 +310,7 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } - ACTOR static Future commit(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionCommitRequest req) { + ACTOR static Future commit(ConfigNodeImpl* self, ConfigTransactionCommitRequest req) { ConfigGeneration currentGeneration = wait(getGeneration(self)); if (req.generation != currentGeneration) { ++self->failedCommits; @@ -318,11 +318,11 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } int index = 0; - for (const auto &mutation : req.mutations) { + for (const auto& mutation : req.mutations) { Key key = versionedMutationKey(req.generation.liveVersion, index++); Value value = ObjectWriter::toValue(mutation, IncludeVersion()); if (mutation.isSet()) { - TraceEvent("SimpleConfigDatabaseNodeSetting") + TraceEvent("ConfigNodeSetting") .detail("ConfigClass", mutation.getConfigClass()) .detail("KnobName", mutation.getKnobName()) .detail("Value", mutation.getValue().toString()) @@ -343,7 +343,7 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } - ACTOR static Future serve(SimpleConfigDatabaseNodeImpl* self, ConfigTransactionInterface const* cti) { + ACTOR static Future serve(ConfigNodeImpl* self, ConfigTransactionInterface const* cti) { loop { choose { when(ConfigTransactionGetGenerationRequest req = waitNext(cti->getGeneration.getFuture())) { @@ -368,7 +368,7 @@ class SimpleConfigDatabaseNodeImpl { } } - ACTOR static Future getSnapshotAndChanges(SimpleConfigDatabaseNodeImpl* self, + ACTOR static Future getSnapshotAndChanges(ConfigNodeImpl* self, ConfigFollowerGetSnapshotAndChangesRequest req) { state ConfigFollowerGetSnapshotAndChangesReply reply; RangeResult data = wait(self->kvStore->readRange(kvKeys)); @@ -392,7 +392,7 @@ class SimpleConfigDatabaseNodeImpl { // Apply mutations from the WAL in mutationKeys into the kvKeys key space. // Periodic compaction prevents the database from growing too large, and improve read performance. // However, commit annotations for compacted mutations are lost - ACTOR static Future compact(SimpleConfigDatabaseNodeImpl* self, ConfigFollowerCompactRequest req) { + ACTOR static Future compact(ConfigNodeImpl* self, ConfigFollowerCompactRequest req) { state Version lastCompactedVersion = wait(getLastCompactedVersion(self)); TraceEvent(SevDebug, "ConfigDatabaseNodeCompacting", self->id) .detail("Version", req.version) @@ -435,14 +435,13 @@ class SimpleConfigDatabaseNodeImpl { return Void(); } - ACTOR static Future getCommittedVersion(SimpleConfigDatabaseNodeImpl* self, - ConfigFollowerGetCommittedVersionRequest req) { + ACTOR static Future getCommittedVersion(ConfigNodeImpl* self, ConfigFollowerGetCommittedVersionRequest req) { ConfigGeneration generation = wait(getGeneration(self)); req.reply.send(ConfigFollowerGetCommittedVersionReply{ generation.committedVersion }); return Void(); } - ACTOR static Future serve(SimpleConfigDatabaseNodeImpl* self, ConfigFollowerInterface const* cfi) { + ACTOR static Future serve(ConfigNodeImpl* self, ConfigFollowerInterface const* cfi) { loop { choose { when(ConfigFollowerGetSnapshotAndChangesRequest req = @@ -467,7 +466,7 @@ class SimpleConfigDatabaseNodeImpl { } public: - SimpleConfigDatabaseNodeImpl(std::string const& folder) + ConfigNodeImpl(std::string const& folder) : id(deterministicRandom()->randomUniqueID()), kvStore(folder, id, "globalconf-"), cc("ConfigDatabaseNode"), compactRequests("CompactRequests", cc), successfulChangeRequests("SuccessfulChangeRequests", cc), failedChangeRequests("FailedChangeRequests", cc), snapshotRequests("SnapshotRequests", cc), @@ -476,7 +475,7 @@ public: getValueRequests("GetValueRequests", cc), newVersionRequests("NewVersionRequests", cc) { logger = traceCounters( "ConfigDatabaseNodeMetrics", id, SERVER_KNOBS->WORKER_LOGGING_INTERVAL, &cc, "ConfigDatabaseNode"); - TraceEvent(SevDebug, "StartingSimpleConfigDatabaseNode", id).detail("KVStoreAlreadyExists", kvStore.exists()); + TraceEvent(SevDebug, "StartingConfigNode", id).detail("KVStoreAlreadyExists", kvStore.exists()); } Future serve(ConfigTransactionInterface const& cti) { return serve(this, &cti); } @@ -484,15 +483,14 @@ public: Future serve(ConfigFollowerInterface const& cfi) { return serve(this, &cfi); } }; -SimpleConfigDatabaseNode::SimpleConfigDatabaseNode(std::string const& folder) - : _impl(std::make_unique(folder)) {} +ConfigNode::ConfigNode(std::string const& folder) : _impl(std::make_unique(folder)) {} -SimpleConfigDatabaseNode::~SimpleConfigDatabaseNode() = default; +ConfigNode::~ConfigNode() = default; -Future SimpleConfigDatabaseNode::serve(ConfigTransactionInterface const& cti) { +Future ConfigNode::serve(ConfigTransactionInterface const& cti) { return impl().serve(cti); } -Future SimpleConfigDatabaseNode::serve(ConfigFollowerInterface const& cfi) { +Future ConfigNode::serve(ConfigFollowerInterface const& cfi) { return impl().serve(cfi); } diff --git a/fdbserver/IConfigDatabaseNode.h b/fdbserver/ConfigNode.h similarity index 60% rename from fdbserver/IConfigDatabaseNode.h rename to fdbserver/ConfigNode.h index 310b1f6a8c..8e70ae2073 100644 --- a/fdbserver/IConfigDatabaseNode.h +++ b/fdbserver/ConfigNode.h @@ -1,5 +1,5 @@ /* - * IConfigDatabaseNode.h + * SimpleConfigDatabaseNode.h * * This source file is part of the FoundationDB open source project * @@ -20,21 +20,19 @@ #pragma once +#include + #include "fdbclient/ConfigTransactionInterface.h" #include "fdbserver/ConfigFollowerInterface.h" -#include "flow/FastRef.h" -#include "flow/flow.h" -#include +class ConfigNode : public ReferenceCounted { + std::unique_ptr _impl; + ConfigNodeImpl const& impl() const { return *_impl; } + ConfigNodeImpl& impl() { return *_impl; } -/* - * Interface for a single node in the configuration database, run on coordinators - */ -class IConfigDatabaseNode : public ReferenceCounted { public: - virtual Future serve(ConfigTransactionInterface const&) = 0; - virtual Future serve(ConfigFollowerInterface const&) = 0; - - static Reference createSimple(std::string const& folder); - static Reference createPaxos(std::string const& folder); + ConfigNode(std::string const& folder); + ~ConfigNode(); + Future serve(ConfigTransactionInterface const&); + Future serve(ConfigFollowerInterface const&); }; diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index eeffd7b4d7..a8691797b2 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -20,7 +20,7 @@ #include "fdbclient/ConfigTransactionInterface.h" #include "fdbserver/CoordinationInterface.h" -#include "fdbserver/IConfigDatabaseNode.h" +#include "fdbserver/ConfigNode.h" #include "fdbserver/IKeyValueStore.h" #include "fdbserver/Knobs.h" #include "fdbserver/OnDemandStore.h" @@ -655,7 +655,7 @@ ACTOR Future coordinationServer(std::string dataFolder, state OnDemandStore store(dataFolder, myID, "coordination-"); state ConfigTransactionInterface configTransactionInterface; state ConfigFollowerInterface configFollowerInterface; - state Reference configDatabaseNode; + state Reference configNode; state Future configDatabaseServer = Never(); TraceEvent("CoordinationServer", myID) .detail("MyInterfaceAddr", myInterface.read.getEndpoint().getPrimaryAddress()) @@ -664,13 +664,9 @@ ACTOR Future coordinationServer(std::string dataFolder, if (useConfigDB != UseConfigDB::DISABLED) { configTransactionInterface.setupWellKnownEndpoints(); configFollowerInterface.setupWellKnownEndpoints(); - if (useConfigDB == UseConfigDB::SIMPLE) { - configDatabaseNode = IConfigDatabaseNode::createSimple(dataFolder); - } else { - configDatabaseNode = IConfigDatabaseNode::createPaxos(dataFolder); - } + configNode = makeReference(dataFolder); configDatabaseServer = - configDatabaseNode->serve(configTransactionInterface) || configDatabaseNode->serve(configFollowerInterface); + configNode->serve(configTransactionInterface) || configNode->serve(configFollowerInterface); } try { diff --git a/fdbserver/IConfigDatabaseNode.cpp b/fdbserver/IConfigDatabaseNode.cpp deleted file mode 100644 index d5b0a84bd6..0000000000 --- a/fdbserver/IConfigDatabaseNode.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * IConfigDatabaseNode.actor.cpp - * - * 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. - */ - -#include "fdbserver/IConfigDatabaseNode.h" -#include "fdbserver/PaxosConfigDatabaseNode.h" -#include "fdbserver/SimpleConfigDatabaseNode.h" - -Reference IConfigDatabaseNode::createSimple(std::string const& folder) { - return makeReference(folder); -} - -Reference IConfigDatabaseNode::createPaxos(std::string const& folder) { - return makeReference(folder); -} diff --git a/fdbserver/PaxosConfigDatabaseNode.actor.cpp b/fdbserver/PaxosConfigDatabaseNode.actor.cpp deleted file mode 100644 index d8d4232dfe..0000000000 --- a/fdbserver/PaxosConfigDatabaseNode.actor.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * PaxosConfigDatabaseNode.actor.cpp - * - * 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. - */ - -#include "fdbserver/PaxosConfigDatabaseNode.h" - -class PaxosConfigDatabaseNodeImpl {}; - -PaxosConfigDatabaseNode::PaxosConfigDatabaseNode(std::string const& folder) { - // TODO: Implement - ASSERT(false); -} - -PaxosConfigDatabaseNode::~PaxosConfigDatabaseNode() = default; - -Future PaxosConfigDatabaseNode::serve(ConfigTransactionInterface const& cti) { - // TODO: Implement - ASSERT(false); - return Void(); -} - -Future PaxosConfigDatabaseNode::serve(ConfigFollowerInterface const& cfi) { - // TODO: Implement - ASSERT(false); - return Void(); -} diff --git a/fdbserver/PaxosConfigDatabaseNode.h b/fdbserver/PaxosConfigDatabaseNode.h deleted file mode 100644 index 062ab809de..0000000000 --- a/fdbserver/PaxosConfigDatabaseNode.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * PaxosConfigDatabaseNode.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. - */ - -#pragma once - -#include "fdbserver/IConfigDatabaseNode.h" - -/* - * Fault-tolerant configuration database node implementation - */ -class PaxosConfigDatabaseNode : public IConfigDatabaseNode { - std::unique_ptr impl; - -public: - PaxosConfigDatabaseNode(std::string const& folder); - ~PaxosConfigDatabaseNode(); - Future serve(ConfigTransactionInterface const&) override; - Future serve(ConfigFollowerInterface const&) override; -}; diff --git a/fdbserver/SimpleConfigDatabaseNode.h b/fdbserver/SimpleConfigDatabaseNode.h deleted file mode 100644 index cd694c7c4b..0000000000 --- a/fdbserver/SimpleConfigDatabaseNode.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SimpleConfigDatabaseNode.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. - */ - -#pragma once - -#include "fdbserver/IConfigDatabaseNode.h" - -/* - * A test-only configuration database node implementation that assumes all data is stored on a single coordinator. - * As such, there is no need to handle rolling forward or rolling back mutations, because this one node is considered - * the source of truth. - */ -class SimpleConfigDatabaseNode : public IConfigDatabaseNode { - std::unique_ptr _impl; - SimpleConfigDatabaseNodeImpl const& impl() const { return *_impl; } - SimpleConfigDatabaseNodeImpl& impl() { return *_impl; } - -public: - SimpleConfigDatabaseNode(std::string const& folder); - ~SimpleConfigDatabaseNode(); - Future serve(ConfigTransactionInterface const&) override; - Future serve(ConfigFollowerInterface const&) override; -}; From 2867e953cf588b51e1e4b3884082aab4a161c40e Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 19:18:48 -0700 Subject: [PATCH 057/225] Add IConfigTransaction::createTestPaxos --- fdbclient/IConfigTransaction.cpp | 6 ++++++ fdbclient/IConfigTransaction.h | 1 + 2 files changed, 7 insertions(+) diff --git a/fdbclient/IConfigTransaction.cpp b/fdbclient/IConfigTransaction.cpp index 060953d55f..f91483eb76 100644 --- a/fdbclient/IConfigTransaction.cpp +++ b/fdbclient/IConfigTransaction.cpp @@ -18,6 +18,8 @@ * limitations under the License. */ +#include + #include "fdbclient/IConfigTransaction.h" #include "fdbclient/SimpleConfigTransaction.h" #include "fdbclient/PaxosConfigTransaction.h" @@ -25,3 +27,7 @@ Reference IConfigTransaction::createTestSimple(ConfigTransactionInterface const& cti) { return makeReference(cti); } + +Reference IConfigTransaction::createTestPaxos(std::vector const& ctis) { + return makeReference(ctis); +} diff --git a/fdbclient/IConfigTransaction.h b/fdbclient/IConfigTransaction.h index a46c914682..42d5769c51 100644 --- a/fdbclient/IConfigTransaction.h +++ b/fdbclient/IConfigTransaction.h @@ -40,6 +40,7 @@ public: virtual ~IConfigTransaction() = default; static Reference createTestSimple(ConfigTransactionInterface const&); + static Reference createTestPaxos(std::vector const&); // Not implemented: void setVersion(Version) override { throw client_invalid_operation(); } From 57033001d3842b7e44c9d124da256ec647e821e1 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 18 Jul 2021 19:26:11 -0700 Subject: [PATCH 058/225] Remove unnecessary template --- fdbserver/ConfigDatabaseUnitTests.actor.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fdbserver/ConfigDatabaseUnitTests.actor.cpp b/fdbserver/ConfigDatabaseUnitTests.actor.cpp index c9d3ce679d..745e2259b3 100644 --- a/fdbserver/ConfigDatabaseUnitTests.actor.cpp +++ b/fdbserver/ConfigDatabaseUnitTests.actor.cpp @@ -65,11 +65,10 @@ class WriteToTransactionEnvironment { return StringRef(reinterpret_cast(s.c_str()), s.size()); } - ACTOR template - static Future set(WriteToTransactionEnvironment* self, - Optional configClass, - T value, - KeyRef knobName) { + ACTOR static Future set(WriteToTransactionEnvironment* self, + Optional configClass, + int64_t value, + KeyRef knobName) { state Reference tr = IConfigTransaction::createTestSimple(self->cti); auto configKey = encodeConfigKey(configClass, knobName); tr->set(configKey, longToValue(value)); @@ -99,8 +98,7 @@ public: setup(); } - template - Future set(Optional configClass, T value, KeyRef knobName = "test_long"_sr) { + Future set(Optional configClass, int64_t value, KeyRef knobName = "test_long"_sr) { return set(this, configClass, value, knobName); } From 39af41ebb7cc55c0f9af43b7d4ff2ecb36bc268a Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Mon, 19 Jul 2021 11:01:09 -0700 Subject: [PATCH 059/225] Closing a multi-version database causes us to cancel the protocol version monitor, invalidating its future. If a version change is triggered after that happens, then an assertion will be triggered that expects the future to be valid. This changes the behavior so that closing the database prevents us from doing any work to update the version. --- fdbclient/MultiVersionTransaction.actor.cpp | 11 ++++++++++- fdbclient/MultiVersionTransaction.h | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index afc92bfec0..b91dde5d60 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -994,7 +994,7 @@ ThreadFuture MultiVersionDatabase::getServerProtocol(Optional

versionMonitorDb) : clusterFilePath(clusterFilePath), versionMonitorDb(versionMonitorDb), - dbVar(new ThreadSafeAsyncVar>(Reference(nullptr))) {} + dbVar(new ThreadSafeAsyncVar>(Reference(nullptr))), closed(false) {} // Adds a client (local or externally loaded) that can be used to connect to the cluster void MultiVersionDatabase::DatabaseState::addClient(Reference client) { @@ -1058,6 +1058,10 @@ ThreadFuture MultiVersionDatabase::DatabaseState::monitorProtocolVersion() // Called when a change to the protocol version of the cluster has been detected. // Must be called from the main thread void MultiVersionDatabase::DatabaseState::protocolVersionChanged(ProtocolVersion protocolVersion) { + if (closed) { + return; + } + // If the protocol version changed but is still compatible, update our local version but keep the same connection if (dbProtocolVersion.present() && protocolVersion.normalizedVersion() == dbProtocolVersion.get().normalizedVersion()) { @@ -1112,6 +1116,10 @@ void MultiVersionDatabase::DatabaseState::protocolVersionChanged(ProtocolVersion // Replaces the active database connection with a new one. Must be called from the main thread. void MultiVersionDatabase::DatabaseState::updateDatabase(Reference newDb, Reference client) { + if (closed) { + return; + } + if (newDb) { optionLock.enter(); for (auto option : options) { @@ -1178,6 +1186,7 @@ void MultiVersionDatabase::DatabaseState::close() { Reference self = Reference::addRef(this); onMainThreadVoid( [self]() { + self->closed = true; if (self->protocolVersionMonitor.isValid()) { self->protocolVersionMonitor.cancel(); } diff --git a/fdbclient/MultiVersionTransaction.h b/fdbclient/MultiVersionTransaction.h index 65892a8dbf..86b214a1a6 100644 --- a/fdbclient/MultiVersionTransaction.h +++ b/fdbclient/MultiVersionTransaction.h @@ -504,10 +504,9 @@ public: // this will be a specially created local db. Reference versionMonitorDb; + bool closed; + ThreadFuture changed; - - bool cancelled; - ThreadFuture dbReady; ThreadFuture protocolVersionMonitor; From d46feb54682566a14eb96dafd82f02e8cee491a5 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 19 Jul 2021 20:17:46 -0700 Subject: [PATCH 060/225] Add COORDINATOR_LEADER_CONNECTION_TIMEOUT server knob --- fdbclient/ServerKnobs.cpp | 1 + fdbclient/ServerKnobs.h | 1 + fdbserver/Coordination.actor.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index 994f367292..0d3226ea35 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -652,6 +652,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi // Coordination init( COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL, 1.0 ); if( randomize && BUGGIFY ) COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL = 10.0; init( ENABLE_CROSS_CLUSTER_SUPPORT, true ); if( randomize && BUGGIFY ) ENABLE_CROSS_CLUSTER_SUPPORT = false; + init( COORDINATOR_LEADER_CONNECTION_TIMEOUT, 20.0 ); // Buggification init( BUGGIFIED_EVENTUAL_CONSISTENCY, 1.0 ); diff --git a/fdbclient/ServerKnobs.h b/fdbclient/ServerKnobs.h index 79600d49bb..c8a093a091 100644 --- a/fdbclient/ServerKnobs.h +++ b/fdbclient/ServerKnobs.h @@ -593,6 +593,7 @@ public: double COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL; bool ENABLE_CROSS_CLUSTER_SUPPORT; // Allow a coordinator to serve requests whose connection string does not match // the local descriptor + double COORDINATOR_LEADER_CONNECTION_TIMEOUT; // Buggification double BUGGIFIED_EVENTUAL_CONSISTENCY; diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index c284c2eabd..d9975c5ecc 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -286,7 +286,7 @@ ACTOR Future leaderRegister(LeaderElectionRegInterface interf, Key key) { state AsyncVar leaderInterface; state Reference>> currentElectedLeader = makeReference>>(); - state LivenessChecker canConnectToLeader(20.0); + state LivenessChecker canConnectToLeader(SERVER_KNOBS->COORDINATOR_LEADER_CONNECTION_TIMEOUT); loop choose { when(OpenDatabaseCoordRequest req = waitNext(interf.openDatabase.getFuture())) { From 6836e49073759f6df09b672dcfb88d13382ab5be Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 19 Jul 2021 21:00:28 -0700 Subject: [PATCH 061/225] Throw error when commitProxy gets stuck --- fdbclient/ServerKnobs.cpp | 1 + fdbclient/ServerKnobs.h | 1 + fdbserver/CommitProxyServer.actor.cpp | 16 +++++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index 0d3226ea35..aeed11b925 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -364,6 +364,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( START_TRANSACTION_MAX_EMPTY_QUEUE_BUDGET, 10.0 ); init( START_TRANSACTION_MAX_QUEUE_SIZE, 1e6 ); init( KEY_LOCATION_MAX_QUEUE_SIZE, 1e6 ); + init( COMMIT_PROXY_LIVENESS_TIMEOUT, 20.0 ); init( COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE, 0.0005 ); if( randomize && BUGGIFY ) COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE = 0.005; init( COMMIT_TRANSACTION_BATCH_INTERVAL_MIN, 0.001 ); if( randomize && BUGGIFY ) COMMIT_TRANSACTION_BATCH_INTERVAL_MIN = 0.1; diff --git a/fdbclient/ServerKnobs.h b/fdbclient/ServerKnobs.h index c8a093a091..18c2a93eac 100644 --- a/fdbclient/ServerKnobs.h +++ b/fdbclient/ServerKnobs.h @@ -297,6 +297,7 @@ public: double START_TRANSACTION_MAX_EMPTY_QUEUE_BUDGET; int START_TRANSACTION_MAX_QUEUE_SIZE; int KEY_LOCATION_MAX_QUEUE_SIZE; + double COMMIT_PROXY_LIVENESS_TIMEOUT; double COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE; double COMMIT_TRANSACTION_BATCH_INTERVAL_MIN; diff --git a/fdbserver/CommitProxyServer.actor.cpp b/fdbserver/CommitProxyServer.actor.cpp index 337a24e956..63fd4e9016 100644 --- a/fdbserver/CommitProxyServer.actor.cpp +++ b/fdbserver/CommitProxyServer.actor.cpp @@ -1922,10 +1922,14 @@ ACTOR Future commitProxyServerCore(CommitProxyInterface proxy, lastCommit = now(); if (trs.size() || lastCommitComplete.isReady()) { - lastCommitComplete = - commitBatch(&commitData, - const_cast*>(&batchedRequests.first), - batchBytes); + lastCommitComplete = transformError( + timeoutError( + commitBatch(&commitData, + const_cast*>(&batchedRequests.first), + batchBytes), + SERVER_KNOBS->COMMIT_PROXY_LIVENESS_TIMEOUT), + timed_out(), + failed_to_progress()); addActor.send(lastCommitComplete); } } @@ -2067,9 +2071,11 @@ ACTOR Future commitProxyServer(CommitProxyInterface proxy, if (e.code() != error_code_worker_removed && e.code() != error_code_tlog_stopped && e.code() != error_code_master_tlog_failed && e.code() != error_code_coordinators_changed && - e.code() != error_code_coordinated_state_conflict && e.code() != error_code_new_coordinators_timed_out) { + e.code() != error_code_coordinated_state_conflict && e.code() != error_code_new_coordinators_timed_out && + e.code() != error_code_failed_to_progress) { throw; } + TEST(e.code() == error_code_failed_to_progress); // Commit proxy failed to progress } return Void(); } From 1dc9839e49f0fa7c44f08ffd94b4e5c364aca0f8 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 19 Jul 2021 22:34:27 -0700 Subject: [PATCH 062/225] Increase max latency for LowLatencySingleClog test --- tests/fast/LowLatencySingleClog.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/fast/LowLatencySingleClog.toml b/tests/fast/LowLatencySingleClog.toml index cbfe6682e3..7a76141504 100644 --- a/tests/fast/LowLatencySingleClog.toml +++ b/tests/fast/LowLatencySingleClog.toml @@ -9,12 +9,14 @@ connectionFailuresDisableDuration = 100000 [[test.workload]] testName = 'Cycle' transactionsPerSecond = 1000.0 - testDuration = 30.0 + testDuration = 60.0 expectedRate = 0 [[test.workload]] testName = 'LowLatency' - testDuration = 30.0 + maxGRVLatency = 40.0 + maxCommitLatency = 40.0 + testDuration = 60.0 [[test.workload]] testName = 'ClogSingleConnection' From 62026ce42a525ae7e987c3ae9351e785a0c57c33 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 19 Jul 2021 22:51:47 -0700 Subject: [PATCH 063/225] Remove ReplyPromise::sendErrorOr --- fdbrpc/fdbrpc.h | 8 -------- fdbserver/Coordination.actor.cpp | 6 +++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fdbrpc/fdbrpc.h b/fdbrpc/fdbrpc.h index 53eb6b13d5..df13a7fa0c 100644 --- a/fdbrpc/fdbrpc.h +++ b/fdbrpc/fdbrpc.h @@ -123,14 +123,6 @@ public: void sendError(const E& exc) const { sav->sendError(exc); } - template - void sendErrorOr(U&& value) const { - if (value.present()) { - sav->send(std::forward(value).get()); - } else { - sav->sendError(value.getError()); - } - } Future getFuture() const { sav->addFutureRef(); diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index d9975c5ecc..fc417a7539 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -233,7 +233,11 @@ ACTOR Future openDatabase(ClientData* db, } } - req.reply.sendErrorOr(replyContents); + if (replyContents.present()) { + req.reply.send(replyContents.get()); + } else { + req.reply.sendError(replyContents.getError()); + } if (--(*clientCount) == 0) { hasConnectedClients->set(false); From 4d9574901fa1d2c51e0e5e61a3ca4b86175c6aed Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 20 Jul 2021 11:03:36 -0700 Subject: [PATCH 064/225] Change default data directory for unit tests outside simulation --- fdbserver/workloads/UnitTests.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/workloads/UnitTests.actor.cpp b/fdbserver/workloads/UnitTests.actor.cpp index 482a89ff13..6bf9eb39dc 100644 --- a/fdbserver/workloads/UnitTests.actor.cpp +++ b/fdbserver/workloads/UnitTests.actor.cpp @@ -55,7 +55,7 @@ struct UnitTestWorkload : TestWorkload { if (g_network->isSimulated()) { testParams.setDataDir(getOption(options, "dataDir"_sr, "simfdb/unittests/"_sr).toString()); } else { - testParams.setDataDir(getOption(options, "dataDir"_sr, "/private/tmp/"_sr).toString()); + testParams.setDataDir(getOption(options, "dataDir"_sr, "unittests/"_sr).toString()); } cleanupAfterTests = getOption(options, "cleanupAfterTests"_sr, true); From 89fa7d055860cd196ad2157e9be5d0541812974d Mon Sep 17 00:00:00 2001 From: Markus Pilman Date: Tue, 20 Jul 2021 18:27:16 -0600 Subject: [PATCH 065/225] remove unnecessary compile guards --- fdbclient/BackupContainerAzureBlobStore.actor.cpp | 4 ---- fdbclient/BackupContainerFileSystem.actor.cpp | 8 -------- fdbclient/BackupContainerFileSystem.h | 2 -- fdbclient/BackupContainerLocalDirectory.actor.cpp | 2 -- 4 files changed, 16 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index e2733bf7ce..6018c4d5cb 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -19,9 +19,7 @@ */ #include "fdbclient/BackupContainerAzureBlobStore.h" -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) #include "fdbrpc/AsyncFileEncrypted.h" -#emdif #include "flow/actorcompiler.h" // This must be the last #include. @@ -250,9 +248,7 @@ BackupContainerAzureBlobStore::BackupContainerAzureBlobStore(const NetworkAddres const std::string& containerName, const Optional& encryptionKeyFileName) : containerName(containerName) { -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) setEncryptionKey(encryptionKeyFileName); -#endif std::string accountKey = std::getenv("AZURE_KEY"); auto credential = std::make_shared(accountName, accountKey); auto storageAccount = std::make_shared( diff --git a/fdbclient/BackupContainerFileSystem.actor.cpp b/fdbclient/BackupContainerFileSystem.actor.cpp index 5417056fed..040c759956 100644 --- a/fdbclient/BackupContainerFileSystem.actor.cpp +++ b/fdbclient/BackupContainerFileSystem.actor.cpp @@ -23,9 +23,7 @@ #include "fdbclient/BackupContainerFileSystem.h" #include "fdbclient/BackupContainerLocalDirectory.h" #include "fdbclient/JsonBuilder.h" -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) #include "flow/StreamCipher.h" -#endif #include "flow/UnitTest.h" #include @@ -1481,7 +1479,6 @@ Future BackupContainerFileSystem::encryptionSetupComplete() const { return encryptionSetupFuture; } -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) void BackupContainerFileSystem::setEncryptionKey(Optional const& encryptionKeyFileName) { if (encryptionKeyFileName.present()) { #if ENCRYPTION_ENABLED @@ -1498,11 +1495,6 @@ Future BackupContainerFileSystem::createTestEncryptionKeyFile(std::string return Void(); #endif } -#else -Future BackupContainerFileSystem::createTestEncryptionKeyFile(std::string const& filename) { - return Void(); -} -#endif namespace backup_test { diff --git a/fdbclient/BackupContainerFileSystem.h b/fdbclient/BackupContainerFileSystem.h index 4b92b2f409..292fc67abb 100644 --- a/fdbclient/BackupContainerFileSystem.h +++ b/fdbclient/BackupContainerFileSystem.h @@ -156,9 +156,7 @@ public: protected: bool usesEncryption() const; -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) void setEncryptionKey(Optional const& encryptionKeyFileName); -#endif Future encryptionSetupComplete() const; private: diff --git a/fdbclient/BackupContainerLocalDirectory.actor.cpp b/fdbclient/BackupContainerLocalDirectory.actor.cpp index fa0f351d5a..b89d085a64 100644 --- a/fdbclient/BackupContainerLocalDirectory.actor.cpp +++ b/fdbclient/BackupContainerLocalDirectory.actor.cpp @@ -133,9 +133,7 @@ std::string BackupContainerLocalDirectory::getURLFormat() { BackupContainerLocalDirectory::BackupContainerLocalDirectory(const std::string& url, const Optional& encryptionKeyFileName) { -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) setEncryptionKey(encryptionKeyFileName); -#endif std::string path; if (url.find("file://") != 0) { From 63ebdc0cc0ca842922896b978ba6697730c2c16c Mon Sep 17 00:00:00 2001 From: Markus Pilman Date: Tue, 20 Jul 2021 18:30:43 -0600 Subject: [PATCH 066/225] added one missed change --- fdbclient/BackupContainerS3BlobStore.actor.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/fdbclient/BackupContainerS3BlobStore.actor.cpp b/fdbclient/BackupContainerS3BlobStore.actor.cpp index c48e66e597..b915701a3f 100644 --- a/fdbclient/BackupContainerS3BlobStore.actor.cpp +++ b/fdbclient/BackupContainerS3BlobStore.actor.cpp @@ -147,9 +147,7 @@ BackupContainerS3BlobStore::BackupContainerS3BlobStore(Reference& encryptionKeyFileName) : m_bstore(bstore), m_name(name), m_bucket("FDB_BACKUPS_V2") { -#if (!defined(TLS_DISABLED) && !defined(_WIN32)) setEncryptionKey(encryptionKeyFileName); -#endif // Currently only one parameter is supported, "bucket" for (const auto& [name, value] : params) { if (name == "bucket") { From 01af7062281fd847b5275b9b973807af5838ca19 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Tue, 20 Jul 2021 21:23:50 -0700 Subject: [PATCH 067/225] Refactor metric logging to be shorter and changed text format to be more condensed. --- fdbserver/IPager.h | 20 ++--- fdbserver/VersionedBTree.actor.cpp | 117 +++++++++++++---------------- 2 files changed, 61 insertions(+), 76 deletions(-) diff --git a/fdbserver/IPager.h b/fdbserver/IPager.h index 22ee4b94ca..922df85ce3 100644 --- a/fdbserver/IPager.h +++ b/fdbserver/IPager.h @@ -42,31 +42,31 @@ typedef uint32_t QueueID; // Pager Events enum class PagerEvents { CacheLookup = 0, CacheHit, CacheMiss, PageWrite, MAXEVENTS }; -static const std::string PagerEventsStrings[] = { "Lookup", "Hit", "Miss", "Write", "Unknown" }; +static const char* const PagerEventsStrings[] = { "Lookup", "Hit", "Miss", "Write", "Unknown" }; // Reasons for page level events. enum class PagerEventReasons { PointRead = 0, RangeRead, RangePrefetch, Commit, LazyClear, MetaData, MAXEVENTREASONS }; -static const std::string PagerEventReasonsStrings[] = { "Get", "GetR", "GetRPF", "Commit", "LazyClr", "Meta", "Unknown" }; +static const char* const PagerEventReasonsStrings[] = { + "Get", "GetR", "GetRPF", "Commit", "LazyClr", "Meta", "Unknown" +}; static const int nonBtreeLevel = 0; -static const std::pair possibleEventReasonPairs[] = { +static const std::vector> possibleEventReasonPairs = { + { PagerEvents::CacheLookup, PagerEventReasons::Commit }, { PagerEvents::CacheLookup, PagerEventReasons::PointRead }, { PagerEvents::CacheLookup, PagerEventReasons::RangeRead }, { PagerEvents::CacheLookup, PagerEventReasons::LazyClear }, - { PagerEvents::CacheLookup, PagerEventReasons::MetaData }, + { PagerEvents::CacheHit, PagerEventReasons::Commit }, { PagerEvents::CacheHit, PagerEventReasons::PointRead }, { PagerEvents::CacheHit, PagerEventReasons::RangeRead }, { PagerEvents::CacheHit, PagerEventReasons::LazyClear }, - { PagerEvents::CacheHit, PagerEventReasons::MetaData }, - { PagerEvents::CacheHit, PagerEventReasons::Commit }, + { PagerEvents::CacheMiss, PagerEventReasons::Commit }, { PagerEvents::CacheMiss, PagerEventReasons::PointRead }, { PagerEvents::CacheMiss, PagerEventReasons::RangeRead }, { PagerEvents::CacheMiss, PagerEventReasons::LazyClear }, - { PagerEvents::CacheMiss, PagerEventReasons::MetaData }, - { PagerEvents::CacheMiss, PagerEventReasons::Commit }, - { PagerEvents::PageWrite, PagerEventReasons::MetaData }, + { PagerEvents::PageWrite, PagerEventReasons::Commit }, { PagerEvents::PageWrite, PagerEventReasons::LazyClear }, }; -static const std::pair L0PossibleEventReasonPairs[] = { +static const std::vector> L0PossibleEventReasonPairs = { { PagerEvents::CacheLookup, PagerEventReasons::RangePrefetch }, { PagerEvents::CacheLookup, PagerEventReasons::MetaData }, { PagerEvents::CacheHit, PagerEventReasons::RangePrefetch }, diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index d0fdd4e283..2882a47198 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -1461,71 +1461,51 @@ struct RedwoodMetrics { } } } + void addEventReason(PagerEvents event, PagerEventReasons reason) { eventReasons[(size_t)event][(size_t)reason] += 1; } - const unsigned int& getEventReason(PagerEvents event, PagerEventReasons reason) { + + unsigned int getEventReason(PagerEvents event, PagerEventReasons reason) const { return eventReasons[(size_t)event][(size_t)reason]; } - std::string ouputSummary(int currLevel) { - std::string result = ""; - PagerEvents prevEvent = PagerEvents::MAXEVENTS; - if (currLevel == 0) { - for (const auto& ER : L0PossibleEventReasonPairs) { - if (prevEvent != ER.first) { - result += "\n"; - result += PagerEventsStrings[(size_t)ER.first]; - result += "\n\t"; - prevEvent = ER.first; - } - std::string num = std::to_string(eventReasons[(size_t)ER.first][(size_t)ER.second]); - result += PagerEventReasonsStrings[(size_t)ER.second]; - result.append(16 - PagerEventReasonsStrings[(size_t)ER.second].length(), ' '); - result.append(8 - num.length(), ' '); - result += num; - result.append(13, ' '); - } - } else { - for (const auto& ER : possibleEventReasonPairs) { - if (prevEvent != ER.first) { - result += "\n"; - result += PagerEventsStrings[(size_t)ER.first]; - result += "\n\t"; - prevEvent = ER.first; - } - std::string num = std::to_string(eventReasons[(size_t)ER.first][(size_t)ER.second]); - result += PagerEventReasonsStrings[(size_t)ER.second]; - result.append(16 - PagerEventReasonsStrings[(size_t)ER.second].length(), ' '); - result.append(8 - num.length(), ' '); - result += num; - result.append(13, ' '); + std::string toString(int level, double elapsed) const { + std::string result; + + const auto& pairs = (level == 0 ? L0PossibleEventReasonPairs : possibleEventReasonPairs); + PagerEvents prevEvent = pairs.front().first; + std::string lineStart = (level == 0) ? "" : "\t"; + + for (const auto& p : pairs) { + if (p.first != prevEvent) { + result += "\n"; + result += lineStart; } + + std::string name = + format("%s%s", PagerEventsStrings[(int)p.first], PagerEventReasonsStrings[(int)p.second]); + int count = getEventReason(p.first, p.second); + result += format("%-15s %8u %8u/s ", name.c_str(), count, int(count / elapsed)); + + prevEvent = p.first; } + return result; } - void reportTrace(TraceEvent* t, int h) { - if (h == 0) { - for (const auto& ER : L0PossibleEventReasonPairs) { - t->detail( - format("L%d%s", - h, - (PagerEventsStrings[(size_t)ER.first] + PagerEventReasonsStrings[(size_t)ER.second]) - .c_str()), - eventReasons[(size_t)ER.first][(size_t)ER.second]); - } - } else { - for (const auto& ER : possibleEventReasonPairs) { - t->detail( - format("L%d%s", - h, - (PagerEventsStrings[(size_t)ER.first] + PagerEventReasonsStrings[(size_t)ER.second]) - .c_str()), - eventReasons[(size_t)ER.first][(size_t)ER.second]); - } + + void toTraceEvent(TraceEvent* t, int level) const { + const auto& pairs = (level == 0 ? L0PossibleEventReasonPairs : possibleEventReasonPairs); + for (const auto& p : pairs) { + std::string name = + format(level == 0 ? "" : "L%d", level) + + format("%s%s", PagerEventsStrings[(int)p.first], PagerEventReasonsStrings[(int)p.second]); + int count = getEventReason(p.first, p.second); + t->detail(std::move(name), count); } } }; + // Metrics by level struct Level { struct Counters { @@ -1542,7 +1522,7 @@ struct RedwoodMetrics { unsigned int lazyClearFreeExt; unsigned int forceUpdate; unsigned int detachChild; - EventReasonsArray eventReasons; + EventReasonsArray events; }; Counters metrics; Reference buildFillPctSketch; @@ -1581,7 +1561,7 @@ struct RedwoodMetrics { 0, maxRecordCount); } - metrics.eventReasons.clear(); + metrics.events.clear(); buildFillPctSketch->clear(); modifyFillPctSketch->clear(); buildStoredPctSketch->clear(); @@ -1655,8 +1635,12 @@ struct RedwoodMetrics { } Level& level(unsigned int level) { + // Storage for metrics for out of bound levels, such as if the BTree grows beyond 5 levels, + // which can happen in simulation with tiny page sizes. static Level outOfBound; // Valid levels are from 0 - btreeLevels + // Levels 1 through btreeLevels correspond to BTree node heights + // Level 0 is for operations that are not BTree level specific if (level < 0 || level > btreeLevels) { return outOfBound; } @@ -1702,7 +1686,8 @@ struct RedwoodMetrics { { "", 0 }, { "PagerRemapFree", metric.pagerRemapFree }, { "PagerRemapCopy", metric.pagerRemapCopy }, - { "PagerRemapSkip", metric.pagerRemapSkip } }; + { "PagerRemapSkip", metric.pagerRemapSkip }, + { "", 0 } }; GetHistogramRegistry().logReport(); double elapsed = now() - startTime; @@ -1714,6 +1699,7 @@ struct RedwoodMetrics { e->detail(m.first, m.second); } } + levels[0].metrics.events.toTraceEvent(e, 0); } if (s != nullptr) { @@ -1724,10 +1710,10 @@ struct RedwoodMetrics { *s += format("%-15s %-8u %8" PRId64 "/s ", m.first, m.second, int64_t(m.second / elapsed)); } } - *s += "\n"; + *s += levels[0].metrics.events.toString(0, elapsed); } - for (int i = 0; i < btreeLevels + 1; ++i) { + for (int i = 1; i < btreeLevels + 1; ++i) { auto& metric = levels[i].metrics; std::pair metrics[] = { @@ -1757,7 +1743,7 @@ struct RedwoodMetrics { e->detail(format("L%d%s", i + 1, m.first + (c == '-' ? 1 : 0)), m.second); } } - metric.eventReasons.reportTrace(e, i); + metric.events.toTraceEvent(e, i); } if (s != nullptr) { @@ -1777,8 +1763,7 @@ struct RedwoodMetrics { *s += format("%-15s %8u %8u/s ", name, m.second, rate ? int(m.second / elapsed) : 0); } } - *s += '\n'; - *s += metric.eventReasons.ouputSummary(i); + *s += metric.events.toString(i, elapsed); } } } @@ -2519,7 +2504,7 @@ public: state PriorityMultiLock::Lock lock = wait(self->ioLock.lock(header ? ioMaxPriority : ioMinPriority)); ++g_redwoodMetrics.metric.pagerDiskWrite; - g_redwoodMetrics.level(level).metrics.eventReasons.addEventReason(PagerEvents::PageWrite, reason); + g_redwoodMetrics.level(level).metrics.events.addEventReason(PagerEvents::PageWrite, reason); if (self->memoryOnly) { return Void(); @@ -2795,7 +2780,7 @@ public: bool noHit) override { // Use cached page if present, without triggering a cache hit. // Otherwise, read the page and return it but don't add it to the cache - auto& eventReasons = g_redwoodMetrics.level(level).metrics.eventReasons; + auto& eventReasons = g_redwoodMetrics.level(level).metrics.events; eventReasons.addEventReason(PagerEvents::CacheLookup, reason); if (!cacheable) { debug_printf("DWALPager(%s) op=readUncached %s\n", filename.c_str(), toString(pageID).c_str()); @@ -2953,7 +2938,7 @@ public: Future> readExtent(LogicalPageID pageID) override { debug_printf("DWALPager(%s) op=readExtent %s\n", filename.c_str(), toString(pageID).c_str()); PageCacheEntry* pCacheEntry = extentCache.getIfExists(pageID); - auto& eventReasons = g_redwoodMetrics.level(0).metrics.eventReasons; + auto& eventReasons = g_redwoodMetrics.level(0).metrics.events; if (pCacheEntry != nullptr) { eventReasons.addEventReason(PagerEvents::CacheLookup, PagerEventReasons::MetaData); debug_printf("DWALPager(%s) Cache Entry exists for %s\n", filename.c_str(), toString(pageID).c_str()); @@ -5415,8 +5400,8 @@ private: } debug_printf("readPage() op=readComplete %s @%" PRId64 " \n", toString(id).c_str(), snapshot->getVersion()); - const BTreePage* pTreePage = (const BTreePage*)page->begin(); - auto& metrics = g_redwoodMetrics.level(pTreePage->height).metrics; + const BTreePage* btPage = (const BTreePage*)page->begin(); + auto& metrics = g_redwoodMetrics.level(btPage->height).metrics; metrics.pageRead += 1; metrics.pageReadExt += (id.size() - 1); @@ -6677,7 +6662,7 @@ public: std::string toString() const { std::string r = format("{ptr=%p reason=%s %s ", this, - PagerEventsStrings[(int)reason].c_str(), + PagerEventsStrings[(int)reason], ::toString(pager->getVersion()).c_str()); for (int i = 0; i < path.size(); ++i) { std::string id = ""; From 5ff58ec8244e0cfd5c2e4c31863465203f0e2556 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Tue, 20 Jul 2021 22:46:56 -0700 Subject: [PATCH 068/225] Fixed valgrind errors caused by memory lifetime bugs in Histogram usage. Removed usage of unneeded level 0. --- fdbserver/VersionedBTree.actor.cpp | 68 ++++++++++++------------------ 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index 2882a47198..5d3cf25928 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -1454,13 +1454,7 @@ struct RedwoodMetrics { unsigned int eventReasons[(size_t)PagerEvents::MAXEVENTS][(size_t)PagerEventReasons::MAXEVENTREASONS]; EventReasonsArray() { clear(); } - void clear() { - for (size_t i = 0; i < (size_t)PagerEvents::MAXEVENTS; i++) { - for (size_t j = 0; j < (size_t)PagerEventReasons::MAXEVENTREASONS; j++) { - eventReasons[i][j] = 0; - } - } - } + void clear() { memset(eventReasons, 0, sizeof(eventReasons)); } void addEventReason(PagerEvents event, PagerEventReasons reason) { eventReasons[(size_t)event][(size_t)reason] += 1; @@ -1534,40 +1528,33 @@ struct RedwoodMetrics { Level() { clear(); } - void clear(int levelCounter = -1) { + void clear(int level = 0) { metrics = {}; - if (!buildFillPctSketch.isValid() || - buildFillPctSketch->name() != ("buildFillPct:" + std::to_string(levelCounter))) { - buildFillPctSketch = Histogram::getHistogram(LiteralStringRef("buildFillPct"), - LiteralStringRef(std::to_string(levelCounter).c_str()), - Histogram::Unit::percentage); - modifyFillPctSketch = Histogram::getHistogram(LiteralStringRef("modifyFillPct"), - LiteralStringRef(std::to_string(levelCounter).c_str()), - Histogram::Unit::percentage); - buildStoredPctSketch = Histogram::getHistogram(LiteralStringRef("buildStoredPct"), - LiteralStringRef(std::to_string(levelCounter).c_str()), - Histogram::Unit::percentage); - modifyStoredPctSketch = Histogram::getHistogram(LiteralStringRef("modifyStoredPct"), - LiteralStringRef(std::to_string(levelCounter).c_str()), - Histogram::Unit::percentage); - buildItemCountSketch = Histogram::getHistogram(LiteralStringRef("buildItemCount"), - LiteralStringRef(std::to_string(levelCounter).c_str()), - Histogram::Unit::count, - 0, - maxRecordCount); - modifyItemCountSketch = Histogram::getHistogram(LiteralStringRef("modifyItemCount"), - LiteralStringRef(std::to_string(levelCounter).c_str()), - Histogram::Unit::count, - 0, - maxRecordCount); + + if (level > 0) { + if (!buildFillPctSketch) { + std::string levelString = format("L%d", level); + buildFillPctSketch = Histogram::getHistogram( + LiteralStringRef("buildFillPct"), levelString, Histogram::Unit::percentage); + modifyFillPctSketch = Histogram::getHistogram( + LiteralStringRef("modifyFillPct"), levelString, Histogram::Unit::percentage); + buildStoredPctSketch = Histogram::getHistogram( + LiteralStringRef("buildStoredPct"), levelString, Histogram::Unit::percentage); + modifyStoredPctSketch = Histogram::getHistogram( + LiteralStringRef("modifyStoredPct"), levelString, Histogram::Unit::percentage); + buildItemCountSketch = Histogram::getHistogram( + LiteralStringRef("buildItemCount"), levelString, Histogram::Unit::count, 0, maxRecordCount); + modifyItemCountSketch = Histogram::getHistogram( + LiteralStringRef("modifyItemCount"), levelString, Histogram::Unit::count, 0, maxRecordCount); + } + + buildFillPctSketch->clear(); + modifyFillPctSketch->clear(); + buildStoredPctSketch->clear(); + modifyStoredPctSketch->clear(); + buildItemCountSketch->clear(); + modifyItemCountSketch->clear(); } - metrics.events.clear(); - buildFillPctSketch->clear(); - modifyFillPctSketch->clear(); - buildStoredPctSketch->clear(); - modifyStoredPctSketch->clear(); - buildItemCountSketch->clear(); - modifyItemCountSketch->clear(); } }; @@ -1650,7 +1637,7 @@ struct RedwoodMetrics { void updateMaxRecordCount(int maxRecords) { if (maxRecordCount != maxRecords) { maxRecordCount = maxRecords; - for (int i = 0; i < btreeLevels + 1; ++i) { + for (int i = 1; i <= btreeLevels; ++i) { auto& level = levels[i]; level.buildItemCountSketch->updateUpperBound(maxRecordCount); level.modifyItemCountSketch->updateUpperBound(maxRecordCount); @@ -1688,7 +1675,6 @@ struct RedwoodMetrics { { "PagerRemapCopy", metric.pagerRemapCopy }, { "PagerRemapSkip", metric.pagerRemapSkip }, { "", 0 } }; - GetHistogramRegistry().logReport(); double elapsed = now() - startTime; From 2f21e0a6bb4000b8d9d164f8f821b7c6e86fd368 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Tue, 20 Jul 2021 23:40:35 -0700 Subject: [PATCH 069/225] BTree levels above the configured count for metrics are now included into the highest level, which fixes some valgrind errors and a crash. --- fdbserver/VersionedBTree.actor.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index 5d3cf25928..fdddc5c01c 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -1447,7 +1447,7 @@ int nextPowerOf2(uint32_t x) { } struct RedwoodMetrics { - static constexpr int btreeLevels = 5; + static constexpr unsigned int btreeLevels = 5; static int maxRecordCount; struct EventReasonsArray { @@ -1622,16 +1622,11 @@ struct RedwoodMetrics { } Level& level(unsigned int level) { - // Storage for metrics for out of bound levels, such as if the BTree grows beyond 5 levels, - // which can happen in simulation with tiny page sizes. - static Level outOfBound; // Valid levels are from 0 - btreeLevels - // Levels 1 through btreeLevels correspond to BTree node heights - // Level 0 is for operations that are not BTree level specific - if (level < 0 || level > btreeLevels) { - return outOfBound; - } - return levels[level]; + // Level 0 is for operations that are not BTree level specific, as many of the metrics are the same + // Level 0 - btreeLevels correspond to BTree node height, however heights above btreeLevels are combined + // into the level at btreeLevels + return levels[std::min(level, btreeLevels)]; } void updateMaxRecordCount(int maxRecords) { @@ -9030,7 +9025,7 @@ TEST_CASE("/redwood/correctness/btree") { mutationBytesThisCommit >= mutationBytesTargetThisCommit) { // Wait for previous commit to finish wait(commit); - printf("Last commit complete. Next commit %d bytes, %" PRId64 " bytes committed so far.", + printf("Commit complete. Next commit %d bytes, %" PRId64 " bytes committed so far.", mutationBytesThisCommit, mutationBytes.get() - mutationBytesThisCommit); printf(" Stats: Insert %.2f MB/s ClearedKeys %.2f MB/s Total %.2f\n", From c16b73bb2fbf30173d026fb52caeada1e7d38f9a Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Wed, 21 Jul 2021 01:28:25 -0700 Subject: [PATCH 070/225] Bug fix, BTreeCursor pager event reason was not being initialized. Changed metric column order. --- fdbserver/IPager.h | 6 +++--- fdbserver/VersionedBTree.actor.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fdbserver/IPager.h b/fdbserver/IPager.h index 922df85ce3..c5558613bc 100644 --- a/fdbserver/IPager.h +++ b/fdbserver/IPager.h @@ -52,17 +52,17 @@ static const char* const PagerEventReasonsStrings[] = { static const int nonBtreeLevel = 0; static const std::vector> possibleEventReasonPairs = { { PagerEvents::CacheLookup, PagerEventReasons::Commit }, + { PagerEvents::CacheLookup, PagerEventReasons::LazyClear }, { PagerEvents::CacheLookup, PagerEventReasons::PointRead }, { PagerEvents::CacheLookup, PagerEventReasons::RangeRead }, - { PagerEvents::CacheLookup, PagerEventReasons::LazyClear }, { PagerEvents::CacheHit, PagerEventReasons::Commit }, + { PagerEvents::CacheHit, PagerEventReasons::LazyClear }, { PagerEvents::CacheHit, PagerEventReasons::PointRead }, { PagerEvents::CacheHit, PagerEventReasons::RangeRead }, - { PagerEvents::CacheHit, PagerEventReasons::LazyClear }, { PagerEvents::CacheMiss, PagerEventReasons::Commit }, + { PagerEvents::CacheMiss, PagerEventReasons::LazyClear }, { PagerEvents::CacheMiss, PagerEventReasons::PointRead }, { PagerEvents::CacheMiss, PagerEventReasons::RangeRead }, - { PagerEvents::CacheMiss, PagerEventReasons::LazyClear }, { PagerEvents::PageWrite, PagerEventReasons::Commit }, { PagerEvents::PageWrite, PagerEventReasons::LazyClear }, }; diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index fdddc5c01c..ecd6540ffb 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -6707,11 +6707,11 @@ public: // Initialize or reinitialize cursor Future init(VersionedBTree* btree_in, - PagerEventReasons reason, + PagerEventReasons reason_in, Reference pager_in, BTreePageIDRef root) { btree = btree_in; - reason = reason; + reason = reason_in; pager = pager_in; path.clear(); path.reserve(6); From 0b6d43fa6fb0f2ba66c430955dd1c9c771987c58 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Wed, 21 Jul 2021 18:36:05 +0000 Subject: [PATCH 071/225] Fix exclude test and re-enable it in ctest --- bindings/python/tests/fdbcli_tests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index 49fd45c632..d18ef9f6d8 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -381,12 +381,19 @@ def exclude(logger): while True: logger.debug("Excluding process: {}".format(excluded_address)) error_message = run_fdbcli_command_and_get_error('exclude', excluded_address) - if not error_message: + if error_message == 'WARNING: {} is a coordinator!'.format(excluded_address): + # exclude coordinator will fail, verify the randomly selected process is the coordinator + coordinator_list = get_value_from_status_json(True, 'client', 'coordinators', 'coordinators') + assert len(coordinator_list) == 1 + assert coordinator_list[0]['address'] == excluded_address break + elif not error_message: + break + else: + logger.debug("Error message: {}\n".format(error_message)) logger.debug("Retry exclude after 1 second") time.sleep(1) output2 = run_fdbcli_command('exclude') - # logger.debug(output3) assert 'There are currently 1 servers or localities being excluded from the database' in output2 assert excluded_address in output2 run_fdbcli_command('include', excluded_address) @@ -416,6 +423,6 @@ if __name__ == '__main__': else: assert process_number > 1, "Process number should be positive" coordinators() - # exclude() + exclude() From 6bf5df6cc5f9f35aff94a78d9c2b22f0d49fbac2 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Wed, 21 Jul 2021 18:38:13 +0000 Subject: [PATCH 072/225] Update comments in fdbcli_tests.py --- bindings/python/tests/fdbcli_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index d18ef9f6d8..8004f77f30 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -382,7 +382,7 @@ def exclude(logger): logger.debug("Excluding process: {}".format(excluded_address)) error_message = run_fdbcli_command_and_get_error('exclude', excluded_address) if error_message == 'WARNING: {} is a coordinator!'.format(excluded_address): - # exclude coordinator will fail, verify the randomly selected process is the coordinator + # exclude coordinator will print the warning, verify the randomly selected process is the coordinator coordinator_list = get_value_from_status_json(True, 'client', 'coordinators', 'coordinators') assert len(coordinator_list) == 1 assert coordinator_list[0]['address'] == excluded_address From 35f835548d2f2b9586b1b796eaef33bac61533e7 Mon Sep 17 00:00:00 2001 From: Markus Pilman Date: Wed, 21 Jul 2021 13:46:39 -0600 Subject: [PATCH 073/225] Fix Java integration tests --- cmake/AddFdbTest.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index d292679e91..752fcb8ebe 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -416,14 +416,14 @@ function(add_fdbclient_test) message(STATUS "Adding Client test ${T_NAME}") if (T_PROCESS_NUMBER) add_test(NAME "${T_NAME}" - COMMAND ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_cluster.py + COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_cluster.py --build-dir ${CMAKE_BINARY_DIR} --process-number ${T_PROCESS_NUMBER} -- ${T_COMMAND}) else() add_test(NAME "${T_NAME}" - COMMAND ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_cluster.py + COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_cluster.py --build-dir ${CMAKE_BINARY_DIR} -- ${T_COMMAND}) @@ -459,7 +459,7 @@ function(add_multi_fdbclient_test) endif() message(STATUS "Adding Client test ${T_NAME}") add_test(NAME "${T_NAME}" - COMMAND ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_multi_cluster.py + COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/TestRunner/tmp_multi_cluster.py --build-dir ${CMAKE_BINARY_DIR} --clusters 3 -- From bdb740b7b8cfdbef91ad6dbecf67f35365276529 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Wed, 21 Jul 2021 15:59:23 -0700 Subject: [PATCH 074/225] Propogate errors if creating a database on an external client fails --- fdbclient/MultiVersionTransaction.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index b91dde5d60..84366a0e06 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -591,7 +591,7 @@ Reference DLApi::createDatabase609(const char* clusterFilePath) { Reference DLApi::createDatabase(const char* clusterFilePath) { if (headerVersion >= 610) { FdbCApi::FDBDatabase* db; - api->createDatabase(clusterFilePath, &db); + throwIfError(api->createDatabase(clusterFilePath, &db)); return Reference(new DLDatabase(api, db)); } else { return DLApi::createDatabase609(clusterFilePath); From 16dfe14db8aaeae1e97abdfc9b13a6f32bf63713 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Wed, 21 Jul 2021 16:19:59 -0700 Subject: [PATCH 075/225] Update release notes --- .../sphinx/source/release-notes/release-notes-630.rst | 5 +++++ .../sphinx/source/release-notes/release-notes-700.rst | 2 ++ 2 files changed, 7 insertions(+) diff --git a/documentation/sphinx/source/release-notes/release-notes-630.rst b/documentation/sphinx/source/release-notes/release-notes-630.rst index 44db8d8a77..fbc17d3053 100644 --- a/documentation/sphinx/source/release-notes/release-notes-630.rst +++ b/documentation/sphinx/source/release-notes/release-notes-630.rst @@ -2,6 +2,11 @@ Release Notes ############# +6.3.16 +====== +* The multi-version client API would not propagate errors that occurred when creating databases on external clients. This could result in a invalid memory accesses. `(PR #5221) `_ +* Fixed a race between the multi-version client connecting to a cluster and destroying the database that could cause an assertion failure. `(PR #5221) `_ + 6.3.15 ====== diff --git a/documentation/sphinx/source/release-notes/release-notes-700.rst b/documentation/sphinx/source/release-notes/release-notes-700.rst index ddb9e11ed1..cfc0730e90 100644 --- a/documentation/sphinx/source/release-notes/release-notes-700.rst +++ b/documentation/sphinx/source/release-notes/release-notes-700.rst @@ -60,6 +60,8 @@ Fixes * Added a new pre-backup action when creating a backup. Backups can now either verify the range data is being saved to is empty before the backup begins (current behavior) or clear the range where data is being saved to. Fixes a ``restore_destination_not_empty`` failure after a backup retry due to ``commit_unknown_failure``. `(PR #4595) `_ * When configured with ``usable_regions=2``, a cluster would not fail over to a region which contained only storage class processes. `(PR #4599) `_ * If a restore is done using a prefix to remove and specific key ranges to restore, the key range boundaries must begin with the prefix to remove. `(PR #4684) `_ +* The multi-version client API would not propagate errors that occurred when creating databases on external clients. This could result in a invalid memory accesses. `(PR #5220) `_ +* Fixed a race between the multi-version client connecting to a cluster and destroying the database that could cause an assertion failure. `(PR #5220) `_ Status ------ From a3133d4b91aa46242ef7bdc513a31d5cf7a2c9ff Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Wed, 21 Jul 2021 18:02:51 -0700 Subject: [PATCH 076/225] Store encryption key file name in encoded Reference tuple --- fdbclient/BackupAgent.actor.h | 15 +++++++++++++-- fdbclient/BackupContainer.actor.cpp | 1 + fdbclient/BackupContainer.h | 4 +++- flow/StreamCipher.cpp | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fdbclient/BackupAgent.actor.h b/fdbclient/BackupAgent.actor.h index e23360b531..30855e2245 100644 --- a/fdbclient/BackupAgent.actor.h +++ b/fdbclient/BackupAgent.actor.h @@ -717,11 +717,22 @@ protected: template <> inline Tuple Codec>::pack(Reference const& bc) { - return Tuple().append(StringRef(bc->getURL())); + Tuple tuple; + tuple.append(StringRef(bc->getURL())); + if (bc->getEncryptionKeyFileName().present()) { + tuple.append(bc->getEncryptionKeyFileName().get()); + } + return tuple; } template <> inline Reference Codec>::unpack(Tuple const& val) { - return IBackupContainer::openContainer(val.getString(0).toString()); + ASSERT(val.size() == 1 || val.size() == 2); + auto url = val.getString(0).toString(); + Optional encryptionKeyFileName; + if (val.size() == 2) { + encryptionKeyFileName = val.getString(1).toString(); + } + return IBackupContainer::openContainer(url, encryptionKeyFileName); } class BackupConfig : public KeyBackedConfig { diff --git a/fdbclient/BackupContainer.actor.cpp b/fdbclient/BackupContainer.actor.cpp index 8f97d6e56e..b14de1c51e 100644 --- a/fdbclient/BackupContainer.actor.cpp +++ b/fdbclient/BackupContainer.actor.cpp @@ -296,6 +296,7 @@ Reference IBackupContainer::openContainer(const std::string& u throw backup_invalid_url(); } + r->encryptionKeyFileName = encryptionKeyFileName; r->URL = url; return r; } catch (Error& e) { diff --git a/fdbclient/BackupContainer.h b/fdbclient/BackupContainer.h index 5a9af3d1d9..dda4bb742d 100644 --- a/fdbclient/BackupContainer.h +++ b/fdbclient/BackupContainer.h @@ -298,12 +298,14 @@ public: static std::vector getURLFormats(); static Future> listContainers(const std::string& baseURL); - std::string getURL() const { return URL; } + std::string const &getURL() const { return URL; } + Optional const &getEncryptionKeyFileName() const { return encryptionKeyFileName; } static std::string lastOpenError; private: std::string URL; + Optional encryptionKeyFileName; }; #endif diff --git a/flow/StreamCipher.cpp b/flow/StreamCipher.cpp index 922054299b..bd0e1521f9 100644 --- a/flow/StreamCipher.cpp +++ b/flow/StreamCipher.cpp @@ -90,6 +90,7 @@ EncryptionStreamCipher::EncryptionStreamCipher(const StreamCipher::Key& key, con } StringRef EncryptionStreamCipher::encrypt(unsigned char const* plaintext, int len, Arena& arena) { + TEST(true); // Encrypting data with StreamCipher auto ciphertext = new (arena) unsigned char[len + AES_BLOCK_SIZE]; int bytes{ 0 }; EVP_EncryptUpdate(cipher.getCtx(), ciphertext, &bytes, plaintext, len); @@ -110,6 +111,7 @@ DecryptionStreamCipher::DecryptionStreamCipher(const StreamCipher::Key& key, con } StringRef DecryptionStreamCipher::decrypt(unsigned char const* ciphertext, int len, Arena& arena) { + TEST(true); // Decrypting data with StreamCipher auto plaintext = new (arena) unsigned char[len]; int bytesDecrypted{ 0 }; EVP_DecryptUpdate(cipher.getCtx(), plaintext, &bytesDecrypted, ciphertext, len); From e62e6503accc72ad12ca81aa6d7c1880568e65df Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Wed, 21 Jul 2021 22:43:04 -0700 Subject: [PATCH 077/225] Fix most delete-non-virtual-dtor clang warnings --- bindings/c/fdb_c.cpp | 2 +- bindings/c/foundationdb/ClientWorkload.h | 1 + bindings/java/JavaWorkload.cpp | 2 +- fdbrpc/Stats.h | 2 +- fdbserver/CoroFlow.actor.cpp | 2 +- fdbserver/IConfigDatabaseNode.h | 1 + fdbserver/KeyValueStoreSQLite.actor.cpp | 15 ++++++++------- fdbserver/OldTLogServer_4_6.actor.cpp | 2 +- fdbserver/OldTLogServer_6_0.actor.cpp | 2 +- fdbserver/OldTLogServer_6_2.actor.cpp | 2 +- fdbserver/TagPartitionedLogSystem.actor.cpp | 2 +- fdbserver/VersionedBTree.actor.cpp | 2 +- flow/FileTraceLogWriter.h | 2 +- flow/IThreadPoolTest.actor.cpp | 4 ++-- flow/JsonTraceLogFormatter.h | 2 +- flow/Net2.actor.cpp | 2 +- flow/ThreadHelper.actor.h | 4 ++-- flow/XmlTraceLogFormatter.h | 2 +- flow/actorcompiler/ActorCompiler.cs | 16 +++++++++++----- 19 files changed, 38 insertions(+), 29 deletions(-) diff --git a/bindings/c/fdb_c.cpp b/bindings/c/fdb_c.cpp index 16fbddf1c9..ecb78e4df7 100644 --- a/bindings/c/fdb_c.cpp +++ b/bindings/c/fdb_c.cpp @@ -162,7 +162,7 @@ extern "C" DLLEXPORT fdb_bool_t fdb_future_is_ready(FDBFuture* f) { return TSAVB(f)->isReady(); } -class CAPICallback : public ThreadCallback { +class CAPICallback final : public ThreadCallback { public: CAPICallback(void (*callbackf)(FDBFuture*, void*), FDBFuture* f, void* userdata) : callbackf(callbackf), f(f), userdata(userdata) {} diff --git a/bindings/c/foundationdb/ClientWorkload.h b/bindings/c/foundationdb/ClientWorkload.h index 0b785e1f31..d04ed68abd 100644 --- a/bindings/c/foundationdb/ClientWorkload.h +++ b/bindings/c/foundationdb/ClientWorkload.h @@ -66,6 +66,7 @@ public: }; struct FDBPromise { + virtual ~FDBPromise() = default; virtual void send(void*) = 0; }; diff --git a/bindings/java/JavaWorkload.cpp b/bindings/java/JavaWorkload.cpp index b2506965eb..555a6cb434 100644 --- a/bindings/java/JavaWorkload.cpp +++ b/bindings/java/JavaWorkload.cpp @@ -513,7 +513,7 @@ struct JVM { } }; -struct JavaWorkload : FDBWorkload { +struct JavaWorkload final : FDBWorkload { std::shared_ptr jvm; FDBLogger& log; FDBWorkloadContext* context = nullptr; diff --git a/fdbrpc/Stats.h b/fdbrpc/Stats.h index 61576ec031..625ce8bf1d 100644 --- a/fdbrpc/Stats.h +++ b/fdbrpc/Stats.h @@ -80,7 +80,7 @@ struct CounterCollection { void logToTraceEvent(TraceEvent& te) const; }; -struct Counter : ICounter, NonCopyable { +struct Counter final : ICounter, NonCopyable { public: typedef int64_t Value; diff --git a/fdbserver/CoroFlow.actor.cpp b/fdbserver/CoroFlow.actor.cpp index cc719423ec..f4f6674b2b 100644 --- a/fdbserver/CoroFlow.actor.cpp +++ b/fdbserver/CoroFlow.actor.cpp @@ -143,7 +143,7 @@ class WorkPool final : public IThreadPool, public ReferenceCounted { public: + virtual ~IConfigDatabaseNode() = default; virtual Future serve(ConfigTransactionInterface const&) = 0; virtual Future serve(ConfigFollowerInterface const&) = 0; diff --git a/fdbserver/KeyValueStoreSQLite.actor.cpp b/fdbserver/KeyValueStoreSQLite.actor.cpp index 6e3043f3f3..52f6b8563b 100644 --- a/fdbserver/KeyValueStoreSQLite.actor.cpp +++ b/fdbserver/KeyValueStoreSQLite.actor.cpp @@ -1639,7 +1639,7 @@ private: return cursor; } - struct ReadValueAction : TypedAction, FastAllocated { + struct ReadValueAction final : TypedAction, FastAllocated { Key key; Optional debugID; ThreadReturnPromise> result; @@ -1692,7 +1692,7 @@ private: // if (t >= 1.0) TraceEvent("ReadValuePrefixActionSlow",dbgid).detail("Elapsed", t); } - struct ReadRangeAction : TypedAction, FastAllocated { + struct ReadRangeAction final : TypedAction, FastAllocated { KeyRange keys; int rowLimit, byteLimit; ThreadReturnPromise result; @@ -1775,7 +1775,7 @@ private: } } - struct InitAction : TypedAction, FastAllocated { + struct InitAction final : TypedAction, FastAllocated { ThreadReturnPromise result; double getTimeEstimate() const override { return 0; } }; @@ -1784,7 +1784,7 @@ private: a.result.send(Void()); } - struct SetAction : TypedAction, FastAllocated { + struct SetAction final : TypedAction, FastAllocated { KeyValue kv; SetAction(KeyValue kv) : kv(kv) {} double getTimeEstimate() const override { return SERVER_KNOBS->SET_TIME_ESTIMATE; } @@ -1799,7 +1799,7 @@ private: TraceEvent("SetActionFinished", dbgid).detail("Elapsed", now() - s); } - struct ClearAction : TypedAction, FastAllocated { + struct ClearAction final : TypedAction, FastAllocated { KeyRange range; ClearAction(KeyRange range) : range(range) {} double getTimeEstimate() const override { return SERVER_KNOBS->CLEAR_TIME_ESTIMATE; } @@ -1813,7 +1813,7 @@ private: TraceEvent("ClearActionFinished", dbgid).detail("Elapsed", now() - s); } - struct CommitAction : TypedAction, FastAllocated { + struct CommitAction final : TypedAction, FastAllocated { double issuedTime; ThreadReturnPromise result; CommitAction() : issuedTime(now()) {} @@ -1887,7 +1887,8 @@ private: // freeListPages, iterationsi, freeTableEmpty); } - struct SpringCleaningAction : TypedAction, FastAllocated { + struct SpringCleaningAction final : TypedAction, + FastAllocated { ThreadReturnPromise result; double getTimeEstimate() const override { return std::max(SERVER_KNOBS->SPRING_CLEANING_LAZY_DELETE_TIME_ESTIMATE, diff --git a/fdbserver/OldTLogServer_4_6.actor.cpp b/fdbserver/OldTLogServer_4_6.actor.cpp index ce291e644c..2b8806a3ae 100644 --- a/fdbserver/OldTLogServer_4_6.actor.cpp +++ b/fdbserver/OldTLogServer_4_6.actor.cpp @@ -108,7 +108,7 @@ struct TLogQueueEntryRef { typedef Standalone TLogQueueEntry; -struct TLogQueue : public IClosable { +struct TLogQueue final : public IClosable { public: TLogQueue(IDiskQueue* queue, UID dbgid) : queue(queue), dbgid(dbgid) {} diff --git a/fdbserver/OldTLogServer_6_0.actor.cpp b/fdbserver/OldTLogServer_6_0.actor.cpp index 35cbc42535..5ece24b4fe 100644 --- a/fdbserver/OldTLogServer_6_0.actor.cpp +++ b/fdbserver/OldTLogServer_6_0.actor.cpp @@ -99,7 +99,7 @@ typedef Standalone TLogQueueEntry; struct LogData; struct TLogData; -struct TLogQueue : public IClosable { +struct TLogQueue final : public IClosable { public: TLogQueue(IDiskQueue* queue, UID dbgid) : queue(queue), dbgid(dbgid) {} diff --git a/fdbserver/OldTLogServer_6_2.actor.cpp b/fdbserver/OldTLogServer_6_2.actor.cpp index c581560faa..b745a22867 100644 --- a/fdbserver/OldTLogServer_6_2.actor.cpp +++ b/fdbserver/OldTLogServer_6_2.actor.cpp @@ -100,7 +100,7 @@ typedef Standalone TLogQueueEntry; struct LogData; struct TLogData; -struct TLogQueue : public IClosable { +struct TLogQueue final : public IClosable { public: TLogQueue(IDiskQueue* queue, UID dbgid) : queue(queue), dbgid(dbgid) {} diff --git a/fdbserver/TagPartitionedLogSystem.actor.cpp b/fdbserver/TagPartitionedLogSystem.actor.cpp index 2ab2b18062..78587bb7fc 100644 --- a/fdbserver/TagPartitionedLogSystem.actor.cpp +++ b/fdbserver/TagPartitionedLogSystem.actor.cpp @@ -152,7 +152,7 @@ OldTLogCoreData::OldTLogCoreData(const OldLogData& oldData) } } -struct TagPartitionedLogSystem : ILogSystem, ReferenceCounted { +struct TagPartitionedLogSystem final : ILogSystem, ReferenceCounted { const UID dbgid; LogSystemType logSystemType; std::vector> tLogs; // LogSets in different locations: primary, satellite, or remote diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index ecd6540ffb..55ac616e40 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -1970,7 +1970,7 @@ class DWALPagerSnapshot; // This process basically describes a "Delayed" Write-Ahead-Log (DWAL) because the remap queue and the newly allocated // alternate pages it references basically serve as a write ahead log for pages that will eventially be copied // back to their original location once the original version is no longer needed. -class DWALPager : public IPager2 { +class DWALPager final : public IPager2 { public: typedef FIFOQueue LogicalPageQueueT; typedef std::map VersionToPageMapT; diff --git a/flow/FileTraceLogWriter.h b/flow/FileTraceLogWriter.h index bc6ed8c4eb..2d28a076b4 100644 --- a/flow/FileTraceLogWriter.h +++ b/flow/FileTraceLogWriter.h @@ -45,7 +45,7 @@ private: std::unique_ptr impl; }; -class FileTraceLogWriter : public ITraceLogWriter, ReferenceCounted { +class FileTraceLogWriter final : public ITraceLogWriter, ReferenceCounted { private: std::string directory; std::string processName; diff --git a/flow/IThreadPoolTest.actor.cpp b/flow/IThreadPoolTest.actor.cpp index 03bce4782f..9c2fe9262c 100644 --- a/flow/IThreadPoolTest.actor.cpp +++ b/flow/IThreadPoolTest.actor.cpp @@ -11,10 +11,10 @@ void forceLinkIThreadPoolTests() {} -struct ThreadNameReceiver : IThreadPoolReceiver { +struct ThreadNameReceiver final : IThreadPoolReceiver { void init() override {} - struct GetNameAction : TypedAction { + struct GetNameAction final : TypedAction { ThreadReturnPromise name; double getTimeEstimate() const override { return 3.; } diff --git a/flow/JsonTraceLogFormatter.h b/flow/JsonTraceLogFormatter.h index 78ce3bb276..246ba0f455 100644 --- a/flow/JsonTraceLogFormatter.h +++ b/flow/JsonTraceLogFormatter.h @@ -21,7 +21,7 @@ #include "flow/FastRef.h" #include "flow/Trace.h" -struct JsonTraceLogFormatter : public ITraceLogFormatter, ReferenceCounted { +struct JsonTraceLogFormatter final : public ITraceLogFormatter, ReferenceCounted { const char* getExtension() override; const char* getHeader() override; // Called when starting a new file const char* getFooter() override; // Called when ending a file diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index 44572113d4..d93caee633 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -1155,7 +1155,7 @@ private: }; #endif -struct PromiseTask : public Task, public FastAllocated { +struct PromiseTask final : public Task, public FastAllocated { Promise promise; PromiseTask() {} explicit PromiseTask(Promise&& promise) noexcept : promise(std::move(promise)) {} diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index 6e2569ed0e..191ded8c9a 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -510,7 +510,7 @@ private: // A callback class used to convert a ThreadFuture into a Future template -struct CompletionCallback : public ThreadCallback, ReferenceCounted> { +struct CompletionCallback final : public ThreadCallback, ReferenceCounted> { // The thread future being waited on ThreadFuture threadFuture; @@ -554,7 +554,7 @@ Future unsafeThreadFutureToFuture(ThreadFuture threadFuture) { // A callback waiting on a thread future and will delete itself once fired template -struct UtilCallback : public ThreadCallback { +struct UtilCallback final : public ThreadCallback { public: UtilCallback(ThreadFuture f, void* userdata) : f(f), userdata(userdata) {} diff --git a/flow/XmlTraceLogFormatter.h b/flow/XmlTraceLogFormatter.h index 006f10908b..3d2444b583 100644 --- a/flow/XmlTraceLogFormatter.h +++ b/flow/XmlTraceLogFormatter.h @@ -27,7 +27,7 @@ #include "flow/FastRef.h" #include "flow/Trace.h" -struct XmlTraceLogFormatter : public ITraceLogFormatter, ReferenceCounted { +struct XmlTraceLogFormatter final : public ITraceLogFormatter, ReferenceCounted { void addref() override; void delref() override; diff --git a/flow/actorcompiler/ActorCompiler.cs b/flow/actorcompiler/ActorCompiler.cs index 7aef82a42e..cec434781e 100644 --- a/flow/actorcompiler/ActorCompiler.cs +++ b/flow/actorcompiler/ActorCompiler.cs @@ -83,6 +83,7 @@ namespace actorcompiler public bool endIsUnreachable = false; public string exceptionParameterIs = null; public bool publicName = false; + public string specifiers; string indentation; StreamWriter body; public bool wasCalled { get; protected set; } @@ -419,7 +420,7 @@ namespace actorcompiler string callback_base_classes = string.Join(", ", callbacks.Select(c=>string.Format("public {0}", c.type))); if (callback_base_classes != "") callback_base_classes += ", "; - writer.WriteLine("class {0} : public Actor<{2}>, {3}public FastAllocated<{1}>, public {4} {{", + writer.WriteLine("class {0} final : public Actor<{2}>, {3}public FastAllocated<{1}>, public {4} {{", className, fullClassName, actor.returnType == null ? "void" : actor.returnType, @@ -429,7 +430,10 @@ namespace actorcompiler writer.WriteLine("public:"); writer.WriteLine("\tusing FastAllocated<{0}>::operator new;", fullClassName); writer.WriteLine("\tusing FastAllocated<{0}>::operator delete;", fullClassName); - writer.WriteLine("\tvirtual void destroy() {{ ((Actor<{0}>*)this)->~Actor(); operator delete(this); }}", actor.returnType == null ? "void" : actor.returnType); + if (actor.returnType != null) + writer.WriteLine("\tvoid destroy() override {{ ((Actor<{0}>*)this)->~Actor(); operator delete(this); }}", actor.returnType); + else + writer.WriteLine("\tvoid destroy() {{ ((Actor*)this)->~Actor(); operator delete(this); }}"); foreach (var cb in callbacks) writer.WriteLine("friend struct {0};", cb.type); @@ -1189,10 +1193,11 @@ namespace actorcompiler private static void WriteFunction(TextWriter writer, Function func, string body) { - writer.WriteLine(memberIndentStr + "{0}{1}({2})", + writer.WriteLine(memberIndentStr + "{0}{1}({2}){3}", func.returnType == "" ? "" : func.returnType + " ", func.useByName(), - string.Join(",", func.formalParameters)); + string.Join(",", func.formalParameters), + func.specifiers == "" ? "" : " " + func.specifiers); if (func.returnType != "") writer.WriteLine(memberIndentStr + "{"); writer.WriteLine(body); @@ -1251,7 +1256,8 @@ namespace actorcompiler returnType = "void", formalParameters = new string[] {}, endIsUnreachable = true, - publicName = true + publicName = true, + specifiers = "override" }; cancelFunc.Indent(codeIndent); cancelFunc.WriteLine("auto wait_state = this->actor_wait_state;"); From 11b803fe0b007adcc4edf10ab9fd9158e238ff62 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Thu, 22 Jul 2021 13:22:04 -0700 Subject: [PATCH 078/225] Handle database creation errors --- fdbclient/MultiVersionTransaction.actor.cpp | 80 ++++++++++++++++----- fdbclient/MultiVersionTransaction.h | 15 ++-- 2 files changed, 72 insertions(+), 23 deletions(-) diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index 84366a0e06..277195dbfa 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -895,22 +895,43 @@ MultiVersionDatabase::MultiVersionDatabase(MultiVersionApi* api, api->runOnExternalClients(threadIdx, [this](Reference client) { dbState->addClient(client); }); - if (!externalClientsInitialized.test_and_set()) { - api->runOnExternalClientsAllThreads([&clusterFilePath](Reference client) { - // This creates a database to initialize some client state on the external library - // We only do this on 6.2+ clients to avoid some bugs associated with older versions - // This deletes the new database immediately to discard its connections - if (client->protocolVersion.hasCloseUnusedConnection()) { - Reference newDb = client->api->createDatabase(clusterFilePath.c_str()); + api->runOnExternalClientsAllThreads([&clusterFilePath](Reference client) { + // This creates a database to initialize some client state on the external library + // We only do this on 6.2+ clients to avoid some bugs associated with older versions + // This deletes the new database immediately to discard its connections + if (client->protocolVersion.hasCloseUnusedConnection() && !client->initialized) { + MutexHolder holder(client->initializationMutex); + + if (!client->initialized) { + try { + Reference newDb = client->api->createDatabase(clusterFilePath.c_str()); + client->initialized = true; + } catch (Error& e) { + // This connection is not initialized. It is still possible to connect with it, + // but we may not see trace logs from this client until a successful connection + // is established. + TraceEvent(SevWarnAlways, "FailedToInitializeExternalClient") + .detail("LibraryPath", client->libPath) + .detail("ClusterFilePath", clusterFilePath) + .error(e); + } } - }); - } + } + }); // For clients older than 6.2 we create and maintain our database connection api->runOnExternalClients(threadIdx, [this, &clusterFilePath](Reference client) { if (!client->protocolVersion.hasCloseUnusedConnection()) { - dbState->legacyDatabaseConnections[client->protocolVersion] = - client->api->createDatabase(clusterFilePath.c_str()); + try { + dbState->legacyDatabaseConnections[client->protocolVersion] = + client->api->createDatabase(clusterFilePath.c_str()); + } catch (Error& e) { + // This connection is discarded + TraceEvent(SevWarnAlways, "FailedToCreateLegacyDatabaseConnection") + .detail("LibraryPath", client->libPath) + .detail("ClusterFilePath", clusterFilePath) + .error(e); + } } }); @@ -1088,7 +1109,20 @@ void MultiVersionDatabase::DatabaseState::protocolVersionChanged(ProtocolVersion .detail("Failed", client->failed) .detail("External", client->external); - Reference newDb = client->api->createDatabase(clusterFilePath.c_str()); + Reference newDb; + try { + newDb = client->api->createDatabase(clusterFilePath.c_str()); + } catch (Error& e) { + TraceEvent(SevWarnAlways, "MultiVersionClientFailedToCreateDatabase") + .detail("LibraryPath", client->libPath) + .detail("External", client->external) + .detail("ClusterFilePath", clusterFilePath) + .error(e); + + // Put the client in a disconnected state until the version changes again + updateDatabase(Reference(), Reference()); + return; + } if (client->external && !MultiVersionApi::apiVersionAtLeast(610)) { // Old API versions return a future when creating the database, so we need to wait for it @@ -1151,12 +1185,28 @@ void MultiVersionDatabase::DatabaseState::updateDatabase(Reference ne versionMonitorDb = db; } else { // For older clients that don't have an API to get the protocol version, we have to monitor it locally - versionMonitorDb = MultiVersionApi::api->getLocalClient()->api->createDatabase(clusterFilePath.c_str()); + try { + versionMonitorDb = MultiVersionApi::api->getLocalClient()->api->createDatabase(clusterFilePath.c_str()); + } catch (Error& e) { + // We can't create a database to monitor the cluster version. This means we will continue using the + // previous one, and that could result in us having extra connections + TraceEvent(SevWarnAlways, "FailedToCreateDatabaseForVersionMonitoring") + .detail("ClusterFilePath", clusterFilePath) + .error(e); + } } } else { // We don't have a database connection, so use the local client to monitor the protocol version db = Reference(); - versionMonitorDb = MultiVersionApi::api->getLocalClient()->api->createDatabase(clusterFilePath.c_str()); + try { + versionMonitorDb = MultiVersionApi::api->getLocalClient()->api->createDatabase(clusterFilePath.c_str()); + } catch (Error& e) { + // We can't create a database to monitor the cluster version. This means we will continue using the + // previous one, and that could result in us having extra connections + TraceEvent(SevWarnAlways, "FailedToCreateDatabaseForVersionMonitoring") + .detail("ClusterFilePath", clusterFilePath) + .error(e); + } } dbVar->set(db); @@ -1264,8 +1314,6 @@ void MultiVersionDatabase::LegacyVersionMonitor::close() { } } -std::atomic_flag MultiVersionDatabase::externalClientsInitialized = ATOMIC_FLAG_INIT; - // MultiVersionApi bool MultiVersionApi::apiVersionAtLeast(int minVersion) { ASSERT_NE(MultiVersionApi::api->apiVersion, 0); diff --git a/fdbclient/MultiVersionTransaction.h b/fdbclient/MultiVersionTransaction.h index 86b214a1a6..0896d676a8 100644 --- a/fdbclient/MultiVersionTransaction.h +++ b/fdbclient/MultiVersionTransaction.h @@ -417,12 +417,17 @@ struct ClientInfo : ClientDesc, ThreadSafeReferenceCounted { ProtocolVersion protocolVersion; IClientApi* api; bool failed; + std::atomic_bool initialized; std::vector> threadCompletionHooks; - ClientInfo() : ClientDesc(std::string(), false), protocolVersion(0), api(nullptr), failed(true) {} - ClientInfo(IClientApi* api) : ClientDesc("internal", false), protocolVersion(0), api(api), failed(false) {} + Mutex initializationMutex; + + ClientInfo() + : ClientDesc(std::string(), false), protocolVersion(0), api(nullptr), failed(true), initialized(false) {} + ClientInfo(IClientApi* api) + : ClientDesc("internal", false), protocolVersion(0), api(api), failed(false), initialized(false) {} ClientInfo(IClientApi* api, std::string libPath) - : ClientDesc(libPath, true), protocolVersion(0), api(api), failed(false) {} + : ClientDesc(libPath, true), protocolVersion(0), api(api), failed(false), initialized(false) {} void loadProtocolVersion(); bool canReplace(Reference other) const; @@ -556,10 +561,6 @@ public: const Reference dbState; friend class MultiVersionTransaction; - - // Clients must create a database object in order to initialize some of their state. - // This needs to be done only once, and this flag tracks whether that has happened. - static std::atomic_flag externalClientsInitialized; }; // An implementation of IClientApi that can choose between multiple different client implementations either provided From 9aa688aa82491e66a4c43b44733f29be5ff998ca Mon Sep 17 00:00:00 2001 From: Tao Lin Date: Thu, 22 Jul 2021 14:14:52 -0700 Subject: [PATCH 079/225] Fix broken image link --- documentation/sphinx/source/ha-write-path.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/sphinx/source/ha-write-path.rst b/documentation/sphinx/source/ha-write-path.rst index ccd18c01ea..41e3048d2d 100644 --- a/documentation/sphinx/source/ha-write-path.rst +++ b/documentation/sphinx/source/ha-write-path.rst @@ -64,7 +64,7 @@ To simplify the description, we ignore the batching mechanisms happening in each Figure 1 illustrates how a mutation is routed inside FDB. The solid lines are asynchronous pull operations, while the dotted lines are synchronous push operations. -.. image:: /images/FDB_ha_write_path.png +.. image:: images/FDB_ha_write_path.png At Client --------- From e0eb7170bae6d0e5ec540169075981237887a90e Mon Sep 17 00:00:00 2001 From: Fuheng Zhao Date: Thu, 22 Jul 2021 17:13:11 -0700 Subject: [PATCH 080/225] increment the version --- fdbserver/VersionedBTree.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index ecd6540ffb..5c50203284 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -4387,7 +4387,7 @@ public: #pragma pack(push, 1) struct MetaKey { - static constexpr int FORMAT_VERSION = 11; + static constexpr int FORMAT_VERSION = 12; // This serves as the format version for the entire tree, individual pages will not be versioned uint16_t formatVersion; uint8_t height; From 9496e12861b898415cec00a7d79a5cd1ec0d070b Mon Sep 17 00:00:00 2001 From: Clement Pang Date: Fri, 23 Jul 2021 12:03:17 +0800 Subject: [PATCH 081/225] Make orEquals() public. Addresses the easy issue for https://github.com/apple/foundationdb/issues/5190 --- bindings/java/src/main/com/apple/foundationdb/KeySelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/java/src/main/com/apple/foundationdb/KeySelector.java b/bindings/java/src/main/com/apple/foundationdb/KeySelector.java index 789128ce6a..9c66aa0830 100644 --- a/bindings/java/src/main/com/apple/foundationdb/KeySelector.java +++ b/bindings/java/src/main/com/apple/foundationdb/KeySelector.java @@ -167,7 +167,7 @@ public class KeySelector { /** * Returns the {@code or-equal} parameter of this {@code KeySelector}. For internal use. */ - boolean orEqual() { + public boolean orEqual() { return orEqual; } From c405bb5cd04471e6ab7eed6e71a3be63e4727e23 Mon Sep 17 00:00:00 2001 From: Mohamed Oulmahdi Date: Fri, 23 Jul 2021 12:03:25 +0200 Subject: [PATCH 082/225] Fix flow build issue on Windows --- flow/IThreadPoolTest.actor.cpp | 6 +++--- flow/flat_buffers.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/flow/IThreadPoolTest.actor.cpp b/flow/IThreadPoolTest.actor.cpp index 03bce4782f..01448fd3ea 100644 --- a/flow/IThreadPoolTest.actor.cpp +++ b/flow/IThreadPoolTest.actor.cpp @@ -1,3 +1,6 @@ +// Thread naming only works on Linux. +#if defined(__linux__) + #include "flow/IThreadPool.h" #include @@ -6,9 +9,6 @@ #include "flow/UnitTest.h" #include "flow/actorcompiler.h" // has to be last include -// Thread naming only works on Linux. -#if defined(__linux__) - void forceLinkIThreadPoolTests() {} struct ThreadNameReceiver : IThreadPoolReceiver { diff --git a/flow/flat_buffers.h b/flow/flat_buffers.h index 4fe5fb524e..d7cd7be270 100644 --- a/flow/flat_buffers.h +++ b/flow/flat_buffers.h @@ -21,6 +21,7 @@ #pragma once #include +#include #include #include #include From 052e32ae185b84793a6b4040d6fe5ef88292020a Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Fri, 23 Jul 2021 15:58:29 +0000 Subject: [PATCH 083/225] Update comment about failure to update version monitor DB --- fdbclient/MultiVersionTransaction.actor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index 277195dbfa..07444d0584 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -1188,8 +1188,8 @@ void MultiVersionDatabase::DatabaseState::updateDatabase(Reference ne try { versionMonitorDb = MultiVersionApi::api->getLocalClient()->api->createDatabase(clusterFilePath.c_str()); } catch (Error& e) { - // We can't create a database to monitor the cluster version. This means we will continue using the - // previous one, and that could result in us having extra connections + // We can't create a new database to monitor the cluster version. This means we will continue using the + // previous one, which should hopefully continue to work. TraceEvent(SevWarnAlways, "FailedToCreateDatabaseForVersionMonitoring") .detail("ClusterFilePath", clusterFilePath) .error(e); @@ -1201,8 +1201,8 @@ void MultiVersionDatabase::DatabaseState::updateDatabase(Reference ne try { versionMonitorDb = MultiVersionApi::api->getLocalClient()->api->createDatabase(clusterFilePath.c_str()); } catch (Error& e) { - // We can't create a database to monitor the cluster version. This means we will continue using the - // previous one, and that could result in us having extra connections + // We can't create a new database to monitor the cluster version. This means we will continue using the + // previous one, which should hopefully continue to work. TraceEvent(SevWarnAlways, "FailedToCreateDatabaseForVersionMonitoring") .detail("ClusterFilePath", clusterFilePath) .error(e); From 8fe3e45fc6732f39fa3c5e69d2e7acd8fdbb7538 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Thu, 22 Jul 2021 23:09:01 -0700 Subject: [PATCH 084/225] Enable more clang warnings --- cmake/ConfigureCompiler.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index a1c231ec06..6f6d20bf7b 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -285,7 +285,7 @@ else() -Wpessimizing-move -Woverloaded-virtual -Wshift-sign-overflow - # Here's the current set of warnings we need to explicitly disable to compile warning-free with clang 10 + # Here's the current set of warnings we need to explicitly disable to compile warning-free with clang 11 -Wno-comment -Wno-dangling-else -Wno-delete-non-virtual-dtor @@ -297,13 +297,11 @@ else() -Wno-sign-compare -Wno-tautological-pointer-compare -Wno-undefined-var-template - -Wno-tautological-pointer-compare -Wno-unknown-pragmas -Wno-unknown-warning-option -Wno-unused-function -Wno-unused-local-typedef -Wno-unused-parameter - -Wno-self-assign ) if (USE_CCACHE) add_compile_options( From 0e9dabcabb14b3f5d1483595a39b89721e5c0072 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Fri, 23 Jul 2021 10:20:50 -0700 Subject: [PATCH 085/225] Remove mutex that was only needed for a minor optimization. --- fdbclient/MultiVersionTransaction.actor.cpp | 36 ++++++++++----------- fdbclient/MultiVersionTransaction.h | 2 -- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index 07444d0584..eedacf80aa 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -896,25 +896,25 @@ MultiVersionDatabase::MultiVersionDatabase(MultiVersionApi* api, api->runOnExternalClients(threadIdx, [this](Reference client) { dbState->addClient(client); }); api->runOnExternalClientsAllThreads([&clusterFilePath](Reference client) { - // This creates a database to initialize some client state on the external library - // We only do this on 6.2+ clients to avoid some bugs associated with older versions - // This deletes the new database immediately to discard its connections + // This creates a database to initialize some client state on the external library. + // We only do this on 6.2+ clients to avoid some bugs associated with older versions. + // This deletes the new database immediately to discard its connections. + // + // Simultaneous attempts to create a database could result in us running this initialization + // code in multiple threads simultaneously. It is necessary that each attempt have a chance + // to run this initialization in case the other fails, and it's safe to run them in parallel. if (client->protocolVersion.hasCloseUnusedConnection() && !client->initialized) { - MutexHolder holder(client->initializationMutex); - - if (!client->initialized) { - try { - Reference newDb = client->api->createDatabase(clusterFilePath.c_str()); - client->initialized = true; - } catch (Error& e) { - // This connection is not initialized. It is still possible to connect with it, - // but we may not see trace logs from this client until a successful connection - // is established. - TraceEvent(SevWarnAlways, "FailedToInitializeExternalClient") - .detail("LibraryPath", client->libPath) - .detail("ClusterFilePath", clusterFilePath) - .error(e); - } + try { + Reference newDb = client->api->createDatabase(clusterFilePath.c_str()); + client->initialized = true; + } catch (Error& e) { + // This connection is not initialized. It is still possible to connect with it, + // but we may not see trace logs from this client until a successful connection + // is established. + TraceEvent(SevWarnAlways, "FailedToInitializeExternalClient") + .detail("LibraryPath", client->libPath) + .detail("ClusterFilePath", clusterFilePath) + .error(e); } } }); diff --git a/fdbclient/MultiVersionTransaction.h b/fdbclient/MultiVersionTransaction.h index 0896d676a8..274df7dd84 100644 --- a/fdbclient/MultiVersionTransaction.h +++ b/fdbclient/MultiVersionTransaction.h @@ -420,8 +420,6 @@ struct ClientInfo : ClientDesc, ThreadSafeReferenceCounted { std::atomic_bool initialized; std::vector> threadCompletionHooks; - Mutex initializationMutex; - ClientInfo() : ClientDesc(std::string(), false), protocolVersion(0), api(nullptr), failed(true), initialized(false) {} ClientInfo(IClientApi* api) From a328617b3f5fd2d572471d381dc43e121847ac4f Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Fri, 23 Jul 2021 14:17:08 -0700 Subject: [PATCH 086/225] Fix release note version to account for two undocumented versions --- documentation/sphinx/source/release-notes/release-notes-630.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/sphinx/source/release-notes/release-notes-630.rst b/documentation/sphinx/source/release-notes/release-notes-630.rst index fbc17d3053..4f51bc273f 100644 --- a/documentation/sphinx/source/release-notes/release-notes-630.rst +++ b/documentation/sphinx/source/release-notes/release-notes-630.rst @@ -2,7 +2,7 @@ Release Notes ############# -6.3.16 +6.3.18 ====== * The multi-version client API would not propagate errors that occurred when creating databases on external clients. This could result in a invalid memory accesses. `(PR #5221) `_ * Fixed a race between the multi-version client connecting to a cluster and destroying the database that could cause an assertion failure. `(PR #5221) `_ From e04646e267279257aa480a0c7cc31e17c49d4880 Mon Sep 17 00:00:00 2001 From: Sajjad Rahnama Date: Fri, 23 Jul 2021 16:28:20 -0700 Subject: [PATCH 087/225] Fault Injection Active/Deactivation --- fdbrpc/sim2.actor.cpp | 3 ++- fdbserver/SimulatedCluster.actor.cpp | 3 ++- fdbserver/fdbserver.actor.cpp | 21 +++++++++++++++++-- .../workloads/MachineAttrition.actor.cpp | 5 +++-- flow/FaultInjection.cpp | 7 ++++++- flow/FaultInjection.h | 2 ++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index fe7ded16e5..33da8e7ed6 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -46,10 +46,11 @@ #include "fdbrpc/Replication.h" #include "fdbrpc/ReplicationUtils.h" #include "fdbrpc/AsyncFileWriteChecker.h" +#include "flow/FaultInjection.h" #include "flow/actorcompiler.h" // This must be the last #include. bool simulator_should_inject_fault(const char* context, const char* file, int line, int error_code) { - if (!g_network->isSimulated()) + if (!g_network->isSimulated() || !faultInjectionActivated) return false; auto p = g_simulator.getCurrentProcess(); diff --git a/fdbserver/SimulatedCluster.actor.cpp b/fdbserver/SimulatedCluster.actor.cpp index 5f656f13f1..56264fa61c 100644 --- a/fdbserver/SimulatedCluster.actor.cpp +++ b/fdbserver/SimulatedCluster.actor.cpp @@ -41,6 +41,7 @@ #include "flow/ProtocolVersion.h" #include "flow/network.h" #include "flow/TypeTraits.h" +#include "flow/FaultInjection.h" #include "flow/actorcompiler.h" // This must be the last #include. #undef max @@ -1651,7 +1652,7 @@ void SimulationConfig::setTss(const TestConfig& testConfig) { std::string confStr = format("tss_count:=%d tss_storage_engine:=%d", tssCount, db.storageServerStoreType); set_config(confStr); double tssRandom = deterministicRandom()->random01(); - if (tssRandom > 0.5) { + if (tssRandom > 0.5 || !faultInjectionActivated) { // normal tss mode g_simulator.tssMode = ISimulator::TSSMode::EnabledNormal; } else if (tssRandom < 0.25 && !testConfig.isFirstTestInRestart) { diff --git a/fdbserver/fdbserver.actor.cpp b/fdbserver/fdbserver.actor.cpp index a9d6697bc8..bc4b8a951e 100644 --- a/fdbserver/fdbserver.actor.cpp +++ b/fdbserver/fdbserver.actor.cpp @@ -68,6 +68,7 @@ #include "flow/TLSConfig.actor.h" #include "flow/Tracing.h" #include "flow/UnitTest.h" +#include "flow/FaultInjection.h" #if defined(__linux__) || defined(__FreeBSD__) #include @@ -92,7 +93,7 @@ enum { OPT_DCID, OPT_MACHINE_CLASS, OPT_BUGGIFY, OPT_VERSION, OPT_BUILD_FLAGS, OPT_CRASHONERROR, OPT_HELP, OPT_NETWORKIMPL, OPT_NOBUFSTDOUT, OPT_BUFSTDOUTERR, OPT_TRACECLOCK, OPT_NUMTESTERS, OPT_DEVHELP, OPT_ROLLSIZE, OPT_MAXLOGS, OPT_MAXLOGSSIZE, OPT_KNOB, OPT_UNITTESTPARAM, OPT_TESTSERVERS, OPT_TEST_ON_SERVERS, OPT_METRICSCONNFILE, OPT_METRICSPREFIX, OPT_LOGGROUP, OPT_LOCALITY, OPT_IO_TRUST_SECONDS, OPT_IO_TRUST_WARN_ONLY, OPT_FILESYSTEM, OPT_PROFILER_RSS_SIZE, OPT_KVFILE, - OPT_TRACE_FORMAT, OPT_WHITELIST_BINPATH, OPT_BLOB_CREDENTIAL_FILE, OPT_CONFIG_PATH, OPT_USE_TEST_CONFIG_DB, + OPT_TRACE_FORMAT, OPT_WHITELIST_BINPATH, OPT_BLOB_CREDENTIAL_FILE, OPT_CONFIG_PATH, OPT_USE_TEST_CONFIG_DB, OPT_FAULT_INJECTION, }; CSimpleOpt::SOption g_rgOptions[] = { @@ -177,6 +178,8 @@ CSimpleOpt::SOption g_rgOptions[] = { { OPT_BLOB_CREDENTIAL_FILE, "--blob_credential_file", SO_REQ_SEP }, { OPT_CONFIG_PATH, "--config_path", SO_REQ_SEP }, { OPT_USE_TEST_CONFIG_DB, "--use_test_config_db", SO_NONE }, + { OPT_FAULT_INJECTION, "-fi", SO_REQ_SEP }, + { OPT_FAULT_INJECTION, "--fault_injection", SO_REQ_SEP }, #ifndef TLS_DISABLED TLS_OPTION_FLAGS @@ -646,6 +649,7 @@ static void printUsage(const char* name, bool devhelp) { "--kvfile FILE", "Input file (SQLite database file) for use by the 'kvfilegeneratesums' and 'kvfileintegritycheck' roles."); printOptionUsage("-b [on,off], --buggify [on,off]", " Sets Buggify system state, defaults to `off'."); + printOptionUsage("-f [on,off], --fault_injection [on,off]", " Sets fault injection, defaults to `on'."); printOptionUsage("--crash", "Crash on serious errors instead of continuing."); printOptionUsage("-N NETWORKIMPL, --network NETWORKIMPL", " Select network implementation, `net2' (default)," @@ -960,7 +964,7 @@ struct CLIOptions { 8LL << 30; // Nice to maintain the same default value for memLimit and SERVER_KNOBS->SERVER_MEM_LIMIT and // SERVER_KNOBS->COMMIT_BATCHES_MEM_BYTES_HARD_LIMIT uint64_t storageMemLimit = 1LL << 30; - bool buggifyEnabled = false, restarting = false; + bool buggifyEnabled = false, faultInjectionEnabled = true, restarting = false; Optional> zoneId; Optional> dcId; ProcessClass processClass = ProcessClass(ProcessClass::UnsetClass, ProcessClass::CommandLineSource); @@ -1382,6 +1386,17 @@ private: flushAndExit(FDB_EXIT_ERROR); } break; + case OPT_FAULT_INJECTION: + if (!strcmp(args.OptionArg(), "on")) + faultInjectionEnabled = true; + else if (!strcmp(args.OptionArg(), "off")) + faultInjectionEnabled = false; + else { + fprintf(stderr, "ERROR: Unknown fault injection state `%s'\n", args.OptionArg()); + printHelpTeaser(argv[0]); + flushAndExit(FDB_EXIT_ERROR); + } + break; case OPT_CRASHONERROR: g_crashOnError = true; break; @@ -1638,6 +1653,7 @@ int main(int argc, char* argv[]) { setThreadLocalDeterministicRandomSeed(opts.randomSeed); enableBuggify(opts.buggifyEnabled, BuggifyType::General); + enableFaultInjection(opts.faultInjectionEnabled); IKnobCollection::setGlobalKnobCollection(IKnobCollection::Type::SERVER, Randomize::True, @@ -1795,6 +1811,7 @@ int main(int argc, char* argv[]) { .detail("CommandLine", opts.commandLine) .setMaxFieldLength(0) .detail("BuggifyEnabled", opts.buggifyEnabled) + .detail("FaultInjectionEnabled", opts.faultInjectionEnabled) .detail("MemoryLimit", opts.memLimit) .trackLatest("ProgramStart"); diff --git a/fdbserver/workloads/MachineAttrition.actor.cpp b/fdbserver/workloads/MachineAttrition.actor.cpp index 75c2c248a9..e46c249c6d 100644 --- a/fdbserver/workloads/MachineAttrition.actor.cpp +++ b/fdbserver/workloads/MachineAttrition.actor.cpp @@ -25,6 +25,7 @@ #include "fdbserver/workloads/workloads.actor.h" #include "fdbrpc/simulator.h" #include "fdbclient/ManagementAPI.actor.h" +#include "flow/FaultInjection.h" #include "flow/actorcompiler.h" // This must be the last #include. static std::set const& normalAttritionErrors() { @@ -78,8 +79,8 @@ struct MachineAttritionWorkload : TestWorkload { std::vector machines; MachineAttritionWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) { - enabled = - !clientId && g_network->isSimulated(); // only do this on the "first" client, and only when in simulation + // only do this on the "first" client, and only when in simulation and only when fault injection is enabled + enabled = !clientId && g_network->isSimulated() && faultInjectionActivated; machinesToKill = getOption(options, LiteralStringRef("machinesToKill"), 2); machinesToLeave = getOption(options, LiteralStringRef("machinesToLeave"), 1); workersToKill = getOption(options, LiteralStringRef("workersToKill"), 2); diff --git a/flow/FaultInjection.cpp b/flow/FaultInjection.cpp index 861de1307a..5ba346efc5 100644 --- a/flow/FaultInjection.cpp +++ b/flow/FaultInjection.cpp @@ -20,4 +20,9 @@ #include "flow/FaultInjection.h" -bool (*should_inject_fault)(const char* context, const char* file, int line, int error_code) = 0; \ No newline at end of file +bool (*should_inject_fault)(const char* context, const char* file, int line, int error_code) = 0; +bool faultInjectionActivated = true; + +void enableFaultInjection(bool enabled) { + faultInjectionActivated = enabled; +} diff --git a/flow/FaultInjection.h b/flow/FaultInjection.h index e1f2aa0bb6..fa8f521076 100644 --- a/flow/FaultInjection.h +++ b/flow/FaultInjection.h @@ -32,6 +32,8 @@ #define SHOULD_INJECT_FAULT(context) (should_inject_fault && should_inject_fault(context, __FILE__, __LINE__, 0)) extern bool (*should_inject_fault)(const char* context, const char* file, int line, int error_code); +extern bool faultInjectionActivated; +extern void enableFaultInjection(bool enabled); // Enable fault injection called from fdbserver actor main function #else #define INJECT_FAULT(error_type, context) #endif From 8d4569b63cce278e3a3caa2daa6bc697696a3210 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Fri, 23 Jul 2021 17:26:37 -0700 Subject: [PATCH 088/225] Enable dangling-else warning for clang --- cmake/ConfigureCompiler.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index a1c231ec06..3f483d3306 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -285,9 +285,8 @@ else() -Wpessimizing-move -Woverloaded-virtual -Wshift-sign-overflow - # Here's the current set of warnings we need to explicitly disable to compile warning-free with clang 10 + # Here's the current set of warnings we need to explicitly disable to compile warning-free with clang 11 -Wno-comment - -Wno-dangling-else -Wno-delete-non-virtual-dtor -Wno-format -Wno-mismatched-tags From 13fe89ff06453e614944ff0f51b3950c28e0ba92 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Fri, 23 Jul 2021 17:32:01 -0700 Subject: [PATCH 089/225] Enable self-assign warning for clang --- cmake/ConfigureCompiler.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index 3f483d3306..ed18a8d4ea 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -302,7 +302,6 @@ else() -Wno-unused-function -Wno-unused-local-typedef -Wno-unused-parameter - -Wno-self-assign ) if (USE_CCACHE) add_compile_options( From b9a22a61efa38782ccd5b6141243adc5ab992d22 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Thu, 22 Jul 2021 22:48:27 -0700 Subject: [PATCH 090/225] Fix many -Wreorder-ctor warnings --- bindings/flow/DirectoryLayer.actor.cpp | 4 +-- bindings/flow/FDBLoanerTypes.h | 4 +-- fdbbackup/FileDecoder.actor.cpp | 2 +- fdbclient/BackupAgent.actor.h | 4 +-- fdbclient/CommitProxyInterface.h | 4 +-- fdbclient/DatabaseContext.h | 2 +- fdbclient/FDBTypes.h | 4 +-- fdbclient/MonitorLeader.h | 2 +- fdbclient/NativeAPI.actor.h | 8 ++--- fdbclient/RYWIterator.h | 2 +- fdbclient/SnapshotCache.h | 2 +- fdbclient/VersionedMap.h | 4 +-- fdbclient/WriteMap.h | 6 ++-- fdbmonitor/fdbmonitor.cpp | 2 +- fdbrpc/AsyncFileCached.actor.h | 6 ++-- fdbrpc/AsyncFileEIO.actor.h | 2 +- fdbrpc/AsyncFileEncrypted.actor.cpp | 2 +- fdbrpc/AsyncFileKAIO.actor.h | 6 ++-- fdbrpc/AsyncFileNonDurable.actor.h | 5 ++- fdbrpc/AsyncFileReadAhead.actor.h | 2 +- fdbrpc/FlowTests.actor.cpp | 2 +- fdbrpc/LoadBalance.actor.h | 2 +- fdbrpc/PerfMetric.h | 6 ++-- fdbrpc/QueueModel.h | 2 +- fdbrpc/Replication.h | 7 ++-- fdbrpc/Stats.actor.cpp | 4 +-- fdbrpc/Stats.h | 2 +- fdbrpc/simulator.h | 14 ++++---- fdbserver/CommitProxyServer.actor.cpp | 4 +-- fdbserver/DeltaTree.h | 20 +++++------ fdbserver/KeyValueStoreMemory.actor.cpp | 8 ++--- fdbserver/LogRouter.actor.cpp | 18 +++++----- fdbserver/LogSystem.h | 2 +- fdbserver/LogSystemDiskQueueAdapter.h | 6 ++-- fdbserver/LogSystemPeekCursor.actor.cpp | 21 ++++++------ fdbserver/MasterInterface.h | 2 +- fdbserver/OldTLogServer_6_2.actor.cpp | 10 +++--- fdbserver/OnDemandStore.actor.cpp | 2 +- fdbserver/ProxyCommitData.actor.h | 29 ++++++++-------- fdbserver/RestoreApplier.actor.h | 11 +++---- fdbserver/RestoreLoader.actor.h | 2 +- fdbserver/SkipList.cpp | 2 +- fdbserver/TLogInterface.h | 10 +++--- fdbserver/TLogServer.actor.cpp | 33 +++++++++---------- fdbserver/VFSAsync.cpp | 2 +- fdbserver/VersionedBTree.actor.cpp | 16 ++++----- fdbserver/WorkerInterface.actor.h | 6 ++-- fdbserver/masterserver.actor.cpp | 18 +++++----- fdbserver/storageserver.actor.cpp | 6 ++-- fdbserver/tester.actor.cpp | 4 +-- fdbserver/workloads/ApiWorkload.h | 2 +- fdbserver/workloads/Cycle.actor.cpp | 4 +-- fdbserver/workloads/DDBalance.actor.cpp | 2 +- fdbserver/workloads/FileSystem.actor.cpp | 2 +- fdbserver/workloads/Increment.actor.cpp | 4 +-- fdbserver/workloads/IndexScan.actor.cpp | 2 +- fdbserver/workloads/KVStoreTest.actor.cpp | 4 +-- fdbserver/workloads/Mako.actor.cpp | 4 +-- fdbserver/workloads/QueuePush.actor.cpp | 2 +- fdbserver/workloads/ReadWrite.actor.cpp | 12 +++---- .../workloads/ReportConflictingKeys.actor.cpp | 2 +- fdbserver/workloads/Storefront.actor.cpp | 4 +-- fdbserver/workloads/TPCC.actor.cpp | 30 ++++++++--------- fdbserver/workloads/ThreadSafety.actor.cpp | 2 +- fdbserver/workloads/Throughput.actor.cpp | 8 ++--- fdbserver/workloads/WriteBandwidth.actor.cpp | 4 +-- .../workloads/WriteTagThrottling.actor.cpp | 4 +-- fdbserver/workloads/workloads.actor.h | 2 +- flow/Deque.h | 2 +- flow/FileTraceLogWriter.cpp | 2 +- flow/Histogram.h | 3 +- flow/IndexedSet.h | 2 +- flow/Platform.actor.cpp | 8 ++--- flow/TDMetric.actor.h | 6 ++-- flow/Trace.h | 2 +- flow/flat_buffers.h | 4 +-- flow/flow.h | 4 +-- flow/genericactors.actor.h | 6 ++-- flow/serialize.h | 2 +- 79 files changed, 237 insertions(+), 242 deletions(-) diff --git a/bindings/flow/DirectoryLayer.actor.cpp b/bindings/flow/DirectoryLayer.actor.cpp index 3ef201456f..750ba85daf 100644 --- a/bindings/flow/DirectoryLayer.actor.cpp +++ b/bindings/flow/DirectoryLayer.actor.cpp @@ -36,8 +36,8 @@ const Subspace DirectoryLayer::DEFAULT_CONTENT_SUBSPACE = Subspace(); const StringRef DirectoryLayer::PARTITION_LAYER = LiteralStringRef("partition"); DirectoryLayer::DirectoryLayer(Subspace nodeSubspace, Subspace contentSubspace, bool allowManualPrefixes) - : nodeSubspace(nodeSubspace), contentSubspace(contentSubspace), allowManualPrefixes(allowManualPrefixes), - rootNode(nodeSubspace.get(nodeSubspace.key())), allocator(rootNode.get(HIGH_CONTENTION_KEY)) {} + : rootNode(nodeSubspace.get(nodeSubspace.key())), nodeSubspace(nodeSubspace), contentSubspace(contentSubspace), + allocator(rootNode.get(HIGH_CONTENTION_KEY)), allowManualPrefixes(allowManualPrefixes) {} Subspace DirectoryLayer::nodeWithPrefix(StringRef const& prefix) const { return nodeSubspace.get(prefix); diff --git a/bindings/flow/FDBLoanerTypes.h b/bindings/flow/FDBLoanerTypes.h index 97e4394298..d33a72203c 100644 --- a/bindings/flow/FDBLoanerTypes.h +++ b/bindings/flow/FDBLoanerTypes.h @@ -167,9 +167,9 @@ struct RangeResultRef : VectorRef { RangeResultRef() : more(false), readToBegin(false), readThroughEnd(false) {} RangeResultRef(Arena& p, const RangeResultRef& toCopy) - : more(toCopy.more), readToBegin(toCopy.readToBegin), readThroughEnd(toCopy.readThroughEnd), + : VectorRef(p, toCopy), more(toCopy.more), readThrough(toCopy.readThrough.present() ? KeyRef(p, toCopy.readThrough.get()) : Optional()), - VectorRef(p, toCopy) {} + readToBegin(toCopy.readToBegin), readThroughEnd(toCopy.readThroughEnd) {} RangeResultRef(const VectorRef& value, bool more, Optional readThrough = Optional()) : VectorRef(value), more(more), readThrough(readThrough), readToBegin(false), readThroughEnd(false) { } diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index b8e4bc138f..107d765d3c 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -298,7 +298,7 @@ class DecodeProgress { public: DecodeProgress() = default; template - DecodeProgress(const LogFile& file, U&& values) : file(file), keyValues(std::forward(values)) {} + DecodeProgress(const LogFile& file, U&& values) : keyValues(std::forward(values)), file(file) {} // If there are no more mutations to pull from the file. // However, we could have unfinished version in the buffer when EOF is true, diff --git a/fdbclient/BackupAgent.actor.h b/fdbclient/BackupAgent.actor.h index e23360b531..856e7a62f5 100644 --- a/fdbclient/BackupAgent.actor.h +++ b/fdbclient/BackupAgent.actor.h @@ -368,8 +368,8 @@ public: DatabaseBackupAgent(DatabaseBackupAgent&& r) noexcept : subspace(std::move(r.subspace)), states(std::move(r.states)), config(std::move(r.config)), errors(std::move(r.errors)), ranges(std::move(r.ranges)), tagNames(std::move(r.tagNames)), - taskBucket(std::move(r.taskBucket)), futureBucket(std::move(r.futureBucket)), - sourceStates(std::move(r.sourceStates)), sourceTagNames(std::move(r.sourceTagNames)) {} + sourceStates(std::move(r.sourceStates)), sourceTagNames(std::move(r.sourceTagNames)), + taskBucket(std::move(r.taskBucket)), futureBucket(std::move(r.futureBucket)) {} void operator=(DatabaseBackupAgent&& r) noexcept { subspace = std::move(r.subspace); diff --git a/fdbclient/CommitProxyInterface.h b/fdbclient/CommitProxyInterface.h index 9ec8b908b2..a22dd0925a 100644 --- a/fdbclient/CommitProxyInterface.h +++ b/fdbclient/CommitProxyInterface.h @@ -244,7 +244,7 @@ struct GetReadVersionRequest : TimedRequest { uint32_t flags = 0, TransactionTagMap tags = TransactionTagMap(), Optional debugID = Optional()) - : spanContext(spanContext), transactionCount(transactionCount), priority(priority), flags(flags), tags(tags), + : spanContext(spanContext), transactionCount(transactionCount), flags(flags), priority(priority), tags(tags), debugID(debugID) { flags = flags & ~FLAG_PRIORITY_MASK; switch (priority) { @@ -313,7 +313,7 @@ struct GetKeyServerLocationsRequest { int limit, bool reverse, Arena const& arena) - : spanContext(spanContext), begin(begin), end(end), limit(limit), reverse(reverse), arena(arena) {} + : arena(arena), spanContext(spanContext), begin(begin), end(end), limit(limit), reverse(reverse) {} template void serialize(Ar& ar) { diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index 751e523af5..8d2cbf21d8 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -51,7 +51,7 @@ public: private: DatabaseContext* cx; StorageServerInfo(DatabaseContext* cx, StorageServerInterface const& interf, LocalityData const& locality) - : cx(cx), ReferencedInterface(interf, locality) {} + : ReferencedInterface(interf, locality), cx(cx) {} }; struct LocationInfo : MultiInterface>, FastAllocated { diff --git a/fdbclient/FDBTypes.h b/fdbclient/FDBTypes.h index 25e31d1134..ee67813e02 100644 --- a/fdbclient/FDBTypes.h +++ b/fdbclient/FDBTypes.h @@ -655,9 +655,9 @@ struct RangeResultRef : VectorRef { RangeResultRef() : more(false), readToBegin(false), readThroughEnd(false) {} RangeResultRef(Arena& p, const RangeResultRef& toCopy) - : more(toCopy.more), readToBegin(toCopy.readToBegin), readThroughEnd(toCopy.readThroughEnd), + : VectorRef(p, toCopy), more(toCopy.more), readThrough(toCopy.readThrough.present() ? KeyRef(p, toCopy.readThrough.get()) : Optional()), - VectorRef(p, toCopy) {} + readToBegin(toCopy.readToBegin), readThroughEnd(toCopy.readThroughEnd) {} RangeResultRef(const VectorRef& value, bool more, Optional readThrough = Optional()) : VectorRef(value), more(more), readThrough(readThrough), readToBegin(false), readThroughEnd(false) { } diff --git a/fdbclient/MonitorLeader.h b/fdbclient/MonitorLeader.h index 22ef1a5300..f57e1ccb4f 100644 --- a/fdbclient/MonitorLeader.h +++ b/fdbclient/MonitorLeader.h @@ -58,7 +58,7 @@ struct MonitorLeaderInfo { MonitorLeaderInfo() : hasConnected(false) {} explicit MonitorLeaderInfo(Reference intermediateConnFile) - : intermediateConnFile(intermediateConnFile), hasConnected(false) {} + : hasConnected(false), intermediateConnFile(intermediateConnFile) {} }; // Monitors the given coordination group's leader election process and provides a best current guess diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h index 6357bb7d80..e671bac8c1 100644 --- a/fdbclient/NativeAPI.actor.h +++ b/fdbclient/NativeAPI.actor.h @@ -189,7 +189,7 @@ struct TransactionLogInfo : public ReferenceCounted, NonCopy TransactionLogInfo() : logLocation(DONT_LOG), maxFieldLength(0) {} TransactionLogInfo(LoggingLocation location) : logLocation(location), maxFieldLength(0) {} TransactionLogInfo(std::string id, LoggingLocation location) - : logLocation(location), identifier(id), maxFieldLength(0) {} + : logLocation(location), maxFieldLength(0), identifier(id) {} void setIdentifier(std::string id) { identifier = id; } void logTo(LoggingLocation loc) { logLocation = logLocation | loc; } @@ -231,10 +231,10 @@ struct Watch : public ReferenceCounted, NonCopyable { Promise onSetWatchTrigger; Future watchFuture; - Watch() : watchFuture(Never()), valuePresent(false), setPresent(false) {} - Watch(Key key) : key(key), watchFuture(Never()), valuePresent(false), setPresent(false) {} + Watch() : valuePresent(false), setPresent(false), watchFuture(Never()) {} + Watch(Key key) : key(key), valuePresent(false), setPresent(false), watchFuture(Never()) {} Watch(Key key, Optional val) - : key(key), value(val), watchFuture(Never()), valuePresent(true), setPresent(false) {} + : key(key), value(val), valuePresent(true), setPresent(false), watchFuture(Never()) {} void setWatch(Future watchFuture); }; diff --git a/fdbclient/RYWIterator.h b/fdbclient/RYWIterator.h index 8bc9091fe2..90ab1884e0 100644 --- a/fdbclient/RYWIterator.h +++ b/fdbclient/RYWIterator.h @@ -28,7 +28,7 @@ class RYWIterator { public: RYWIterator(SnapshotCache* snapshotCache, WriteMap* writeMap) - : cache(snapshotCache), writes(writeMap), begin_key_cmp(0), end_key_cmp(0), bypassUnreadable(false) {} + : begin_key_cmp(0), end_key_cmp(0), cache(snapshotCache), writes(writeMap), bypassUnreadable(false) {} enum SEGMENT_TYPE { UNKNOWN_RANGE, EMPTY_RANGE, KV }; static const SEGMENT_TYPE typeMap[12]; diff --git a/fdbclient/SnapshotCache.h b/fdbclient/SnapshotCache.h index eabd289aee..f4e110edc4 100644 --- a/fdbclient/SnapshotCache.h +++ b/fdbclient/SnapshotCache.h @@ -311,7 +311,7 @@ public: entries.insert(Entry(allKeys.end, afterAllKeys, VectorRef()), NoMetric(), true); } // Visual Studio refuses to generate these, apparently despite the standard - SnapshotCache(SnapshotCache&& r) noexcept : entries(std::move(r.entries)), arena(r.arena) {} + SnapshotCache(SnapshotCache&& r) noexcept : arena(r.arena), entries(std::move(r.entries)) {} SnapshotCache& operator=(SnapshotCache&& r) noexcept { entries = std::move(r.entries); arena = r.arena; diff --git a/fdbclient/VersionedMap.h b/fdbclient/VersionedMap.h index b9da8621a0..32371689a2 100644 --- a/fdbclient/VersionedMap.h +++ b/fdbclient/VersionedMap.h @@ -58,11 +58,11 @@ struct PTree : public ReferenceCounted>, FastAllocated>, NonCo Reference left(Version at) const { return child(false, at); } Reference right(Version at) const { return child(true, at); } - PTree(const T& data, Version ver) : data(data), lastUpdateVersion(ver), updated(false) { + PTree(const T& data, Version ver) : lastUpdateVersion(ver), updated(false), data(data) { priority = deterministicRandom()->randomUInt32(); } PTree(uint32_t pri, T const& data, Reference const& left, Reference const& right, Version ver) - : priority(pri), data(data), lastUpdateVersion(ver), updated(false) { + : priority(pri), lastUpdateVersion(ver), updated(false), data(data) { pointer[0] = left; pointer[1] = right; } diff --git a/fdbclient/WriteMap.h b/fdbclient/WriteMap.h index 0471c16270..129509b1b4 100644 --- a/fdbclient/WriteMap.h +++ b/fdbclient/WriteMap.h @@ -168,7 +168,7 @@ private: typedef Reference Tree; public: - explicit WriteMap(Arena* arena) : arena(arena), ver(-1), scratch_iterator(this), writeMapEmpty(true) { + explicit WriteMap(Arena* arena) : arena(arena), writeMapEmpty(true), ver(-1), scratch_iterator(this) { PTreeImpl::insert( writes, ver, WriteMapEntry(allKeys.begin, OperationStack(), false, false, false, false, false)); PTreeImpl::insert(writes, ver, WriteMapEntry(allKeys.end, OperationStack(), false, false, false, false, false)); @@ -177,8 +177,8 @@ public: } WriteMap(WriteMap&& r) noexcept - : writeMapEmpty(r.writeMapEmpty), writes(std::move(r.writes)), ver(r.ver), - scratch_iterator(std::move(r.scratch_iterator)), arena(r.arena) {} + : arena(r.arena), writeMapEmpty(r.writeMapEmpty), writes(std::move(r.writes)), ver(r.ver), + scratch_iterator(std::move(r.scratch_iterator)) {} WriteMap& operator=(WriteMap&& r) noexcept { writeMapEmpty = r.writeMapEmpty; writes = std::move(r.writes); diff --git a/fdbmonitor/fdbmonitor.cpp b/fdbmonitor/fdbmonitor.cpp index 6d88b54af4..f624783f23 100644 --- a/fdbmonitor/fdbmonitor.cpp +++ b/fdbmonitor/fdbmonitor.cpp @@ -393,7 +393,7 @@ public: Command() : argv(nullptr) {} Command(const CSimpleIni& ini, std::string _section, ProcessID id, fdb_fd_set fds, int* maxfd) - : section(_section), argv(nullptr), fork_retry_time(-1), quiet(false), delete_envvars(nullptr), fds(fds), + : fds(fds), argv(nullptr), section(_section), fork_retry_time(-1), quiet(false), delete_envvars(nullptr), deconfigured(false), kill_on_configuration_change(true) { char _ssection[strlen(section.c_str()) + 22]; snprintf(_ssection, strlen(section.c_str()) + 22, "%s", id.c_str()); diff --git a/fdbrpc/AsyncFileCached.actor.h b/fdbrpc/AsyncFileCached.actor.h index fd6fe27524..cb082d1096 100644 --- a/fdbrpc/AsyncFileCached.actor.h +++ b/fdbrpc/AsyncFileCached.actor.h @@ -298,7 +298,7 @@ private: const std::string& filename, int64_t length, Reference pageCache) - : uncached(uncached), filename(filename), length(length), prevLength(length), pageCache(pageCache), + : filename(filename), uncached(uncached), length(length), prevLength(length), pageCache(pageCache), currentTruncate(Void()), currentTruncateSize(0), rateControl(nullptr) { if (!g_network->isSimulated()) { countFileCacheWrites.init(LiteralStringRef("AsyncFile.CountFileCacheWrites"), filename); @@ -610,8 +610,8 @@ struct AFCPage : public EvictablePage, public FastAllocated { } AFCPage(AsyncFileCached* owner, int64_t offset) - : EvictablePage(owner->pageCache), owner(owner), pageOffset(offset), dirty(false), valid(false), truncated(false), - notReading(Void()), notFlushing(Void()), zeroCopyRefCount(0), flushableIndex(-1), writeThroughCount(0) { + : EvictablePage(owner->pageCache), owner(owner), pageOffset(offset), notReading(Void()), notFlushing(Void()), + dirty(false), valid(false), truncated(false), writeThroughCount(0), flushableIndex(-1), zeroCopyRefCount(0) { pageCache->allocate(this); } diff --git a/fdbrpc/AsyncFileEIO.actor.h b/fdbrpc/AsyncFileEIO.actor.h index 44fe6448db..ea1d8d416e 100644 --- a/fdbrpc/AsyncFileEIO.actor.h +++ b/fdbrpc/AsyncFileEIO.actor.h @@ -277,7 +277,7 @@ private: mutable Int64MetricHandle countLogicalReads; AsyncFileEIO(int fd, int flags, std::string const& filename) - : fd(fd), flags(flags), filename(filename), err(new ErrorInfo) { + : fd(fd), flags(flags), err(new ErrorInfo), filename(filename) { if (!g_network->isSimulated()) { countFileLogicalWrites.init(LiteralStringRef("AsyncFile.CountFileLogicalWrites"), filename); countFileLogicalReads.init(LiteralStringRef("AsyncFile.CountFileLogicalReads"), filename); diff --git a/fdbrpc/AsyncFileEncrypted.actor.cpp b/fdbrpc/AsyncFileEncrypted.actor.cpp index 588c6e5cc3..1df9345998 100644 --- a/fdbrpc/AsyncFileEncrypted.actor.cpp +++ b/fdbrpc/AsyncFileEncrypted.actor.cpp @@ -131,7 +131,7 @@ public: }; AsyncFileEncrypted::AsyncFileEncrypted(Reference file, Mode mode) - : file(file), mode(mode), currentBlock(0), readBuffers(FLOW_KNOBS->MAX_DECRYPTED_BLOCKS) { + : file(file), mode(mode), readBuffers(FLOW_KNOBS->MAX_DECRYPTED_BLOCKS), currentBlock(0) { firstBlockIV = AsyncFileEncryptedImpl::getFirstBlockIV(file->getFilename()); if (mode == Mode::APPEND_ONLY) { encryptor = std::make_unique(StreamCipher::Key::getKey(), getIV(currentBlock)); diff --git a/fdbrpc/AsyncFileKAIO.actor.h b/fdbrpc/AsyncFileKAIO.actor.h index 5e6592e6ba..8fab78e74c 100644 --- a/fdbrpc/AsyncFileKAIO.actor.h +++ b/fdbrpc/AsyncFileKAIO.actor.h @@ -568,8 +568,8 @@ private: uint32_t opsIssued; Context() - : iocx(0), evfd(-1), outstanding(0), opsIssued(0), ioStallBegin(0), fallocateSupported(true), - fallocateZeroSupported(true), submittedRequestList(nullptr) { + : iocx(0), evfd(-1), outstanding(0), ioStallBegin(0), fallocateSupported(true), fallocateZeroSupported(true), + submittedRequestList(nullptr), opsIssued(0) { setIOTimeout(0); } @@ -619,7 +619,7 @@ private: static Context ctx; explicit AsyncFileKAIO(int fd, int flags, std::string const& filename) - : fd(fd), flags(flags), filename(filename), failed(false) { + : failed(false), fd(fd), flags(flags), filename(filename) { ASSERT(!FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO); if (!g_network->isSimulated()) { countFileLogicalWrites.init(LiteralStringRef("AsyncFile.CountFileLogicalWrites"), filename); diff --git a/fdbrpc/AsyncFileNonDurable.actor.h b/fdbrpc/AsyncFileNonDurable.actor.h index f813c1a354..f89d804670 100644 --- a/fdbrpc/AsyncFileNonDurable.actor.h +++ b/fdbrpc/AsyncFileNonDurable.actor.h @@ -190,9 +190,8 @@ private: Reference diskParameters, NetworkAddress openedAddress, bool aio) - : filename(filename), initialFilename(initialFilename), file(file), diskParameters(diskParameters), - openedAddress(openedAddress), pendingModifications(uint64_t(-1)), approximateSize(0), reponses(false), - aio(aio) { + : filename(filename), initialFilename(initialFilename), approximateSize(0), openedAddress(openedAddress), + aio(aio), file(file), diskParameters(diskParameters), pendingModifications(uint64_t(-1)), reponses(false) { // This is only designed to work in simulation ASSERT(g_network->isSimulated()); diff --git a/fdbrpc/AsyncFileReadAhead.actor.h b/fdbrpc/AsyncFileReadAhead.actor.h index 732bb53cfe..5bd951e7c4 100644 --- a/fdbrpc/AsyncFileReadAhead.actor.h +++ b/fdbrpc/AsyncFileReadAhead.actor.h @@ -199,7 +199,7 @@ public: int maxConcurrentReads, int cacheSizeBlocks) : m_f(f), m_block_size(blockSize), m_read_ahead_blocks(readAheadBlocks), - m_max_concurrent_reads(maxConcurrentReads), m_cache_block_limit(std::max(1, cacheSizeBlocks)) {} + m_cache_block_limit(std::max(1, cacheSizeBlocks)), m_max_concurrent_reads(maxConcurrentReads) {} }; #include "flow/unactorcompiler.h" diff --git a/fdbrpc/FlowTests.actor.cpp b/fdbrpc/FlowTests.actor.cpp index d3cf206c8f..b6e14812fb 100644 --- a/fdbrpc/FlowTests.actor.cpp +++ b/fdbrpc/FlowTests.actor.cpp @@ -1386,7 +1386,7 @@ TEST_CASE("/flow/DeterministicRandom/SignedOverflow") { struct Tracker { int copied; bool moved; - Tracker(int copied = 0) : moved(false), copied(copied) {} + Tracker(int copied = 0) : copied(copied), moved(false) {} Tracker(Tracker&& other) : Tracker(other.copied) { ASSERT(!other.moved); other.moved = true; diff --git a/fdbrpc/LoadBalance.actor.h b/fdbrpc/LoadBalance.actor.h index 84a04caa70..3dbd95b88c 100644 --- a/fdbrpc/LoadBalance.actor.h +++ b/fdbrpc/LoadBalance.actor.h @@ -52,7 +52,7 @@ struct ModelHolder : NonCopyable, public ReferenceCounted { double delta; uint64_t token; - ModelHolder(QueueModel* model, uint64_t token) : model(model), token(token), released(false), startTime(now()) { + ModelHolder(QueueModel* model, uint64_t token) : model(model), released(false), startTime(now()), token(token) { if (model) { delta = model->addRequest(token); } diff --git a/fdbrpc/PerfMetric.h b/fdbrpc/PerfMetric.h index 0ba6b83eb4..ebdc01d5fa 100644 --- a/fdbrpc/PerfMetric.h +++ b/fdbrpc/PerfMetric.h @@ -30,11 +30,11 @@ using std::vector; struct PerfMetric { constexpr static FileIdentifier file_identifier = 5980618; - PerfMetric() : m_name(""), m_value(0), m_averaged(false), m_format_code("%.3g") {} + PerfMetric() : m_name(""), m_format_code("%.3g"), m_value(0), m_averaged(false) {} PerfMetric(std::string name, double value, bool averaged) - : m_name(name), m_value(value), m_averaged(averaged), m_format_code("%.3g") {} + : m_name(name), m_format_code("%.3g"), m_value(value), m_averaged(averaged) {} PerfMetric(std::string name, double value, bool averaged, std::string format_code) - : m_name(name), m_value(value), m_averaged(averaged), m_format_code(format_code) {} + : m_name(name), m_format_code(format_code), m_value(value), m_averaged(averaged) {} std::string name() const { return m_name; } double value() const { return m_value; } diff --git a/fdbrpc/QueueModel.h b/fdbrpc/QueueModel.h index 84ec5c5afe..e1e59db3e7 100644 --- a/fdbrpc/QueueModel.h +++ b/fdbrpc/QueueModel.h @@ -75,7 +75,7 @@ struct QueueData { Optional tssData; QueueData() - : latency(0.001), penalty(1.0), smoothOutstanding(FLOW_KNOBS->QUEUE_MODEL_SMOOTHING_AMOUNT), failedUntil(0), + : smoothOutstanding(FLOW_KNOBS->QUEUE_MODEL_SMOOTHING_AMOUNT), latency(0.001), penalty(1.0), failedUntil(0), futureVersionBackoff(FLOW_KNOBS->FUTURE_VERSION_INITIAL_BACKOFF), increaseBackoffTime(0) {} }; diff --git a/fdbrpc/Replication.h b/fdbrpc/Replication.h index 7016964349..c562128651 100644 --- a/fdbrpc/Replication.h +++ b/fdbrpc/Replication.h @@ -29,12 +29,11 @@ struct LocalitySet : public ReferenceCounted { public: LocalitySet(LocalitySet const& source) - : _entryArray(source._entryArray), _mutableEntryArray(source._mutableEntryArray), + : _keymap(source._keymap), _entryArray(source._entryArray), _mutableEntryArray(source._mutableEntryArray), _keyValueArray(source._keyValueArray), _keyIndexArray(source._keyIndexArray), _cacheArray(source._cacheArray), - _keymap(source._keymap), _localitygroup(source._localitygroup), _cachehits(source._cachehits), - _cachemisses(source._cachemisses) {} + _localitygroup(source._localitygroup), _cachehits(source._cachehits), _cachemisses(source._cachemisses) {} LocalitySet(LocalitySet& localityGroup) - : _localitygroup(&localityGroup), _keymap(new StringToIntMap()), _cachehits(0), _cachemisses(0) {} + : _keymap(new StringToIntMap()), _localitygroup(&localityGroup), _cachehits(0), _cachemisses(0) {} virtual ~LocalitySet() {} virtual void addref() { ReferenceCounted::addref(); } diff --git a/fdbrpc/Stats.actor.cpp b/fdbrpc/Stats.actor.cpp index 1ad6d6c91f..78f839c622 100644 --- a/fdbrpc/Stats.actor.cpp +++ b/fdbrpc/Stats.actor.cpp @@ -22,8 +22,8 @@ #include "flow/actorcompiler.h" // has to be last include Counter::Counter(std::string const& name, CounterCollection& collection) - : name(name), interval_start(0), last_event(0), interval_sq_time(0), interval_start_value(0), interval_delta(0), - roughness_interval_start(0) { + : name(name), interval_start(0), last_event(0), interval_sq_time(0), roughness_interval_start(0), interval_delta(0), + interval_start_value(0) { metric.init(collection.name + "." + (char)toupper(name.at(0)) + name.substr(1), collection.id); collection.counters.push_back(this); } diff --git a/fdbrpc/Stats.h b/fdbrpc/Stats.h index 61576ec031..147a9e8a47 100644 --- a/fdbrpc/Stats.h +++ b/fdbrpc/Stats.h @@ -227,7 +227,7 @@ private: class LatencySample { public: LatencySample(std::string name, UID id, double loggingInterval, int sampleSize) - : name(name), id(id), sample(sampleSize), sampleStart(now()) { + : name(name), id(id), sampleStart(now()), sample(sampleSize) { logger = recurring([this]() { logSample(); }, loggingInterval); } diff --git a/fdbrpc/simulator.h b/fdbrpc/simulator.h index 6404eafc17..1608959e04 100644 --- a/fdbrpc/simulator.h +++ b/fdbrpc/simulator.h @@ -39,9 +39,9 @@ class ISimulator : public INetwork { public: ISimulator() : desiredCoordinators(1), physicalDatacenters(1), processesPerMachine(0), listenersPerProcess(1), - isStopped(false), lastConnectionFailure(0), connectionFailuresDisableDuration(0), speedUpSimulation(false), - allSwapsDisabled(false), backupAgents(BackupAgentType::WaitForType), drAgents(BackupAgentType::WaitForType), - extraDB(nullptr), allowLogSetKills(true), usableRegions(1), tssMode(TSSMode::Disabled) {} + extraDB(nullptr), usableRegions(1), allowLogSetKills(true), tssMode(TSSMode::Disabled), isStopped(false), + lastConnectionFailure(0), connectionFailuresDisableDuration(0), speedUpSimulation(false), + backupAgents(BackupAgentType::WaitForType), drAgents(BackupAgentType::WaitForType), allSwapsDisabled(false) {} // Order matters! enum KillType { @@ -99,10 +99,10 @@ public: INetworkConnections* net, const char* dataFolder, const char* coordinationFolder) - : name(name), locality(locality), startingClass(startingClass), addresses(addresses), - address(addresses.address), dataFolder(dataFolder), network(net), coordinationFolder(coordinationFolder), - failed(false), excluded(false), rebooting(false), fault_injection_p1(0), fault_injection_p2(0), - fault_injection_r(0), machine(0), cleared(false), failedDisk(false) { + : name(name), coordinationFolder(coordinationFolder), dataFolder(dataFolder), machine(nullptr), + addresses(addresses), address(addresses.address), locality(locality), startingClass(startingClass), + failed(false), excluded(false), cleared(false), rebooting(false), network(net), fault_injection_r(0), + fault_injection_p1(0), fault_injection_p2(0), failedDisk(false) { uid = deterministicRandom()->randomUniqueID(); } diff --git a/fdbserver/CommitProxyServer.actor.cpp b/fdbserver/CommitProxyServer.actor.cpp index 71316dcdb7..9c4c90e889 100644 --- a/fdbserver/CommitProxyServer.actor.cpp +++ b/fdbserver/CommitProxyServer.actor.cpp @@ -500,9 +500,7 @@ CommitBatchContext::CommitBatchContext(ProxyCommitData* const pProxyCommitData_, localBatchNumber(++pProxyCommitData->localCommitBatchesStarted), toCommit(pProxyCommitData->logSystem), - committed(trs.size()), - - span("MP:commitBatch"_loc) { + span("MP:commitBatch"_loc), committed(trs.size()) { evaluateBatchSize(); diff --git a/fdbserver/DeltaTree.h b/fdbserver/DeltaTree.h index 7f2b1ae723..c1219bd71a 100644 --- a/fdbserver/DeltaTree.h +++ b/fdbserver/DeltaTree.h @@ -239,19 +239,19 @@ public: // construct root node DecodedNode(Node* raw, const T* prev, const T* next, Arena& arena, bool large) - : raw(raw), parent(nullptr), otherAncestor(nullptr), leftChild(nullptr), rightChild(nullptr), prev(prev), - next(next), item(raw->delta(large).apply(raw->delta(large).getPrefixSource() ? *prev : *next, arena)), - large(large) { + : large(large), raw(raw), parent(nullptr), otherAncestor(nullptr), leftChild(nullptr), rightChild(nullptr), + prev(prev), next(next), + item(raw->delta(large).apply(raw->delta(large).getPrefixSource() ? *prev : *next, arena)) { // printf("DecodedNode1 raw=%p delta=%s\n", raw, raw->delta(large).toString().c_str()); } // Construct non-root node // wentLeft indicates that we've gone left to get to the raw node. DecodedNode(Node* raw, DecodedNode* parent, bool wentLeft, Arena& arena) - : parent(parent), large(parent->large), - otherAncestor(wentLeft ? parent->getPrevAncestor() : parent->getNextAncestor()), - prev(wentLeft ? parent->prev : &parent->item), next(wentLeft ? &parent->item : parent->next), - leftChild(nullptr), rightChild(nullptr), raw(raw), + : large(parent->large), raw(raw), parent(parent), + otherAncestor(wentLeft ? parent->getPrevAncestor() : parent->getNextAncestor()), leftChild(nullptr), + rightChild(nullptr), prev(wentLeft ? parent->prev : &parent->item), + next(wentLeft ? &parent->item : parent->next), item(raw->delta(large).apply(raw->delta(large).getPrefixSource() ? *prev : *next, arena)) { // printf("DecodedNode2 raw=%p delta=%s\n", raw, raw->delta(large).toString().c_str()); } @@ -1134,12 +1134,12 @@ public: struct Cursor { Cursor() : cache(nullptr), nodeIndex(-1) {} - Cursor(DecodeCache* cache, DeltaTree2* tree) : cache(cache), tree(tree), nodeIndex(-1) {} + Cursor(DecodeCache* cache, DeltaTree2* tree) : tree(tree), cache(cache), nodeIndex(-1) {} - Cursor(DecodeCache* cache, DeltaTree2* tree, int nodeIndex) : cache(cache), tree(tree), nodeIndex(nodeIndex) {} + Cursor(DecodeCache* cache, DeltaTree2* tree, int nodeIndex) : tree(tree), cache(cache), nodeIndex(nodeIndex) {} // Copy constructor does not copy item because normally a copied cursor will be immediately moved. - Cursor(const Cursor& c) : cache(c.cache), tree(c.tree), nodeIndex(c.nodeIndex) {} + Cursor(const Cursor& c) : tree(c.tree), cache(c.cache), nodeIndex(c.nodeIndex) {} Cursor next() const { Cursor c = *this; diff --git a/fdbserver/KeyValueStoreMemory.actor.cpp b/fdbserver/KeyValueStoreMemory.actor.cpp index 0008296a96..7a9364dbe6 100644 --- a/fdbserver/KeyValueStoreMemory.actor.cpp +++ b/fdbserver/KeyValueStoreMemory.actor.cpp @@ -861,10 +861,10 @@ KeyValueStoreMemory::KeyValueStoreMemory(IDiskQueue* log, bool disableSnapshot, bool replaceContent, bool exactRecovery) - : log(log), id(id), type(storeType), previousSnapshotEnd(-1), currentSnapshotEnd(-1), resetSnapshot(false), - memoryLimit(memoryLimit), committedWriteBytes(0), overheadWriteBytes(0), committedDataSize(0), transactionSize(0), - transactionIsLarge(false), disableSnapshot(disableSnapshot), replaceContent(replaceContent), snapshotCount(0), - firstCommitWithSnapshot(true) { + : type(storeType), id(id), log(log), committedWriteBytes(0), overheadWriteBytes(0), currentSnapshotEnd(-1), + previousSnapshotEnd(-1), committedDataSize(0), transactionSize(0), transactionIsLarge(false), resetSnapshot(false), + disableSnapshot(disableSnapshot), replaceContent(replaceContent), firstCommitWithSnapshot(true), snapshotCount(0), + memoryLimit(memoryLimit) { // create reserved buffer for radixtree store type this->reserved_buffer = (storeType == KeyValueStoreType::MEMORY) ? nullptr : new uint8_t[CLIENT_KNOBS->SYSTEM_KEY_SIZE_LIMIT]; diff --git a/fdbserver/LogRouter.actor.cpp b/fdbserver/LogRouter.actor.cpp index 5b0aa75ad7..e6ac9fac46 100644 --- a/fdbserver/LogRouter.actor.cpp +++ b/fdbserver/LogRouter.actor.cpp @@ -43,11 +43,11 @@ struct LogRouterData { Tag tag; TagData(Tag tag, Version popped, Version durableKnownCommittedVersion) - : tag(tag), popped(popped), durableKnownCommittedVersion(durableKnownCommittedVersion) {} + : popped(popped), durableKnownCommittedVersion(durableKnownCommittedVersion), tag(tag) {} TagData(TagData&& r) noexcept - : version_messages(std::move(r.version_messages)), tag(r.tag), popped(r.popped), - durableKnownCommittedVersion(r.durableKnownCommittedVersion) {} + : version_messages(std::move(r.version_messages)), popped(r.popped), + durableKnownCommittedVersion(r.durableKnownCommittedVersion), tag(r.tag) {} void operator=(TagData&& r) noexcept { version_messages = std::move(r.version_messages); tag = r.tag; @@ -136,14 +136,14 @@ struct LogRouterData { } LogRouterData(UID dbgid, const InitializeLogRouterRequest& req) - : dbgid(dbgid), routerTag(req.routerTag), logSystem(new AsyncVar>()), - version(req.startVersion - 1), minPopped(0), generation(req.recoveryCount), startVersion(req.startVersion), - allowPops(false), minKnownCommittedVersion(0), poppedVersion(0), foundEpochEnd(false), - cc("LogRouter", dbgid.toString()), getMoreCount("GetMoreCount", cc), - getMoreBlockedCount("GetMoreBlockedCount", cc), + : dbgid(dbgid), logSystem(new AsyncVar>()), version(req.startVersion - 1), minPopped(0), + startVersion(req.startVersion), minKnownCommittedVersion(0), poppedVersion(0), routerTag(req.routerTag), + allowPops(false), foundEpochEnd(false), generation(req.recoveryCount), peekLatencyDist(Histogram::getHistogram(LiteralStringRef("LogRouter"), LiteralStringRef("PeekTLogLatency"), - Histogram::Unit::microseconds)) { + Histogram::Unit::microseconds)), + cc("LogRouter", dbgid.toString()), getMoreCount("GetMoreCount", cc), + getMoreBlockedCount("GetMoreBlockedCount", cc) { // setup just enough of a logSet to be able to call getPushLocations logSet.logServers.resize(req.tLogLocalities.size()); logSet.tLogPolicy = req.tLogPolicy; diff --git a/fdbserver/LogSystem.h b/fdbserver/LogSystem.h index 5aa14810de..ea968d9edd 100644 --- a/fdbserver/LogSystem.h +++ b/fdbserver/LogSystem.h @@ -47,7 +47,7 @@ struct ConnectionResetInfo : public ReferenceCounted { int slowReplies; int fastReplies; - ConnectionResetInfo() : lastReset(now()), slowReplies(0), fastReplies(0), resetCheck(Void()) {} + ConnectionResetInfo() : lastReset(now()), resetCheck(Void()), slowReplies(0), fastReplies(0) {} }; // The set of tLog servers, logRouters and backupWorkers for a log tag diff --git a/fdbserver/LogSystemDiskQueueAdapter.h b/fdbserver/LogSystemDiskQueueAdapter.h index a59c5b6df4..b8a71d0e9a 100644 --- a/fdbserver/LogSystemDiskQueueAdapter.h +++ b/fdbserver/LogSystemDiskQueueAdapter.h @@ -60,9 +60,9 @@ public: Reference> peekLocality, Version txsPoppedVersion, bool recover) - : logSystem(logSystem), peekLocality(peekLocality), enableRecovery(recover), recoveryLoc(txsPoppedVersion), - recoveryQueueLoc(txsPoppedVersion), poppedUpTo(0), nextCommit(1), recoveryQueueDataSize(0), peekTypeSwitches(0), - hasDiscardedData(false), totalRecoveredBytes(0) { + : peekLocality(peekLocality), peekTypeSwitches(0), enableRecovery(recover), logSystem(logSystem), + recoveryLoc(txsPoppedVersion), recoveryQueueLoc(txsPoppedVersion), recoveryQueueDataSize(0), poppedUpTo(0), + nextCommit(1), hasDiscardedData(false), totalRecoveredBytes(0) { if (enableRecovery) { localityChanged = peekLocality ? peekLocality->onChange() : Never(); cursor = logSystem->peekTxs(UID(), diff --git a/fdbserver/LogSystemPeekCursor.actor.cpp b/fdbserver/LogSystemPeekCursor.actor.cpp index 26287919cd..32dbe29831 100644 --- a/fdbserver/LogSystemPeekCursor.actor.cpp +++ b/fdbserver/LogSystemPeekCursor.actor.cpp @@ -31,11 +31,10 @@ ILogSystem::ServerPeekCursor::ServerPeekCursor(ReferencerandomUniqueID()), - poppedVersion(0), returnIfBlocked(returnIfBlocked), sequence(0), onlySpilled(false), - parallelGetMore(parallelGetMore), lastReset(0), slowReplies(0), fastReplies(0), unknownReplies(0), - resetCheck(Void()) { + : interf(interf), tag(tag), rd(results.arena, results.messages, Unversioned()), messageVersion(begin), end(end), + poppedVersion(0), hasMsg(false), randomID(deterministicRandom()->randomUniqueID()), + returnIfBlocked(returnIfBlocked), onlySpilled(false), parallelGetMore(parallelGetMore), sequence(0), lastReset(0), + resetCheck(Void()), slowReplies(0), fastReplies(0), unknownReplies(0) { this->results.maxKnownVersion = 0; this->results.minKnownCommittedVersion = 0; //TraceEvent("SPC_Starting", randomID).detail("Tag", tag.toString()).detail("Begin", begin).detail("End", end).backtrace(); @@ -48,7 +47,7 @@ ILogSystem::ServerPeekCursor::ServerPeekCursor(TLogPeekReply const& results, bool hasMsg, Version poppedVersion, Tag tag) - : results(results), tag(tag), rd(results.arena, results.messages, Unversioned()), messageVersion(messageVersion), + : tag(tag), results(results), rd(results.arena, results.messages, Unversioned()), messageVersion(messageVersion), end(end), messageAndTags(message), hasMsg(hasMsg), randomID(deterministicRandom()->randomUniqueID()), poppedVersion(poppedVersion), returnIfBlocked(false), sequence(0), onlySpilled(false), parallelGetMore(false), lastReset(0), slowReplies(0), fastReplies(0), unknownReplies(0), resetCheck(Void()) { @@ -426,8 +425,8 @@ ILogSystem::MergedPeekCursor::MergedPeekCursor( std::vector const& tLogLocalities, Reference const tLogPolicy, int tLogReplicationFactor) - : bestServer(bestServer), readQuorum(readQuorum), tag(tag), currentCursor(0), hasNextMessage(false), - messageVersion(begin), randomID(deterministicRandom()->randomUniqueID()), + : tag(tag), bestServer(bestServer), currentCursor(0), readQuorum(readQuorum), messageVersion(begin), + hasNextMessage(false), randomID(deterministicRandom()->randomUniqueID()), tLogReplicationFactor(tLogReplicationFactor) { if (tLogPolicy) { logSet = makeReference(); @@ -1170,9 +1169,9 @@ ILogSystem::BufferedCursor::BufferedCursor( Version begin, Version end, bool parallelGetMore) - : messageVersion(begin), end(end), withTags(true), collectTags(false), hasNextMessage(false), messageIndex(0), - poppedVersion(0), initialPoppedVersion(0), canDiscardPopped(false), knownUnique(true), minKnownCommittedVersion(0), - randomID(deterministicRandom()->randomUniqueID()) { + : messageVersion(begin), end(end), withTags(true), messageIndex(0), hasNextMessage(false), poppedVersion(0), + initialPoppedVersion(0), canDiscardPopped(false), knownUnique(true), minKnownCommittedVersion(0), + randomID(deterministicRandom()->randomUniqueID()), collectTags(false) { targetQueueSize = SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES / logServers.size(); messages.reserve(SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES); cursorMessages.resize(logServers.size()); diff --git a/fdbserver/MasterInterface.h b/fdbserver/MasterInterface.h index eea733b14c..a9fb8122aa 100644 --- a/fdbserver/MasterInterface.h +++ b/fdbserver/MasterInterface.h @@ -154,7 +154,7 @@ struct GetCommitVersionReply { GetCommitVersionReply() : resolverChangesVersion(0), version(0), prevVersion(0), requestNum(0) {} explicit GetCommitVersionReply(Version version, Version prevVersion, uint64_t requestNum) - : version(version), prevVersion(prevVersion), resolverChangesVersion(0), requestNum(requestNum) {} + : resolverChangesVersion(0), version(version), prevVersion(prevVersion), requestNum(requestNum) {} template void serialize(Ar& ar) { diff --git a/fdbserver/OldTLogServer_6_2.actor.cpp b/fdbserver/OldTLogServer_6_2.actor.cpp index c581560faa..91649c3054 100644 --- a/fdbserver/OldTLogServer_6_2.actor.cpp +++ b/fdbserver/OldTLogServer_6_2.actor.cpp @@ -58,7 +58,7 @@ struct TLogQueueEntryRef { TLogQueueEntryRef() : version(0), knownCommittedVersion(0) {} TLogQueueEntryRef(Arena& a, TLogQueueEntryRef const& from) - : version(from.version), knownCommittedVersion(from.knownCommittedVersion), id(from.id), + : id(from.id), version(from.version), knownCommittedVersion(from.knownCommittedVersion), messages(a, from.messages) {} template @@ -369,8 +369,8 @@ struct TLogData : NonCopyable { std::string folder) : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), persistentData(persistentData), rawPersistentQueue(persistentQueue), - persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), degraded(degraded), queueCommitBegin(0), - queueCommitEnd(0), diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), bytesInput(0), bytesDurable(0), + persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), queueCommitEnd(0), degraded(degraded), + queueCommitBegin(0), diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), bytesInput(0), bytesDurable(0), targetVolatileBytes(SERVER_KNOBS->TLOG_SPILL_THRESHOLD), overheadBytesInput(0), overheadBytesDurable(0), peekMemoryLimiter(SERVER_KNOBS->TLOG_SPILL_REFERENCE_MAX_PEEK_MEMORY_BYTES), concurrentLogRouterReads(SERVER_KNOBS->CONCURRENT_LOG_ROUTER_READS), ignorePopRequest(false), @@ -607,8 +607,8 @@ struct LogData : NonCopyable, public ReferenceCounted { ProtocolVersion protocolVersion, std::vector tags, std::string context) - : tLogData(tLogData), knownCommittedVersion(0), logId(interf.id()), cc("TLog", interf.id().toString()), - bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), remoteTag(remoteTag), isPrimary(isPrimary), + : cc("TLog", interf.id().toString()), bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), + logId(interf.id()), tLogData(tLogData), knownCommittedVersion(0), remoteTag(remoteTag), isPrimary(isPrimary), logRouterTags(logRouterTags), txsTags(txsTags), recruitmentID(recruitmentID), protocolVersion(protocolVersion), logSystem(new AsyncVar>()), logRouterPoppedVersion(0), durableKnownCommittedVersion(0), minKnownCommittedVersion(0), queuePoppedVersion(0), allTags(tags.begin(), tags.end()), diff --git a/fdbserver/OnDemandStore.actor.cpp b/fdbserver/OnDemandStore.actor.cpp index 8867db40c4..fda08008a1 100644 --- a/fdbserver/OnDemandStore.actor.cpp +++ b/fdbserver/OnDemandStore.actor.cpp @@ -34,7 +34,7 @@ void OnDemandStore::open() { } OnDemandStore::OnDemandStore(std::string const& folder, UID myID, std::string const& prefix) - : folder(folder), prefix(prefix), store(nullptr), myID(myID) {} + : folder(folder), myID(myID), store(nullptr), prefix(prefix) {} OnDemandStore::~OnDemandStore() { if (store) { diff --git a/fdbserver/ProxyCommitData.actor.h b/fdbserver/ProxyCommitData.actor.h index 29f7802bd7..d625f1f508 100644 --- a/fdbserver/ProxyCommitData.actor.h +++ b/fdbserver/ProxyCommitData.actor.h @@ -90,16 +90,16 @@ struct ProxyStats { Version* pVersion, NotifiedVersion* pCommittedVersion, int64_t* commitBatchesMemBytesCountPtr) - : cc("ProxyStats", id.toString()), maxComputeNS(0), minComputeNS(1e12), txnCommitIn("TxnCommitIn", cc), + : cc("ProxyStats", id.toString()), txnCommitIn("TxnCommitIn", cc), txnCommitVersionAssigned("TxnCommitVersionAssigned", cc), txnCommitResolving("TxnCommitResolving", cc), txnCommitResolved("TxnCommitResolved", cc), txnCommitOut("TxnCommitOut", cc), txnCommitOutSuccess("TxnCommitOutSuccess", cc), txnCommitErrors("TxnCommitErrors", cc), - txnConflicts("TxnConflicts", cc), commitBatchIn("CommitBatchIn", cc), - txnRejectedForQueuedTooLong("TxnRejectedForQueuedTooLong", cc), commitBatchOut("CommitBatchOut", cc), - mutationBytes("MutationBytes", cc), mutations("Mutations", cc), conflictRanges("ConflictRanges", cc), + txnConflicts("TxnConflicts", cc), txnRejectedForQueuedTooLong("TxnRejectedForQueuedTooLong", cc), + commitBatchIn("CommitBatchIn", cc), commitBatchOut("CommitBatchOut", cc), mutationBytes("MutationBytes", cc), + mutations("Mutations", cc), conflictRanges("ConflictRanges", cc), keyServerLocationIn("KeyServerLocationIn", cc), keyServerLocationOut("KeyServerLocationOut", cc), - keyServerLocationErrors("KeyServerLocationErrors", cc), lastCommitVersionAssigned(0), - txnExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), + keyServerLocationErrors("KeyServerLocationErrors", cc), + txnExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), lastCommitVersionAssigned(0), commitLatencySample("CommitLatencyMetrics", id, SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL, @@ -112,7 +112,8 @@ struct ProxyStats { commitBatchingWindowSize("CommitBatchingWindowSize", id, SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL, - SERVER_KNOBS->LATENCY_SAMPLE_SIZE) { + SERVER_KNOBS->LATENCY_SAMPLE_SIZE), + maxComputeNS(0), minComputeNS(1e12) { specialCounter(cc, "LastAssignedCommitVersion", [this]() { return this->lastCommitVersionAssigned; }); specialCounter(cc, "Version", [pVersion]() { return *pVersion; }); specialCounter(cc, "CommittedVersion", [pCommittedVersion]() { return pCommittedVersion->get(); }); @@ -241,14 +242,14 @@ struct ProxyCommitData { RequestStream commit, Reference const> db, bool firstProxy) - : dbgid(dbgid), stats(dbgid, &version, &committedVersion, &commitBatchesMemBytesCount), master(master), - logAdapter(nullptr), txnStateStore(nullptr), popRemoteTxs(false), committedVersion(recoveryTransactionVersion), - version(0), minKnownCommittedVersion(0), lastVersionTime(0), commitVersionRequestNumber(1), - mostRecentProcessedRequestNumber(0), getConsistentReadVersion(getConsistentReadVersion), commit(commit), - lastCoalesceTime(0), localCommitBatchesStarted(0), locked(false), - commitBatchInterval(SERVER_KNOBS->COMMIT_TRANSACTION_BATCH_INTERVAL_MIN), firstProxy(firstProxy), + : dbgid(dbgid), commitBatchesMemBytesCount(0), + stats(dbgid, &version, &committedVersion, &commitBatchesMemBytesCount), master(master), logAdapter(nullptr), + txnStateStore(nullptr), committedVersion(recoveryTransactionVersion), minKnownCommittedVersion(0), version(0), + lastVersionTime(0), commitVersionRequestNumber(1), mostRecentProcessedRequestNumber(0), firstProxy(firstProxy), + lastCoalesceTime(0), locked(false), commitBatchInterval(SERVER_KNOBS->COMMIT_TRANSACTION_BATCH_INTERVAL_MIN), + localCommitBatchesStarted(0), getConsistentReadVersion(getConsistentReadVersion), commit(commit), cx(openDBOnServer(db, TaskPriority::DefaultEndpoint, LockAware::True)), db(db), - singleKeyMutationEvent(LiteralStringRef("SingleKeyMutation")), commitBatchesMemBytesCount(0), lastTxsPop(0), + singleKeyMutationEvent(LiteralStringRef("SingleKeyMutation")), lastTxsPop(0), popRemoteTxs(false), lastStartCommit(0), lastCommitLatency(SERVER_KNOBS->REQUIRED_MIN_RECOVERY_DURATION), lastCommitTime(0), lastMasterReset(now()), lastResolverReset(now()) { commitComputePerOperation.resize(SERVER_KNOBS->PROXY_COMPUTE_BUCKETS, 0.0); diff --git a/fdbserver/RestoreApplier.actor.h b/fdbserver/RestoreApplier.actor.h index 55a465fb14..2a8144f97b 100644 --- a/fdbserver/RestoreApplier.actor.h +++ b/fdbserver/RestoreApplier.actor.h @@ -55,7 +55,7 @@ struct StagingKey { LogMessageVersion version; // largest version of set or clear for the key std::map> pendingMutations; // mutations not set or clear type - explicit StagingKey(Key key) : key(key), version(0), type(MutationRef::MAX_ATOMIC_OP) {} + explicit StagingKey(Key key) : key(key), type(MutationRef::MAX_ATOMIC_OP), version(0) {} // Add mutation m at newVersion to stagingKey // Assume: SetVersionstampedKey and SetVersionstampedValue have been converted to set @@ -269,8 +269,8 @@ struct ApplierBatchData : public ReferenceCounted { Counters(ApplierBatchData* self, UID applierInterfID, int batchIndex) : cc("ApplierBatch", applierInterfID.toString() + ":" + std::to_string(batchIndex)), - receivedBytes("ReceivedBytes", cc), receivedMutations("ReceivedMutations", cc), - receivedAtomicOps("ReceivedAtomicOps", cc), receivedWeightedBytes("ReceivedWeightedMutations", cc), + receivedBytes("ReceivedBytes", cc), receivedWeightedBytes("ReceivedWeightedMutations", cc), + receivedMutations("ReceivedMutations", cc), receivedAtomicOps("ReceivedAtomicOps", cc), appliedBytes("AppliedBytes", cc), appliedWeightedBytes("AppliedWeightedBytes", cc), appliedMutations("AppliedMutations", cc), appliedAtomicOps("AppliedAtomicOps", cc), appliedTxns("AppliedTxns", cc), appliedTxnRetries("AppliedTxnRetries", cc), fetchKeys("FetchKeys", cc), @@ -282,10 +282,9 @@ struct ApplierBatchData : public ReferenceCounted { void delref() { return ReferenceCounted::delref(); } explicit ApplierBatchData(UID nodeID, int batchIndex) - : counters(this, nodeID, batchIndex), + : vbState(ApplierVersionBatchState::NOT_INIT), receiveMutationReqs(0), receivedBytes(0), appliedBytes(0), targetWriteRateMB(SERVER_KNOBS->FASTRESTORE_WRITE_BW_MB / SERVER_KNOBS->FASTRESTORE_NUM_APPLIERS), - totalBytesToWrite(-1), applyingDataBytes(0), vbState(ApplierVersionBatchState::NOT_INIT), - receiveMutationReqs(0), receivedBytes(0), appliedBytes(0) { + totalBytesToWrite(-1), applyingDataBytes(0), counters(this, nodeID, batchIndex) { pollMetrics = traceCounters(format("FastRestoreApplierMetrics%d", batchIndex), nodeID, SERVER_KNOBS->FASTRESTORE_ROLE_LOGGING_DELAY, diff --git a/fdbserver/RestoreLoader.actor.h b/fdbserver/RestoreLoader.actor.h index b3de3340a0..d41ebe697d 100644 --- a/fdbserver/RestoreLoader.actor.h +++ b/fdbserver/RestoreLoader.actor.h @@ -92,7 +92,7 @@ struct LoaderBatchData : public ReferenceCounted { } counters; explicit LoaderBatchData(UID nodeID, int batchIndex) - : counters(this, nodeID, batchIndex), vbState(LoaderVersionBatchState::NOT_INIT), loadFileReqs(0) { + : vbState(LoaderVersionBatchState::NOT_INIT), loadFileReqs(0), counters(this, nodeID, batchIndex) { pollMetrics = traceCounters(format("FastRestoreLoaderMetrics%d", batchIndex), nodeID, SERVER_KNOBS->FASTRESTORE_ROLE_LOGGING_DELAY, diff --git a/fdbserver/SkipList.cpp b/fdbserver/SkipList.cpp index a75f11073d..86489f3850 100644 --- a/fdbserver/SkipList.cpp +++ b/fdbserver/SkipList.cpp @@ -786,7 +786,7 @@ private: }; struct ConflictSet { - ConflictSet() : oldestVersion(0), removalKey(makeString(0)) {} + ConflictSet() : removalKey(makeString(0)), oldestVersion(0) {} ~ConflictSet() {} SkipList versionHistory; diff --git a/fdbserver/TLogInterface.h b/fdbserver/TLogInterface.h index e9e5b20b0d..787e00ed2c 100644 --- a/fdbserver/TLogInterface.h +++ b/fdbserver/TLogInterface.h @@ -52,13 +52,13 @@ struct TLogInterface { TLogInterface() {} explicit TLogInterface(const LocalityData& locality) - : uniqueID(deterministicRandom()->randomUniqueID()), filteredLocality(locality) { + : filteredLocality(locality), uniqueID(deterministicRandom()->randomUniqueID()) { sharedTLogID = uniqueID; } TLogInterface(UID sharedTLogID, const LocalityData& locality) - : uniqueID(deterministicRandom()->randomUniqueID()), sharedTLogID(sharedTLogID), filteredLocality(locality) {} + : filteredLocality(locality), uniqueID(deterministicRandom()->randomUniqueID()), sharedTLogID(sharedTLogID) {} TLogInterface(UID uniqueID, UID sharedTLogID, const LocalityData& locality) - : uniqueID(uniqueID), sharedTLogID(sharedTLogID), filteredLocality(locality) {} + : filteredLocality(locality), uniqueID(uniqueID), sharedTLogID(sharedTLogID) {} UID id() const { return uniqueID; } UID getSharedTLogID() const { return sharedTLogID; } std::string toString() const { return id().shortString(); } @@ -152,7 +152,7 @@ struct VerUpdateRef { VectorRef mutations; bool isPrivateData; - VerUpdateRef() : isPrivateData(false), version(invalidVersion) {} + VerUpdateRef() : version(invalidVersion), isPrivateData(false) {} VerUpdateRef(Arena& to, const VerUpdateRef& from) : version(from.version), mutations(to, from.mutations), isPrivateData(from.isPrivateData) {} int expectedSize() const { return mutations.expectedSize(); } @@ -200,7 +200,7 @@ struct TLogPeekRequest { bool returnIfBlocked, bool onlySpilled, Optional> sequence = Optional>()) - : begin(begin), tag(tag), returnIfBlocked(returnIfBlocked), sequence(sequence), onlySpilled(onlySpilled) {} + : begin(begin), tag(tag), returnIfBlocked(returnIfBlocked), onlySpilled(onlySpilled), sequence(sequence) {} TLogPeekRequest() {} template diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index ff5b72ccdc..97c0856a25 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -60,7 +60,7 @@ struct TLogQueueEntryRef { TLogQueueEntryRef() : version(0), knownCommittedVersion(0) {} TLogQueueEntryRef(Arena& a, TLogQueueEntryRef const& from) - : version(from.version), knownCommittedVersion(from.knownCommittedVersion), id(from.id), + : id(from.id), version(from.version), knownCommittedVersion(from.knownCommittedVersion), messages(a, from.messages) {} // To change this serialization, ProtocolVersion::TLogQueueEntryRef must be updated, and downgrades need to be @@ -375,14 +375,14 @@ struct TLogData : NonCopyable { Reference const> dbInfo, Reference> degraded, std::string folder) - : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), - persistentData(persistentData), rawPersistentQueue(persistentQueue), - persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), degraded(degraded), queueCommitBegin(0), - queueCommitEnd(0), diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), bytesInput(0), bytesDurable(0), + : dbgid(dbgid), workerID(workerID), persistentData(persistentData), rawPersistentQueue(persistentQueue), + persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), queueCommitEnd(0), queueCommitBegin(0), + diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), + instanceID(deterministicRandom()->randomUniqueID().first()), bytesInput(0), bytesDurable(0), targetVolatileBytes(SERVER_KNOBS->TLOG_SPILL_THRESHOLD), overheadBytesInput(0), overheadBytesDurable(0), peekMemoryLimiter(SERVER_KNOBS->TLOG_SPILL_REFERENCE_MAX_PEEK_MEMORY_BYTES), concurrentLogRouterReads(SERVER_KNOBS->CONCURRENT_LOG_ROUTER_READS), ignorePopRequest(false), - ignorePopDeadline(), ignorePopUid(), dataFolder(folder), toBePopped(), + dataFolder(folder), degraded(degraded), commitLatencyDist(Histogram::getHistogram(LiteralStringRef("tLog"), LiteralStringRef("commit"), Histogram::Unit::microseconds)) { @@ -626,17 +626,16 @@ struct LogData : NonCopyable, public ReferenceCounted { TLogSpillType logSpillType, std::vector tags, std::string context) - : tLogData(tLogData), knownCommittedVersion(0), logId(interf.id()), cc("TLog", interf.id().toString()), - bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), remoteTag(remoteTag), isPrimary(isPrimary), - logRouterTags(logRouterTags), txsTags(txsTags), recruitmentID(recruitmentID), protocolVersion(protocolVersion), - logSpillType(logSpillType), logSystem(new AsyncVar>()), logRouterPoppedVersion(0), - durableKnownCommittedVersion(0), minKnownCommittedVersion(0), queuePoppedVersion(0), - allTags(tags.begin(), tags.end()), terminated(tLogData->terminated.getFuture()), minPoppedTagVersion(0), - minPoppedTag(invalidTag), - // These are initialized differently on init() or recovery - recoveryCount(), stopped(false), initialized(false), queueCommittingVersion(0), - newPersistentDataVersion(invalidVersion), unrecoveredBefore(1), recoveredAt(1), unpoppedRecoveredTags(0), - logRouterPopToVersion(0), locality(tagLocalityInvalid), execOpCommitInProgress(false) { + : stopped(false), initialized(false), knownCommittedVersion(0), cc("TLog", interf.id().toString()), + bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), logId(interf.id()), + protocolVersion(protocolVersion), newPersistentDataVersion(invalidVersion), tLogData(tLogData), + unrecoveredBefore(1), recoveredAt(1), logSystem(new AsyncVar>()), remoteTag(remoteTag), + isPrimary(isPrimary), logRouterTags(logRouterTags), txsTags(txsTags), recruitmentID(recruitmentID), + logSpillType(logSpillType), logRouterPoppedVersion(0), durableKnownCommittedVersion(0), + minKnownCommittedVersion(0), queuePoppedVersion(0), allTags(tags.begin(), tags.end()), + terminated(tLogData->terminated.getFuture()), minPoppedTagVersion(0), minPoppedTag(invalidTag), + queueCommittingVersion(0), unpoppedRecoveredTags(0), logRouterPopToVersion(0), locality(tagLocalityInvalid), + execOpCommitInProgress(false) { startRole(Role::TRANSACTION_LOG, interf.id(), tLogData->workerID, diff --git a/fdbserver/VFSAsync.cpp b/fdbserver/VFSAsync.cpp index fe4f1b882d..17f2b69c9e 100644 --- a/fdbserver/VFSAsync.cpp +++ b/fdbserver/VFSAsync.cpp @@ -61,7 +61,7 @@ const uint32_t RESERVED_COUNT = 1U << 29; VFSAsyncFile::VFSAsyncFile(std::string const& filename, int flags) - : filename(filename), flags(flags), pLockCount(&filename_lockCount_openCount[filename].first), debug_zcrefs(0), + : flags(flags), filename(filename), pLockCount(&filename_lockCount_openCount[filename].first), debug_zcrefs(0), debug_zcreads(0), debug_reads(0), chunkSize(0) { filename_lockCount_openCount[filename].second++; diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index ecd6540ffb..e253ecb3a8 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -2050,10 +2050,10 @@ public: int concurrentExtentReads, bool memoryOnly = false, Promise errorPromise = {}) - : desiredPageSize(desiredPageSize), desiredExtentSize(desiredExtentSize), filename(filename), pHeader(nullptr), - pageCacheBytes(pageCacheSizeBytes), memoryOnly(memoryOnly), remapCleanupWindow(remapCleanupWindow), - concurrentExtentReads(new FlowLock(concurrentExtentReads)), errorPromise(errorPromise), - ioLock(FLOW_KNOBS->MAX_OUTSTANDING, ioMaxPriority) { + : ioLock(FLOW_KNOBS->MAX_OUTSTANDING, ioMaxPriority), pageCacheBytes(pageCacheSizeBytes), pHeader(nullptr), + desiredPageSize(desiredPageSize), desiredExtentSize(desiredExtentSize), filename(filename), + memoryOnly(memoryOnly), errorPromise(errorPromise), remapCleanupWindow(remapCleanupWindow), + concurrentExtentReads(new FlowLock(concurrentExtentReads)) { if (!g_redwoodMetricsActor.isValid()) { g_redwoodMetricsActor = redwoodMetricsLogger(); @@ -3550,7 +3550,7 @@ private: class DWALPagerSnapshot : public IPagerSnapshot, public ReferenceCounted { public: DWALPagerSnapshot(DWALPager* pager, Key meta, Version version, Future expiredFuture) - : pager(pager), metaKey(meta), version(version), expired(expiredFuture) {} + : pager(pager), expired(expiredFuture), version(version), metaKey(meta) {} ~DWALPagerSnapshot() override {} Future> getPhysicalPage(PagerEventReasons reason, @@ -4477,7 +4477,7 @@ public: Version getLastCommittedVersion() const { return m_lastCommittedVersion; } VersionedBTree(IPager2* pager, std::string name) - : m_pager(pager), m_writeVersion(invalidVersion), m_lastCommittedVersion(invalidVersion), m_pBuffer(nullptr), + : m_pager(pager), m_pBuffer(nullptr), m_writeVersion(invalidVersion), m_lastCommittedVersion(invalidVersion), m_name(name), m_pHeader(nullptr), m_headerSpace(0) { m_lazyClearActor = 0; @@ -5642,7 +5642,7 @@ private: struct InternalPageModifier { InternalPageModifier() {} InternalPageModifier(Reference p, bool alreadyCloned, bool updating, ParentInfo* parentInfo) - : page(p), clonedPage(alreadyCloned), updating(updating), changesMade(false), parentInfo(parentInfo) {} + : updating(updating), page(p), clonedPage(alreadyCloned), changesMade(false), parentInfo(parentInfo) {} // Whether updating the existing page is allowed bool updating; @@ -8746,7 +8746,7 @@ TEST_CASE("/redwood/correctness/unit/deltaTree/IntIntPair") { } struct SimpleCounter { - SimpleCounter() : x(0), xt(0), t(timer()), start(t) {} + SimpleCounter() : x(0), t(timer()), start(t), xt(0) {} void operator+=(int n) { x += n; } void operator++() { x++; } int64_t get() { return x; } diff --git a/fdbserver/WorkerInterface.actor.h b/fdbserver/WorkerInterface.actor.h index ddd62d6aff..72cfd55166 100644 --- a/fdbserver/WorkerInterface.actor.h +++ b/fdbserver/WorkerInterface.actor.h @@ -746,7 +746,7 @@ struct EventLogRequest { ReplyPromise reply; EventLogRequest() : getLastError(true) {} - explicit EventLogRequest(Standalone eventName) : eventName(eventName), getLastError(false) {} + explicit EventLogRequest(Standalone eventName) : getLastError(false), eventName(eventName) {} template void serialize(Ar& ar) { @@ -762,8 +762,8 @@ struct DebugEntryRef { MutationRef mutation; DebugEntryRef() {} DebugEntryRef(const char* c, Version v, MutationRef const& m) - : context((const uint8_t*)c, strlen(c)), version(v), mutation(m), time(now()), - address(g_network->getLocalAddress()) {} + : time(now()), address(g_network->getLocalAddress()), context((const uint8_t*)c, strlen(c)), version(v), + mutation(m) {} DebugEntryRef(Arena& a, DebugEntryRef const& d) : time(d.time), address(d.address), context(d.context), version(d.version), mutation(a, d.mutation) {} diff --git a/fdbserver/masterserver.actor.cpp b/fdbserver/masterserver.actor.cpp index f3fb50bfff..39cd0dd087 100644 --- a/fdbserver/masterserver.actor.cpp +++ b/fdbserver/masterserver.actor.cpp @@ -262,14 +262,16 @@ struct MasterData : NonCopyable, ReferenceCounted { Standalone const& dbId, PromiseStream> const& addActor, bool forceRecovery) - : dbgid(myInterface.id()), myInterface(myInterface), dbInfo(dbInfo), cstate(coordinators, addActor, dbgid), - coordinators(coordinators), clusterController(clusterController), dbId(dbId), forceRecovery(forceRecovery), - safeLocality(tagLocalityInvalid), primaryLocality(tagLocalityInvalid), neverCreated(false), - lastEpochEnd(invalidVersion), liveCommittedVersion(invalidVersion), databaseLocked(false), - minKnownCommittedVersion(invalidVersion), recoveryTransactionVersion(invalidVersion), lastCommitTime(0), - registrationCount(0), version(invalidVersion), lastVersionTime(0), txnStateStore(nullptr), memoryLimit(2e9), - addActor(addActor), hasConfiguration(false), recruitmentStalled(makeReference>(false)), - cc("Master", dbgid.toString()), changeCoordinatorsRequests("ChangeCoordinatorsRequests", cc), + + : dbgid(myInterface.id()), lastEpochEnd(invalidVersion), recoveryTransactionVersion(invalidVersion), + lastCommitTime(0), liveCommittedVersion(invalidVersion), databaseLocked(false), + minKnownCommittedVersion(invalidVersion), myInterface(myInterface), dbInfo(dbInfo), + cstate(coordinators, addActor, dbgid), coordinators(coordinators), clusterController(clusterController), + dbId(dbId), forceRecovery(forceRecovery), safeLocality(tagLocalityInvalid), primaryLocality(tagLocalityInvalid), + neverCreated(false), hasConfiguration(false), version(invalidVersion), lastVersionTime(0), + txnStateStore(nullptr), memoryLimit(2e9), registrationCount(0), addActor(addActor), + recruitmentStalled(makeReference>(false)), cc("Master", dbgid.toString()), + changeCoordinatorsRequests("ChangeCoordinatorsRequests", cc), getCommitVersionRequests("GetCommitVersionRequests", cc), backupWorkerDoneRequests("BackupWorkerDoneRequests", cc), getLiveCommittedVersionRequests("GetLiveCommittedVersionRequests", cc), diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index ffd0ee4f40..7b21eaa7e3 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -808,8 +808,8 @@ public: StorageServer(IKeyValueStore* storage, Reference const> const& db, StorageServerInterface const& ssi) - : fetchKeysHistograms(), instanceID(deterministicRandom()->randomUniqueID().first()), storage(this, storage), - db(db), actors(false), lastTLogVersion(0), lastVersionWithData(0), restoredVersion(0), + : instanceID(deterministicRandom()->randomUniqueID().first()), storage(this, storage), db(db), actors(false), + lastTLogVersion(0), lastVersionWithData(0), restoredVersion(0), rebootAfterDurableVersion(std::numeric_limits::max()), durableInProgress(Void()), versionLag(0), primaryLocality(tagLocalityInvalid), updateEagerReads(0), shardChangeCounter(0), fetchKeysParallelismLock(SERVER_KNOBS->FETCH_KEYS_PARALLELISM), @@ -3402,7 +3402,7 @@ static const KeyRef persistPrimaryLocality = LiteralStringRef(PERSIST_PREFIX "Pr class StorageUpdater { public: StorageUpdater() - : fromVersion(invalidVersion), currentVersion(invalidVersion), restoredVersion(invalidVersion), + : currentVersion(invalidVersion), fromVersion(invalidVersion), restoredVersion(invalidVersion), processedStartKey(false), processedCacheStartKey(false) {} StorageUpdater(Version fromVersion, Version restoredVersion) : fromVersion(fromVersion), currentVersion(fromVersion), restoredVersion(restoredVersion), diff --git a/fdbserver/tester.actor.cpp b/fdbserver/tester.actor.cpp index 44826b4590..574d2df2fd 100644 --- a/fdbserver/tester.actor.cpp +++ b/fdbserver/tester.actor.cpp @@ -48,8 +48,8 @@ using namespace std; WorkloadContext::WorkloadContext() {} WorkloadContext::WorkloadContext(const WorkloadContext& r) - : options(r.options), clientId(r.clientId), clientCount(r.clientCount), dbInfo(r.dbInfo), - sharedRandomNumber(r.sharedRandomNumber) {} + : options(r.options), clientId(r.clientId), clientCount(r.clientCount), sharedRandomNumber(r.sharedRandomNumber), + dbInfo(r.dbInfo) {} WorkloadContext::~WorkloadContext() {} diff --git a/fdbserver/workloads/ApiWorkload.h b/fdbserver/workloads/ApiWorkload.h index 152ac72205..b3992f33f3 100644 --- a/fdbserver/workloads/ApiWorkload.h +++ b/fdbserver/workloads/ApiWorkload.h @@ -223,7 +223,7 @@ struct ApiWorkload : TestWorkload { Database extraDB; ApiWorkload(WorkloadContext const& wcx, int maxClients = -1) - : TestWorkload(wcx), success(true), transactionFactory(nullptr), maxClients(maxClients) { + : TestWorkload(wcx), maxClients(maxClients), success(true), transactionFactory(nullptr) { clientPrefixInt = getOption(options, LiteralStringRef("clientId"), clientId); clientPrefix = format("%010d", clientPrefixInt); diff --git a/fdbserver/workloads/Cycle.actor.cpp b/fdbserver/workloads/Cycle.actor.cpp index c80b2348f7..8083e84ee0 100644 --- a/fdbserver/workloads/Cycle.actor.cpp +++ b/fdbserver/workloads/Cycle.actor.cpp @@ -40,8 +40,8 @@ struct CycleWorkload : TestWorkload { PerfDoubleCounter totalLatency; CycleWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), totalLatency("Latency"), - tooOldRetries("Retries.too_old"), commitFailedRetries("Retries.commit_failed") { + : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), tooOldRetries("Retries.too_old"), + commitFailedRetries("Retries.commit_failed"), totalLatency("Latency") { testDuration = getOption(options, "testDuration"_sr, 10.0); transactionsPerSecond = getOption(options, "transactionsPerSecond"_sr, 5000.0) / clientCount; actorCount = getOption(options, "actorsPerClient"_sr, transactionsPerSecond / 5); diff --git a/fdbserver/workloads/DDBalance.actor.cpp b/fdbserver/workloads/DDBalance.actor.cpp index 780b081db7..31c0da11c7 100644 --- a/fdbserver/workloads/DDBalance.actor.cpp +++ b/fdbserver/workloads/DDBalance.actor.cpp @@ -35,7 +35,7 @@ struct DDBalanceWorkload : TestWorkload { ContinuousSample latencies; DDBalanceWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), latencies(2000), bin_shifts("Bin_Shifts"), operations("Operations"), retries("Retries") { + : TestWorkload(wcx), bin_shifts("Bin_Shifts"), operations("Operations"), retries("Retries"), latencies(2000) { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); binCount = getOption(options, LiteralStringRef("binCount"), 1000); writesPerTransaction = getOption(options, LiteralStringRef("writesPerTransaction"), 1); diff --git a/fdbserver/workloads/FileSystem.actor.cpp b/fdbserver/workloads/FileSystem.actor.cpp index 1b8b3d86e7..82cac5c810 100644 --- a/fdbserver/workloads/FileSystem.actor.cpp +++ b/fdbserver/workloads/FileSystem.actor.cpp @@ -43,7 +43,7 @@ struct FileSystemWorkload : TestWorkload { }; FileSystemWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), latencies(2500), writeLatencies(1000), queries("Queries"), writes("Latency") { + : TestWorkload(wcx), queries("Queries"), writes("Latency"), latencies(2500), writeLatencies(1000) { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); transactionsPerSecond = getOption(options, LiteralStringRef("transactionsPerSecond"), 5000.0) / clientCount; double allowedLatency = getOption(options, LiteralStringRef("allowedLatency"), 0.250); diff --git a/fdbserver/workloads/Increment.actor.cpp b/fdbserver/workloads/Increment.actor.cpp index b940e98c4f..5824f2d4a5 100644 --- a/fdbserver/workloads/Increment.actor.cpp +++ b/fdbserver/workloads/Increment.actor.cpp @@ -33,8 +33,8 @@ struct Increment : TestWorkload { PerfDoubleCounter totalLatency; Increment(WorkloadContext const& wcx) - : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), totalLatency("Latency"), - tooOldRetries("Retries.too_old"), commitFailedRetries("Retries.commit_failed") { + : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), tooOldRetries("Retries.too_old"), + commitFailedRetries("Retries.commit_failed"), totalLatency("Latency") { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); transactionsPerSecond = getOption(options, LiteralStringRef("transactionsPerSecond"), 5000.0); actorCount = getOption(options, LiteralStringRef("actorsPerClient"), transactionsPerSecond / 5); diff --git a/fdbserver/workloads/IndexScan.actor.cpp b/fdbserver/workloads/IndexScan.actor.cpp index f384664650..4e238d79b7 100644 --- a/fdbserver/workloads/IndexScan.actor.cpp +++ b/fdbserver/workloads/IndexScan.actor.cpp @@ -33,7 +33,7 @@ struct IndexScanWorkload : KVWorkload { bool singleProcess, readYourWrites; IndexScanWorkload(WorkloadContext const& wcx) - : KVWorkload(wcx), failedTransactions(0), rowsRead(0), chunks(0), scans(0) { + : KVWorkload(wcx), rowsRead(0), chunks(0), failedTransactions(0), scans(0) { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); bytesPerRead = getOption(options, LiteralStringRef("bytesPerRead"), 80000); transactionDuration = getOption(options, LiteralStringRef("transactionDuration"), 1.0); diff --git a/fdbserver/workloads/KVStoreTest.actor.cpp b/fdbserver/workloads/KVStoreTest.actor.cpp index 9c100cfa36..165adf143d 100644 --- a/fdbserver/workloads/KVStoreTest.actor.cpp +++ b/fdbserver/workloads/KVStoreTest.actor.cpp @@ -110,8 +110,8 @@ struct KVTest { bool dispose; explicit KVTest(int nodeCount, bool dispose, int keyBytes) - : store(nullptr), dispose(dispose), startVersion(Version(time(nullptr)) << 30), lastSet(startVersion), - lastCommit(startVersion), lastDurable(startVersion), nodeCount(nodeCount), keyBytes(keyBytes) {} + : store(nullptr), startVersion(Version(time(nullptr)) << 30), lastSet(startVersion), lastCommit(startVersion), + lastDurable(startVersion), nodeCount(nodeCount), keyBytes(keyBytes), dispose(dispose) {} ~KVTest() { close(); } void close() { if (store) { diff --git a/fdbserver/workloads/Mako.actor.cpp b/fdbserver/workloads/Mako.actor.cpp index 7bfd33bf62..029bd120cc 100644 --- a/fdbserver/workloads/Mako.actor.cpp +++ b/fdbserver/workloads/Mako.actor.cpp @@ -52,8 +52,8 @@ struct MakoWorkload : TestWorkload { "CLEAR", "SETCLEAR", "CLEARRANGE", "SETCLEARRANGE", "COMMIT" }; MakoWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), xacts("Transactions"), retries("Retries"), conflicts("Conflicts"), commits("Commits"), - totalOps("Operations"), loadTime(0.0) { + : TestWorkload(wcx), loadTime(0.0), xacts("Transactions"), retries("Retries"), conflicts("Conflicts"), + commits("Commits"), totalOps("Operations") { // init parameters from test file // Number of rows populated rowCount = getOption(options, LiteralStringRef("rows"), 10000); diff --git a/fdbserver/workloads/QueuePush.actor.cpp b/fdbserver/workloads/QueuePush.actor.cpp index cae37474f1..3f1308f68c 100644 --- a/fdbserver/workloads/QueuePush.actor.cpp +++ b/fdbserver/workloads/QueuePush.actor.cpp @@ -39,7 +39,7 @@ struct QueuePushWorkload : TestWorkload { ContinuousSample commitLatencies, GRVLatencies; QueuePushWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), commitLatencies(2000), GRVLatencies(2000), transactions("Transactions"), retries("Retries") { + : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), commitLatencies(2000), GRVLatencies(2000) { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); actorCount = getOption(options, LiteralStringRef("actorCount"), 50); diff --git a/fdbserver/workloads/ReadWrite.actor.cpp b/fdbserver/workloads/ReadWrite.actor.cpp index aab168be41..c1ef14fc4c 100644 --- a/fdbserver/workloads/ReadWrite.actor.cpp +++ b/fdbserver/workloads/ReadWrite.actor.cpp @@ -121,12 +121,12 @@ struct ReadWriteWorkload : KVWorkload { bool doSetup; ReadWriteWorkload(WorkloadContext const& wcx) - : KVWorkload(wcx), latencies(sampleSize), readLatencies(sampleSize), fullReadLatencies(sampleSize), - commitLatencies(sampleSize), GRVLatencies(sampleSize), readLatencyTotal(0), readLatencyCount(0), loadTime(0.0), - dependentReads(false), adjacentReads(false), adjacentWrites(false), clientBegin(0), - aTransactions("A Transactions"), bTransactions("B Transactions"), retries("Retries"), - totalReadsMetric(LiteralStringRef("RWWorkload.TotalReads")), - totalRetriesMetric(LiteralStringRef("RWWorkload.TotalRetries")) { + : KVWorkload(wcx), loadTime(0.0), clientBegin(0), dependentReads(false), adjacentReads(false), + adjacentWrites(false), totalReadsMetric(LiteralStringRef("RWWorkload.TotalReads")), + totalRetriesMetric(LiteralStringRef("RWWorkload.TotalRetries")), aTransactions("A Transactions"), + bTransactions("B Transactions"), retries("Retries"), latencies(sampleSize), readLatencies(sampleSize), + commitLatencies(sampleSize), GRVLatencies(sampleSize), fullReadLatencies(sampleSize), readLatencyTotal(0), + readLatencyCount(0) { transactionSuccessMetric.init(LiteralStringRef("RWWorkload.SuccessfulTransaction")); transactionFailureMetric.init(LiteralStringRef("RWWorkload.FailedTransaction")); readMetric.init(LiteralStringRef("RWWorkload.Read")); diff --git a/fdbserver/workloads/ReportConflictingKeys.actor.cpp b/fdbserver/workloads/ReportConflictingKeys.actor.cpp index a68b34b900..e6e0858a03 100644 --- a/fdbserver/workloads/ReportConflictingKeys.actor.cpp +++ b/fdbserver/workloads/ReportConflictingKeys.actor.cpp @@ -38,7 +38,7 @@ struct ReportConflictingKeysWorkload : TestWorkload { PerfIntCounter invalidReports, commits, conflicts, xacts; ReportConflictingKeysWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), invalidReports("InvalidReports"), conflicts("Conflicts"), commits("Commits"), + : TestWorkload(wcx), invalidReports("InvalidReports"), commits("commits"), conflicts("Conflicts"), xacts("Transactions") { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); // transactionsPerSecond = getOption(options, LiteralStringRef("transactionsPerSecond"), 5000.0) / clientCount; diff --git a/fdbserver/workloads/Storefront.actor.cpp b/fdbserver/workloads/Storefront.actor.cpp index 9988385cfd..20e87702e8 100644 --- a/fdbserver/workloads/Storefront.actor.cpp +++ b/fdbserver/workloads/Storefront.actor.cpp @@ -41,8 +41,8 @@ struct StorefrontWorkload : TestWorkload { PerfDoubleCounter totalLatency; StorefrontWorkload(WorkloadContext const& wcx) - : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), totalLatency("Total Latency"), - spuriousCommitFailures("Spurious Commit Failures") { + : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), + spuriousCommitFailures("Spurious Commit Failures"), totalLatency("Total Latency") { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); transactionsPerSecond = getOption(options, LiteralStringRef("transactionsPerSecond"), 1000.0); actorCount = diff --git a/fdbserver/workloads/TPCC.actor.cpp b/fdbserver/workloads/TPCC.actor.cpp index 32c8e3c9d3..400e2cd63b 100644 --- a/fdbserver/workloads/TPCC.actor.cpp +++ b/fdbserver/workloads/TPCC.actor.cpp @@ -31,23 +31,23 @@ namespace { struct TPCCMetrics { static constexpr int latenciesStored = 1000; - uint64_t successfulStockLevelTransactions, failedStockLevelTransactions, successfulDeliveryTransactions, - failedDeliveryTransactions, successfulOrderStatusTransactions, failedOrderStatusTransactions, - successfulPaymentTransactions, failedPaymentTransactions, successfulNewOrderTransactions, - failedNewOrderTransactions; - double stockLevelResponseTime, deliveryResponseTime, orderStatusResponseTime, paymentResponseTime, - newOrderResponseTime; + uint64_t successfulStockLevelTransactions{ 0 }; + uint64_t failedStockLevelTransactions{ 0 }; + uint64_t successfulDeliveryTransactions{ 0 }; + uint64_t failedDeliveryTransactions{ 0 }; + uint64_t successfulOrderStatusTransactions{ 0 }; + uint64_t failedOrderStatusTransactions{ 0 }; + uint64_t successfulPaymentTransactions{ 0 }; + uint64_t failedPaymentTransactions{ 0 }; + uint64_t successfulNewOrderTransactions{ 0 }; + uint64_t failedNewOrderTransactions{ 0 }; + double stockLevelResponseTime{ 0.0 }; + double deliveryResponseTime{ 0.0 }; + double orderStatusResponseTime{ 0.0 }; + double paymentResponseTime{ 0.0 }; + double newOrderResponseTime{ 0.0 }; std::vector stockLevelLatencies, deliveryLatencies, orderStatusLatencies, paymentLatencies, newOrderLatencies; - TPCCMetrics() - : successfulStockLevelTransactions(0), successfulDeliveryTransactions(0), successfulOrderStatusTransactions(0), - successfulPaymentTransactions(0), successfulNewOrderTransactions(0), failedStockLevelTransactions(0), - failedDeliveryTransactions(0), failedOrderStatusTransactions(0), failedPaymentTransactions(0), - failedNewOrderTransactions(0), stockLevelResponseTime(0.0), deliveryResponseTime(0.0), - orderStatusResponseTime(0.0), paymentResponseTime(0.0), newOrderResponseTime(0.0), - stockLevelLatencies(latenciesStored, 0.0), deliveryLatencies(latenciesStored, 0.0), - orderStatusLatencies(latenciesStored, 0.0), paymentLatencies(latenciesStored, 0.0), - newOrderLatencies(latenciesStored, 0.0) {} void sort() { std::sort(stockLevelLatencies.begin(), stockLevelLatencies.end()); diff --git a/fdbserver/workloads/ThreadSafety.actor.cpp b/fdbserver/workloads/ThreadSafety.actor.cpp index a04f9293c0..313732f209 100644 --- a/fdbserver/workloads/ThreadSafety.actor.cpp +++ b/fdbserver/workloads/ThreadSafety.actor.cpp @@ -121,7 +121,7 @@ struct ThreadSafetyWorkload : TestWorkload { Reference tr; - ThreadSafetyWorkload(WorkloadContext const& wcx) : TestWorkload(wcx), tr(nullptr), stopped(false) { + ThreadSafetyWorkload(WorkloadContext const& wcx) : TestWorkload(wcx), stopped(false) { threadsPerClient = getOption(options, LiteralStringRef("threadsPerClient"), 3); threadDuration = getOption(options, LiteralStringRef("threadDuration"), 60.0); diff --git a/fdbserver/workloads/Throughput.actor.cpp b/fdbserver/workloads/Throughput.actor.cpp index b8b5553166..ea9f235563 100644 --- a/fdbserver/workloads/Throughput.actor.cpp +++ b/fdbserver/workloads/Throughput.actor.cpp @@ -57,8 +57,8 @@ struct RWTransactor : ITransactor { int keyCount, keyBytes; RWTransactor(int reads, int writes, int keyCount, int keyBytes, int minValueBytes, int maxValueBytes) - : reads(reads), writes(writes), keyCount(keyCount), keyBytes(keyBytes), minValueBytes(minValueBytes), - maxValueBytes(maxValueBytes) { + : reads(reads), writes(writes), minValueBytes(minValueBytes), maxValueBytes(maxValueBytes), keyCount(keyCount), + keyBytes(keyBytes) { ASSERT(minValueBytes <= maxValueBytes); valueString = std::string(maxValueBytes, '.'); } @@ -138,7 +138,7 @@ struct ABTransactor : ITransactor { Reference a, b; double alpha; // 0.0 = all a, 1.0 = all b - ABTransactor(double alpha, Reference a, Reference b) : alpha(alpha), a(a), b(b) {} + ABTransactor(double alpha, Reference a, Reference b) : a(a), b(b), alpha(alpha) {} Future doTransaction(Database const& db, Stats* stats) override { return deterministicRandom()->random01() >= alpha ? a->doTransaction(db, stats) : b->doTransaction(db, stats); @@ -154,7 +154,7 @@ struct SweepTransactor : ITransactor { double duration; SweepTransactor(double duration, double startDelay, Reference a, Reference b) - : a(a), b(b), duration(duration), startTime(-1), startDelay(startDelay) {} + : a(a), b(b), startTime(-1), startDelay(startDelay), duration(duration) {} Future doTransaction(Database const& db, Stats* stats) override { if (startTime == -1) diff --git a/fdbserver/workloads/WriteBandwidth.actor.cpp b/fdbserver/workloads/WriteBandwidth.actor.cpp index 6d04b3cf2d..5382daf744 100644 --- a/fdbserver/workloads/WriteBandwidth.actor.cpp +++ b/fdbserver/workloads/WriteBandwidth.actor.cpp @@ -38,8 +38,8 @@ struct WriteBandwidthWorkload : KVWorkload { ContinuousSample commitLatencies, GRVLatencies; WriteBandwidthWorkload(WorkloadContext const& wcx) - : KVWorkload(wcx), commitLatencies(2000), GRVLatencies(2000), loadTime(0.0), transactions("Transactions"), - retries("Retries") { + : KVWorkload(wcx), loadTime(0.0), transactions("Transactions"), retries("Retries"), commitLatencies(2000), + GRVLatencies(2000) { testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0); keysPerTransaction = getOption(options, LiteralStringRef("keysPerTransaction"), 100); valueString = std::string(maxValueBytes, '.'); diff --git a/fdbserver/workloads/WriteTagThrottling.actor.cpp b/fdbserver/workloads/WriteTagThrottling.actor.cpp index 5f9e3c2a8d..e943db4b58 100644 --- a/fdbserver/workloads/WriteTagThrottling.actor.cpp +++ b/fdbserver/workloads/WriteTagThrottling.actor.cpp @@ -64,8 +64,8 @@ struct WriteTagThrottlingWorkload : KVWorkload { static constexpr int MIN_TRANSACTION_TAG_LENGTH = 2; WriteTagThrottlingWorkload(WorkloadContext const& wcx) - : KVWorkload(wcx), badActorCommitLatency(SAMPLE_SIZE), badActorReadLatency(SAMPLE_SIZE), - goodActorCommitLatency(SAMPLE_SIZE), goodActorReadLatency(SAMPLE_SIZE) { + : KVWorkload(wcx), badActorReadLatency(SAMPLE_SIZE), goodActorReadLatency(SAMPLE_SIZE), + badActorCommitLatency(SAMPLE_SIZE), goodActorCommitLatency(SAMPLE_SIZE) { testDuration = getOption(options, LiteralStringRef("testDuration"), 120.0); badOpRate = getOption(options, LiteralStringRef("badOpRate"), 0.9); numWritePerTr = getOption(options, LiteralStringRef("numWritePerTr"), 1); diff --git a/fdbserver/workloads/workloads.actor.h b/fdbserver/workloads/workloads.actor.h index 5829b19fa6..702a408968 100644 --- a/fdbserver/workloads/workloads.actor.h +++ b/fdbserver/workloads/workloads.actor.h @@ -166,7 +166,7 @@ public: double startDelay = 30.0, bool useDB = true, double databasePingDelay = -1.0) - : title(title), dumpAfterTest(dump), clearAfterTest(clear), startDelay(startDelay), useDB(useDB), timeout(600), + : title(title), dumpAfterTest(dump), clearAfterTest(clear), useDB(useDB), startDelay(startDelay), timeout(600), databasePingDelay(databasePingDelay), runConsistencyCheck(g_network->isSimulated()), runConsistencyCheckOnCache(false), runConsistencyCheckOnTSS(false), waitForQuiescenceBegin(true), waitForQuiescenceEnd(true), restorePerpetualWiggleSetting(true), simCheckRelocationDuration(false), diff --git a/flow/Deque.h b/flow/Deque.h index fc67dad588..d2156cbf04 100644 --- a/flow/Deque.h +++ b/flow/Deque.h @@ -81,7 +81,7 @@ public: } } - Deque(Deque&& r) noexcept : begin(r.begin), end(r.end), mask(r.mask), arr(r.arr) { + Deque(Deque&& r) noexcept : arr(r.arr), begin(r.begin), end(r.end), mask(r.mask) { r.arr = nullptr; r.begin = r.end = 0; r.mask = -1; diff --git a/flow/FileTraceLogWriter.cpp b/flow/FileTraceLogWriter.cpp index e418c2081d..e57f7502f6 100644 --- a/flow/FileTraceLogWriter.cpp +++ b/flow/FileTraceLogWriter.cpp @@ -91,7 +91,7 @@ FileTraceLogWriter::FileTraceLogWriter(std::string const& directory, std::function const& onError, Reference const& issues) : directory(directory), processName(processName), basename(basename), extension(extension), maxLogsSize(maxLogsSize), - traceFileFD(-1), index(0), onError(onError), issues(issues) {} + traceFileFD(-1), index(0), issues(issues), onError(onError) {} void FileTraceLogWriter::addref() { ReferenceCounted::addref(); diff --git a/flow/Histogram.h b/flow/Histogram.h index fef99d949c..5fa32dbb69 100644 --- a/flow/Histogram.h +++ b/flow/Histogram.h @@ -69,8 +69,7 @@ private: HistogramRegistry& registry, uint32_t lower, uint32_t upper) - : group(group), op(op), unit(unit), registry(registry), lowerBound(lower), - upperBound(upper), ReferenceCounted() { + : group(group), op(op), unit(unit), registry(registry), lowerBound(lower), upperBound(upper) { ASSERT(unit < Unit::MAXHISTOGRAMUNIT); ASSERT(upperBound >= lowerBound); diff --git a/flow/IndexedSet.h b/flow/IndexedSet.h index f7e689ff53..753abdfb11 100644 --- a/flow/IndexedSet.h +++ b/flow/IndexedSet.h @@ -70,7 +70,7 @@ private: // Forward-declare IndexedSet::Node because Clang is much stricter abou // combinations, but still take advantage of move constructors when available (or required). template Node(T_&& data, Metric_&& m, Node* parent = 0) - : data(std::forward(data)), total(std::forward(m)), parent(parent), balance(0) { + : data(std::forward(data)), balance(0), total(std::forward(m)), parent(parent) { child[0] = child[1] = nullptr; } Node(Node const&) = delete; diff --git a/flow/Platform.actor.cpp b/flow/Platform.actor.cpp index bf19de35db..005a2cdbd3 100644 --- a/flow/Platform.actor.cpp +++ b/flow/Platform.actor.cpp @@ -1384,7 +1384,8 @@ struct SystemStatisticsState { HCOUNTER ProcessorIdleCounter; SystemStatisticsState() : Query(nullptr), QueueLengthCounter(nullptr), DiskTimeCounter(nullptr), ReadsCounter(nullptr), - WritesCounter(nullptr), WriteBytesCounter(nullptr), ProcessorIdleCounter(nullptr), + WritesCounter(nullptr), WriteBytesCounter(nullptr), ProcessorIdleCounter(nullptr), lastTime(0), + lastClockThread(0), lastClockProcess(0), processLastSent(0), processLastReceived(0) {} #elif defined(__unixish__) uint64_t machineLastSent, machineLastReceived; uint64_t machineLastOutSegs, machineLastRetransSegs; @@ -1393,12 +1394,11 @@ struct SystemStatisticsState { SystemStatisticsState() : machineLastSent(0), machineLastReceived(0), machineLastOutSegs(0), machineLastRetransSegs(0), lastBusyTicks(0), lastReads(0), lastWrites(0), lastWriteSectors(0), lastReadSectors(0), lastClockIdleTime(0), - lastClockTotalTime(0), + lastClockTotalTime(0), lastTime(0), lastClockThread(0), lastClockProcess(0), processLastSent(0), + processLastReceived(0) {} #else #error Port me! #endif - lastTime(0), lastClockThread(0), lastClockProcess(0), processLastSent(0), processLastReceived(0) { - } }; #if defined(_WIN32) diff --git a/flow/TDMetric.actor.h b/flow/TDMetric.actor.h index 21944dd0e7..03287984d3 100644 --- a/flow/TDMetric.actor.h +++ b/flow/TDMetric.actor.h @@ -231,8 +231,8 @@ struct MetricData { BinaryWriter writer; explicit MetricData(uint64_t appendStart = 0) - : writer(AssumeVersion(g_network->protocolVersion())), start(0), rollTime(std::numeric_limits::max()), - appendStart(appendStart) {} + : start(0), rollTime(std::numeric_limits::max()), appendStart(appendStart), + writer(AssumeVersion(g_network->protocolVersion())) {} MetricData(MetricData&& r) noexcept : start(r.start), rollTime(r.rollTime), appendStart(r.appendStart), writer(std::move(r.writer)) {} @@ -720,7 +720,7 @@ struct TimeDescriptor { }; struct BaseMetric { - BaseMetric(MetricNameRef const& name) : metricName(name), pCollection(nullptr), registered(false), enabled(false) { + BaseMetric(MetricNameRef const& name) : metricName(name), enabled(false), pCollection(nullptr), registered(false) { setConfig(false); } virtual ~BaseMetric() {} diff --git a/flow/Trace.h b/flow/Trace.h index 57f4911d8c..ac9da282bc 100644 --- a/flow/Trace.h +++ b/flow/Trace.h @@ -510,7 +510,7 @@ private: class StringRef; struct TraceInterval { - TraceInterval(const char* type) : count(-1), type(type), severity(SevInfo) {} + TraceInterval(const char* type) : type(type), count(-1), severity(SevInfo) {} TraceInterval& begin(); TraceInterval& end() { return *this; } diff --git a/flow/flat_buffers.h b/flow/flat_buffers.h index 4fe5fb524e..95faa6dfbc 100644 --- a/flow/flat_buffers.h +++ b/flow/flat_buffers.h @@ -480,8 +480,8 @@ struct WriteToBuffer : Context { int vtable_start, uint8_t* buffer, std::vector::iterator writeToOffsetsIter) - : Context(context), buffer_length(buffer_length), vtable_start(vtable_start), buffer(buffer), - writeToOffsetsIter(writeToOffsetsIter) {} + : Context(context), buffer_length(buffer_length), vtable_start(vtable_start), + writeToOffsetsIter(writeToOffsetsIter), buffer(buffer) {} struct MessageWriter { template diff --git a/flow/flow.h b/flow/flow.h index b598f82987..9b65ffc864 100644 --- a/flow/flow.h +++ b/flow/flow.h @@ -434,7 +434,7 @@ public: T& value() { return *(T*)&value_storage; } SAV(int futures, int promises) - : futures(futures), promises(promises), error_state(Error::fromCode(UNSET_ERROR_CODE)) { + : promises(promises), futures(futures), error_state(Error::fromCode(UNSET_ERROR_CODE)) { Callback::prev = Callback::next = this; } ~SAV() { @@ -763,7 +763,7 @@ struct NotifiedQueue : private SingleCallback, FastAllocated Promise onEmpty; Error error; - NotifiedQueue(int futures, int promises) : futures(futures), promises(promises), onEmpty(nullptr) { + NotifiedQueue(int futures, int promises) : promises(promises), futures(futures), onEmpty(nullptr) { SingleCallback::next = this; } diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index 30794d9791..0a86fc6bc3 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -1543,10 +1543,10 @@ struct BoundedFlowLock : NonCopyable, public ReferenceCounted { } }; - BoundedFlowLock() : unrestrictedPermits(1), boundedPermits(0), nextPermitNumber(0), minOutstanding(0) {} + BoundedFlowLock() : minOutstanding(0), nextPermitNumber(0), unrestrictedPermits(1), boundedPermits(0) {} explicit BoundedFlowLock(int64_t unrestrictedPermits, int64_t boundedPermits) - : unrestrictedPermits(unrestrictedPermits), boundedPermits(boundedPermits), nextPermitNumber(0), - minOutstanding(0) {} + : minOutstanding(0), nextPermitNumber(0), unrestrictedPermits(unrestrictedPermits), + boundedPermits(boundedPermits) {} Future take() { return takeActor(this); } void release(int64_t permitNumber) { diff --git a/flow/serialize.h b/flow/serialize.h index 940747a504..07f70b1f24 100644 --- a/flow/serialize.h +++ b/flow/serialize.h @@ -527,7 +527,7 @@ public: typedef OverWriter WRITER; template - explicit OverWriter(SplitBuffer buf, VersionOptions vo) : buf(buf), len(std::numeric_limits::max()) { + explicit OverWriter(SplitBuffer buf, VersionOptions vo) : len(std::numeric_limits::max()), buf(buf) { vo.write(*this); } From 9af401b2059a6e521199fabeb6ed956672d559ae Mon Sep 17 00:00:00 2001 From: Clement Pang Date: Sat, 24 Jul 2021 09:10:46 +0800 Subject: [PATCH 091/225] Add comments to orEqual() --- .../java/src/main/com/apple/foundationdb/KeySelector.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bindings/java/src/main/com/apple/foundationdb/KeySelector.java b/bindings/java/src/main/com/apple/foundationdb/KeySelector.java index 9c66aa0830..5061b51ba7 100644 --- a/bindings/java/src/main/com/apple/foundationdb/KeySelector.java +++ b/bindings/java/src/main/com/apple/foundationdb/KeySelector.java @@ -165,7 +165,11 @@ public class KeySelector { } /** - * Returns the {@code or-equal} parameter of this {@code KeySelector}. For internal use. + * Returns the orEqual parameter for this {@code KeySelector}. See the + * {@link #KeySelector(byte[], boolean, int)} KeySelector constructor} + * for more details. + * + * @return the {@code or-equal} parameter of this {@code KeySelector}. */ public boolean orEqual() { return orEqual; From 64dc1dc185b3ab0b2b271f5474c6301d24a70824 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 00:23:06 -0700 Subject: [PATCH 092/225] Fix -Wreorder-ctor warnings in NativeAPI.actor.cpp and several other files --- fdbclient/MultiVersionAssignmentVars.h | 2 +- fdbclient/NativeAPI.actor.cpp | 47 ++++++++++----------- fdbclient/ReadYourWrites.actor.cpp | 15 ++++--- fdbrpc/AsyncFileNonDurable.actor.h | 2 +- fdbrpc/sim2.actor.cpp | 6 +-- fdbserver/DBCoreState.h | 2 +- fdbserver/GrvProxyServer.actor.cpp | 8 ++-- fdbserver/LogSystemPeekCursor.actor.cpp | 7 ++- fdbserver/OldTLogServer_6_0.actor.cpp | 35 ++++++++------- fdbserver/TagPartitionedLogSystem.actor.cpp | 12 +++--- flow/Platform.actor.cpp | 6 +-- flow/TDMetric.cpp | 2 +- 12 files changed, 72 insertions(+), 72 deletions(-) diff --git a/fdbclient/MultiVersionAssignmentVars.h b/fdbclient/MultiVersionAssignmentVars.h index c21af9f96d..58b68713de 100644 --- a/fdbclient/MultiVersionAssignmentVars.h +++ b/fdbclient/MultiVersionAssignmentVars.h @@ -281,7 +281,7 @@ template class FlatMapSingleAssignmentVar final : public ThreadSingleAssignmentVar, ThreadCallback { public: FlatMapSingleAssignmentVar(ThreadFuture source, std::function>(ErrorOr)> mapValue) - : source(source), mapValue(mapValue), cancelled(false), released(false) { + : source(source), cancelled(false), released(false), mapValue(mapValue) { ThreadSingleAssignmentVar::addref(); int userParam; diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 20d2b9343d..c9f2d438e6 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -116,10 +116,10 @@ TLSConfig tlsConfig(TLSEndpointType::CLIENT); // The default values, TRACE_DEFAULT_ROLL_SIZE and TRACE_DEFAULT_MAX_LOGS_SIZE are located in Trace.h. NetworkOptions::NetworkOptions() - : localAddress(""), clusterFile(""), traceDirectory(Optional()), traceRollSize(TRACE_DEFAULT_ROLL_SIZE), - traceMaxLogsSize(TRACE_DEFAULT_MAX_LOGS_SIZE), traceLogGroup("default"), traceFormat("xml"), - traceClockSource("now"), runLoopProfilingEnabled(false), - supportedVersions(new ReferencedObject>>()) {} + : traceRollSize(TRACE_DEFAULT_ROLL_SIZE), traceMaxLogsSize(TRACE_DEFAULT_MAX_LOGS_SIZE), traceLogGroup("default"), + traceFormat("xml"), traceClockSource("now"), + supportedVersions(new ReferencedObject>>()), runLoopProfilingEnabled(false) { +} static const Key CLIENT_LATENCY_INFO_PREFIX = LiteralStringRef("client_latency/"); static const Key CLIENT_LATENCY_INFO_CTR_PREFIX = LiteralStringRef("client_latency_counter/"); @@ -1094,11 +1094,10 @@ DatabaseContext::DatabaseContext(ReferenceSHARD_STAT_SMOOTH_AMOUNT), - transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), + transactionsProcessBehind("ProcessBehind", cc), transactionsThrottled("Throttled", cc), + transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), latencies(1000), readLatencies(1000), + commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), outstandingWatches(0), + transactionTracingEnabled(true), taskID(taskID), clientInfo(clientInfo), clientInfoMonitor(clientInfoMonitor), + coordinator(coordinator), apiVersion(apiVersion), mvCacheInsertLocation(0), healthMetricsLastUpdated(0), + detailedHealthMetricsLastUpdated(0), smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT), specialKeySpace(std::make_unique(specialKeys.begin, specialKeys.end, /* test */ false)) { dbId = deterministicRandom()->randomUniqueID(); connected = (clientInfo->get().commitProxies.size() && clientInfo->get().grvProxies.size()) @@ -1340,8 +1340,8 @@ DatabaseContext::DatabaseContext(ReferenceSHARD_STAT_SMOOTH_AMOUNT), - transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), internal(IsInternal::False), - transactionTracingEnabled(true) {} + transactionsProcessBehind("ProcessBehind", cc), transactionsThrottled("Throttled", cc), + transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), latencies(1000), readLatencies(1000), + commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), + transactionTracingEnabled(true), smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT) {} // Static constructor used by server processes to create a DatabaseContext // For internal (fdbserver) use only @@ -4093,9 +4092,9 @@ Transaction::Transaction() : info(TaskPriority::DefaultEndpoint, generateSpanID(true)), span(info.spanID, "Transaction"_loc) {} Transaction::Transaction(Database const& cx) - : cx(cx), info(cx->taskID, generateSpanID(cx->transactionTracingEnabled)), backoff(CLIENT_KNOBS->DEFAULT_BACKOFF), - committedVersion(invalidVersion), versionstampPromise(Promise>()), options(cx), numErrors(0), - trLogInfo(createTrLogInfoProbabilistically(cx)), tr(info.spanID), span(info.spanID, "Transaction"_loc) { + : info(cx->taskID, generateSpanID(cx->transactionTracingEnabled)), numErrors(0), options(cx), + span(info.spanID, "Transaction"_loc), trLogInfo(createTrLogInfoProbabilistically(cx)), cx(cx), + backoff(CLIENT_KNOBS->DEFAULT_BACKOFF), committedVersion(invalidVersion), tr(info.spanID) { if (DatabaseContext::debugUseTags) { debugAddTags(this); } diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index f3f9a391c7..9ef5217b0c 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -1285,9 +1285,9 @@ public: }; ReadYourWritesTransaction::ReadYourWritesTransaction(Database const& cx) - : ISingleThreadTransaction(cx->deferredError), cache(&arena), writes(&arena), tr(cx), retries(0), approximateSize(0), - creationTime(now()), commitStarted(false), options(tr), versionStampFuture(tr.getVersionstamp()), - specialKeySpaceWriteMap(std::make_pair(false, Optional()), specialKeys.end) { + : ISingleThreadTransaction(cx->deferredError), tr(cx), cache(&arena), writes(&arena), retries(0), approximateSize(0), + creationTime(now()), commitStarted(false), versionStampFuture(tr.getVersionstamp()), + specialKeySpaceWriteMap(std::make_pair(false, Optional()), specialKeys.end), options(tr) { std::copy( cx.getTransactionDefaults().begin(), cx.getTransactionDefaults().end(), std::back_inserter(persistentOptions)); applyPersistentOptions(); @@ -2284,10 +2284,11 @@ void ReadYourWritesTransaction::operator=(ReadYourWritesTransaction&& r) noexcep } ReadYourWritesTransaction::ReadYourWritesTransaction(ReadYourWritesTransaction&& r) noexcept - : ISingleThreadTransaction(std::move(r.deferredError)), cache(std::move(r.cache)), writes(std::move(r.writes)), - arena(std::move(r.arena)), reading(std::move(r.reading)), retries(r.retries), approximateSize(r.approximateSize), - creationTime(r.creationTime), timeoutActor(std::move(r.timeoutActor)), resetPromise(std::move(r.resetPromise)), - commitStarted(r.commitStarted), options(r.options), transactionDebugInfo(r.transactionDebugInfo) { + : ISingleThreadTransaction(std::move(r.deferredError)), arena(std::move(r.arena)), cache(std::move(r.cache)), + writes(std::move(r.writes)), resetPromise(std::move(r.resetPromise)), reading(std::move(r.reading)), + retries(r.retries), approximateSize(r.approximateSize), timeoutActor(std::move(r.timeoutActor)), + creationTime(r.creationTime), commitStarted(r.commitStarted), transactionDebugInfo(r.transactionDebugInfo), + options(r.options) { cache.arena = &arena; writes.arena = &arena; tr = std::move(r.tr); diff --git a/fdbrpc/AsyncFileNonDurable.actor.h b/fdbrpc/AsyncFileNonDurable.actor.h index f89d804670..a9578619fc 100644 --- a/fdbrpc/AsyncFileNonDurable.actor.h +++ b/fdbrpc/AsyncFileNonDurable.actor.h @@ -191,7 +191,7 @@ private: NetworkAddress openedAddress, bool aio) : filename(filename), initialFilename(initialFilename), approximateSize(0), openedAddress(openedAddress), - aio(aio), file(file), diskParameters(diskParameters), pendingModifications(uint64_t(-1)), reponses(false) { + aio(aio), file(file), pendingModifications(uint64_t(-1)), diskParameters(diskParameters), reponses(false) { // This is only designed to work in simulation ASSERT(g_network->isSimulated()); diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index fe7ded16e5..6023072e3f 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -2012,13 +2012,13 @@ public: ProcessInfo* machine; Promise action; Task(double time, TaskPriority taskID, uint64_t stable, ProcessInfo* machine, Promise&& action) - : time(time), taskID(taskID), stable(stable), machine(machine), action(std::move(action)) {} + : taskID(taskID), time(time), stable(stable), machine(machine), action(std::move(action)) {} Task(double time, TaskPriority taskID, uint64_t stable, ProcessInfo* machine, Future& future) - : time(time), taskID(taskID), stable(stable), machine(machine) { + : taskID(taskID), time(time), stable(stable), machine(machine) { future = action.getFuture(); } Task(Task&& rhs) noexcept - : time(rhs.time), taskID(rhs.taskID), stable(rhs.stable), machine(rhs.machine), + : taskID(rhs.taskID), time(rhs.time), stable(rhs.stable), machine(rhs.machine), action(std::move(rhs.action)) {} void operator=(Task const& rhs) { taskID = rhs.taskID; diff --git a/fdbserver/DBCoreState.h b/fdbserver/DBCoreState.h index b95c6359d0..6b4a747240 100644 --- a/fdbserver/DBCoreState.h +++ b/fdbserver/DBCoreState.h @@ -97,7 +97,7 @@ struct OldTLogCoreData { std::set pseudoLocalities; LogEpoch epoch; - OldTLogCoreData() : epochBegin(0), epochEnd(0), logRouterTags(0), txsTags(0), epoch(0) {} + OldTLogCoreData() : logRouterTags(0), txsTags(0), epochBegin(0), epochEnd(0), epoch(0) {} explicit OldTLogCoreData(const OldLogData&); bool operator==(const OldTLogCoreData& rhs) const { diff --git a/fdbserver/GrvProxyServer.actor.cpp b/fdbserver/GrvProxyServer.actor.cpp index 3ebf2931e6..40a2d5d874 100644 --- a/fdbserver/GrvProxyServer.actor.cpp +++ b/fdbserver/GrvProxyServer.actor.cpp @@ -81,8 +81,8 @@ struct GrvProxyStats { // Current stats maintained for a given grv proxy server explicit GrvProxyStats(UID id) - : cc("GrvProxyStats", id.toString()), recentRequests(0), lastBucketBegin(now()), - bucketInterval(FLOW_KNOBS->BASIC_LOAD_BALANCE_UPDATE_RATE / FLOW_KNOBS->BASIC_LOAD_BALANCE_BUCKETS), + : cc("GrvProxyStats", id.toString()), + txnRequestIn("TxnRequestIn", cc), txnRequestOut("TxnRequestOut", cc), txnRequestErrors("TxnRequestErrors", cc), txnStartIn("TxnStartIn", cc), txnStartOut("TxnStartOut", cc), txnStartBatch("TxnStartBatch", cc), txnSystemPriorityStartIn("TxnSystemPriorityStartIn", cc), @@ -102,6 +102,7 @@ struct GrvProxyStats { id, SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL, SERVER_KNOBS->LATENCY_SAMPLE_SIZE), + grvLatencyBands("GRVLatencyBands", id, SERVER_KNOBS->STORAGE_LOGGING_DELAY), grvLatencySample("GRVLatencyMetrics", id, SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL, @@ -110,7 +111,8 @@ struct GrvProxyStats { id, SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL, SERVER_KNOBS->LATENCY_SAMPLE_SIZE), - grvLatencyBands("GRVLatencyBands", id, SERVER_KNOBS->STORAGE_LOGGING_DELAY) { + recentRequests(0), lastBucketBegin(now()), + bucketInterval(FLOW_KNOBS->BASIC_LOAD_BALANCE_UPDATE_RATE / FLOW_KNOBS->BASIC_LOAD_BALANCE_BUCKETS) { // The rate at which the limit(budget) is allowed to grow. specialCounter(cc, "SystemGRVQueueSize", [this]() { return this->systemGRVQueueSize; }); specialCounter(cc, "DefaultGRVQueueSize", [this]() { return this->defaultGRVQueueSize; }); diff --git a/fdbserver/LogSystemPeekCursor.actor.cpp b/fdbserver/LogSystemPeekCursor.actor.cpp index 32dbe29831..1886d05449 100644 --- a/fdbserver/LogSystemPeekCursor.actor.cpp +++ b/fdbserver/LogSystemPeekCursor.actor.cpp @@ -1154,10 +1154,9 @@ ILogSystem::BufferedCursor::BufferedCursor(std::vector> c bool withTags, bool collectTags, bool canDiscardPopped) - : cursors(cursors), messageVersion(begin), end(end), withTags(withTags), collectTags(collectTags), - hasNextMessage(false), messageIndex(0), poppedVersion(0), initialPoppedVersion(0), - canDiscardPopped(canDiscardPopped), knownUnique(false), minKnownCommittedVersion(0), - randomID(deterministicRandom()->randomUniqueID()) { + : cursors(cursors), messageIndex(0), messageVersion(begin), end(end), hasNextMessage(false), withTags(withTags), + poppedVersion(0), initialPoppedVersion(0), canDiscardPopped(canDiscardPopped), knownUnique(false), + minKnownCommittedVersion(0), randomID(deterministicRandom()->randomUniqueID()), collectTags(collectTags) { targetQueueSize = SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES / cursors.size(); messages.reserve(SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES); cursorMessages.resize(cursors.size()); diff --git a/fdbserver/OldTLogServer_6_0.actor.cpp b/fdbserver/OldTLogServer_6_0.actor.cpp index 35cbc42535..0de80a420d 100644 --- a/fdbserver/OldTLogServer_6_0.actor.cpp +++ b/fdbserver/OldTLogServer_6_0.actor.cpp @@ -57,7 +57,7 @@ struct TLogQueueEntryRef { TLogQueueEntryRef() : version(0), knownCommittedVersion(0) {} TLogQueueEntryRef(Arena& a, TLogQueueEntryRef const& from) - : version(from.version), knownCommittedVersion(from.knownCommittedVersion), id(from.id), + : id(from.id), version(from.version), knownCommittedVersion(from.knownCommittedVersion), messages(a, from.messages) {} template @@ -304,13 +304,13 @@ struct TLogData : NonCopyable { Reference const> dbInfo, Reference> degraded, std::string folder) - : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), - persistentData(persistentData), rawPersistentQueue(persistentQueue), - persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), degraded(degraded), queueCommitBegin(0), - queueCommitEnd(0), diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), bytesInput(0), bytesDurable(0), + : dbgid(dbgid), workerID(workerID), persistentData(persistentData), rawPersistentQueue(persistentQueue), + persistentQueue(new TLogQueue(persistentQueue, dbgid)), diskQueueCommitBytes(0), + largeDiskQueueCommitBytes(false), dbInfo(dbInfo), queueCommitEnd(0), queueCommitBegin(0), + instanceID(deterministicRandom()->randomUniqueID().first()), bytesInput(0), bytesDurable(0), targetVolatileBytes(SERVER_KNOBS->TLOG_SPILL_THRESHOLD), overheadBytesInput(0), overheadBytesDurable(0), concurrentLogRouterReads(SERVER_KNOBS->CONCURRENT_LOG_ROUTER_READS), ignorePopRequest(false), - ignorePopDeadline(), ignorePopUid(), dataFolder(folder), toBePopped() { + dataFolder(folder), degraded(degraded) { cx = openDBOnServer(dbInfo, TaskPriority::DefaultEndpoint, LockAware::True); } }; @@ -326,12 +326,12 @@ struct LogData : NonCopyable, public ReferenceCounted { Tag tag; TagData(Tag tag, Version popped, bool nothingPersistent, bool poppedRecently, bool unpoppedRecovered) - : tag(tag), nothingPersistent(nothingPersistent), popped(popped), poppedRecently(poppedRecently), - unpoppedRecovered(unpoppedRecovered) {} + : nothingPersistent(nothingPersistent), poppedRecently(poppedRecently), popped(popped), + unpoppedRecovered(unpoppedRecovered), tag(tag) {} TagData(TagData&& r) noexcept : versionMessages(std::move(r.versionMessages)), nothingPersistent(r.nothingPersistent), - poppedRecently(r.poppedRecently), popped(r.popped), tag(r.tag), unpoppedRecovered(r.unpoppedRecovered) {} + poppedRecently(r.poppedRecently), popped(r.popped), unpoppedRecovered(r.unpoppedRecovered), tag(r.tag) {} void operator=(TagData&& r) noexcept { versionMessages = std::move(r.versionMessages); nothingPersistent = r.nothingPersistent; @@ -524,15 +524,14 @@ struct LogData : NonCopyable, public ReferenceCounted { UID recruitmentID, std::vector tags, std::string context) - : tLogData(tLogData), knownCommittedVersion(0), logId(interf.id()), cc("TLog", interf.id().toString()), - bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), remoteTag(remoteTag), isPrimary(isPrimary), - logRouterTags(logRouterTags), txsTags(txsTags), recruitmentID(recruitmentID), - logSystem(new AsyncVar>()), logRouterPoppedVersion(0), durableKnownCommittedVersion(0), - minKnownCommittedVersion(0), allTags(tags.begin(), tags.end()), terminated(tLogData->terminated.getFuture()), - // These are initialized differently on init() or recovery - recoveryCount(), stopped(false), initialized(false), queueCommittingVersion(0), - newPersistentDataVersion(invalidVersion), unrecoveredBefore(1), recoveredAt(1), unpoppedRecoveredTags(0), - logRouterPopToVersion(0), locality(tagLocalityInvalid), execOpCommitInProgress(false) { + : stopped(false), initialized(false), queueCommittingVersion(0), knownCommittedVersion(0), + durableKnownCommittedVersion(0), minKnownCommittedVersion(0), unpoppedRecoveredTags(0), + cc("TLog", interf.id().toString()), bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), + logId(interf.id()), newPersistentDataVersion(invalidVersion), tLogData(tLogData), unrecoveredBefore(1), + recoveredAt(1), logSystem(new AsyncVar>()), remoteTag(remoteTag), isPrimary(isPrimary), + logRouterTags(logRouterTags), logRouterPoppedVersion(0), logRouterPopToVersion(0), locality(tagLocalityInvalid), + recruitmentID(recruitmentID), allTags(tags.begin(), tags.end()), terminated(tLogData->terminated.getFuture()), + execOpCommitInProgress(false), txsTags(txsTags) { startRole(Role::TRANSACTION_LOG, interf.id(), tLogData->workerID, diff --git a/fdbserver/TagPartitionedLogSystem.actor.cpp b/fdbserver/TagPartitionedLogSystem.actor.cpp index 2ab2b18062..a018f77120 100644 --- a/fdbserver/TagPartitionedLogSystem.actor.cpp +++ b/fdbserver/TagPartitionedLogSystem.actor.cpp @@ -52,7 +52,7 @@ struct OldLogData { std::set pseudoLocalities; LogEpoch epoch; - OldLogData() : epochBegin(0), epochEnd(0), logRouterTags(0), txsTags(0), epoch(0) {} + OldLogData() : logRouterTags(0), txsTags(0), epochBegin(0), epochEnd(0), epoch(0) {} // Constructor for T of OldTLogConf and OldTLogCoreData template @@ -124,8 +124,8 @@ TLogSet::TLogSet(const LogSet& rhs) } OldTLogConf::OldTLogConf(const OldLogData& oldLogData) - : logRouterTags(oldLogData.logRouterTags), txsTags(oldLogData.txsTags), epochBegin(oldLogData.epochBegin), - epochEnd(oldLogData.epochEnd), pseudoLocalities(oldLogData.pseudoLocalities), epoch(oldLogData.epoch) { + : epochBegin(oldLogData.epochBegin), epochEnd(oldLogData.epochEnd), logRouterTags(oldLogData.logRouterTags), + txsTags(oldLogData.txsTags), pseudoLocalities(oldLogData.pseudoLocalities), epoch(oldLogData.epoch) { for (const Reference& logSet : oldLogData.tLogs) { tLogs.emplace_back(*logSet); } @@ -202,9 +202,9 @@ struct TagPartitionedLogSystem : ILogSystem, ReferenceCounted>> addActor = Optional>>()) : dbgid(dbgid), logSystemType(LogSystemType::empty), expectedLogSets(0), logRouterTags(0), txsTags(0), - repopulateRegionAntiQuorum(0), epoch(e), oldestBackupEpoch(0), recoveryCompleteWrittenToCoreState(false), - locality(locality), remoteLogsWrittenToCoreState(false), hasRemoteServers(false), stopped(false), - addActor(addActor), popActors(false) {} + repopulateRegionAntiQuorum(0), stopped(false), epoch(e), oldestBackupEpoch(0), + recoveryCompleteWrittenToCoreState(false), remoteLogsWrittenToCoreState(false), hasRemoteServers(false), + locality(locality), addActor(addActor), popActors(false) {} void stopRejoins() final { rejoins = Future(); } diff --git a/flow/Platform.actor.cpp b/flow/Platform.actor.cpp index 005a2cdbd3..e2807c8c30 100644 --- a/flow/Platform.actor.cpp +++ b/flow/Platform.actor.cpp @@ -1392,10 +1392,10 @@ struct SystemStatisticsState { uint64_t lastBusyTicks, lastReads, lastWrites, lastWriteSectors, lastReadSectors; uint64_t lastClockIdleTime, lastClockTotalTime; SystemStatisticsState() - : machineLastSent(0), machineLastReceived(0), machineLastOutSegs(0), machineLastRetransSegs(0), lastBusyTicks(0), + : processLastReceived(0), lastTime(0), lastClockThread(0), lastClockProcess(0), processLastSent(0), + machineLastSent(0), machineLastReceived(0), machineLastOutSegs(0), machineLastRetransSegs(0), lastBusyTicks(0), lastReads(0), lastWrites(0), lastWriteSectors(0), lastReadSectors(0), lastClockIdleTime(0), - lastClockTotalTime(0), lastTime(0), lastClockThread(0), lastClockProcess(0), processLastSent(0), - processLastReceived(0) {} + lastClockTotalTime(0) {} #else #error Port me! #endif diff --git a/flow/TDMetric.cpp b/flow/TDMetric.cpp index d1848f9708..98ee9db4d8 100644 --- a/flow/TDMetric.cpp +++ b/flow/TDMetric.cpp @@ -144,7 +144,7 @@ void TDMetricCollection::checkRoll(uint64_t t, int64_t usedBytes) { } DynamicEventMetric::DynamicEventMetric(MetricNameRef const& name, Void) - : BaseEventMetric(name), newFields(false), latestRecorded(false) {} + : latestRecorded(false), BaseEventMetric(name), newFields(false) {} uint64_t DynamicEventMetric::log(uint64_t explicitTime) { if (!enabled) From e006e4fed4eefc434260fdb4d52de56f0ddfe6b7 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 00:48:13 -0700 Subject: [PATCH 093/225] Fix -Wreorder-ctor warnings in LogSystemPeekCursor.actor.cpp and several other files --- fdbrpc/sim2.actor.cpp | 8 +++---- fdbserver/LogSystemPeekCursor.actor.cpp | 31 +++++++++++++------------ flow/Platform.actor.cpp | 2 +- flow/TDMetric.cpp | 2 +- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index 6023072e3f..ddc3d73c32 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -178,7 +178,7 @@ SimClogging g_clogging; struct Sim2Conn final : IConnection, ReferenceCounted { Sim2Conn(ISimulator::ProcessInfo* process) - : process(process), dbgid(deterministicRandom()->randomUniqueID()), opened(false), closedByCaller(false), + : opened(false), closedByCaller(false), process(process), dbgid(deterministicRandom()->randomUniqueID()), stopReceive(Never()) { pipes = sender(this) && receiver(this); } @@ -562,8 +562,8 @@ private: const std::string& filename, const std::string& actualFilename, int flags) - : h(h), diskParameters(diskParameters), delayOnWrite(delayOnWrite), filename(filename), - actualFilename(actualFilename), dbgId(deterministicRandom()->randomUniqueID()), flags(flags) {} + : h(h), diskParameters(diskParameters), filename(filename), actualFilename(actualFilename), flags(flags), + dbgId(deterministicRandom()->randomUniqueID()), delayOnWrite(delayOnWrite) {} static int flagConversion(int flags) { int outFlags = O_BINARY | O_CLOEXEC; @@ -1988,7 +1988,7 @@ public: } Sim2() - : time(0.0), timerTime(0.0), taskCount(0), yielded(false), yield_limit(0), currentTaskID(TaskPriority::Zero) { + : time(0.0), timerTime(0.0), currentTaskID(TaskPriority::Zero), taskCount(0), yielded(false), yield_limit(0) { // Not letting currentProcess be nullptr eliminates some annoying special cases currentProcess = new ProcessInfo("NoMachine", diff --git a/fdbserver/LogSystemPeekCursor.actor.cpp b/fdbserver/LogSystemPeekCursor.actor.cpp index 1886d05449..ca9a12900e 100644 --- a/fdbserver/LogSystemPeekCursor.actor.cpp +++ b/fdbserver/LogSystemPeekCursor.actor.cpp @@ -48,9 +48,10 @@ ILogSystem::ServerPeekCursor::ServerPeekCursor(TLogPeekReply const& results, Version poppedVersion, Tag tag) : tag(tag), results(results), rd(results.arena, results.messages, Unversioned()), messageVersion(messageVersion), - end(end), messageAndTags(message), hasMsg(hasMsg), randomID(deterministicRandom()->randomUniqueID()), - poppedVersion(poppedVersion), returnIfBlocked(false), sequence(0), onlySpilled(false), parallelGetMore(false), - lastReset(0), slowReplies(0), fastReplies(0), unknownReplies(0), resetCheck(Void()) { + end(end), poppedVersion(poppedVersion), messageAndTags(message), hasMsg(hasMsg), + randomID(deterministicRandom()->randomUniqueID()), returnIfBlocked(false), onlySpilled(false), + parallelGetMore(false), sequence(0), lastReset(0), resetCheck(Void()), slowReplies(0), fastReplies(0), + unknownReplies(0) { //TraceEvent("SPC_Clone", randomID); this->results.maxKnownVersion = 0; this->results.minKnownCommittedVersion = 0; @@ -408,8 +409,8 @@ Version ILogSystem::ServerPeekCursor::popped() const { ILogSystem::MergedPeekCursor::MergedPeekCursor(vector> const& serverCursors, Version begin) - : serverCursors(serverCursors), bestServer(-1), readQuorum(serverCursors.size()), tag(invalidTag), currentCursor(0), - hasNextMessage(false), messageVersion(begin), randomID(deterministicRandom()->randomUniqueID()), + : serverCursors(serverCursors), tag(invalidTag), bestServer(-1), currentCursor(0), readQuorum(serverCursors.size()), + messageVersion(begin), hasNextMessage(false), randomID(deterministicRandom()->randomUniqueID()), tLogReplicationFactor(0) { sortedVersions.resize(serverCursors.size()); } @@ -452,8 +453,8 @@ ILogSystem::MergedPeekCursor::MergedPeekCursor(vector nextVersion, Reference logSet, int tLogReplicationFactor) - : serverCursors(serverCursors), bestServer(bestServer), readQuorum(readQuorum), currentCursor(0), - hasNextMessage(false), messageVersion(messageVersion), nextVersion(nextVersion), logSet(logSet), + : logSet(logSet), serverCursors(serverCursors), bestServer(bestServer), currentCursor(0), readQuorum(readQuorum), + nextVersion(nextVersion), messageVersion(messageVersion), hasNextMessage(false), randomID(deterministicRandom()->randomUniqueID()), tLogReplicationFactor(tLogReplicationFactor) { sortedVersions.resize(serverCursors.size()); calcHasMessage(); @@ -697,8 +698,8 @@ ILogSystem::SetPeekCursor::SetPeekCursor(std::vector> const& l Version begin, Version end, bool parallelGetMore) - : logSets(logSets), bestSet(bestSet), bestServer(bestServer), tag(tag), currentCursor(0), currentSet(bestSet), - hasNextMessage(false), messageVersion(begin), useBestSet(true), randomID(deterministicRandom()->randomUniqueID()) { + : logSets(logSets), tag(tag), bestSet(bestSet), bestServer(bestServer), currentSet(bestSet), currentCursor(0), + messageVersion(begin), hasNextMessage(false), useBestSet(true), randomID(deterministicRandom()->randomUniqueID()) { serverCursors.resize(logSets.size()); int maxServers = 0; for (int i = 0; i < logSets.size(); i++) { @@ -719,8 +720,8 @@ ILogSystem::SetPeekCursor::SetPeekCursor(std::vector> const& l int bestServer, Optional nextVersion, bool useBestSet) - : logSets(logSets), serverCursors(serverCursors), messageVersion(messageVersion), bestSet(bestSet), - bestServer(bestServer), nextVersion(nextVersion), currentSet(bestSet), currentCursor(0), hasNextMessage(false), + : logSets(logSets), serverCursors(serverCursors), bestSet(bestSet), bestServer(bestServer), currentSet(bestSet), + currentCursor(0), nextVersion(nextVersion), messageVersion(messageVersion), hasNextMessage(false), useBestSet(useBestSet), randomID(deterministicRandom()->randomUniqueID()) { int maxServers = 0; for (int i = 0; i < logSets.size(); i++) { @@ -1155,8 +1156,8 @@ ILogSystem::BufferedCursor::BufferedCursor(std::vector> c bool collectTags, bool canDiscardPopped) : cursors(cursors), messageIndex(0), messageVersion(begin), end(end), hasNextMessage(false), withTags(withTags), - poppedVersion(0), initialPoppedVersion(0), canDiscardPopped(canDiscardPopped), knownUnique(false), - minKnownCommittedVersion(0), randomID(deterministicRandom()->randomUniqueID()), collectTags(collectTags) { + knownUnique(false), minKnownCommittedVersion(0), poppedVersion(0), initialPoppedVersion(0), + canDiscardPopped(canDiscardPopped), randomID(deterministicRandom()->randomUniqueID()), collectTags(collectTags) { targetQueueSize = SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES / cursors.size(); messages.reserve(SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES); cursorMessages.resize(cursors.size()); @@ -1168,8 +1169,8 @@ ILogSystem::BufferedCursor::BufferedCursor( Version begin, Version end, bool parallelGetMore) - : messageVersion(begin), end(end), withTags(true), messageIndex(0), hasNextMessage(false), poppedVersion(0), - initialPoppedVersion(0), canDiscardPopped(false), knownUnique(true), minKnownCommittedVersion(0), + : messageIndex(0), messageVersion(begin), end(end), hasNextMessage(false), withTags(true), knownUnique(true), + minKnownCommittedVersion(0), poppedVersion(0), initialPoppedVersion(0), canDiscardPopped(false), randomID(deterministicRandom()->randomUniqueID()), collectTags(false) { targetQueueSize = SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES / logServers.size(); messages.reserve(SERVER_KNOBS->DESIRED_OUTSTANDING_MESSAGES); diff --git a/flow/Platform.actor.cpp b/flow/Platform.actor.cpp index e2807c8c30..72b6bf2424 100644 --- a/flow/Platform.actor.cpp +++ b/flow/Platform.actor.cpp @@ -1392,7 +1392,7 @@ struct SystemStatisticsState { uint64_t lastBusyTicks, lastReads, lastWrites, lastWriteSectors, lastReadSectors; uint64_t lastClockIdleTime, lastClockTotalTime; SystemStatisticsState() - : processLastReceived(0), lastTime(0), lastClockThread(0), lastClockProcess(0), processLastSent(0), + : lastTime(0), lastClockThread(0), lastClockProcess(0), processLastSent(0), processLastReceived(0), machineLastSent(0), machineLastReceived(0), machineLastOutSegs(0), machineLastRetransSegs(0), lastBusyTicks(0), lastReads(0), lastWrites(0), lastWriteSectors(0), lastReadSectors(0), lastClockIdleTime(0), lastClockTotalTime(0) {} diff --git a/flow/TDMetric.cpp b/flow/TDMetric.cpp index 98ee9db4d8..002d96c0ca 100644 --- a/flow/TDMetric.cpp +++ b/flow/TDMetric.cpp @@ -144,7 +144,7 @@ void TDMetricCollection::checkRoll(uint64_t t, int64_t usedBytes) { } DynamicEventMetric::DynamicEventMetric(MetricNameRef const& name, Void) - : latestRecorded(false), BaseEventMetric(name), newFields(false) {} + : BaseEventMetric(name), latestRecorded(false), newFields(false) {} uint64_t DynamicEventMetric::log(uint64_t explicitTime) { if (!enabled) From 3442ebd3b7a69cc601252d61a3b06682f3adb6be Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 11:20:51 -0700 Subject: [PATCH 094/225] Fix more -Wreorder-ctor warnings across many files --- .../BackupContainerLocalDirectory.actor.cpp | 3 +- fdbclient/DatabaseBackupAgent.actor.cpp | 25 ++++++++------- fdbclient/MultiVersionTransaction.actor.cpp | 10 +++--- fdbclient/SpecialKeySpace.actor.cpp | 5 +-- fdbclient/TaskBucket.actor.cpp | 13 ++++---- fdbrpc/FlowTransport.actor.cpp | 20 ++++++------ fdbserver/BackupWorker.actor.cpp | 4 +-- fdbserver/ClusterController.actor.cpp | 32 +++++++++---------- fdbserver/ConfigBroadcaster.actor.cpp | 2 +- fdbserver/ConfigDatabaseUnitTests.actor.cpp | 9 +++--- fdbserver/DataDistributionQueue.actor.cpp | 16 +++++----- fdbserver/DataDistributionTracker.actor.cpp | 8 ++--- fdbserver/DiskQueue.actor.cpp | 16 +++++----- fdbserver/KeyValueStoreSQLite.actor.cpp | 12 +++---- fdbserver/LocalConfiguration.actor.cpp | 6 ++-- fdbserver/MetricLogger.actor.cpp | 2 +- fdbserver/Ratekeeper.actor.cpp | 10 +++--- fdbserver/SkipList.cpp | 4 +-- fdbserver/StorageCache.actor.cpp | 22 ++++++------- fdbserver/masterserver.actor.cpp | 16 +++++----- .../workloads/AsyncFileCorrectness.actor.cpp | 2 +- fdbserver/workloads/AsyncFileWrite.actor.cpp | 2 +- flow/Net2.actor.cpp | 19 +++++------ flow/Profiler.actor.cpp | 2 +- flow/Trace.cpp | 21 ++++++------ flow/Tracing.actor.cpp | 2 +- 26 files changed, 142 insertions(+), 141 deletions(-) diff --git a/fdbclient/BackupContainerLocalDirectory.actor.cpp b/fdbclient/BackupContainerLocalDirectory.actor.cpp index b89d085a64..0a397f40c8 100644 --- a/fdbclient/BackupContainerLocalDirectory.actor.cpp +++ b/fdbclient/BackupContainerLocalDirectory.actor.cpp @@ -31,7 +31,8 @@ namespace { class BackupFile : public IBackupFile, ReferenceCounted { public: BackupFile(const std::string& fileName, Reference file, const std::string& finalFullPath) - : IBackupFile(fileName), m_file(file), m_finalFullPath(finalFullPath), m_writeOffset(0), m_blockSize(CLIENT_KNOBS->BACKUP_LOCAL_FILE_WRITE_BLOCK) { + : IBackupFile(fileName), m_file(file), m_writeOffset(0), m_finalFullPath(finalFullPath), + m_blockSize(CLIENT_KNOBS->BACKUP_LOCAL_FILE_WRITE_BLOCK) { if (BUGGIFY) { m_blockSize = deterministicRandom()->randomInt(100, 20000); } diff --git a/fdbclient/DatabaseBackupAgent.actor.cpp b/fdbclient/DatabaseBackupAgent.actor.cpp index a8de6819dd..a7a9c7fbc3 100644 --- a/fdbclient/DatabaseBackupAgent.actor.cpp +++ b/fdbclient/DatabaseBackupAgent.actor.cpp @@ -44,28 +44,29 @@ const Key DatabaseBackupAgent::keyDatabasesInSync = LiteralStringRef("databases_ const int DatabaseBackupAgent::LATEST_DR_VERSION = 1; DatabaseBackupAgent::DatabaseBackupAgent() - : subspace(Subspace(databaseBackupPrefixRange.begin)), tagNames(subspace.get(BackupAgentBase::keyTagName)), - states(subspace.get(BackupAgentBase::keyStates)), config(subspace.get(BackupAgentBase::keyConfig)), - errors(subspace.get(BackupAgentBase::keyErrors)), ranges(subspace.get(BackupAgentBase::keyRanges)), + : subspace(Subspace(databaseBackupPrefixRange.begin)), states(subspace.get(BackupAgentBase::keyStates)), + config(subspace.get(BackupAgentBase::keyConfig)), errors(subspace.get(BackupAgentBase::keyErrors)), + ranges(subspace.get(BackupAgentBase::keyRanges)), tagNames(subspace.get(BackupAgentBase::keyTagName)), + sourceStates(subspace.get(BackupAgentBase::keySourceStates)), + sourceTagNames(subspace.get(BackupAgentBase::keyTagName)), taskBucket(new TaskBucket(subspace.get(BackupAgentBase::keyTasks), AccessSystemKeys::True, PriorityBatch::False, LockAware::True)), - futureBucket(new FutureBucket(subspace.get(BackupAgentBase::keyFutures), AccessSystemKeys::True, LockAware::True)), - sourceStates(subspace.get(BackupAgentBase::keySourceStates)), - sourceTagNames(subspace.get(BackupAgentBase::keyTagName)) {} + futureBucket(new FutureBucket(subspace.get(BackupAgentBase::keyFutures), AccessSystemKeys::True, LockAware::True)) { +} DatabaseBackupAgent::DatabaseBackupAgent(Database src) - : subspace(Subspace(databaseBackupPrefixRange.begin)), tagNames(subspace.get(BackupAgentBase::keyTagName)), - states(subspace.get(BackupAgentBase::keyStates)), config(subspace.get(BackupAgentBase::keyConfig)), - errors(subspace.get(BackupAgentBase::keyErrors)), ranges(subspace.get(BackupAgentBase::keyRanges)), + : subspace(Subspace(databaseBackupPrefixRange.begin)), states(subspace.get(BackupAgentBase::keyStates)), + config(subspace.get(BackupAgentBase::keyConfig)), errors(subspace.get(BackupAgentBase::keyErrors)), + ranges(subspace.get(BackupAgentBase::keyRanges)), tagNames(subspace.get(BackupAgentBase::keyTagName)), + sourceStates(subspace.get(BackupAgentBase::keySourceStates)), + sourceTagNames(subspace.get(BackupAgentBase::keyTagName)), taskBucket(new TaskBucket(subspace.get(BackupAgentBase::keyTasks), AccessSystemKeys::True, PriorityBatch::False, LockAware::True)), - futureBucket(new FutureBucket(subspace.get(BackupAgentBase::keyFutures), AccessSystemKeys::True, LockAware::True)), - sourceStates(subspace.get(BackupAgentBase::keySourceStates)), - sourceTagNames(subspace.get(BackupAgentBase::keyTagName)) { + futureBucket(new FutureBucket(subspace.get(BackupAgentBase::keyFutures), AccessSystemKeys::True, LockAware::True)) { taskBucket->src = src; } diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index afc92bfec0..acab668e7c 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -396,7 +396,7 @@ void loadClientFunction(T* fp, void* lib, std::string libPath, const char* funct } DLApi::DLApi(std::string fdbCPath, bool unlinkOnLoad) - : api(new FdbCApi()), fdbCPath(fdbCPath), unlinkOnLoad(unlinkOnLoad), networkSetup(false) {} + : fdbCPath(fdbCPath), api(new FdbCApi()), unlinkOnLoad(unlinkOnLoad), networkSetup(false) {} // Loads client API functions (definitions are in FdbCApi struct) void DLApi::init() { @@ -993,8 +993,8 @@ ThreadFuture MultiVersionDatabase::getServerProtocol(Optional

versionMonitorDb) - : clusterFilePath(clusterFilePath), versionMonitorDb(versionMonitorDb), - dbVar(new ThreadSafeAsyncVar>(Reference(nullptr))) {} + : dbVar(new ThreadSafeAsyncVar>(Reference(nullptr))), + clusterFilePath(clusterFilePath), versionMonitorDb(versionMonitorDb) {} // Adds a client (local or externally loaded) that can be used to connect to the cluster void MultiVersionDatabase::DatabaseState::addClient(Reference client) { @@ -1855,8 +1855,8 @@ void MultiVersionApi::loadEnvironmentVariableNetworkOptions() { } MultiVersionApi::MultiVersionApi() - : bypassMultiClientApi(false), networkStartSetup(false), networkSetup(false), callbackOnMainThread(true), - externalClient(false), localClientDisabled(false), apiVersion(0), envOptionsLoaded(false), threadCount(0) {} + : callbackOnMainThread(true), localClientDisabled(false), networkStartSetup(false), networkSetup(false), + bypassMultiClientApi(false), externalClient(false), apiVersion(0), threadCount(0), envOptionsLoaded(false) {} MultiVersionApi* MultiVersionApi::api = new MultiVersionApi(); diff --git a/fdbclient/SpecialKeySpace.actor.cpp b/fdbclient/SpecialKeySpace.actor.cpp index fc6bf0b2fe..441699df2d 100644 --- a/fdbclient/SpecialKeySpace.actor.cpp +++ b/fdbclient/SpecialKeySpace.actor.cpp @@ -248,8 +248,9 @@ ACTOR Future normalizeKeySelectorActor(SpecialKeySpace* sks, } SpecialKeySpace::SpecialKeySpace(KeyRef spaceStartKey, KeyRef spaceEndKey, bool testOnly) - : range(KeyRangeRef(spaceStartKey, spaceEndKey)), readImpls(nullptr, spaceEndKey), writeImpls(nullptr, spaceEndKey), - modules(testOnly ? SpecialKeySpace::MODULE::TESTONLY : SpecialKeySpace::MODULE::UNKNOWN, spaceEndKey) { + : readImpls(nullptr, spaceEndKey), + modules(testOnly ? SpecialKeySpace::MODULE::TESTONLY : SpecialKeySpace::MODULE::UNKNOWN, spaceEndKey), + writeImpls(nullptr, spaceEndKey), range(KeyRangeRef(spaceStartKey, spaceEndKey)) { // Default begin of KeyRangeMap is Key(), insert the range to update start key readImpls.insert(range, nullptr); writeImpls.insert(range, nullptr); diff --git a/fdbclient/TaskBucket.actor.cpp b/fdbclient/TaskBucket.actor.cpp index f7e4ed7e24..97c58efa9a 100644 --- a/fdbclient/TaskBucket.actor.cpp +++ b/fdbclient/TaskBucket.actor.cpp @@ -873,13 +873,14 @@ TaskBucket::TaskBucket(const Subspace& subspace, AccessSystemKeys sysAccess, PriorityBatch priorityBatch, LockAware lockAware) - : prefix(subspace), active(prefix.get(LiteralStringRef("ac"))), available(prefix.get(LiteralStringRef("av"))), + : cc("TaskBucket"), dbgid(deterministicRandom()->randomUniqueID()), + dispatchSlotChecksStarted("DispatchSlotChecksStarted", cc), dispatchErrors("DispatchErrors", cc), + dispatchDoTasks("DispatchDoTasks", cc), dispatchEmptyTasks("DispatchEmptyTasks", cc), + dispatchSlotChecksComplete("DispatchSlotChecksComplete", cc), prefix(subspace), + active(prefix.get(LiteralStringRef("ac"))), available(prefix.get(LiteralStringRef("av"))), available_prioritized(prefix.get(LiteralStringRef("avp"))), timeouts(prefix.get(LiteralStringRef("to"))), - pauseKey(prefix.pack(LiteralStringRef("pause"))), timeout(CLIENT_KNOBS->TASKBUCKET_TIMEOUT_VERSIONS), - system_access(sysAccess), priority_batch(priorityBatch), lockAware(lockAware), cc("TaskBucket"), - dbgid(deterministicRandom()->randomUniqueID()), dispatchSlotChecksStarted("DispatchSlotChecksStarted", cc), - dispatchErrors("DispatchErrors", cc), dispatchDoTasks("DispatchDoTasks", cc), - dispatchEmptyTasks("DispatchEmptyTasks", cc), dispatchSlotChecksComplete("DispatchSlotChecksComplete", cc) {} + timeout(CLIENT_KNOBS->TASKBUCKET_TIMEOUT_VERSIONS), pauseKey(prefix.pack(LiteralStringRef("pause"))), + system_access(sysAccess), priority_batch(priorityBatch), lockAware(lockAware) {} TaskBucket::~TaskBucket() {} diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index d44483da12..d6af0d3eb7 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -340,9 +340,8 @@ ACTOR Future pingLatencyLogger(TransportData* self) { } TransportData::TransportData(uint64_t transportId) - : endpoints(WLTOKEN_COUNTS), endpointNotFoundReceiver(endpoints), pingReceiver(endpoints), - warnAlwaysForLargePacket(true), lastIncompatibleMessage(0), transportId(transportId), - numIncompatibleConnections(0) { + : warnAlwaysForLargePacket(true), endpoints(WLTOKEN_COUNTS), endpointNotFoundReceiver(endpoints), + pingReceiver(endpoints), numIncompatibleConnections(0), lastIncompatibleMessage(0), transportId(transportId) { degraded = makeReference>(false); pingLogger = pingLatencyLogger(this); } @@ -795,13 +794,14 @@ ACTOR Future connectionKeeper(Reference self, } Peer::Peer(TransportData* transport, NetworkAddress const& destination) - : transport(transport), destination(destination), outgoingConnectionIdle(true), lastConnectTime(0.0), - reconnectionDelay(FLOW_KNOBS->INITIAL_RECONNECTION_TIME), compatible(true), outstandingReplies(0), - incompatibleProtocolVersionNewer(false), peerReferences(-1), bytesReceived(0), lastDataPacketSentTime(now()), - pingLatencies(destination.isPublic() ? FLOW_KNOBS->PING_SAMPLE_AMOUNT : 1), lastLoggedBytesReceived(0), - bytesSent(0), lastLoggedBytesSent(0), timeoutCount(0), lastLoggedTime(0.0), connectOutgoingCount(0), connectIncomingCount(0), - connectFailedCount(0), connectLatencies(destination.isPublic() ? FLOW_KNOBS->NETWORK_CONNECT_SAMPLE_AMOUNT : 1), - protocolVersion(Reference>>(new AsyncVar>())) { + : transport(transport), destination(destination), compatible(true), outgoingConnectionIdle(true), + lastConnectTime(0.0), reconnectionDelay(FLOW_KNOBS->INITIAL_RECONNECTION_TIME), peerReferences(-1), + outstandingReplies(0), pingLatencies(destination.isPublic() ? FLOW_KNOBS->PING_SAMPLE_AMOUNT : 1), + lastLoggedTime(0.0), lastLoggedBytesReceived(0), lastLoggedBytesSent(0), timeoutCount(0), + incompatibleProtocolVersionNewer(false), bytesReceived(0), bytesSent(0), lastDataPacketSentTime(now()), + protocolVersion(Reference>>(new AsyncVar>())), + connectOutgoingCount(0), connectIncomingCount(0), connectFailedCount(0), + connectLatencies(destination.isPublic() ? FLOW_KNOBS->NETWORK_CONNECT_SAMPLE_AMOUNT : 1) { IFailureMonitor::failureMonitor().setStatus(destination, FailureStatus(false)); } diff --git a/fdbserver/BackupWorker.actor.cpp b/fdbserver/BackupWorker.actor.cpp index d6bd6a0ebb..fb43bd18cc 100644 --- a/fdbserver/BackupWorker.actor.cpp +++ b/fdbserver/BackupWorker.actor.cpp @@ -241,8 +241,8 @@ struct BackupData { : myId(id), tag(req.routerTag), totalTags(req.totalTags), startVersion(req.startVersion), endVersion(req.endVersion), recruitedEpoch(req.recruitedEpoch), backupEpoch(req.backupEpoch), minKnownCommittedVersion(invalidVersion), savedVersion(req.startVersion - 1), popVersion(req.startVersion - 1), - cc("BackupWorker", myId.toString()), pulledVersion(0), paused(false), - lock(new FlowLock(SERVER_KNOBS->BACKUP_LOCK_BYTES)) { + pulledVersion(0), paused(false), lock(new FlowLock(SERVER_KNOBS->BACKUP_LOCK_BYTES)), + cc("BackupWorker", myId.toString()) { cx = openDBOnServer(db, TaskPriority::DefaultEndpoint, LockAware::True); specialCounter(cc, "SavedVersion", [this]() { return this->savedVersion; }); diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index 97ef92b1e5..971eede909 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -128,15 +128,15 @@ public: std::map> clientStatus; DBInfo() - : masterRegistrationCount(0), recoveryStalled(false), forceRecovery(false), unfinishedRecoveries(0), - logGenerations(0), cachePopulated(false), clientInfo(new AsyncVar()), dbInfoCount(0), - serverInfo(new AsyncVar()), db(DatabaseContext::create(clientInfo, - Future(), - LocalityData(), - EnableLocalityLoadBalance::True, - TaskPriority::DefaultEndpoint, - LockAware::True)) // SOMEDAY: Locality! - {} + : clientInfo(new AsyncVar()), serverInfo(new AsyncVar()), + masterRegistrationCount(0), dbInfoCount(0), recoveryStalled(false), forceRecovery(false), + db(DatabaseContext::create(clientInfo, + Future(), + LocalityData(), + EnableLocalityLoadBalance::True, + TaskPriority::DefaultEndpoint, + LockAware::True)), // SOMEDAY: Locality! + unfinishedRecoveries(0), logGenerations(0), cachePopulated(false) {} void setDistributor(const DataDistributorInterface& interf) { auto newInfo = serverInfo->get(); @@ -1431,12 +1431,12 @@ public: bool degraded = false; RoleFitness(int bestFit, int worstFit, int count, ProcessClass::ClusterRole role) - : bestFit((ProcessClass::Fitness)bestFit), worstFit((ProcessClass::Fitness)worstFit), count(count), - role(role) {} + : bestFit((ProcessClass::Fitness)bestFit), worstFit((ProcessClass::Fitness)worstFit), role(role), + count(count) {} RoleFitness(int fitness, int count, ProcessClass::ClusterRole role) - : bestFit((ProcessClass::Fitness)fitness), worstFit((ProcessClass::Fitness)fitness), count(count), - role(role) {} + : bestFit((ProcessClass::Fitness)fitness), worstFit((ProcessClass::Fitness)fitness), role(role), + count(count) {} RoleFitness() : bestFit(ProcessClass::NeverAssign), worstFit(ProcessClass::NeverAssign), role(ProcessClass::NoRole), @@ -3059,9 +3059,9 @@ public: ClusterControllerData(ClusterControllerFullInterface const& ccInterface, LocalityData const& locality, ServerCoordinators const& coordinators) - : clusterControllerProcessId(locality.processId()), clusterControllerDcId(locality.dcId()), id(ccInterface.id()), - ac(false), outstandingRequestChecker(Void()), outstandingRemoteRequestChecker(Void()), gotProcessClasses(false), - gotFullyRecoveredConfig(false), startTime(now()), goodRecruitmentTime(Never()), + : gotProcessClasses(false), gotFullyRecoveredConfig(false), clusterControllerProcessId(locality.processId()), + clusterControllerDcId(locality.dcId()), id(ccInterface.id()), ac(false), outstandingRequestChecker(Void()), + outstandingRemoteRequestChecker(Void()), startTime(now()), goodRecruitmentTime(Never()), goodRemoteRecruitmentTime(Never()), datacenterVersionDifference(0), versionDifferenceUpdated(false), recruitingDistributor(false), recruitRatekeeper(false), clusterControllerMetrics("ClusterController", id.toString()), diff --git a/fdbserver/ConfigBroadcaster.actor.cpp b/fdbserver/ConfigBroadcaster.actor.cpp index e386bb4dc5..a5beb99e6a 100644 --- a/fdbserver/ConfigBroadcaster.actor.cpp +++ b/fdbserver/ConfigBroadcaster.actor.cpp @@ -203,7 +203,7 @@ class ConfigBroadcasterImpl { } ConfigBroadcasterImpl() - : id(deterministicRandom()->randomUniqueID()), lastCompactedVersion(0), mostRecentVersion(0), + : mostRecentVersion(0), lastCompactedVersion(0), id(deterministicRandom()->randomUniqueID()), cc("ConfigBroadcaster"), compactRequest("CompactRequest", cc), successfulChangeRequest("SuccessfulChangeRequest", cc), failedChangeRequest("FailedChangeRequest", cc), snapshotRequest("SnapshotRequest", cc) { diff --git a/fdbserver/ConfigDatabaseUnitTests.actor.cpp b/fdbserver/ConfigDatabaseUnitTests.actor.cpp index 39d7be0ac1..4bd32ad5ea 100644 --- a/fdbserver/ConfigDatabaseUnitTests.actor.cpp +++ b/fdbserver/ConfigDatabaseUnitTests.actor.cpp @@ -241,8 +241,8 @@ class BroadcasterToLocalConfigEnvironment { public: BroadcasterToLocalConfigEnvironment(std::string const& dataDir, std::string const& configPath) - : broadcaster(ConfigFollowerInterface{}), cbfi(makeReference>()), - readFrom(dataDir, configPath, {}) {} + : readFrom(dataDir, configPath, {}), cbfi(makeReference>()), + broadcaster(ConfigFollowerInterface{}) {} Future setup() { return setup(this); } @@ -371,8 +371,9 @@ class TransactionToLocalConfigEnvironment { public: TransactionToLocalConfigEnvironment(std::string const& dataDir, std::string const& configPath) - : writeTo(dataDir), readFrom(dataDir, configPath, {}), broadcaster(writeTo.getFollowerInterface()), - cbfi(makeReference>()) {} + : writeTo(dataDir), readFrom(dataDir, configPath, {}), + cbfi(makeReference>()), broadcaster(writeTo.getFollowerInterface()) { + } Future setup() { return setup(this); } diff --git a/fdbserver/DataDistributionQueue.actor.cpp b/fdbserver/DataDistributionQueue.actor.cpp index 6f55c39438..aa623f3361 100644 --- a/fdbserver/DataDistributionQueue.actor.cpp +++ b/fdbserver/DataDistributionQueue.actor.cpp @@ -50,7 +50,7 @@ struct RelocateData { TraceInterval interval; RelocateData() - : startTime(-1), priority(-1), boundaryPriority(-1), healthPriority(-1), workFactor(0), wantsNewServers(false), + : priority(-1), boundaryPriority(-1), healthPriority(-1), startTime(-1), workFactor(0), wantsNewServers(false), interval("QueuedRelocation") {} explicit RelocateData(RelocateShard const& rs) : keys(rs.keys), priority(rs.priority), boundaryPriority(isBoundaryPriority(rs.priority) ? rs.priority : -1), @@ -448,14 +448,14 @@ struct DDQueueData { FutureStream input, PromiseStream getShardMetrics, double* lastLimited) - : activeRelocations(0), queuedRelocations(0), bytesWritten(0), teamCollections(teamCollections), - shardsAffectedByTeamFailure(sABTF), getAverageShardBytes(getAverageShardBytes), distributorId(mid), lock(lock), - cx(cx), teamSize(teamSize), singleRegionTeamSize(singleRegionTeamSize), output(output), input(input), - getShardMetrics(getShardMetrics), startMoveKeysParallelismLock(SERVER_KNOBS->DD_MOVE_KEYS_PARALLELISM), + : distributorId(mid), lock(lock), cx(cx), teamCollections(teamCollections), shardsAffectedByTeamFailure(sABTF), + getAverageShardBytes(getAverageShardBytes), + startMoveKeysParallelismLock(SERVER_KNOBS->DD_MOVE_KEYS_PARALLELISM), finishMoveKeysParallelismLock(SERVER_KNOBS->DD_MOVE_KEYS_PARALLELISM), - fetchSourceLock(new FlowLock(SERVER_KNOBS->DD_FETCH_SOURCE_PARALLELISM)), lastLimited(lastLimited), - suppressIntervals(0), lastInterval(0), unhealthyRelocations(0), - rawProcessingUnhealthy(new AsyncVar(false)) {} + fetchSourceLock(new FlowLock(SERVER_KNOBS->DD_FETCH_SOURCE_PARALLELISM)), activeRelocations(0), + queuedRelocations(0), bytesWritten(0), teamSize(teamSize), singleRegionTeamSize(singleRegionTeamSize), + output(output), input(input), getShardMetrics(getShardMetrics), lastLimited(lastLimited), lastInterval(0), + suppressIntervals(0), rawProcessingUnhealthy(new AsyncVar(false)), unhealthyRelocations(0) {} void validate() { if (EXPENSIVE_VALIDATION) { diff --git a/fdbserver/DataDistributionTracker.actor.cpp b/fdbserver/DataDistributionTracker.actor.cpp index 40ca28aa08..e27dbf4e56 100644 --- a/fdbserver/DataDistributionTracker.actor.cpp +++ b/fdbserver/DataDistributionTracker.actor.cpp @@ -123,10 +123,10 @@ struct DataDistributionTracker { Reference> anyZeroHealthyTeams, KeyRangeMap& shards, bool& trackerCancelled) - : cx(cx), distributorId(distributorId), dbSizeEstimate(new AsyncVar()), systemSizeEstimate(0), - maxShardSize(new AsyncVar>()), sizeChanges(false), readyToStart(readyToStart), output(output), - shardsAffectedByTeamFailure(shardsAffectedByTeamFailure), anyZeroHealthyTeams(anyZeroHealthyTeams), - shards(shards), trackerCancelled(trackerCancelled) {} + : cx(cx), distributorId(distributorId), shards(shards), sizeChanges(false), systemSizeEstimate(0), + dbSizeEstimate(new AsyncVar()), maxShardSize(new AsyncVar>()), output(output), + shardsAffectedByTeamFailure(shardsAffectedByTeamFailure), readyToStart(readyToStart), + anyZeroHealthyTeams(anyZeroHealthyTeams), trackerCancelled(trackerCancelled) {} ~DataDistributionTracker() { trackerCancelled = true; diff --git a/fdbserver/DiskQueue.actor.cpp b/fdbserver/DiskQueue.actor.cpp index a7a5402374..372ad1a135 100644 --- a/fdbserver/DiskQueue.actor.cpp +++ b/fdbserver/DiskQueue.actor.cpp @@ -168,11 +168,11 @@ private: class RawDiskQueue_TwoFiles : public Tracked { public: RawDiskQueue_TwoFiles(std::string basename, std::string fileExtension, UID dbgid, int64_t fileSizeWarningLimit) - : basename(basename), fileExtension(fileExtension), onError(delayed(error.getFuture())), - onStopped(stopped.getFuture()), readingFile(-1), readingPage(-1), writingPos(-1), dbgid(dbgid), - dbg_file0BeginSeq(0), fileExtensionBytes(SERVER_KNOBS->DISK_QUEUE_FILE_EXTENSION_BYTES), - fileShrinkBytes(SERVER_KNOBS->DISK_QUEUE_FILE_SHRINK_BYTES), readingBuffer(dbgid), readyToPush(Void()), - fileSizeWarningLimit(fileSizeWarningLimit), lastCommit(Void()), isFirstCommit(true) { + : basename(basename), fileExtension(fileExtension), dbgid(dbgid), dbg_file0BeginSeq(0), + fileSizeWarningLimit(fileSizeWarningLimit), onError(delayed(error.getFuture())), onStopped(stopped.getFuture()), + readyToPush(Void()), lastCommit(Void()), isFirstCommit(true), readingBuffer(dbgid), readingFile(-1), + readingPage(-1), writingPos(-1), fileExtensionBytes(SERVER_KNOBS->DISK_QUEUE_FILE_EXTENSION_BYTES), + fileShrinkBytes(SERVER_KNOBS->DISK_QUEUE_FILE_SHRINK_BYTES) { if (BUGGIFY) fileExtensionBytes = _PAGE_SIZE * deterministicRandom()->randomSkewedUInt32(1, 10 << 10); if (BUGGIFY) @@ -878,9 +878,9 @@ public: DiskQueueVersion diskQueueVersion, int64_t fileSizeWarningLimit) : rawQueue(new RawDiskQueue_TwoFiles(basename, fileExtension, dbgid, fileSizeWarningLimit)), dbgid(dbgid), - diskQueueVersion(diskQueueVersion), anyPopped(false), nextPageSeq(0), poppedSeq(0), lastPoppedSeq(0), - nextReadLocation(-1), readBufPage(nullptr), readBufPos(0), pushed_page_buffer(nullptr), recovered(false), - initialized(false), lastCommittedSeq(-1), warnAlwaysForMemory(true) {} + diskQueueVersion(diskQueueVersion), anyPopped(false), warnAlwaysForMemory(true), nextPageSeq(0), poppedSeq(0), + lastPoppedSeq(0), lastCommittedSeq(-1), pushed_page_buffer(nullptr), recovered(false), initialized(false), + nextReadLocation(-1), readBufPage(nullptr), readBufPos(0) {} location push(StringRef contents) override { ASSERT(recovered); diff --git a/fdbserver/KeyValueStoreSQLite.actor.cpp b/fdbserver/KeyValueStoreSQLite.actor.cpp index 6e3043f3f3..e52ca14198 100644 --- a/fdbserver/KeyValueStoreSQLite.actor.cpp +++ b/fdbserver/KeyValueStoreSQLite.actor.cpp @@ -681,7 +681,7 @@ struct SQLiteTransaction { struct IntKeyCursor { SQLiteDB& db; BtCursor* cursor; - IntKeyCursor(SQLiteDB& db, int table, bool write) : cursor(0), db(db) { + IntKeyCursor(SQLiteDB& db, int table, bool write) : db(db), cursor(nullptr) { cursor = (BtCursor*)new char[sqlite3BtreeCursorSize()]; sqlite3BtreeCursorZero(cursor); db.checkError("BtreeCursor", sqlite3BtreeCursor(db.btree, table, write, nullptr, cursor)); @@ -705,7 +705,7 @@ struct RawCursor { operator bool() const { return valid; } - RawCursor(SQLiteDB& db, int table, bool write) : cursor(0), db(db), valid(false) { + RawCursor(SQLiteDB& db, int table, bool write) : db(db), cursor(nullptr), valid(false) { keyInfo.db = db.db; keyInfo.enc = db.db->aDb[0].pSchema->enc; keyInfo.aColl[0] = db.db->pDfltColl; @@ -1732,9 +1732,9 @@ private: volatile int64_t& freeListPages, UID dbgid, vector>* pReadThreads) - : kvs(kvs), conn(kvs->filename, isBtreeV2, isBtreeV2), commits(), setsThisCommit(), freeTableEmpty(false), - writesComplete(writesComplete), springCleaningStats(springCleaningStats), diskBytesUsed(diskBytesUsed), - freeListPages(freeListPages), cursor(nullptr), dbgid(dbgid), readThreads(*pReadThreads), + : kvs(kvs), conn(kvs->filename, isBtreeV2, isBtreeV2), cursor(nullptr), commits(), setsThisCommit(), + freeTableEmpty(false), writesComplete(writesComplete), springCleaningStats(springCleaningStats), + diskBytesUsed(diskBytesUsed), freeListPages(freeListPages), dbgid(dbgid), readThreads(*pReadThreads), checkAllChecksumsOnOpen(checkAllChecksumsOnOpen), checkIntegrityOnOpen(checkIntegrityOnOpen) {} ~Writer() override { TraceEvent("KVWriterDestroying", dbgid); @@ -2109,7 +2109,7 @@ KeyValueStoreSQLite::KeyValueStoreSQLite(std::string const& filename, KeyValueStoreType storeType, bool checkChecksums, bool checkIntegrity) - : type(storeType), filename(filename), logID(id), readThreads(CoroThreadPool::createThreadPool()), + : type(storeType), logID(id), filename(filename), readThreads(CoroThreadPool::createThreadPool()), writeThread(CoroThreadPool::createThreadPool()), readsRequested(0), writesRequested(0), writesComplete(0), diskBytesUsed(0), freeListPages(0) { TraceEvent(SevDebug, "KeyValueStoreSQLiteCreate").detail("Filename", filename); diff --git a/fdbserver/LocalConfiguration.actor.cpp b/fdbserver/LocalConfiguration.actor.cpp index 238db7041e..f375e6f85e 100644 --- a/fdbserver/LocalConfiguration.actor.cpp +++ b/fdbserver/LocalConfiguration.actor.cpp @@ -326,9 +326,9 @@ public: std::string const& configPath, std::map const& manualKnobOverrides, IsTest isTest) - : id(deterministicRandom()->randomUniqueID()), kvStore(dataFolder, id, "localconf-"), cc("LocalConfiguration"), - broadcasterChanges("BroadcasterChanges", cc), snapshots("Snapshots", cc), - changeRequestsFetched("ChangeRequestsFetched", cc), mutations("Mutations", cc), configKnobOverrides(configPath), + : id(deterministicRandom()->randomUniqueID()), kvStore(dataFolder, id, "localconf-"), + configKnobOverrides(configPath), cc("LocalConfiguration"), broadcasterChanges("BroadcasterChanges", cc), + snapshots("Snapshots", cc), changeRequestsFetched("ChangeRequestsFetched", cc), mutations("Mutations", cc), manualKnobOverrides(manualKnobOverrides) { if (isTest) { testKnobCollection = diff --git a/fdbserver/MetricLogger.actor.cpp b/fdbserver/MetricLogger.actor.cpp index aee9ea67d6..284c782626 100644 --- a/fdbserver/MetricLogger.actor.cpp +++ b/fdbserver/MetricLogger.actor.cpp @@ -29,7 +29,7 @@ struct MetricsRule { MetricsRule(bool enabled = false, int minLevel = 0, StringRef const& name = StringRef()) - : enabled(enabled), minLevel(minLevel), namePattern(name) {} + : namePattern(name), enabled(enabled), minLevel(minLevel) {} Standalone typePattern; Standalone namePattern; diff --git a/fdbserver/Ratekeeper.actor.cpp b/fdbserver/Ratekeeper.actor.cpp index a13f9583be..3fcb63ef4e 100644 --- a/fdbserver/Ratekeeper.actor.cpp +++ b/fdbserver/Ratekeeper.actor.cpp @@ -515,8 +515,7 @@ struct RatekeeperLimits { int64_t logSpringBytes, double maxVersionDifference, int64_t durabilityLagTargetVersions) - : priority(priority), tpsLimit(std::numeric_limits::infinity()), - tpsLimitMetric(StringRef("Ratekeeper.TPSLimit" + context)), + : tpsLimit(std::numeric_limits::infinity()), tpsLimitMetric(StringRef("Ratekeeper.TPSLimit" + context)), reasonMetric(StringRef("Ratekeeper.Reason" + context)), storageTargetBytes(storageTargetBytes), storageSpringBytes(storageSpringBytes), logTargetBytes(logTargetBytes), logSpringBytes(logSpringBytes), maxVersionDifference(maxVersionDifference), @@ -524,7 +523,8 @@ struct RatekeeperLimits { durabilityLagTargetVersions + SERVER_KNOBS->MAX_READ_TRANSACTION_LIFE_VERSIONS), // The read transaction life versions are expected to not // be durable on the storage servers - durabilityLagLimit(std::numeric_limits::infinity()), lastDurabilityLag(0), context(context) {} + lastDurabilityLag(0), durabilityLagLimit(std::numeric_limits::infinity()), priority(priority), + context(context) {} }; struct GrvProxyInfo { @@ -536,7 +536,7 @@ struct GrvProxyInfo { double lastTagPushTime; GrvProxyInfo() - : totalTransactions(0), batchTransactions(0), lastUpdateTime(0), lastThrottledTagChangeId(0), lastTagPushTime(0) { + : totalTransactions(0), batchTransactions(0), lastThrottledTagChangeId(0), lastUpdateTime(0), lastTagPushTime(0) { } }; @@ -577,7 +577,7 @@ struct RatekeeperData { smoothBatchReleasedTransactions(SERVER_KNOBS->SMOOTHING_AMOUNT), smoothTotalDurableBytes(SERVER_KNOBS->SLOW_SMOOTHING_AMOUNT), actualTpsMetric(LiteralStringRef("Ratekeeper.ActualTPS")), lastWarning(0), lastSSListFetchedTimestamp(now()), - throttledTagChangeId(0), lastBusiestCommitTagPick(0), + lastBusiestCommitTagPick(0), throttledTagChangeId(0), normalLimits(TransactionPriority::DEFAULT, "", SERVER_KNOBS->TARGET_BYTES_PER_STORAGE_SERVER, diff --git a/fdbserver/SkipList.cpp b/fdbserver/SkipList.cpp index 86489f3850..d90e649b58 100644 --- a/fdbserver/SkipList.cpp +++ b/fdbserver/SkipList.cpp @@ -92,7 +92,7 @@ struct KeyInfo { KeyInfo() = default; KeyInfo(StringRef key, bool begin, bool write, int transaction, int* pIndex) - : key(key), begin(begin), write(write), transaction(transaction), pIndex(pIndex) {} + : key(key), pIndex(pIndex), begin(begin), write(write), transaction(transaction) {} }; force_inline int extra_ordering(const KeyInfo& ki) { @@ -343,7 +343,7 @@ public: StringRef value; Finger() = default; - Finger(Node* header, const StringRef& ptr) : value(ptr), x(header) {} + Finger(Node* header, const StringRef& ptr) : x(header), value(ptr) {} void init(const StringRef& value, Node* header) { this->value = value; diff --git a/fdbserver/StorageCache.actor.cpp b/fdbserver/StorageCache.actor.cpp index 8f44f054d6..7fa81738c6 100644 --- a/fdbserver/StorageCache.actor.cpp +++ b/fdbserver/StorageCache.actor.cpp @@ -224,14 +224,14 @@ public: // LatencyBands readLatencyBands; Counters(StorageCacheData* self) - : cc("StorageCacheServer", self->thisServerID.toString()), getKeyQueries("GetKeyQueries", cc), - getValueQueries("GetValueQueries", cc), getRangeQueries("GetRangeQueries", cc), - allQueries("QueryQueue", cc), finishedQueries("FinishedQueries", cc), rowsQueried("RowsQueried", cc), - bytesQueried("BytesQueried", cc), bytesInput("BytesInput", cc), bytesFetched("BytesFetched", cc), - mutationBytes("MutationBytes", cc), mutations("Mutations", cc), setMutations("SetMutations", cc), - clearRangeMutations("ClearRangeMutations", cc), atomicMutations("AtomicMutations", cc), - updateBatches("UpdateBatches", cc), updateVersions("UpdateVersions", cc), loops("Loops", cc), - readsRejected("ReadsRejected", cc) { + : cc("StorageCacheServer", self->thisServerID.toString()), allQueries("QueryQueue", cc), + getKeyQueries("GetKeyQueries", cc), getValueQueries("GetValueQueries", cc), + getRangeQueries("GetRangeQueries", cc), finishedQueries("FinishedQueries", cc), + rowsQueried("RowsQueried", cc), bytesQueried("BytesQueried", cc), bytesInput("BytesInput", cc), + bytesFetched("BytesFetched", cc), mutationBytes("MutationBytes", cc), mutations("Mutations", cc), + setMutations("SetMutations", cc), clearRangeMutations("ClearRangeMutations", cc), + atomicMutations("AtomicMutations", cc), updateBatches("UpdateBatches", cc), + updateVersions("UpdateVersions", cc), loops("Loops", cc), readsRejected("ReadsRejected", cc) { specialCounter(cc, "LastTLogVersion", [self]() { return self->lastTLogVersion; }); specialCounter(cc, "Version", [self]() { return self->version.get(); }); specialCounter(cc, "VersionLag", [self]() { return self->versionLag; }); @@ -1542,7 +1542,7 @@ ACTOR Future fetchKeys(StorageCacheData* data, AddingCacheRange* cacheRang }; AddingCacheRange::AddingCacheRange(StorageCacheData* server, KeyRangeRef const& keys) - : server(server), keys(keys), transferredVersion(invalidVersion), phase(WaitPrevious) { + : keys(keys), server(server), transferredVersion(invalidVersion), phase(WaitPrevious) { fetchClient = fetchKeys(server, this); } @@ -1704,9 +1704,9 @@ void cacheWarmup(StorageCacheData* data, const KeyRangeRef& keys, bool nowAssign class StorageCacheUpdater { public: StorageCacheUpdater() - : fromVersion(invalidVersion), currentVersion(invalidVersion), processedCacheStartKey(false) {} + : currentVersion(invalidVersion), fromVersion(invalidVersion), processedCacheStartKey(false) {} StorageCacheUpdater(Version currentVersion) - : fromVersion(currentVersion), currentVersion(currentVersion), processedCacheStartKey(false) {} + : currentVersion(invalidVersion), fromVersion(currentVersion), processedCacheStartKey(false) {} void applyMutation(StorageCacheData* data, MutationRef const& m, Version ver) { //TraceEvent("SCNewVersion", data->thisServerID).detail("VerWas", data->mutableData().latestVersion).detail("ChVer", ver); diff --git a/fdbserver/masterserver.actor.cpp b/fdbserver/masterserver.actor.cpp index 39cd0dd087..136ef3cb1e 100644 --- a/fdbserver/masterserver.actor.cpp +++ b/fdbserver/masterserver.actor.cpp @@ -95,8 +95,8 @@ public: ReusableCoordinatedState(ServerCoordinators const& coordinators, PromiseStream> const& addActor, UID const& dbgid) - : coordinators(coordinators), cstate(coordinators), addActor(addActor), dbgid(dbgid), finalWriteStarted(false), - previousWrite(Void()) {} + : finalWriteStarted(false), previousWrite(Void()), cstate(coordinators), coordinators(coordinators), + addActor(addActor), dbgid(dbgid) {} Future read() { return _read(this); } @@ -265,12 +265,12 @@ struct MasterData : NonCopyable, ReferenceCounted { : dbgid(myInterface.id()), lastEpochEnd(invalidVersion), recoveryTransactionVersion(invalidVersion), lastCommitTime(0), liveCommittedVersion(invalidVersion), databaseLocked(false), - minKnownCommittedVersion(invalidVersion), myInterface(myInterface), dbInfo(dbInfo), - cstate(coordinators, addActor, dbgid), coordinators(coordinators), clusterController(clusterController), - dbId(dbId), forceRecovery(forceRecovery), safeLocality(tagLocalityInvalid), primaryLocality(tagLocalityInvalid), - neverCreated(false), hasConfiguration(false), version(invalidVersion), lastVersionTime(0), - txnStateStore(nullptr), memoryLimit(2e9), registrationCount(0), addActor(addActor), - recruitmentStalled(makeReference>(false)), cc("Master", dbgid.toString()), + minKnownCommittedVersion(invalidVersion), hasConfiguration(false), coordinators(coordinators), + version(invalidVersion), lastVersionTime(0), txnStateStore(nullptr), memoryLimit(2e9), dbId(dbId), + myInterface(myInterface), clusterController(clusterController), cstate(coordinators, addActor, dbgid), + dbInfo(dbInfo), registrationCount(0), addActor(addActor), + recruitmentStalled(makeReference>(false)), forceRecovery(forceRecovery), neverCreated(false), + safeLocality(tagLocalityInvalid), primaryLocality(tagLocalityInvalid), cc("Master", dbgid.toString()), changeCoordinatorsRequests("ChangeCoordinatorsRequests", cc), getCommitVersionRequests("GetCommitVersionRequests", cc), backupWorkerDoneRequests("BackupWorkerDoneRequests", cc), diff --git a/fdbserver/workloads/AsyncFileCorrectness.actor.cpp b/fdbserver/workloads/AsyncFileCorrectness.actor.cpp index 4a7e8fd1ec..96dd3f2283 100644 --- a/fdbserver/workloads/AsyncFileCorrectness.actor.cpp +++ b/fdbserver/workloads/AsyncFileCorrectness.actor.cpp @@ -73,7 +73,7 @@ struct AsyncFileCorrectnessWorkload : public AsyncFileWorkload { PerfIntCounter numOperations; AsyncFileCorrectnessWorkload(WorkloadContext const& wcx) - : AsyncFileWorkload(wcx), success(true), numOperations("Num Operations"), memoryFile(nullptr) { + : AsyncFileWorkload(wcx), memoryFile(nullptr), success(true), numOperations("Num Operations") { maxOperationSize = getOption(options, LiteralStringRef("maxOperationSize"), 4096); numSimultaneousOperations = getOption(options, LiteralStringRef("numSimultaneousOperations"), 10); targetFileSize = getOption(options, LiteralStringRef("targetFileSize"), (uint64_t)163840); diff --git a/fdbserver/workloads/AsyncFileWrite.actor.cpp b/fdbserver/workloads/AsyncFileWrite.actor.cpp index 23659e832d..2848eaa9e3 100644 --- a/fdbserver/workloads/AsyncFileWrite.actor.cpp +++ b/fdbserver/workloads/AsyncFileWrite.actor.cpp @@ -46,7 +46,7 @@ struct AsyncFileWriteWorkload : public AsyncFileWorkload { PerfIntCounter bytesWritten; AsyncFileWriteWorkload(WorkloadContext const& wcx) - : AsyncFileWorkload(wcx), bytesWritten("Bytes Written"), writeBuffer(nullptr) { + : AsyncFileWorkload(wcx), writeBuffer(nullptr), bytesWritten("Bytes Written") { numParallelWrites = getOption(options, LiteralStringRef("numParallelWrites"), 0); writeSize = getOption(options, LiteralStringRef("writeSize"), _PAGE_SIZE); fileSize = getOption(options, LiteralStringRef("fileSize"), 10002432); diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index 44572113d4..6d377d9746 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -243,7 +243,7 @@ public: struct DelayedTask : OrderedTask { double at; DelayedTask(double at, int64_t priority, TaskPriority taskID, Task* task) - : at(at), OrderedTask(priority, taskID, task) {} + : OrderedTask(priority, taskID, task), at(at) {} bool operator<(DelayedTask const& rhs) const { return at > rhs.at; } // Ordering is reversed for priority_queue }; std::priority_queue> timers; @@ -1169,19 +1169,16 @@ struct PromiseTask : public Task, public FastAllocated { // 5MB for loading files into memory Net2::Net2(const TLSConfig& tlsConfig, bool useThreadPool, bool useMetrics) - : useThreadPool(useThreadPool), network(this), reactor(this), stopped(false), tasksIssued(0), - ready(FLOW_KNOBS->READY_QUEUE_RESERVED_SIZE), - // Until run() is called, yield() will always yield - tscBegin(0), tscEnd(0), taskBegin(0), currentTaskID(TaskPriority::DefaultYield), numYields(0), - lastPriorityStats(nullptr), tlsInitializedState(ETLSInitState::NONE), tlsConfig(tlsConfig), started(false) + : useThreadPool(useThreadPool), reactor(this), #ifndef TLS_DISABLED - , sslContextVar({ ReferencedObject::from( boost::asio::ssl::context(boost::asio::ssl::context::tls)) }), - sslPoolHandshakesInProgress(0), sslHandshakerThreadsStarted(0) + sslHandshakerThreadsStarted(0), sslPoolHandshakesInProgress(0), #endif - -{ + tlsConfig(tlsConfig), network(this), tscBegin(0), tscEnd(0), taskBegin(0), + currentTaskID(TaskPriority::DefaultYield), tasksIssued(0), stopped(false), started(false), numYields(0), + lastPriorityStats(nullptr), ready(FLOW_KNOBS->READY_QUEUE_RESERVED_SIZE), tlsInitializedState(ETLSInitState::NONE) { + // Until run() is called, yield() will always yield TraceEvent("Net2Starting"); // Set the global members @@ -1908,7 +1905,7 @@ void Net2::getDiskBytes(std::string const& directory, int64_t& free, int64_t& to #include #endif -ASIOReactor::ASIOReactor(Net2* net) : network(net), firstTimer(ios), do_not_stop(ios) { +ASIOReactor::ASIOReactor(Net2* net) : do_not_stop(ios), network(net), firstTimer(ios) { #ifdef __linux__ // Reactor flags are used only for experimentation, and are platform-specific if (FLOW_KNOBS->REACTOR_FLAGS & 1) { diff --git a/flow/Profiler.actor.cpp b/flow/Profiler.actor.cpp index 1275c5d410..0ee9dfce0e 100644 --- a/flow/Profiler.actor.cpp +++ b/flow/Profiler.actor.cpp @@ -128,7 +128,7 @@ struct Profiler { bool timerInitialized; Profiler(int period, std::string const& outfn, INetwork* network) - : environmentInfoWriter(Unversioned()), signalClosure(signal_handler_for_closure, this), network(network), + : signalClosure(signal_handler_for_closure, this), environmentInfoWriter(Unversioned()), network(network), timerInitialized(false) { actor = profile(this, period, outfn); } diff --git a/flow/Trace.cpp b/flow/Trace.cpp index e8655cf6cb..c099636644 100644 --- a/flow/Trace.cpp +++ b/flow/Trace.cpp @@ -205,7 +205,7 @@ public: WriterThread(Reference barriers, Reference logWriter, Reference formatter) - : barriers(barriers), logWriter(logWriter), formatter(formatter) {} + : logWriter(logWriter), formatter(formatter), barriers(barriers) {} void init() override {} @@ -277,8 +277,8 @@ public: }; TraceLog() - : bufferLength(0), loggedLength(0), opened(false), preopenOverflowCount(0), barriers(new BarrierList), - logTraceEventMetrics(false), formatter(new XmlTraceLogFormatter()), issues(new IssuesList) {} + : formatter(new XmlTraceLogFormatter()), loggedLength(0), bufferLength(0), opened(false), preopenOverflowCount(0), + logTraceEventMetrics(false), issues(new IssuesList), barriers(new BarrierList) {} bool isOpen() const { return opened; } @@ -835,28 +835,27 @@ Future pingTraceLogWriterThread() { } TraceEvent::TraceEvent(const char* type, UID id) - : id(id), type(type), severity(SevInfo), initialized(false), enabled(true), logged(false) { + : initialized(false), enabled(true), logged(false), severity(SevInfo), type(type), id(id) { setMaxFieldLength(0); setMaxEventLength(0); } TraceEvent::TraceEvent(Severity severity, const char* type, UID id) - : id(id), type(type), severity(severity), initialized(false), logged(false), - enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= severity) { + : initialized(false), enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= severity), logged(false), + severity(severity), type(type), id(id) { setMaxFieldLength(0); setMaxEventLength(0); } TraceEvent::TraceEvent(TraceInterval& interval, UID id) - : id(id), type(interval.type), severity(interval.severity), initialized(false), logged(false), - enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= interval.severity) { - + : initialized(false), enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= interval.severity), + logged(false), type(interval.type), id(id), severity(interval.severity) { setMaxFieldLength(0); setMaxEventLength(0); init(interval); } TraceEvent::TraceEvent(Severity severity, TraceInterval& interval, UID id) - : id(id), type(interval.type), severity(severity), initialized(false), logged(false), - enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= severity) { + : initialized(false), logged(false), enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= severity), + type(interval.type), id(id), severity(severity) { setMaxFieldLength(0); setMaxEventLength(0); diff --git a/flow/Tracing.actor.cpp b/flow/Tracing.actor.cpp index de62069a4f..f3bb438e14 100644 --- a/flow/Tracing.actor.cpp +++ b/flow/Tracing.actor.cpp @@ -276,7 +276,7 @@ ACTOR Future fastTraceLogger(int* unreadyMessages, int* failedMessages, in struct FastUDPTracer : public UDPTracer { FastUDPTracer() - : socket_fd_(-1), unready_socket_messages_(0), failed_messages_(0), total_messages_(0), send_error_(false) { + : unready_socket_messages_(0), failed_messages_(0), total_messages_(0), socket_fd_(-1), send_error_(false) { request_ = TraceRequest{ .buffer = std::make_unique(kTraceBufferSize), .data_size = 0, .buffer_size = kTraceBufferSize }; From b20e02ca25b3b112aca8bea6e56eeaac911f189e Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 11:43:19 -0700 Subject: [PATCH 095/225] Fix more -Wreorder-ctor warnings across several files --- fdbclient/TaskBucket.actor.cpp | 11 +++++------ fdbrpc/FlowTransport.actor.cpp | 2 +- fdbserver/ConfigBroadcaster.actor.cpp | 2 +- fdbserver/LocalConfiguration.actor.cpp | 6 +++--- flow/Trace.cpp | 6 +++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fdbclient/TaskBucket.actor.cpp b/fdbclient/TaskBucket.actor.cpp index 97c58efa9a..a1f6526fd3 100644 --- a/fdbclient/TaskBucket.actor.cpp +++ b/fdbclient/TaskBucket.actor.cpp @@ -873,13 +873,12 @@ TaskBucket::TaskBucket(const Subspace& subspace, AccessSystemKeys sysAccess, PriorityBatch priorityBatch, LockAware lockAware) - : cc("TaskBucket"), dbgid(deterministicRandom()->randomUniqueID()), - dispatchSlotChecksStarted("DispatchSlotChecksStarted", cc), dispatchErrors("DispatchErrors", cc), + : cc("TaskBucket"), dispatchSlotChecksStarted("DispatchSlotChecksStarted", cc), dispatchErrors("DispatchErrors", cc), dispatchDoTasks("DispatchDoTasks", cc), dispatchEmptyTasks("DispatchEmptyTasks", cc), - dispatchSlotChecksComplete("DispatchSlotChecksComplete", cc), prefix(subspace), - active(prefix.get(LiteralStringRef("ac"))), available(prefix.get(LiteralStringRef("av"))), - available_prioritized(prefix.get(LiteralStringRef("avp"))), timeouts(prefix.get(LiteralStringRef("to"))), - timeout(CLIENT_KNOBS->TASKBUCKET_TIMEOUT_VERSIONS), pauseKey(prefix.pack(LiteralStringRef("pause"))), + dispatchSlotChecksComplete("DispatchSlotChecksComplete", cc), dbgid(deterministicRandom()->randomUniqueID()), + prefix(subspace), active(prefix.get(LiteralStringRef("ac"))), pauseKey(prefix.pack(LiteralStringRef("pause"))), + available(prefix.get(LiteralStringRef("av"))), available_prioritized(prefix.get(LiteralStringRef("avp"))), + timeouts(prefix.get(LiteralStringRef("to"))), timeout(CLIENT_KNOBS->TASKBUCKET_TIMEOUT_VERSIONS), system_access(sysAccess), priority_batch(priorityBatch), lockAware(lockAware) {} TaskBucket::~TaskBucket() {} diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index d6af0d3eb7..3e75d09ae5 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -796,9 +796,9 @@ ACTOR Future connectionKeeper(Reference self, Peer::Peer(TransportData* transport, NetworkAddress const& destination) : transport(transport), destination(destination), compatible(true), outgoingConnectionIdle(true), lastConnectTime(0.0), reconnectionDelay(FLOW_KNOBS->INITIAL_RECONNECTION_TIME), peerReferences(-1), + incompatibleProtocolVersionNewer(false), bytesReceived(0), bytesSent(0), lastDataPacketSentTime(now()), outstandingReplies(0), pingLatencies(destination.isPublic() ? FLOW_KNOBS->PING_SAMPLE_AMOUNT : 1), lastLoggedTime(0.0), lastLoggedBytesReceived(0), lastLoggedBytesSent(0), timeoutCount(0), - incompatibleProtocolVersionNewer(false), bytesReceived(0), bytesSent(0), lastDataPacketSentTime(now()), protocolVersion(Reference>>(new AsyncVar>())), connectOutgoingCount(0), connectIncomingCount(0), connectFailedCount(0), connectLatencies(destination.isPublic() ? FLOW_KNOBS->NETWORK_CONNECT_SAMPLE_AMOUNT : 1) { diff --git a/fdbserver/ConfigBroadcaster.actor.cpp b/fdbserver/ConfigBroadcaster.actor.cpp index a5beb99e6a..7b060aaf99 100644 --- a/fdbserver/ConfigBroadcaster.actor.cpp +++ b/fdbserver/ConfigBroadcaster.actor.cpp @@ -203,7 +203,7 @@ class ConfigBroadcasterImpl { } ConfigBroadcasterImpl() - : mostRecentVersion(0), lastCompactedVersion(0), id(deterministicRandom()->randomUniqueID()), + : lastCompactedVersion(0), mostRecentVersion(0), id(deterministicRandom()->randomUniqueID()), cc("ConfigBroadcaster"), compactRequest("CompactRequest", cc), successfulChangeRequest("SuccessfulChangeRequest", cc), failedChangeRequest("FailedChangeRequest", cc), snapshotRequest("SnapshotRequest", cc) { diff --git a/fdbserver/LocalConfiguration.actor.cpp b/fdbserver/LocalConfiguration.actor.cpp index f375e6f85e..d77589600b 100644 --- a/fdbserver/LocalConfiguration.actor.cpp +++ b/fdbserver/LocalConfiguration.actor.cpp @@ -327,9 +327,9 @@ public: std::map const& manualKnobOverrides, IsTest isTest) : id(deterministicRandom()->randomUniqueID()), kvStore(dataFolder, id, "localconf-"), - configKnobOverrides(configPath), cc("LocalConfiguration"), broadcasterChanges("BroadcasterChanges", cc), - snapshots("Snapshots", cc), changeRequestsFetched("ChangeRequestsFetched", cc), mutations("Mutations", cc), - manualKnobOverrides(manualKnobOverrides) { + configKnobOverrides(configPath), manualKnobOverrides(manualKnobOverrides), cc("LocalConfiguration"), + broadcasterChanges("BroadcasterChanges", cc), snapshots("Snapshots", cc), + changeRequestsFetched("ChangeRequestsFetched", cc), mutations("Mutations", cc) { if (isTest) { testKnobCollection = IKnobCollection::create(IKnobCollection::Type::TEST, diff --git a/flow/Trace.cpp b/flow/Trace.cpp index c099636644..f54bb0f9c3 100644 --- a/flow/Trace.cpp +++ b/flow/Trace.cpp @@ -847,15 +847,15 @@ TraceEvent::TraceEvent(Severity severity, const char* type, UID id) } TraceEvent::TraceEvent(TraceInterval& interval, UID id) : initialized(false), enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= interval.severity), - logged(false), type(interval.type), id(id), severity(interval.severity) { + logged(false), severity(interval.severity), type(interval.type), id(id) { setMaxFieldLength(0); setMaxEventLength(0); init(interval); } TraceEvent::TraceEvent(Severity severity, TraceInterval& interval, UID id) - : initialized(false), logged(false), enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= severity), - type(interval.type), id(id), severity(severity) { + : initialized(false), enabled(g_network == nullptr || FLOW_KNOBS->MIN_TRACE_SEVERITY <= severity), logged(false), + severity(severity), type(interval.type), id(id) { setMaxFieldLength(0); setMaxEventLength(0); From da50e13f3e0568a49c1aa88576c8463fac6bfec8 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 17:29:27 -0700 Subject: [PATCH 096/225] Fix more -Wreorder-ctor warnings in DataDistribution.actor.cpp, OldTLogServer_4_6.actor.cpp, and Net2.actor.cpp --- fdbserver/DataDistribution.actor.cpp | 20 ++++++++++---------- fdbserver/OldTLogServer_4_6.actor.cpp | 19 +++++++++---------- flow/Net2.actor.cpp | 4 ++-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index ac6538596e..27dfd2f8b6 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -87,10 +87,10 @@ struct TCServerInfo : public ReferenceCounted { bool inDesiredDC, Reference storageServerSet, Version addedVersion = 0) - : id(ssi.id()), collection(collection), lastKnownInterface(ssi), lastKnownClass(processClass), - dataInFlightToServer(0), onInterfaceChanged(interfaceChanged.getFuture()), onRemoved(removed.getFuture()), - inDesiredDC(inDesiredDC), storeType(KeyValueStoreType::END), onTSSPairRemoved(Never()), - addedVersion(addedVersion) { + : id(ssi.id()), addedVersion(addedVersion), collection(collection), lastKnownInterface(ssi), + lastKnownClass(processClass), dataInFlightToServer(0), onInterfaceChanged(interfaceChanged.getFuture()), + onRemoved(removed.getFuture()), onTSSPairRemoved(Never()), inDesiredDC(inDesiredDC), + storeType(KeyValueStoreType::END) { if (!ssi.isTss()) { localityEntry = ((LocalityMap*)storageServerSet.getPtr())->add(ssi.locality, &id); @@ -187,7 +187,7 @@ public: Future tracker; explicit TCTeamInfo(vector> const& servers) - : servers(servers), healthy(true), priority(SERVER_KNOBS->PRIORITY_TEAM_HEALTHY), wrongConfiguration(false), + : servers(servers), healthy(true), wrongConfiguration(false), priority(SERVER_KNOBS->PRIORITY_TEAM_HEALTHY), id(deterministicRandom()->randomUniqueID()) { if (servers.empty()) { TraceEvent(SevInfo, "ConstructTCTeamFromEmptyServers"); @@ -377,8 +377,8 @@ struct ServerStatus { ServerStatus() : isWiggling(false), isFailed(true), isUndesired(false), isWrongConfiguration(false), initialized(false) {} ServerStatus(bool isFailed, bool isUndesired, bool isWiggling, LocalityData const& locality) - : isFailed(isFailed), isUndesired(isUndesired), locality(locality), isWrongConfiguration(false), - initialized(true), isWiggling(isWiggling) {} + : isWiggling(isWiggling), isFailed(isFailed), isUndesired(isUndesired), isWrongConfiguration(false), + initialized(true), locality(locality) {} bool isUnhealthy() const { return isFailed || isUndesired; } const char* toString() const { return isFailed ? "Failed" : isUndesired ? "Undesired" : isWiggling ? "Wiggling" : "Healthy"; @@ -751,8 +751,8 @@ struct DDTeamCollection : ReferenceCounted { zeroHealthyTeams(zeroHealthyTeams), zeroOptimalTeams(true), primary(primary), isTssRecruiting(false), medianAvailableSpace(SERVER_KNOBS->MIN_AVAILABLE_SPACE_RATIO), lastMedianAvailableSpaceUpdate(0), processingUnhealthy(processingUnhealthy), lowestUtilizationTeam(0), highestUtilizationTeam(0), - getShardMetrics(getShardMetrics), removeFailedServer(removeFailedServer), - getUnhealthyRelocationCount(getUnhealthyRelocationCount) { + getShardMetrics(getShardMetrics), getUnhealthyRelocationCount(getUnhealthyRelocationCount), + removeFailedServer(removeFailedServer) { if (!primary || configuration.usableRegions == 1) { TraceEvent("DDTrackerStarting", distributorId).detail("State", "Inactive").trackLatest("DDTrackerStarting"); } @@ -4987,7 +4987,7 @@ struct TSSPairState : ReferenceCounted, NonCopyable { TSSPairState() : active(false) {} TSSPairState(const LocalityData& locality) - : active(true), dcId(locality.dcId()), dataHallId(locality.dataHallId()) {} + : dcId(locality.dcId()), dataHallId(locality.dataHallId()), active(true) {} bool inDataZone(const LocalityData& locality) { return locality.dcId() == dcId && locality.dataHallId() == dataHallId; diff --git a/fdbserver/OldTLogServer_4_6.actor.cpp b/fdbserver/OldTLogServer_4_6.actor.cpp index ce291e644c..2501e43b75 100644 --- a/fdbserver/OldTLogServer_4_6.actor.cpp +++ b/fdbserver/OldTLogServer_4_6.actor.cpp @@ -90,7 +90,7 @@ struct TLogQueueEntryRef { TLogQueueEntryRef() : version(0), knownCommittedVersion(0) {} TLogQueueEntryRef(Arena& a, TLogQueueEntryRef const& from) - : version(from.version), knownCommittedVersion(from.knownCommittedVersion), id(from.id), + : id(from.id), version(from.version), knownCommittedVersion(from.knownCommittedVersion), messages(a, from.messages), tags(a, from.tags) {} template @@ -322,10 +322,10 @@ struct TLogData : NonCopyable { IKeyValueStore* persistentData, IDiskQueue* persistentQueue, Reference const> const& dbInfo) - : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), - persistentData(persistentData), rawPersistentQueue(persistentQueue), - persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), queueCommitBegin(0), queueCommitEnd(0), - prevVersion(0), diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), bytesInput(0), bytesDurable(0), + : dbgid(dbgid), workerID(workerID), persistentData(persistentData), rawPersistentQueue(persistentQueue), + persistentQueue(new TLogQueue(persistentQueue, dbgid)), diskQueueCommitBytes(0), + largeDiskQueueCommitBytes(false), dbInfo(dbInfo), queueCommitEnd(0), queueCommitBegin(0), + instanceID(deterministicRandom()->randomUniqueID().first()), bytesInput(0), bytesDurable(0), prevVersion(0), updatePersist(Void()), terminated(false) {} }; @@ -339,7 +339,7 @@ struct LogData : NonCopyable, public ReferenceCounted { bool update_version_sizes; TagData(Version popped, bool nothing_persistent, bool popped_recently, OldTag tag) - : nothing_persistent(nothing_persistent), popped(popped), popped_recently(popped_recently), + : nothing_persistent(nothing_persistent), popped_recently(popped_recently), popped(popped), update_version_sizes(tag != txsTagOld) {} TagData(TagData&& r) noexcept @@ -440,11 +440,10 @@ struct LogData : NonCopyable, public ReferenceCounted { Future recovery; explicit LogData(TLogData* tLogData, TLogInterface interf) - : tLogData(tLogData), knownCommittedVersion(0), tli(interf), logId(interf.id()), + : stopped(false), initialized(false), recoveryCount(), queueCommittingVersion(0), knownCommittedVersion(0), cc("TLog", interf.id().toString()), bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), - // These are initialized differently on init() or recovery - recoveryCount(), stopped(false), initialized(false), queueCommittingVersion(0), - newPersistentDataVersion(invalidVersion), recovery(Void()) { + logId(interf.id()), newPersistentDataVersion(invalidVersion), tli(interf), tLogData(tLogData), + recovery(Void()) { startRole(Role::TRANSACTION_LOG, interf.id(), tLogData->workerID, diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index 6d377d9746..fb07bab21b 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -1175,9 +1175,9 @@ Net2::Net2(const TLSConfig& tlsConfig, bool useThreadPool, bool useMetrics) boost::asio::ssl::context(boost::asio::ssl::context::tls)) }), sslHandshakerThreadsStarted(0), sslPoolHandshakesInProgress(0), #endif - tlsConfig(tlsConfig), network(this), tscBegin(0), tscEnd(0), taskBegin(0), + tlsConfig(tlsConfig), tlsInitializedState(ETLSInitState::NONE), network(this), tscBegin(0), tscEnd(0), taskBegin(0), currentTaskID(TaskPriority::DefaultYield), tasksIssued(0), stopped(false), started(false), numYields(0), - lastPriorityStats(nullptr), ready(FLOW_KNOBS->READY_QUEUE_RESERVED_SIZE), tlsInitializedState(ETLSInitState::NONE) { + lastPriorityStats(nullptr), ready(FLOW_KNOBS->READY_QUEUE_RESERVED_SIZE) { // Until run() is called, yield() will always yield TraceEvent("Net2Starting"); From e5e449b34049f5af580e5f453527fa6cc06a13b7 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 17:33:29 -0700 Subject: [PATCH 097/225] Fix more -Wreorder-ctor warnings in storageserver.actor.cpp --- fdbserver/storageserver.actor.cpp | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 7b21eaa7e3..36fdd8a03d 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -764,9 +764,9 @@ public: LatencyBands readLatencyBands; Counters(StorageServer* self) - : cc("StorageServer", self->thisServerID.toString()), getKeyQueries("GetKeyQueries", cc), - getValueQueries("GetValueQueries", cc), getRangeQueries("GetRangeQueries", cc), - getRangeStreamQueries("GetRangeStreamQueries", cc), allQueries("QueryQueue", cc), + : cc("StorageServer", self->thisServerID.toString()), allQueries("QueryQueue", cc), + getKeyQueries("GetKeyQueries", cc), getValueQueries("GetValueQueries", cc), + getRangeQueries("GetRangeQueries", cc), getRangeStreamQueries("GetRangeStreamQueries", cc), finishedQueries("FinishedQueries", cc), lowPriorityQueries("LowPriorityQueries", cc), rowsQueried("RowsQueried", cc), bytesQueried("BytesQueried", cc), watchQueries("WatchQueries", cc), emptyQueries("EmptyQueries", cc), bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), @@ -808,18 +808,7 @@ public: StorageServer(IKeyValueStore* storage, Reference const> const& db, StorageServerInterface const& ssi) - : instanceID(deterministicRandom()->randomUniqueID().first()), storage(this, storage), db(db), actors(false), - lastTLogVersion(0), lastVersionWithData(0), restoredVersion(0), - rebootAfterDurableVersion(std::numeric_limits::max()), durableInProgress(Void()), versionLag(0), - primaryLocality(tagLocalityInvalid), updateEagerReads(0), shardChangeCounter(0), - fetchKeysParallelismLock(SERVER_KNOBS->FETCH_KEYS_PARALLELISM), - fetchKeysBytesBudget(SERVER_KNOBS->STORAGE_FETCH_BYTES), fetchKeysBudgetUsed(false), shuttingDown(false), - debug_inApplyUpdate(false), debug_lastValidateTime(0), watchBytes(0), numWatches(0), logProtocol(0), - counters(this), tag(invalidTag), maxQueryQueue(0), thisServerID(ssi.id()), tssInQuarantine(false), - readQueueSizeMetric(LiteralStringRef("StorageServer.ReadQueueSize")), behind(false), versionBehind(false), - byteSampleClears(false, LiteralStringRef("\xff\xff\xff")), noRecentUpdates(false), lastUpdate(now()), - poppedAllAfter(std::numeric_limits::max()), cpuUsage(0.0), diskUsage(0.0), - tlogCursorReadsLatencyHistogram(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, + : tlogCursorReadsLatencyHistogram(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, TLOG_CURSOR_READS_LATENCY_HISTOGRAM, Histogram::Unit::microseconds)), ssVersionLockLatencyHistogram(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, @@ -842,7 +831,18 @@ public: Histogram::Unit::microseconds)), ssDurableVersionUpdateLatencyHistogram(Histogram::getHistogram(STORAGESERVER_HISTOGRAM_GROUP, SS_DURABLE_VERSION_UPDATE_LATENCY_HISTOGRAM, - Histogram::Unit::microseconds)) { + Histogram::Unit::microseconds)), + tag(invalidTag), poppedAllAfter(std::numeric_limits::max()), cpuUsage(0.0), diskUsage(0.0), + storage(this, storage), shardChangeCounter(0), lastTLogVersion(0), lastVersionWithData(0), restoredVersion(0), + rebootAfterDurableVersion(std::numeric_limits::max()), primaryLocality(tagLocalityInvalid), + versionLag(0), logProtocol(0), thisServerID(ssi.id()), tssInQuarantine(false), db(db), actors(false), + byteSampleClears(false, LiteralStringRef("\xff\xff\xff")), durableInProgress(Void()), watchBytes(0), + numWatches(0), noRecentUpdates(false), lastUpdate(now()), + readQueueSizeMetric(LiteralStringRef("StorageServer.ReadQueueSize")), updateEagerReads(nullptr), + fetchKeysParallelismLock(SERVER_KNOBS->FETCH_KEYS_PARALLELISM), + fetchKeysBytesBudget(SERVER_KNOBS->STORAGE_FETCH_BYTES), fetchKeysBudgetUsed(false), + instanceID(deterministicRandom()->randomUniqueID().first()), shuttingDown(false), behind(false), + versionBehind(false), debug_inApplyUpdate(false), debug_lastValidateTime(0), maxQueryQueue(0), counters(this) { version.initMetric(LiteralStringRef("StorageServer.Version"), counters.cc.id); oldestVersion.initMetric(LiteralStringRef("StorageServer.OldestVersion"), counters.cc.id); durableVersion.initMetric(LiteralStringRef("StorageServer.DurableVersion"), counters.cc.id); @@ -3154,7 +3154,7 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { }; AddingShard::AddingShard(StorageServer* server, KeyRangeRef const& keys) - : server(server), keys(keys), transferredVersion(invalidVersion), phase(WaitPrevious) { + : keys(keys), server(server), transferredVersion(invalidVersion), phase(WaitPrevious) { fetchClient = fetchKeys(server, this); } @@ -3405,7 +3405,7 @@ public: : currentVersion(invalidVersion), fromVersion(invalidVersion), restoredVersion(invalidVersion), processedStartKey(false), processedCacheStartKey(false) {} StorageUpdater(Version fromVersion, Version restoredVersion) - : fromVersion(fromVersion), currentVersion(fromVersion), restoredVersion(restoredVersion), + : currentVersion(fromVersion), fromVersion(fromVersion), restoredVersion(restoredVersion), processedStartKey(false), processedCacheStartKey(false) {} void applyMutation(StorageServer* data, MutationRef const& m, Version ver) { From a27d7c86f440c0efbfe4c12fd25a978bc9f9917b Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 22:14:43 -0700 Subject: [PATCH 098/225] Fix more -Wreorder-ctor warnings in DataDistribution.actor.cpp --- fdbserver/DataDistribution.actor.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 27dfd2f8b6..7dd61aa651 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -737,20 +737,20 @@ struct DDTeamCollection : ReferenceCounted { PromiseStream getShardMetrics, Promise removeFailedServer, PromiseStream> getUnhealthyRelocationCount) - : cx(cx), distributorId(distributorId), lock(lock), output(output), - shardsAffectedByTeamFailure(shardsAffectedByTeamFailure), doBuildTeams(true), lastBuildTeamsFailed(false), - teamBuilder(Void()), badTeamRemover(Void()), checkInvalidLocalities(Void()), wrongStoreTypeRemover(Void()), - configuration(configuration), readyToStart(readyToStart), clearHealthyZoneFuture(true), - checkTeamDelay(delay(SERVER_KNOBS->CHECK_TEAM_DELAY, TaskPriority::DataDistribution)), + : cx(cx), distributorId(distributorId), configuration(configuration), doBuildTeams(true), + lastBuildTeamsFailed(false), teamBuilder(Void()), lock(lock), output(output), unhealthyServers(0), + shardsAffectedByTeamFailure(shardsAffectedByTeamFailure), initialFailureReactionDelay( delayed(readyToStart, SERVER_KNOBS->INITIAL_FAILURE_REACTION_DELAY, TaskPriority::DataDistribution)), - healthyTeamCount(0), storageServerSet(new LocalityMap()), initializationDoneActor(logOnCompletion(readyToStart && initialFailureReactionDelay, this)), - optimalTeamCount(0), recruitingStream(0), restartRecruiting(SERVER_KNOBS->DEBOUNCE_RECRUITING_DELAY), - unhealthyServers(0), includedDCs(includedDCs), otherTrackedDCs(otherTrackedDCs), - zeroHealthyTeams(zeroHealthyTeams), zeroOptimalTeams(true), primary(primary), isTssRecruiting(false), - medianAvailableSpace(SERVER_KNOBS->MIN_AVAILABLE_SPACE_RATIO), lastMedianAvailableSpaceUpdate(0), - processingUnhealthy(processingUnhealthy), lowestUtilizationTeam(0), highestUtilizationTeam(0), + recruitingStream(0), restartRecruiting(SERVER_KNOBS->DEBOUNCE_RECRUITING_DELAY), healthyTeamCount(0), + zeroHealthyTeams(zeroHealthyTeams), optimalTeamCount(0), zeroOptimalTeams(true), isTssRecruiting(false), + includedDCs(includedDCs), otherTrackedDCs(otherTrackedDCs), primary(primary), + processingUnhealthy(processingUnhealthy), readyToStart(readyToStart), + checkTeamDelay(delay(SERVER_KNOBS->CHECK_TEAM_DELAY, TaskPriority::DataDistribution)), badTeamRemover(Void()), + checkInvalidLocalities(Void()), wrongStoreTypeRemover(Void()), storageServerSet(new LocalityMap()), + clearHealthyZoneFuture(true), medianAvailableSpace(SERVER_KNOBS->MIN_AVAILABLE_SPACE_RATIO), + lastMedianAvailableSpaceUpdate(0), lowestUtilizationTeam(0), highestUtilizationTeam(0), getShardMetrics(getShardMetrics), getUnhealthyRelocationCount(getUnhealthyRelocationCount), removeFailedServer(removeFailedServer) { if (!primary || configuration.usableRegions == 1) { From e26efd6799c3a2c87e77286cfc20ba718671d758 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 22:51:57 -0700 Subject: [PATCH 099/225] Fix more -Wreorder-ctor warnings in OldTLogServer_6_2.actor.cpp --- fdbserver/OldTLogServer_6_2.actor.cpp | 39 +++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/fdbserver/OldTLogServer_6_2.actor.cpp b/fdbserver/OldTLogServer_6_2.actor.cpp index 91649c3054..e2c8e8f3a0 100644 --- a/fdbserver/OldTLogServer_6_2.actor.cpp +++ b/fdbserver/OldTLogServer_6_2.actor.cpp @@ -367,14 +367,14 @@ struct TLogData : NonCopyable { Reference const> dbInfo, Reference> degraded, std::string folder) - : dbgid(dbgid), workerID(workerID), instanceID(deterministicRandom()->randomUniqueID().first()), - persistentData(persistentData), rawPersistentQueue(persistentQueue), - persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), queueCommitEnd(0), degraded(degraded), - queueCommitBegin(0), diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), bytesInput(0), bytesDurable(0), + : dbgid(dbgid), workerID(workerID), persistentData(persistentData), rawPersistentQueue(persistentQueue), + persistentQueue(new TLogQueue(persistentQueue, dbgid)), diskQueueCommitBytes(0), + largeDiskQueueCommitBytes(false), dbInfo(dbInfo), queueCommitEnd(0), queueCommitBegin(0), + instanceID(deterministicRandom()->randomUniqueID().first()), bytesInput(0), bytesDurable(0), targetVolatileBytes(SERVER_KNOBS->TLOG_SPILL_THRESHOLD), overheadBytesInput(0), overheadBytesDurable(0), peekMemoryLimiter(SERVER_KNOBS->TLOG_SPILL_REFERENCE_MAX_PEEK_MEMORY_BYTES), concurrentLogRouterReads(SERVER_KNOBS->CONCURRENT_LOG_ROUTER_READS), ignorePopRequest(false), - ignorePopDeadline(), ignorePopUid(), dataFolder(folder), toBePopped() { + dataFolder(folder), degraded(degraded) { cx = openDBOnServer(dbInfo, TaskPriority::DefaultEndpoint, LockAware::True); } }; @@ -398,15 +398,15 @@ struct LogData : NonCopyable, public ReferenceCounted { bool nothingPersistent, bool poppedRecently, bool unpoppedRecovered) - : tag(tag), nothingPersistent(nothingPersistent), poppedRecently(poppedRecently), popped(popped), - persistentPopped(0), versionForPoppedLocation(0), poppedLocation(poppedLocation), - unpoppedRecovered(unpoppedRecovered) {} + : nothingPersistent(nothingPersistent), poppedRecently(poppedRecently), popped(popped), persistentPopped(0), + versionForPoppedLocation(0), poppedLocation(poppedLocation), unpoppedRecovered(unpoppedRecovered), + tag(tag) {} TagData(TagData&& r) noexcept : versionMessages(std::move(r.versionMessages)), nothingPersistent(r.nothingPersistent), poppedRecently(r.poppedRecently), popped(r.popped), persistentPopped(r.persistentPopped), - versionForPoppedLocation(r.versionForPoppedLocation), poppedLocation(r.poppedLocation), tag(r.tag), - unpoppedRecovered(r.unpoppedRecovered) {} + versionForPoppedLocation(r.versionForPoppedLocation), poppedLocation(r.poppedLocation), + unpoppedRecovered(r.unpoppedRecovered), tag(r.tag) {} void operator=(TagData&& r) noexcept { versionMessages = std::move(r.versionMessages); nothingPersistent = r.nothingPersistent; @@ -607,16 +607,15 @@ struct LogData : NonCopyable, public ReferenceCounted { ProtocolVersion protocolVersion, std::vector tags, std::string context) - : cc("TLog", interf.id().toString()), bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), - logId(interf.id()), tLogData(tLogData), knownCommittedVersion(0), remoteTag(remoteTag), isPrimary(isPrimary), - logRouterTags(logRouterTags), txsTags(txsTags), recruitmentID(recruitmentID), protocolVersion(protocolVersion), - logSystem(new AsyncVar>()), logRouterPoppedVersion(0), durableKnownCommittedVersion(0), - minKnownCommittedVersion(0), queuePoppedVersion(0), allTags(tags.begin(), tags.end()), - terminated(tLogData->terminated.getFuture()), minPoppedTagVersion(0), minPoppedTag(invalidTag), - // These are initialized differently on init() or recovery - recoveryCount(), stopped(false), initialized(false), queueCommittingVersion(0), - newPersistentDataVersion(invalidVersion), unrecoveredBefore(1), recoveredAt(1), unpoppedRecoveredTags(0), - logRouterPopToVersion(0), locality(tagLocalityInvalid), execOpCommitInProgress(false) { + : stopped(false), initialized(false), recoveryCount(), queueCommittingVersion(0), knownCommittedVersion(0), + durableKnownCommittedVersion(0), minKnownCommittedVersion(0), queuePoppedVersion(0), minPoppedTagVersion(0), + minPoppedTag(invalidTag), unpoppedRecoveredTags(0), cc("TLog", interf.id().toString()), + bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), logId(interf.id()), + protocolVersion(protocolVersion), newPersistentDataVersion(invalidVersion), tLogData(tLogData), + unrecoveredBefore(1), recoveredAt(1), logSystem(new AsyncVar>()), remoteTag(remoteTag), + isPrimary(isPrimary), logRouterTags(logRouterTags), logRouterPoppedVersion(0), logRouterPopToVersion(0), + locality(tagLocalityInvalid), recruitmentID(recruitmentID), allTags(tags.begin(), tags.end()), + terminated(tLogData->terminated.getFuture()), execOpCommitInProgress(false), txsTags(txsTags) { startRole(Role::TRANSACTION_LOG, interf.id(), tLogData->workerID, From 23558a5430e459ffeac9f978794f6c589620fb1f Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 23:15:22 -0700 Subject: [PATCH 100/225] Fix -Wreorder-ctor warnings in TLogServer.actor.cpp --- fdbserver/TLogServer.actor.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index 97c0856a25..fe87918233 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -376,8 +376,8 @@ struct TLogData : NonCopyable { Reference> degraded, std::string folder) : dbgid(dbgid), workerID(workerID), persistentData(persistentData), rawPersistentQueue(persistentQueue), - persistentQueue(new TLogQueue(persistentQueue, dbgid)), dbInfo(dbInfo), queueCommitEnd(0), queueCommitBegin(0), - diskQueueCommitBytes(0), largeDiskQueueCommitBytes(false), + persistentQueue(new TLogQueue(persistentQueue, dbgid)), diskQueueCommitBytes(0), + largeDiskQueueCommitBytes(false), dbInfo(dbInfo), queueCommitEnd(0), queueCommitBegin(0), instanceID(deterministicRandom()->randomUniqueID().first()), bytesInput(0), bytesDurable(0), targetVolatileBytes(SERVER_KNOBS->TLOG_SPILL_THRESHOLD), overheadBytesInput(0), overheadBytesDurable(0), peekMemoryLimiter(SERVER_KNOBS->TLOG_SPILL_REFERENCE_MAX_PEEK_MEMORY_BYTES), @@ -409,15 +409,15 @@ struct LogData : NonCopyable, public ReferenceCounted { bool nothingPersistent, bool poppedRecently, bool unpoppedRecovered) - : tag(tag), nothingPersistent(nothingPersistent), poppedRecently(poppedRecently), popped(popped), - persistentPopped(0), versionForPoppedLocation(0), poppedLocation(poppedLocation), - unpoppedRecovered(unpoppedRecovered) {} + : nothingPersistent(nothingPersistent), poppedRecently(poppedRecently), popped(popped), persistentPopped(0), + versionForPoppedLocation(0), poppedLocation(poppedLocation), unpoppedRecovered(unpoppedRecovered), + tag(tag) {} TagData(TagData&& r) noexcept : versionMessages(std::move(r.versionMessages)), nothingPersistent(r.nothingPersistent), poppedRecently(r.poppedRecently), popped(r.popped), persistentPopped(r.persistentPopped), - versionForPoppedLocation(r.versionForPoppedLocation), poppedLocation(r.poppedLocation), tag(r.tag), - unpoppedRecovered(r.unpoppedRecovered) {} + versionForPoppedLocation(r.versionForPoppedLocation), poppedLocation(r.poppedLocation), + unpoppedRecovered(r.unpoppedRecovered), tag(r.tag) {} void operator=(TagData&& r) noexcept { versionMessages = std::move(r.versionMessages); nothingPersistent = r.nothingPersistent; @@ -626,16 +626,16 @@ struct LogData : NonCopyable, public ReferenceCounted { TLogSpillType logSpillType, std::vector tags, std::string context) - : stopped(false), initialized(false), knownCommittedVersion(0), cc("TLog", interf.id().toString()), + : stopped(false), initialized(false), queueCommittingVersion(0), knownCommittedVersion(0), + durableKnownCommittedVersion(0), minKnownCommittedVersion(0), queuePoppedVersion(0), minPoppedTagVersion(0), + minPoppedTag(invalidTag), unpoppedRecoveredTags(0), cc("TLog", interf.id().toString()), bytesInput("BytesInput", cc), bytesDurable("BytesDurable", cc), logId(interf.id()), protocolVersion(protocolVersion), newPersistentDataVersion(invalidVersion), tLogData(tLogData), unrecoveredBefore(1), recoveredAt(1), logSystem(new AsyncVar>()), remoteTag(remoteTag), - isPrimary(isPrimary), logRouterTags(logRouterTags), txsTags(txsTags), recruitmentID(recruitmentID), - logSpillType(logSpillType), logRouterPoppedVersion(0), durableKnownCommittedVersion(0), - minKnownCommittedVersion(0), queuePoppedVersion(0), allTags(tags.begin(), tags.end()), - terminated(tLogData->terminated.getFuture()), minPoppedTagVersion(0), minPoppedTag(invalidTag), - queueCommittingVersion(0), unpoppedRecoveredTags(0), logRouterPopToVersion(0), locality(tagLocalityInvalid), - execOpCommitInProgress(false) { + isPrimary(isPrimary), logRouterTags(logRouterTags), logRouterPoppedVersion(0), logRouterPopToVersion(0), + locality(tagLocalityInvalid), recruitmentID(recruitmentID), logSpillType(logSpillType), + allTags(tags.begin(), tags.end()), terminated(tLogData->terminated.getFuture()), execOpCommitInProgress(false), + txsTags(txsTags) { startRole(Role::TRANSACTION_LOG, interf.id(), tLogData->workerID, From cedaa72c0f1a7e279fe8da31fb8a5ffaa911807a Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sat, 24 Jul 2021 23:23:52 -0700 Subject: [PATCH 101/225] Enable reorder and reorder-ctor warnings --- cmake/ConfigureCompiler.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index ed18a8d4ea..5468da9479 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -291,8 +291,6 @@ else() -Wno-format -Wno-mismatched-tags -Wno-missing-field-initializers - -Wno-reorder - -Wno-reorder-ctor -Wno-sign-compare -Wno-tautological-pointer-compare -Wno-undefined-var-template From 79f7b3c13a7bb5a0ec978f34a28fec6e085b9f36 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 25 Jul 2021 10:57:48 -0700 Subject: [PATCH 102/225] Remove macros from ACTOR functions in BackupContainerAzureBlobStore.actor.cpp --- .../BackupContainerAzureBlobStore.actor.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index aee52df03e..0839e9114f 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -163,6 +163,15 @@ public: static bool isDirectory(const std::string& blobName) { return blobName.size() && blobName.back() == '/'; } + // Hack to get around the fact that macros don't work inside actor functions + static Reference encryptFile(Reference const& f, AsyncFileEncrypted::Mode mode) { + Reference result = f; +#if ENCRYPTION_ENABLED + result = makeReference(result, mode); +#endif + return result; + } + ACTOR static Future> readFile(BackupContainerAzureBlobStore* self, std::string fileName) { bool exists = wait(self->blobExists(fileName)); if (!exists) { @@ -170,11 +179,9 @@ public: } Reference f = makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); -#if ENCRYPTION_ENABLED if (self->usesEncryption()) { - f = makeReference(f, AsyncFileEncrypted::Mode::READ_ONLY); + f = encryptFile(f, AsyncFileEncrypted::Mode::READ_ONLY); } -#endif return f; } @@ -184,12 +191,11 @@ public: auto outcome = client->create_append_blob(containerName, fileName).get(); return Void(); })); - auto f = makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); -#if ENCRYPTION_ENABLED + Reference f = + makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); if (self->usesEncryption()) { - f = makeReference(f, AsyncFileEncrypted::Mode::APPEND_ONLY); + f = encryptFile(f, AsyncFileEncrypted::Mode::APPEND_ONLY); } -#endif return makeReference(fileName, f); } From c9e063f5f7e70c385dce477e626c9e4326cf053c Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 25 Jul 2021 11:08:39 -0700 Subject: [PATCH 103/225] Remove reference fields from BackupContainerAzureBlobStoreImpl::ReadFile and BackupContainerAzureBlobStoreImpl::WriteFile --- .../BackupContainerAzureBlobStore.actor.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 0839e9114f..0f3bd0f1bb 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -28,7 +28,7 @@ public: using AzureClient = azure::storage_lite::blob_client; class ReadFile final : public IAsyncFile, ReferenceCounted { - AsyncTaskThread& asyncTaskThread; + AsyncTaskThread* asyncTaskThread; std::string containerName; std::string blobName; AzureClient* client; @@ -37,18 +37,18 @@ public: ReadFile(AsyncTaskThread& asyncTaskThread, const std::string& containerName, const std::string& blobName, - AzureClient* client) - : asyncTaskThread(asyncTaskThread), containerName(containerName), blobName(blobName), client(client) {} + AzureClient& client) + : asyncTaskThread(&asyncTaskThread), containerName(containerName), blobName(blobName), client(&client) {} void addref() override { ReferenceCounted::addref(); } void delref() override { ReferenceCounted::delref(); } Future read(void* data, int length, int64_t offset) override { - return asyncTaskThread.execAsync([client = this->client, - containerName = this->containerName, - blobName = this->blobName, - data, - length, - offset] { + return asyncTaskThread->execAsync([client = this->client, + containerName = this->containerName, + blobName = this->blobName, + data, + length, + offset] { std::ostringstream oss(std::ios::out | std::ios::binary); client->download_blob_to_stream(containerName, blobName, offset, length, oss); auto str = std::move(oss).str(); @@ -61,9 +61,9 @@ public: Future truncate(int64_t size) override { throw file_not_writable(); } Future sync() override { throw file_not_writable(); } Future size() const override { - return asyncTaskThread.execAsync([client = this->client, - containerName = this->containerName, - blobName = this->blobName] { + return asyncTaskThread->execAsync([client = this->client, + containerName = this->containerName, + blobName = this->blobName] { return static_cast(client->get_blob_properties(containerName, blobName).get().response().size); }); } @@ -72,7 +72,7 @@ public: }; class WriteFile final : public IAsyncFile, ReferenceCounted { - AsyncTaskThread& asyncTaskThread; + AsyncTaskThread* asyncTaskThread; AzureClient* client; std::string containerName; std::string blobName; @@ -88,8 +88,8 @@ public: WriteFile(AsyncTaskThread& asyncTaskThread, const std::string& containerName, const std::string& blobName, - AzureClient* client) - : asyncTaskThread(asyncTaskThread), containerName(containerName), blobName(blobName), client(client) {} + AzureClient& client) + : asyncTaskThread(&asyncTaskThread), containerName(containerName), blobName(blobName), client(&client) {} void addref() override { ReferenceCounted::addref(); } void delref() override { ReferenceCounted::delref(); } @@ -116,17 +116,17 @@ public: Future sync() override { auto movedBuffer = std::move(buffer); buffer.clear(); - return asyncTaskThread.execAsync([client = this->client, - containerName = this->containerName, - blobName = this->blobName, - buffer = std::move(movedBuffer)] { + return asyncTaskThread->execAsync([client = this->client, + containerName = this->containerName, + blobName = this->blobName, + buffer = std::move(movedBuffer)] { std::istringstream iss(std::move(buffer)); auto resp = client->append_block_from_stream(containerName, blobName, iss).get(); return Void(); }); } Future size() const override { - return asyncTaskThread.execAsync( + return asyncTaskThread->execAsync( [client = this->client, containerName = this->containerName, blobName = this->blobName] { auto resp = client->get_blob_properties(containerName, blobName).get().response(); ASSERT(resp.valid()); // TODO: Should instead throw here @@ -178,7 +178,7 @@ public: throw file_not_found(); } Reference f = - makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); + makeReference(self->asyncTaskThread, self->containerName, fileName, *self->client); if (self->usesEncryption()) { f = encryptFile(f, AsyncFileEncrypted::Mode::READ_ONLY); } @@ -192,7 +192,7 @@ public: return Void(); })); Reference f = - makeReference(self->asyncTaskThread, self->containerName, fileName, self->client.get()); + makeReference(self->asyncTaskThread, self->containerName, fileName, *self->client); if (self->usesEncryption()) { f = encryptFile(f, AsyncFileEncrypted::Mode::APPEND_ONLY); } From 7cb879d79a21f46a501731a46ba2479d904c5c97 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Sun, 25 Jul 2021 11:13:33 -0700 Subject: [PATCH 104/225] Use std::shared_ptr for BackupContainerAzureBlobStore::client --- .../BackupContainerAzureBlobStore.actor.cpp | 58 +++++++++---------- fdbclient/BackupContainerAzureBlobStore.h | 2 +- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 0f3bd0f1bb..d79db91849 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -31,14 +31,14 @@ public: AsyncTaskThread* asyncTaskThread; std::string containerName; std::string blobName; - AzureClient* client; + std::shared_ptr client; public: ReadFile(AsyncTaskThread& asyncTaskThread, const std::string& containerName, const std::string& blobName, - AzureClient& client) - : asyncTaskThread(&asyncTaskThread), containerName(containerName), blobName(blobName), client(&client) {} + std::shared_ptr const& client) + : asyncTaskThread(&asyncTaskThread), containerName(containerName), blobName(blobName), client(client) {} void addref() override { ReferenceCounted::addref(); } void delref() override { ReferenceCounted::delref(); } @@ -73,7 +73,7 @@ public: class WriteFile final : public IAsyncFile, ReferenceCounted { AsyncTaskThread* asyncTaskThread; - AzureClient* client; + std::shared_ptr client; std::string containerName; std::string blobName; int64_t m_cursor{ 0 }; @@ -88,8 +88,8 @@ public: WriteFile(AsyncTaskThread& asyncTaskThread, const std::string& containerName, const std::string& blobName, - AzureClient& client) - : asyncTaskThread(&asyncTaskThread), containerName(containerName), blobName(blobName), client(&client) {} + std::shared_ptr const& client) + : asyncTaskThread(&asyncTaskThread), containerName(containerName), blobName(blobName), client(client) {} void addref() override { ReferenceCounted::addref(); } void delref() override { ReferenceCounted::delref(); } @@ -178,7 +178,7 @@ public: throw file_not_found(); } Reference f = - makeReference(self->asyncTaskThread, self->containerName, fileName, *self->client); + makeReference(self->asyncTaskThread, self->containerName, fileName, self->client); if (self->usesEncryption()) { f = encryptFile(f, AsyncFileEncrypted::Mode::READ_ONLY); } @@ -187,19 +187,19 @@ public: ACTOR static Future> writeFile(BackupContainerAzureBlobStore* self, std::string fileName) { wait(self->asyncTaskThread.execAsync( - [client = self->client.get(), containerName = self->containerName, fileName = fileName] { + [client = self->client, containerName = self->containerName, fileName = fileName] { auto outcome = client->create_append_blob(containerName, fileName).get(); return Void(); })); Reference f = - makeReference(self->asyncTaskThread, self->containerName, fileName, *self->client); + makeReference(self->asyncTaskThread, self->containerName, fileName, self->client); if (self->usesEncryption()) { f = encryptFile(f, AsyncFileEncrypted::Mode::APPEND_ONLY); } return makeReference(fileName, f); } - static void listFiles(AzureClient* client, + static void listFiles(std::shared_ptr const& client, const std::string& containerName, const std::string& path, std::function folderPathFilter, @@ -220,7 +220,7 @@ public: BackupContainerFileSystem::FilesAndSizesT files = wait(self->listFiles()); filesToDelete = files.size(); } - wait(self->asyncTaskThread.execAsync([containerName = self->containerName, client = self->client.get()] { + wait(self->asyncTaskThread.execAsync([containerName = self->containerName, client = self->client] { client->delete_container(containerName).wait(); return Void(); })); @@ -233,11 +233,10 @@ public: }; Future BackupContainerAzureBlobStore::blobExists(const std::string& fileName) { - return asyncTaskThread.execAsync( - [client = this->client.get(), containerName = this->containerName, fileName = fileName] { - auto resp = client->get_blob_properties(containerName, fileName).get().response(); - return resp.valid(); - }); + return asyncTaskThread.execAsync([client = this->client, containerName = this->containerName, fileName = fileName] { + auto resp = client->get_blob_properties(containerName, fileName).get().response(); + return resp.valid(); + }); } BackupContainerAzureBlobStore::BackupContainerAzureBlobStore(const NetworkAddress& address, @@ -263,7 +262,7 @@ void BackupContainerAzureBlobStore::delref() { Future BackupContainerAzureBlobStore::create() { Future createContainerFuture = - asyncTaskThread.execAsync([containerName = this->containerName, client = this->client.get()] { + asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { client->create_container(containerName).wait(); return Void(); }); @@ -271,7 +270,7 @@ Future BackupContainerAzureBlobStore::create() { return createContainerFuture && encryptionSetupFuture; } Future BackupContainerAzureBlobStore::exists() { - return asyncTaskThread.execAsync([containerName = this->containerName, client = this->client.get()] { + return asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { auto resp = client->get_container_properties(containerName).get().response(); return resp.valid(); }); @@ -288,22 +287,19 @@ Future> BackupContainerAzureBlobStore::writeFile(const st Future BackupContainerAzureBlobStore::listFiles( const std::string& path, std::function folderPathFilter) { - return asyncTaskThread.execAsync([client = this->client.get(), - containerName = this->containerName, - path = path, - folderPathFilter = folderPathFilter] { - FilesAndSizesT result; - BackupContainerAzureBlobStoreImpl::listFiles(client, containerName, path, folderPathFilter, result); - return result; - }); + return asyncTaskThread.execAsync( + [client = this->client, containerName = this->containerName, path = path, folderPathFilter = folderPathFilter] { + FilesAndSizesT result; + BackupContainerAzureBlobStoreImpl::listFiles(client, containerName, path, folderPathFilter, result); + return result; + }); } Future BackupContainerAzureBlobStore::deleteFile(const std::string& fileName) { - return asyncTaskThread.execAsync( - [containerName = this->containerName, fileName = fileName, client = client.get()]() { - client->delete_blob(containerName, fileName).wait(); - return Void(); - }); + return asyncTaskThread.execAsync([containerName = this->containerName, fileName = fileName, client = client]() { + client->delete_blob(containerName, fileName).wait(); + return Void(); + }); } Future BackupContainerAzureBlobStore::deleteContainer(int* pNumDeleted) { diff --git a/fdbclient/BackupContainerAzureBlobStore.h b/fdbclient/BackupContainerAzureBlobStore.h index aae378fcf4..ec569ced97 100644 --- a/fdbclient/BackupContainerAzureBlobStore.h +++ b/fdbclient/BackupContainerAzureBlobStore.h @@ -33,7 +33,7 @@ class BackupContainerAzureBlobStore final : public BackupContainerFileSystem, ReferenceCounted { using AzureClient = azure::storage_lite::blob_client; - std::unique_ptr client; + std::shared_ptr client; std::string containerName; AsyncTaskThread asyncTaskThread; From 34fecb61de698d0df8c033438fa28dab98c26513 Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Wed, 9 Jun 2021 14:24:00 -0400 Subject: [PATCH 105/225] Reject connections to clusters forwarded in the (configurable) past --- fdbclient/ServerKnobs.cpp | 1 + fdbserver/Coordination.actor.cpp | 34 +- fdbserver/Knobs.h | 644 ++++++++++++++++++++++++++++++- 3 files changed, 677 insertions(+), 2 deletions(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index 6d74c2f67a..4377afaa1b 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -653,6 +653,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi // Coordination init( COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL, 1.0 ); if( randomize && BUGGIFY ) COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL = 10.0; + init( FORWARD_REQUEST_TOO_OLD, 4*24*60*60 ); if( randomize && BUGGIFY ) FORWARD_REQUEST_TOO_OLD = 60.0; init( ENABLE_CROSS_CLUSTER_SUPPORT, true ); if( randomize && BUGGIFY ) ENABLE_CROSS_CLUSTER_SUPPORT = false; // Buggification diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index eeffd7b4d7..fc603746d4 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -425,12 +425,18 @@ const KeyRangeRef fwdKeys(LiteralStringRef("\xff" LiteralStringRef("\xff" "fwe")); +// The time when forwarding was last set is stored in this range: +const KeyRangeRef fwdTimeKeys(LiteralStringRef("\xff" + "fwdTime"), + LiteralStringRef("\xff" + "fwdTimf")); struct LeaderRegisterCollection { // SOMEDAY: Factor this into a generic tool? Extend ActorCollection to support removal actions? What? ActorCollection actors; Map registerInterfaces; Map forward; OnDemandStore* pStore; + Map forwardStartTime; LeaderRegisterCollection(OnDemandStore* pStore) : actors(false), pStore(pStore) {} @@ -438,32 +444,58 @@ struct LeaderRegisterCollection { if (!self->pStore->exists()) return Void(); OnDemandStore& store = *self->pStore; - RangeResult forwardingInfo = wait(store->readRange(fwdKeys)); + state Future> forwardingInfoF = store->readRange(fwdKeys); + state Future> forwardingTimeF = store->readRange(fwdTimeKeys); + wait(success(forwardingInfoF) && success(forwardingTimeF)); + Standalone forwardingInfo = forwardingInfoF.get(); + Standalone forwardingTime = forwardingTimeF.get(); for (int i = 0; i < forwardingInfo.size(); i++) { LeaderInfo forwardInfo; forwardInfo.forward = true; forwardInfo.serializedInfo = forwardingInfo[i].value; self->forward[forwardingInfo[i].key.removePrefix(fwdKeys.begin)] = forwardInfo; } + for (int i = 0; i < forwardingTime.size(); i++) { + double time = std::stod(forwardingTime[i].value.toString().c_str()); + self->forwardStartTime[forwardingTime[i].key.removePrefix(fwdTimeKeys.begin)] = time; + } return Void(); } Future onError() { return actors.getResult(); } + // Check if the this coordinator is no longer the leader, and the new one was stored in the "forward" keyspace. + // If the "forward" keyspace was set some time ago (as configured by knob), log an error to indicate the client is + // using a very old cluster file. Optional getForward(KeyRef key) { auto i = forward.find(key); + auto t = forwardStartTime.find(key); if (i == forward.end()) return Optional(); + if (t != forwardStartTime.end()) { + double forwardTime = t->value; + if (now() - forwardTime > SERVER_KNOBS->FORWARD_REQUEST_TOO_OLD) { + TraceEvent(SevWarnAlways, "AccessOldForward") + .detail("ForwardSetSecondsAgo", now() - forwardTime) + .detail("ForwardClusterKey", key); + } + } return i->value; } + // When the lead coordinator changes, store the new connection ID in the "fwd" keyspace. + // If a request arrives using an old connection id, resend it to the new coordinator using the stored connection id. + // Store when this change took place in the fwdTime keyspace. ACTOR static Future setForward(LeaderRegisterCollection* self, KeyRef key, ClusterConnectionString conn) { + double forwardTime = now(); LeaderInfo forwardInfo; forwardInfo.forward = true; forwardInfo.serializedInfo = conn.toString(); self->forward[key] = forwardInfo; + self->forwardStartTime[key] = forwardTime; OnDemandStore& store = *self->pStore; store->set(KeyValueRef(key.withPrefix(fwdKeys.begin), conn.toString())); + store->set(KeyValueRef(key.withPrefix(fwdTimeKeys.begin), std::to_string(forwardTime))); wait(store->commit()); return Void(); } diff --git a/fdbserver/Knobs.h b/fdbserver/Knobs.h index 67f474b0eb..44b653bd68 100644 --- a/fdbserver/Knobs.h +++ b/fdbserver/Knobs.h @@ -22,4 +22,646 @@ #include "fdbclient/IKnobCollection.h" -#define SERVER_KNOBS (&IKnobCollection::getGlobalKnobCollection().getServerKnobs()) +// Disk queue +static const int _PAGE_SIZE = 4096; + +class ServerKnobs : public Knobs { +public: + // Versions + int64_t VERSIONS_PER_SECOND; + int64_t MAX_VERSIONS_IN_FLIGHT; + int64_t MAX_VERSIONS_IN_FLIGHT_FORCED; + int64_t MAX_READ_TRANSACTION_LIFE_VERSIONS; + int64_t MAX_WRITE_TRANSACTION_LIFE_VERSIONS; + double MAX_COMMIT_BATCH_INTERVAL; // Each commit proxy generates a CommitTransactionBatchRequest at least this + // often, so that versions always advance smoothly + + // TLogs + double TLOG_TIMEOUT; // tlog OR commit proxy failure - master's reaction time + double TLOG_SLOW_REJOIN_WARN_TIMEOUT_SECS; // Warns if a tlog takes too long to rejoin + double RECOVERY_TLOG_SMART_QUORUM_DELAY; // smaller might be better for bug amplification + double TLOG_STORAGE_MIN_UPDATE_INTERVAL; + double BUGGIFY_TLOG_STORAGE_MIN_UPDATE_INTERVAL; + int DESIRED_TOTAL_BYTES; + int DESIRED_UPDATE_BYTES; + double UPDATE_DELAY; + int MAXIMUM_PEEK_BYTES; + int APPLY_MUTATION_BYTES; + int RECOVERY_DATA_BYTE_LIMIT; + int BUGGIFY_RECOVERY_DATA_LIMIT; + double LONG_TLOG_COMMIT_TIME; + int64_t LARGE_TLOG_COMMIT_BYTES; + double BUGGIFY_RECOVER_MEMORY_LIMIT; + double BUGGIFY_WORKER_REMOVED_MAX_LAG; + int64_t UPDATE_STORAGE_BYTE_LIMIT; + int64_t REFERENCE_SPILL_UPDATE_STORAGE_BYTE_LIMIT; + double TLOG_PEEK_DELAY; + int LEGACY_TLOG_UPGRADE_ENTRIES_PER_VERSION; + int VERSION_MESSAGES_OVERHEAD_FACTOR_1024THS; // Multiplicative factor to bound total space used to store a version + // message (measured in 1/1024ths, e.g. a value of 2048 yields a + // factor of 2). + int64_t VERSION_MESSAGES_ENTRY_BYTES_WITH_OVERHEAD; + double TLOG_MESSAGE_BLOCK_OVERHEAD_FACTOR; + int64_t TLOG_MESSAGE_BLOCK_BYTES; + int64_t MAX_MESSAGE_SIZE; + int LOG_SYSTEM_PUSHED_DATA_BLOCK_SIZE; + double PEEK_TRACKER_EXPIRATION_TIME; + int PARALLEL_GET_MORE_REQUESTS; + int MULTI_CURSOR_PRE_FETCH_LIMIT; + int64_t MAX_QUEUE_COMMIT_BYTES; + int DESIRED_OUTSTANDING_MESSAGES; + double DESIRED_GET_MORE_DELAY; + int CONCURRENT_LOG_ROUTER_READS; + int LOG_ROUTER_PEEK_FROM_SATELLITES_PREFERRED; // 0==peek from primary, non-zero==peek from satellites + double DISK_QUEUE_ADAPTER_MIN_SWITCH_TIME; + double DISK_QUEUE_ADAPTER_MAX_SWITCH_TIME; + int64_t TLOG_SPILL_REFERENCE_MAX_PEEK_MEMORY_BYTES; + int64_t TLOG_SPILL_REFERENCE_MAX_BATCHES_PER_PEEK; + int64_t TLOG_SPILL_REFERENCE_MAX_BYTES_PER_BATCH; + int64_t DISK_QUEUE_FILE_EXTENSION_BYTES; // When we grow the disk queue, by how many bytes should it grow? + int64_t DISK_QUEUE_FILE_SHRINK_BYTES; // When we shrink the disk queue, by how many bytes should it shrink? + int64_t DISK_QUEUE_MAX_TRUNCATE_BYTES; // A truncate larger than this will cause the file to be replaced instead. + double TLOG_DEGRADED_DURATION; + int64_t MAX_CACHE_VERSIONS; + double TXS_POPPED_MAX_DELAY; + double TLOG_MAX_CREATE_DURATION; + int PEEK_LOGGING_AMOUNT; + double PEEK_LOGGING_DELAY; + double PEEK_RESET_INTERVAL; + double PEEK_MAX_LATENCY; + bool PEEK_COUNT_SMALL_MESSAGES; + double PEEK_STATS_INTERVAL; + double PEEK_STATS_SLOW_AMOUNT; + double PEEK_STATS_SLOW_RATIO; + double PUSH_RESET_INTERVAL; + double PUSH_MAX_LATENCY; + double PUSH_STATS_INTERVAL; + double PUSH_STATS_SLOW_AMOUNT; + double PUSH_STATS_SLOW_RATIO; + int TLOG_POP_BATCH_SIZE; + + // Data distribution queue + double HEALTH_POLL_TIME; + double BEST_TEAM_STUCK_DELAY; + double BG_REBALANCE_POLLING_INTERVAL; + double BG_REBALANCE_SWITCH_CHECK_INTERVAL; + double DD_QUEUE_LOGGING_INTERVAL; + double RELOCATION_PARALLELISM_PER_SOURCE_SERVER; + int DD_QUEUE_MAX_KEY_SERVERS; + int DD_REBALANCE_PARALLELISM; + int DD_REBALANCE_RESET_AMOUNT; + double BG_DD_MAX_WAIT; + double BG_DD_MIN_WAIT; + double BG_DD_INCREASE_RATE; + double BG_DD_DECREASE_RATE; + double BG_DD_SATURATION_DELAY; + double INFLIGHT_PENALTY_HEALTHY; + double INFLIGHT_PENALTY_REDUNDANT; + double INFLIGHT_PENALTY_UNHEALTHY; + double INFLIGHT_PENALTY_ONE_LEFT; + bool USE_OLD_NEEDED_SERVERS; + + // Higher priorities are executed first + // Priority/100 is the "priority group"/"superpriority". Priority inversion + // is possible within but not between priority groups; fewer priority groups + // mean better worst case time bounds + // Maximum allowable priority is 999. + int PRIORITY_RECOVER_MOVE; + int PRIORITY_REBALANCE_UNDERUTILIZED_TEAM; + int PRIORITY_REBALANCE_OVERUTILIZED_TEAM; + int PRIORITY_TEAM_HEALTHY; + int PRIORITY_TEAM_CONTAINS_UNDESIRED_SERVER; + int PRIORITY_TEAM_REDUNDANT; + int PRIORITY_MERGE_SHARD; + int PRIORITY_POPULATE_REGION; + int PRIORITY_TEAM_UNHEALTHY; + int PRIORITY_TEAM_2_LEFT; + int PRIORITY_TEAM_1_LEFT; + int PRIORITY_TEAM_FAILED; // Priority when a server in the team is excluded as failed + int PRIORITY_TEAM_0_LEFT; + int PRIORITY_SPLIT_SHARD; + + // Data distribution + double RETRY_RELOCATESHARD_DELAY; + double DATA_DISTRIBUTION_FAILURE_REACTION_TIME; + int MIN_SHARD_BYTES, SHARD_BYTES_RATIO, SHARD_BYTES_PER_SQRT_BYTES, MAX_SHARD_BYTES, KEY_SERVER_SHARD_BYTES; + int64_t SHARD_MAX_BYTES_PER_KSEC, // Shards with more than this bandwidth will be split immediately + SHARD_MIN_BYTES_PER_KSEC, // Shards with more than this bandwidth will not be merged + SHARD_SPLIT_BYTES_PER_KSEC; // When splitting a shard, it is split into pieces with less than this bandwidth + double SHARD_MAX_READ_DENSITY_RATIO; + int64_t SHARD_READ_HOT_BANDWITH_MIN_PER_KSECONDS; + double SHARD_MAX_BYTES_READ_PER_KSEC_JITTER; + double STORAGE_METRIC_TIMEOUT; + double METRIC_DELAY; + double ALL_DATA_REMOVED_DELAY; + double INITIAL_FAILURE_REACTION_DELAY; + double CHECK_TEAM_DELAY; + double LOG_ON_COMPLETION_DELAY; + int BEST_TEAM_MAX_TEAM_TRIES; + int BEST_TEAM_OPTION_COUNT; + int BEST_OF_AMT; + double SERVER_LIST_DELAY; + double RECRUITMENT_IDLE_DELAY; + double STORAGE_RECRUITMENT_DELAY; + bool TSS_HACK_IDENTITY_MAPPING; + double TSS_RECRUITMENT_TIMEOUT; + double TSS_DD_KILL_INTERVAL; + double DATA_DISTRIBUTION_LOGGING_INTERVAL; + double DD_ENABLED_CHECK_DELAY; + double DD_STALL_CHECK_DELAY; + double DD_LOW_BANDWIDTH_DELAY; + double DD_MERGE_COALESCE_DELAY; + double STORAGE_METRICS_POLLING_DELAY; + double STORAGE_METRICS_RANDOM_DELAY; + double AVAILABLE_SPACE_RATIO_CUTOFF; + int DESIRED_TEAMS_PER_SERVER; + int MAX_TEAMS_PER_SERVER; + int64_t DD_SHARD_SIZE_GRANULARITY; + int64_t DD_SHARD_SIZE_GRANULARITY_SIM; + int DD_MOVE_KEYS_PARALLELISM; + int DD_FETCH_SOURCE_PARALLELISM; + int DD_MERGE_LIMIT; + double DD_SHARD_METRICS_TIMEOUT; + int64_t DD_LOCATION_CACHE_SIZE; + double MOVEKEYS_LOCK_POLLING_DELAY; + double DEBOUNCE_RECRUITING_DELAY; + int REBALANCE_MAX_RETRIES; + int DD_OVERLAP_PENALTY; + int DD_EXCLUDE_MIN_REPLICAS; + bool DD_VALIDATE_LOCALITY; + int DD_CHECK_INVALID_LOCALITY_DELAY; + bool DD_ENABLE_VERBOSE_TRACING; + int64_t + DD_SS_FAILURE_VERSIONLAG; // Allowed SS version lag from the current read version before marking it as failed. + int64_t DD_SS_ALLOWED_VERSIONLAG; // SS will be marked as healthy if it's version lag goes below this value. + double DD_SS_STUCK_TIME_LIMIT; // If a storage server is not getting new versions for this amount of time, then it + // becomes undesired. + int DD_TEAMS_INFO_PRINT_INTERVAL; + int DD_TEAMS_INFO_PRINT_YIELD_COUNT; + int DD_TEAM_ZERO_SERVER_LEFT_LOG_DELAY; + + // TeamRemover to remove redundant teams + bool TR_FLAG_DISABLE_MACHINE_TEAM_REMOVER; // disable the machineTeamRemover actor + double TR_REMOVE_MACHINE_TEAM_DELAY; // wait for the specified time before try to remove next machine team + bool TR_FLAG_REMOVE_MT_WITH_MOST_TEAMS; // guard to select which machineTeamRemover logic to use + + bool TR_FLAG_DISABLE_SERVER_TEAM_REMOVER; // disable the serverTeamRemover actor + double TR_REMOVE_SERVER_TEAM_DELAY; // wait for the specified time before try to remove next server team + double TR_REMOVE_SERVER_TEAM_EXTRA_DELAY; // serverTeamRemover waits for the delay and check DD healthyness again to + // ensure it runs after machineTeamRemover + + // Remove wrong storage engines + double DD_REMOVE_STORE_ENGINE_DELAY; // wait for the specified time before remove the next batch + + double DD_FAILURE_TIME; + double DD_ZERO_HEALTHY_TEAM_DELAY; + + // Redwood Storage Engine + int PREFIX_TREE_IMMEDIATE_KEY_SIZE_LIMIT; + int PREFIX_TREE_IMMEDIATE_KEY_SIZE_MIN; + + // KeyValueStore SQLITE + int CLEAR_BUFFER_SIZE; + double READ_VALUE_TIME_ESTIMATE; + double READ_RANGE_TIME_ESTIMATE; + double SET_TIME_ESTIMATE; + double CLEAR_TIME_ESTIMATE; + double COMMIT_TIME_ESTIMATE; + int CHECK_FREE_PAGE_AMOUNT; + double DISK_METRIC_LOGGING_INTERVAL; + int64_t SOFT_HEAP_LIMIT; + + int SQLITE_PAGE_SCAN_ERROR_LIMIT; + int SQLITE_BTREE_PAGE_USABLE; + int SQLITE_BTREE_CELL_MAX_LOCAL; + int SQLITE_BTREE_CELL_MIN_LOCAL; + int SQLITE_FRAGMENT_PRIMARY_PAGE_USABLE; + int SQLITE_FRAGMENT_OVERFLOW_PAGE_USABLE; + double SQLITE_FRAGMENT_MIN_SAVINGS; + int SQLITE_CHUNK_SIZE_PAGES; + int SQLITE_CHUNK_SIZE_PAGES_SIM; + int SQLITE_READER_THREADS; + int SQLITE_WRITE_WINDOW_LIMIT; + double SQLITE_WRITE_WINDOW_SECONDS; + + // KeyValueStoreSqlite spring cleaning + double SPRING_CLEANING_NO_ACTION_INTERVAL; + double SPRING_CLEANING_LAZY_DELETE_INTERVAL; + double SPRING_CLEANING_VACUUM_INTERVAL; + double SPRING_CLEANING_LAZY_DELETE_TIME_ESTIMATE; + double SPRING_CLEANING_VACUUM_TIME_ESTIMATE; + double SPRING_CLEANING_VACUUMS_PER_LAZY_DELETE_PAGE; + int SPRING_CLEANING_MIN_LAZY_DELETE_PAGES; + int SPRING_CLEANING_MAX_LAZY_DELETE_PAGES; + int SPRING_CLEANING_LAZY_DELETE_BATCH_SIZE; + int SPRING_CLEANING_MIN_VACUUM_PAGES; + int SPRING_CLEANING_MAX_VACUUM_PAGES; + + // KeyValueStoreMemory + int64_t REPLACE_CONTENTS_BYTES; + + // KeyValueStoreRocksDB + int ROCKSDB_BACKGROUND_PARALLELISM; + int ROCKSDB_READ_PARALLELISM; + int64_t ROCKSDB_MEMTABLE_BYTES; + bool ROCKSDB_UNSAFE_AUTO_FSYNC; + int64_t ROCKSDB_PERIODIC_COMPACTION_SECONDS; + int ROCKSDB_PREFIX_LEN; + int64_t ROCKSDB_BLOCK_CACHE_SIZE; + + // Leader election + int MAX_NOTIFICATIONS; + int MIN_NOTIFICATIONS; + double NOTIFICATION_FULL_CLEAR_TIME; + double CANDIDATE_MIN_DELAY; + double CANDIDATE_MAX_DELAY; + double CANDIDATE_GROWTH_RATE; + double POLLING_FREQUENCY; + double HEARTBEAT_FREQUENCY; + + // Commit CommitProxy + double START_TRANSACTION_BATCH_INTERVAL_MIN; + double START_TRANSACTION_BATCH_INTERVAL_MAX; + double START_TRANSACTION_BATCH_INTERVAL_LATENCY_FRACTION; + double START_TRANSACTION_BATCH_INTERVAL_SMOOTHER_ALPHA; + double START_TRANSACTION_BATCH_QUEUE_CHECK_INTERVAL; + double START_TRANSACTION_MAX_TRANSACTIONS_TO_START; + int START_TRANSACTION_MAX_REQUESTS_TO_START; + double START_TRANSACTION_RATE_WINDOW; + double START_TRANSACTION_MAX_EMPTY_QUEUE_BUDGET; + int START_TRANSACTION_MAX_QUEUE_SIZE; + int KEY_LOCATION_MAX_QUEUE_SIZE; + + double COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE; + double COMMIT_TRANSACTION_BATCH_INTERVAL_MIN; + double COMMIT_TRANSACTION_BATCH_INTERVAL_MAX; + double COMMIT_TRANSACTION_BATCH_INTERVAL_LATENCY_FRACTION; + double COMMIT_TRANSACTION_BATCH_INTERVAL_SMOOTHER_ALPHA; + int COMMIT_TRANSACTION_BATCH_COUNT_MAX; + int COMMIT_TRANSACTION_BATCH_BYTES_MIN; + int COMMIT_TRANSACTION_BATCH_BYTES_MAX; + double COMMIT_TRANSACTION_BATCH_BYTES_SCALE_BASE; + double COMMIT_TRANSACTION_BATCH_BYTES_SCALE_POWER; + int64_t COMMIT_BATCHES_MEM_BYTES_HARD_LIMIT; + double COMMIT_BATCHES_MEM_FRACTION_OF_TOTAL; + double COMMIT_BATCHES_MEM_TO_TOTAL_MEM_SCALE_FACTOR; + + double RESOLVER_COALESCE_TIME; + int BUGGIFIED_ROW_LIMIT; + double PROXY_SPIN_DELAY; + double UPDATE_REMOTE_LOG_VERSION_INTERVAL; + int MAX_TXS_POP_VERSION_HISTORY; + double MIN_CONFIRM_INTERVAL; + double ENFORCED_MIN_RECOVERY_DURATION; + double REQUIRED_MIN_RECOVERY_DURATION; + bool ALWAYS_CAUSAL_READ_RISKY; + int MAX_COMMIT_UPDATES; + double MAX_PROXY_COMPUTE; + double MAX_COMPUTE_PER_OPERATION; + int PROXY_COMPUTE_BUCKETS; + double PROXY_COMPUTE_GROWTH_RATE; + int TXN_STATE_SEND_AMOUNT; + double REPORT_TRANSACTION_COST_ESTIMATION_DELAY; + bool PROXY_REJECT_BATCH_QUEUED_TOO_LONG; + + int RESET_MASTER_BATCHES; + int RESET_RESOLVER_BATCHES; + double RESET_MASTER_DELAY; + double RESET_RESOLVER_DELAY; + + // Master Server + double COMMIT_SLEEP_TIME; + double MIN_BALANCE_TIME; + int64_t MIN_BALANCE_DIFFERENCE; + double SECONDS_BEFORE_NO_FAILURE_DELAY; + int64_t MAX_TXS_SEND_MEMORY; + int64_t MAX_RECOVERY_VERSIONS; + double MAX_RECOVERY_TIME; + double PROVISIONAL_START_DELAY; + double PROVISIONAL_DELAY_GROWTH; + double PROVISIONAL_MAX_DELAY; + double SECONDS_BEFORE_RECRUIT_BACKUP_WORKER; + double CC_INTERFACE_TIMEOUT; + + // Resolver + int64_t KEY_BYTES_PER_SAMPLE; + int64_t SAMPLE_OFFSET_PER_KEY; + double SAMPLE_EXPIRATION_TIME; + double SAMPLE_POLL_TIME; + int64_t RESOLVER_STATE_MEMORY_LIMIT; + + // Backup Worker + double BACKUP_TIMEOUT; // master's reaction time for backup failure + double BACKUP_NOOP_POP_DELAY; + int BACKUP_FILE_BLOCK_BYTES; + int64_t BACKUP_LOCK_BYTES; + double BACKUP_UPLOAD_DELAY; + + // Cluster Controller + double CLUSTER_CONTROLLER_LOGGING_DELAY; + double MASTER_FAILURE_REACTION_TIME; + double MASTER_FAILURE_SLOPE_DURING_RECOVERY; + int WORKER_COORDINATION_PING_DELAY; + double SIM_SHUTDOWN_TIMEOUT; + double SHUTDOWN_TIMEOUT; + double MASTER_SPIN_DELAY; + double CC_CHANGE_DELAY; + double CC_CLASS_DELAY; + double WAIT_FOR_GOOD_RECRUITMENT_DELAY; + double WAIT_FOR_GOOD_REMOTE_RECRUITMENT_DELAY; + double ATTEMPT_RECRUITMENT_DELAY; + double WAIT_FOR_DISTRIBUTOR_JOIN_DELAY; + double WAIT_FOR_RATEKEEPER_JOIN_DELAY; + double WORKER_FAILURE_TIME; + double CHECK_OUTSTANDING_INTERVAL; + double INCOMPATIBLE_PEERS_LOGGING_INTERVAL; + double VERSION_LAG_METRIC_INTERVAL; + int64_t MAX_VERSION_DIFFERENCE; + double FORCE_RECOVERY_CHECK_DELAY; + double RATEKEEPER_FAILURE_TIME; + double REPLACE_INTERFACE_DELAY; + double REPLACE_INTERFACE_CHECK_DELAY; + double COORDINATOR_REGISTER_INTERVAL; + double CLIENT_REGISTER_INTERVAL; + + // Knobs used to select the best policy (via monte carlo) + int POLICY_RATING_TESTS; // number of tests per policy (in order to compare) + int POLICY_GENERATIONS; // number of policies to generate + + int EXPECTED_MASTER_FITNESS; + int EXPECTED_TLOG_FITNESS; + int EXPECTED_LOG_ROUTER_FITNESS; + int EXPECTED_COMMIT_PROXY_FITNESS; + int EXPECTED_GRV_PROXY_FITNESS; + int EXPECTED_RESOLVER_FITNESS; + double RECRUITMENT_TIMEOUT; + int DBINFO_SEND_AMOUNT; + double DBINFO_BATCH_DELAY; + + // Move Keys + double SHARD_READY_DELAY; + double SERVER_READY_QUORUM_INTERVAL; + double SERVER_READY_QUORUM_TIMEOUT; + double REMOVE_RETRY_DELAY; + int MOVE_KEYS_KRM_LIMIT; + int MOVE_KEYS_KRM_LIMIT_BYTES; // This must be sufficiently larger than CLIENT_KNOBS->KEY_SIZE_LIMIT + // (fdbclient/Knobs.h) to ensure that at least two entries will be returned from an + // attempt to read a key range map + int MAX_SKIP_TAGS; + double MAX_ADDED_SOURCES_MULTIPLIER; + + // FdbServer + double MIN_REBOOT_TIME; + double MAX_REBOOT_TIME; + std::string LOG_DIRECTORY; + int64_t SERVER_MEM_LIMIT; + double SYSTEM_MONITOR_FREQUENCY; + + // Ratekeeper + double SMOOTHING_AMOUNT; + double SLOW_SMOOTHING_AMOUNT; + double METRIC_UPDATE_RATE; + double DETAILED_METRIC_UPDATE_RATE; + double LAST_LIMITED_RATIO; + double RATEKEEPER_DEFAULT_LIMIT; + + int64_t TARGET_BYTES_PER_STORAGE_SERVER; + int64_t SPRING_BYTES_STORAGE_SERVER; + int64_t AUTO_TAG_THROTTLE_STORAGE_QUEUE_BYTES; + int64_t TARGET_BYTES_PER_STORAGE_SERVER_BATCH; + int64_t SPRING_BYTES_STORAGE_SERVER_BATCH; + int64_t STORAGE_HARD_LIMIT_BYTES; + int64_t STORAGE_DURABILITY_LAG_HARD_MAX; + int64_t STORAGE_DURABILITY_LAG_SOFT_MAX; + + int64_t LOW_PRIORITY_STORAGE_QUEUE_BYTES; + int64_t LOW_PRIORITY_DURABILITY_LAG; + + int64_t TARGET_BYTES_PER_TLOG; + int64_t SPRING_BYTES_TLOG; + int64_t TARGET_BYTES_PER_TLOG_BATCH; + int64_t SPRING_BYTES_TLOG_BATCH; + int64_t TLOG_SPILL_THRESHOLD; + int64_t TLOG_HARD_LIMIT_BYTES; + int64_t TLOG_RECOVER_MEMORY_LIMIT; + double TLOG_IGNORE_POP_AUTO_ENABLE_DELAY; + + int64_t MAX_MANUAL_THROTTLED_TRANSACTION_TAGS; + int64_t MAX_AUTO_THROTTLED_TRANSACTION_TAGS; + double MIN_TAG_COST; + double AUTO_THROTTLE_TARGET_TAG_BUSYNESS; + double AUTO_THROTTLE_RAMP_TAG_BUSYNESS; + double AUTO_TAG_THROTTLE_RAMP_UP_TIME; + double AUTO_TAG_THROTTLE_DURATION; + double TAG_THROTTLE_PUSH_INTERVAL; + double AUTO_TAG_THROTTLE_START_AGGREGATION_TIME; + double AUTO_TAG_THROTTLE_UPDATE_FREQUENCY; + double TAG_THROTTLE_EXPIRED_CLEANUP_INTERVAL; + bool AUTO_TAG_THROTTLING_ENABLED; + + double MAX_TRANSACTIONS_PER_BYTE; + + int64_t MIN_AVAILABLE_SPACE; + double MIN_AVAILABLE_SPACE_RATIO; + double TARGET_AVAILABLE_SPACE_RATIO; + double AVAILABLE_SPACE_UPDATE_DELAY; + + double MAX_TL_SS_VERSION_DIFFERENCE; // spring starts at half this value + double MAX_TL_SS_VERSION_DIFFERENCE_BATCH; + int MAX_MACHINES_FALLING_BEHIND; + + int MAX_TPS_HISTORY_SAMPLES; + int NEEDED_TPS_HISTORY_SAMPLES; + int64_t TARGET_DURABILITY_LAG_VERSIONS; + int64_t AUTO_TAG_THROTTLE_DURABILITY_LAG_VERSIONS; + int64_t TARGET_DURABILITY_LAG_VERSIONS_BATCH; + int64_t DURABILITY_LAG_UNLIMITED_THRESHOLD; + double INITIAL_DURABILITY_LAG_MULTIPLIER; + double DURABILITY_LAG_REDUCTION_RATE; + double DURABILITY_LAG_INCREASE_RATE; + + double STORAGE_SERVER_LIST_FETCH_TIMEOUT; + + // disk snapshot + int64_t MAX_FORKED_PROCESS_OUTPUT; + double SNAP_CREATE_MAX_TIMEOUT; + + // Storage Metrics + double STORAGE_METRICS_AVERAGE_INTERVAL; + double STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS; + double SPLIT_JITTER_AMOUNT; + int64_t IOPS_UNITS_PER_SAMPLE; + int64_t BANDWIDTH_UNITS_PER_SAMPLE; + int64_t BYTES_READ_UNITS_PER_SAMPLE; + int64_t READ_HOT_SUB_RANGE_CHUNK_SIZE; + int64_t EMPTY_READ_PENALTY; + bool READ_SAMPLING_ENABLED; + + // Storage Server + double STORAGE_LOGGING_DELAY; + double STORAGE_SERVER_POLL_METRICS_DELAY; + double FUTURE_VERSION_DELAY; + int STORAGE_LIMIT_BYTES; + int BUGGIFY_LIMIT_BYTES; + int FETCH_BLOCK_BYTES; + int FETCH_KEYS_PARALLELISM_BYTES; + int FETCH_KEYS_LOWER_PRIORITY; + int BUGGIFY_BLOCK_BYTES; + double STORAGE_DURABILITY_LAG_REJECT_THRESHOLD; + double STORAGE_DURABILITY_LAG_MIN_RATE; + int STORAGE_COMMIT_BYTES; + double STORAGE_COMMIT_INTERVAL; + double UPDATE_SHARD_VERSION_INTERVAL; + int BYTE_SAMPLING_FACTOR; + int BYTE_SAMPLING_OVERHEAD; + int MAX_STORAGE_SERVER_WATCH_BYTES; + int MAX_BYTE_SAMPLE_CLEAR_MAP_SIZE; + double LONG_BYTE_SAMPLE_RECOVERY_DELAY; + int BYTE_SAMPLE_LOAD_PARALLELISM; + double BYTE_SAMPLE_LOAD_DELAY; + double BYTE_SAMPLE_START_DELAY; + double UPDATE_STORAGE_PROCESS_STATS_INTERVAL; + double BEHIND_CHECK_DELAY; + int BEHIND_CHECK_COUNT; + int64_t BEHIND_CHECK_VERSIONS; + double WAIT_METRICS_WRONG_SHARD_CHANCE; + int64_t MIN_TAG_READ_PAGES_RATE; + int64_t MIN_TAG_WRITE_PAGES_RATE; + double TAG_MEASUREMENT_INTERVAL; + int64_t READ_COST_BYTE_FACTOR; + bool PREFIX_COMPRESS_KVS_MEM_SNAPSHOTS; + bool REPORT_DD_METRICS; + double DD_METRICS_REPORT_INTERVAL; + double FETCH_KEYS_TOO_LONG_TIME_CRITERIA; + double MAX_STORAGE_COMMIT_TIME; + + // Wait Failure + int MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS; + double WAIT_FAILURE_DELAY_LIMIT; + + // Worker + double WORKER_LOGGING_INTERVAL; + double HEAP_PROFILER_INTERVAL; + double UNKNOWN_CC_TIMEOUT; + double DEGRADED_RESET_INTERVAL; + double DEGRADED_WARNING_LIMIT; + double DEGRADED_WARNING_RESET_DELAY; + int64_t TRACE_LOG_FLUSH_FAILURE_CHECK_INTERVAL_SECONDS; + double TRACE_LOG_PING_TIMEOUT_SECONDS; + double MIN_DELAY_CC_WORST_FIT_CANDIDACY_SECONDS; // Listen for a leader for N seconds, and if not heard, then try to + // become the leader. + double MAX_DELAY_CC_WORST_FIT_CANDIDACY_SECONDS; + double DBINFO_FAILED_DELAY; + + // Test harness + double WORKER_POLL_DELAY; + + // Coordination + double COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL; + double FORWARD_REQUEST_TOO_OLD; + bool ENABLE_CROSS_CLUSTER_SUPPORT; // Allow a coordinator to serve requests whose connection string does not match + // the local descriptor + + // Buggification + double BUGGIFIED_EVENTUAL_CONSISTENCY; + bool BUGGIFY_ALL_COORDINATION; + + // Status + double STATUS_MIN_TIME_BETWEEN_REQUESTS; + double MAX_STATUS_REQUESTS_PER_SECOND; + int CONFIGURATION_ROWS_TO_FETCH; + bool DISABLE_DUPLICATE_LOG_WARNING; + double HISTOGRAM_REPORT_INTERVAL; + + // IPager + int PAGER_RESERVED_PAGES; + + // IndirectShadowPager + int FREE_PAGE_VACUUM_THRESHOLD; + int VACUUM_QUEUE_SIZE; + int VACUUM_BYTES_PER_SECOND; + + // Timekeeper + int64_t TIME_KEEPER_DELAY; + int64_t TIME_KEEPER_MAX_ENTRIES; + + // Fast Restore + // TODO: After 6.3, review FR knobs, remove unneeded ones and change default value + int64_t FASTRESTORE_FAILURE_TIMEOUT; + int64_t FASTRESTORE_HEARTBEAT_INTERVAL; + double FASTRESTORE_SAMPLING_PERCENT; + int64_t FASTRESTORE_NUM_LOADERS; + int64_t FASTRESTORE_NUM_APPLIERS; + // FASTRESTORE_TXN_BATCH_MAX_BYTES is target txn size used by appliers to apply mutations + double FASTRESTORE_TXN_BATCH_MAX_BYTES; + // FASTRESTORE_VERSIONBATCH_MAX_BYTES is the maximum data size in each version batch + double FASTRESTORE_VERSIONBATCH_MAX_BYTES; + // FASTRESTORE_VB_PARALLELISM is the number of concurrently running version batches + int64_t FASTRESTORE_VB_PARALLELISM; + int64_t FASTRESTORE_VB_MONITOR_DELAY; // How quickly monitor finished version batch + double FASTRESTORE_VB_LAUNCH_DELAY; + int64_t FASTRESTORE_ROLE_LOGGING_DELAY; + int64_t FASTRESTORE_UPDATE_PROCESS_STATS_INTERVAL; // How quickly to update process metrics for restore + int64_t FASTRESTORE_ATOMICOP_WEIGHT; // workload amplication factor for atomic op + int64_t FASTRESTORE_APPLYING_PARALLELISM; // number of outstanding txns writing to dest. DB + int64_t FASTRESTORE_MONITOR_LEADER_DELAY; + int64_t FASTRESTORE_STRAGGLER_THRESHOLD_SECONDS; + bool FASTRESTORE_TRACK_REQUEST_LATENCY; // true to track reply latency of each request in a request batch + bool FASTRESTORE_TRACK_LOADER_SEND_REQUESTS; // track requests of load send mutations to appliers? + int64_t FASTRESTORE_MEMORY_THRESHOLD_MB_SOFT; // threshold when pipelined actors should be delayed + int64_t FASTRESTORE_WAIT_FOR_MEMORY_LATENCY; + int64_t FASTRESTORE_HEARTBEAT_DELAY; // interval for master to ping loaders and appliers + int64_t + FASTRESTORE_HEARTBEAT_MAX_DELAY; // master claim a node is down if no heart beat from the node for this delay + int64_t FASTRESTORE_APPLIER_FETCH_KEYS_SIZE; // number of keys to fetch in a txn on applier + int64_t FASTRESTORE_LOADER_SEND_MUTATION_MSG_BYTES; // desired size of mutation message sent from loader to appliers + bool FASTRESTORE_GET_RANGE_VERSIONS_EXPENSIVE; // parse each range file to get (range, version) it has? + int64_t FASTRESTORE_REQBATCH_PARALLEL; // number of requests to wait on for getBatchReplies() + bool FASTRESTORE_REQBATCH_LOG; // verbose log information for getReplyBatches + int FASTRESTORE_TXN_CLEAR_MAX; // threshold to start tracking each clear op in a txn + int FASTRESTORE_TXN_RETRY_MAX; // threshold to start output error on too many retries + double FASTRESTORE_TXN_EXTRA_DELAY; // extra delay to avoid overwhelming fdb + bool FASTRESTORE_NOT_WRITE_DB; // do not write result to DB. Only for dev testing + bool FASTRESTORE_USE_RANGE_FILE; // use range file in backup + bool FASTRESTORE_USE_LOG_FILE; // use log file in backup + int64_t FASTRESTORE_SAMPLE_MSG_BYTES; // sample message desired size + double FASTRESTORE_SCHED_UPDATE_DELAY; // delay in seconds in updating process metrics + int FASTRESTORE_SCHED_TARGET_CPU_PERCENT; // release as many requests as possible when cpu usage is below the knob + int FASTRESTORE_SCHED_MAX_CPU_PERCENT; // max cpu percent when scheduler shall not release non-urgent requests + int FASTRESTORE_SCHED_INFLIGHT_LOAD_REQS; // number of inflight requests to load backup files + int FASTRESTORE_SCHED_INFLIGHT_SEND_REQS; // number of inflight requests for loaders to send mutations to appliers + int FASTRESTORE_SCHED_LOAD_REQ_BATCHSIZE; // number of load request to release at once + int FASTRESTORE_SCHED_INFLIGHT_SENDPARAM_THRESHOLD; // we can send future VB requests if it is less than this knob + int FASTRESTORE_SCHED_SEND_FUTURE_VB_REQS_BATCH; // number of future VB sendLoadingParam requests to process at once + int FASTRESTORE_NUM_TRACE_EVENTS; + bool FASTRESTORE_EXPENSIVE_VALIDATION; // when set true, performance will be heavily affected + double FASTRESTORE_WRITE_BW_MB; // target aggregated write bandwidth from all appliers + double FASTRESTORE_RATE_UPDATE_SECONDS; // how long to update appliers target write rate + + int REDWOOD_DEFAULT_PAGE_SIZE; // Page size for new Redwood files + int REDWOOD_KVSTORE_CONCURRENT_READS; // Max number of simultaneous point or range reads in progress. + int REDWOOD_COMMIT_CONCURRENT_READS; // Max number of concurrent reads done to support commit operations + double REDWOOD_PAGE_REBUILD_MAX_SLACK; // When rebuilding pages, max slack to allow in page + int REDWOOD_LAZY_CLEAR_BATCH_SIZE_PAGES; // Number of pages to try to pop from the lazy delete queue and process at + // once + int REDWOOD_LAZY_CLEAR_MIN_PAGES; // Minimum number of pages to free before ending a lazy clear cycle, unless the + // queue is empty + int REDWOOD_LAZY_CLEAR_MAX_PAGES; // Maximum number of pages to free before ending a lazy clear cycle, unless the + // queue is empty + int64_t REDWOOD_REMAP_CLEANUP_WINDOW; // Remap remover lag interval in which to coalesce page writes + double REDWOOD_REMAP_CLEANUP_LAG; // Maximum allowed remap remover lag behind the cleanup window as a multiple of + // the window size + double REDWOOD_LOGGING_INTERVAL; + + // Server request latency measurement + int LATENCY_SAMPLE_SIZE; + double LATENCY_METRICS_LOGGING_INTERVAL; + + ServerKnobs(); + void initialize(bool randomize = false, ClientKnobs* clientKnobs = nullptr, bool isSimulated = false); +}; + +extern std::unique_ptr globalServerKnobs; +extern ServerKnobs const* SERVER_KNOBS; + +#endif From ae424f11950cb2819fcd2ebfd179536a84805e53 Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Mon, 26 Jul 2021 10:55:22 -0400 Subject: [PATCH 106/225] rebase --- fdbclient/ServerKnobs.h | 1 + fdbserver/Knobs.h | 644 +--------------------------------------- 2 files changed, 2 insertions(+), 643 deletions(-) diff --git a/fdbclient/ServerKnobs.h b/fdbclient/ServerKnobs.h index 79600d49bb..734a10daab 100644 --- a/fdbclient/ServerKnobs.h +++ b/fdbclient/ServerKnobs.h @@ -593,6 +593,7 @@ public: double COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL; bool ENABLE_CROSS_CLUSTER_SUPPORT; // Allow a coordinator to serve requests whose connection string does not match // the local descriptor + double FORWARD_REQUEST_TOO_OLD; // Do not forward requests older than this setting // Buggification double BUGGIFIED_EVENTUAL_CONSISTENCY; diff --git a/fdbserver/Knobs.h b/fdbserver/Knobs.h index 44b653bd68..67f474b0eb 100644 --- a/fdbserver/Knobs.h +++ b/fdbserver/Knobs.h @@ -22,646 +22,4 @@ #include "fdbclient/IKnobCollection.h" -// Disk queue -static const int _PAGE_SIZE = 4096; - -class ServerKnobs : public Knobs { -public: - // Versions - int64_t VERSIONS_PER_SECOND; - int64_t MAX_VERSIONS_IN_FLIGHT; - int64_t MAX_VERSIONS_IN_FLIGHT_FORCED; - int64_t MAX_READ_TRANSACTION_LIFE_VERSIONS; - int64_t MAX_WRITE_TRANSACTION_LIFE_VERSIONS; - double MAX_COMMIT_BATCH_INTERVAL; // Each commit proxy generates a CommitTransactionBatchRequest at least this - // often, so that versions always advance smoothly - - // TLogs - double TLOG_TIMEOUT; // tlog OR commit proxy failure - master's reaction time - double TLOG_SLOW_REJOIN_WARN_TIMEOUT_SECS; // Warns if a tlog takes too long to rejoin - double RECOVERY_TLOG_SMART_QUORUM_DELAY; // smaller might be better for bug amplification - double TLOG_STORAGE_MIN_UPDATE_INTERVAL; - double BUGGIFY_TLOG_STORAGE_MIN_UPDATE_INTERVAL; - int DESIRED_TOTAL_BYTES; - int DESIRED_UPDATE_BYTES; - double UPDATE_DELAY; - int MAXIMUM_PEEK_BYTES; - int APPLY_MUTATION_BYTES; - int RECOVERY_DATA_BYTE_LIMIT; - int BUGGIFY_RECOVERY_DATA_LIMIT; - double LONG_TLOG_COMMIT_TIME; - int64_t LARGE_TLOG_COMMIT_BYTES; - double BUGGIFY_RECOVER_MEMORY_LIMIT; - double BUGGIFY_WORKER_REMOVED_MAX_LAG; - int64_t UPDATE_STORAGE_BYTE_LIMIT; - int64_t REFERENCE_SPILL_UPDATE_STORAGE_BYTE_LIMIT; - double TLOG_PEEK_DELAY; - int LEGACY_TLOG_UPGRADE_ENTRIES_PER_VERSION; - int VERSION_MESSAGES_OVERHEAD_FACTOR_1024THS; // Multiplicative factor to bound total space used to store a version - // message (measured in 1/1024ths, e.g. a value of 2048 yields a - // factor of 2). - int64_t VERSION_MESSAGES_ENTRY_BYTES_WITH_OVERHEAD; - double TLOG_MESSAGE_BLOCK_OVERHEAD_FACTOR; - int64_t TLOG_MESSAGE_BLOCK_BYTES; - int64_t MAX_MESSAGE_SIZE; - int LOG_SYSTEM_PUSHED_DATA_BLOCK_SIZE; - double PEEK_TRACKER_EXPIRATION_TIME; - int PARALLEL_GET_MORE_REQUESTS; - int MULTI_CURSOR_PRE_FETCH_LIMIT; - int64_t MAX_QUEUE_COMMIT_BYTES; - int DESIRED_OUTSTANDING_MESSAGES; - double DESIRED_GET_MORE_DELAY; - int CONCURRENT_LOG_ROUTER_READS; - int LOG_ROUTER_PEEK_FROM_SATELLITES_PREFERRED; // 0==peek from primary, non-zero==peek from satellites - double DISK_QUEUE_ADAPTER_MIN_SWITCH_TIME; - double DISK_QUEUE_ADAPTER_MAX_SWITCH_TIME; - int64_t TLOG_SPILL_REFERENCE_MAX_PEEK_MEMORY_BYTES; - int64_t TLOG_SPILL_REFERENCE_MAX_BATCHES_PER_PEEK; - int64_t TLOG_SPILL_REFERENCE_MAX_BYTES_PER_BATCH; - int64_t DISK_QUEUE_FILE_EXTENSION_BYTES; // When we grow the disk queue, by how many bytes should it grow? - int64_t DISK_QUEUE_FILE_SHRINK_BYTES; // When we shrink the disk queue, by how many bytes should it shrink? - int64_t DISK_QUEUE_MAX_TRUNCATE_BYTES; // A truncate larger than this will cause the file to be replaced instead. - double TLOG_DEGRADED_DURATION; - int64_t MAX_CACHE_VERSIONS; - double TXS_POPPED_MAX_DELAY; - double TLOG_MAX_CREATE_DURATION; - int PEEK_LOGGING_AMOUNT; - double PEEK_LOGGING_DELAY; - double PEEK_RESET_INTERVAL; - double PEEK_MAX_LATENCY; - bool PEEK_COUNT_SMALL_MESSAGES; - double PEEK_STATS_INTERVAL; - double PEEK_STATS_SLOW_AMOUNT; - double PEEK_STATS_SLOW_RATIO; - double PUSH_RESET_INTERVAL; - double PUSH_MAX_LATENCY; - double PUSH_STATS_INTERVAL; - double PUSH_STATS_SLOW_AMOUNT; - double PUSH_STATS_SLOW_RATIO; - int TLOG_POP_BATCH_SIZE; - - // Data distribution queue - double HEALTH_POLL_TIME; - double BEST_TEAM_STUCK_DELAY; - double BG_REBALANCE_POLLING_INTERVAL; - double BG_REBALANCE_SWITCH_CHECK_INTERVAL; - double DD_QUEUE_LOGGING_INTERVAL; - double RELOCATION_PARALLELISM_PER_SOURCE_SERVER; - int DD_QUEUE_MAX_KEY_SERVERS; - int DD_REBALANCE_PARALLELISM; - int DD_REBALANCE_RESET_AMOUNT; - double BG_DD_MAX_WAIT; - double BG_DD_MIN_WAIT; - double BG_DD_INCREASE_RATE; - double BG_DD_DECREASE_RATE; - double BG_DD_SATURATION_DELAY; - double INFLIGHT_PENALTY_HEALTHY; - double INFLIGHT_PENALTY_REDUNDANT; - double INFLIGHT_PENALTY_UNHEALTHY; - double INFLIGHT_PENALTY_ONE_LEFT; - bool USE_OLD_NEEDED_SERVERS; - - // Higher priorities are executed first - // Priority/100 is the "priority group"/"superpriority". Priority inversion - // is possible within but not between priority groups; fewer priority groups - // mean better worst case time bounds - // Maximum allowable priority is 999. - int PRIORITY_RECOVER_MOVE; - int PRIORITY_REBALANCE_UNDERUTILIZED_TEAM; - int PRIORITY_REBALANCE_OVERUTILIZED_TEAM; - int PRIORITY_TEAM_HEALTHY; - int PRIORITY_TEAM_CONTAINS_UNDESIRED_SERVER; - int PRIORITY_TEAM_REDUNDANT; - int PRIORITY_MERGE_SHARD; - int PRIORITY_POPULATE_REGION; - int PRIORITY_TEAM_UNHEALTHY; - int PRIORITY_TEAM_2_LEFT; - int PRIORITY_TEAM_1_LEFT; - int PRIORITY_TEAM_FAILED; // Priority when a server in the team is excluded as failed - int PRIORITY_TEAM_0_LEFT; - int PRIORITY_SPLIT_SHARD; - - // Data distribution - double RETRY_RELOCATESHARD_DELAY; - double DATA_DISTRIBUTION_FAILURE_REACTION_TIME; - int MIN_SHARD_BYTES, SHARD_BYTES_RATIO, SHARD_BYTES_PER_SQRT_BYTES, MAX_SHARD_BYTES, KEY_SERVER_SHARD_BYTES; - int64_t SHARD_MAX_BYTES_PER_KSEC, // Shards with more than this bandwidth will be split immediately - SHARD_MIN_BYTES_PER_KSEC, // Shards with more than this bandwidth will not be merged - SHARD_SPLIT_BYTES_PER_KSEC; // When splitting a shard, it is split into pieces with less than this bandwidth - double SHARD_MAX_READ_DENSITY_RATIO; - int64_t SHARD_READ_HOT_BANDWITH_MIN_PER_KSECONDS; - double SHARD_MAX_BYTES_READ_PER_KSEC_JITTER; - double STORAGE_METRIC_TIMEOUT; - double METRIC_DELAY; - double ALL_DATA_REMOVED_DELAY; - double INITIAL_FAILURE_REACTION_DELAY; - double CHECK_TEAM_DELAY; - double LOG_ON_COMPLETION_DELAY; - int BEST_TEAM_MAX_TEAM_TRIES; - int BEST_TEAM_OPTION_COUNT; - int BEST_OF_AMT; - double SERVER_LIST_DELAY; - double RECRUITMENT_IDLE_DELAY; - double STORAGE_RECRUITMENT_DELAY; - bool TSS_HACK_IDENTITY_MAPPING; - double TSS_RECRUITMENT_TIMEOUT; - double TSS_DD_KILL_INTERVAL; - double DATA_DISTRIBUTION_LOGGING_INTERVAL; - double DD_ENABLED_CHECK_DELAY; - double DD_STALL_CHECK_DELAY; - double DD_LOW_BANDWIDTH_DELAY; - double DD_MERGE_COALESCE_DELAY; - double STORAGE_METRICS_POLLING_DELAY; - double STORAGE_METRICS_RANDOM_DELAY; - double AVAILABLE_SPACE_RATIO_CUTOFF; - int DESIRED_TEAMS_PER_SERVER; - int MAX_TEAMS_PER_SERVER; - int64_t DD_SHARD_SIZE_GRANULARITY; - int64_t DD_SHARD_SIZE_GRANULARITY_SIM; - int DD_MOVE_KEYS_PARALLELISM; - int DD_FETCH_SOURCE_PARALLELISM; - int DD_MERGE_LIMIT; - double DD_SHARD_METRICS_TIMEOUT; - int64_t DD_LOCATION_CACHE_SIZE; - double MOVEKEYS_LOCK_POLLING_DELAY; - double DEBOUNCE_RECRUITING_DELAY; - int REBALANCE_MAX_RETRIES; - int DD_OVERLAP_PENALTY; - int DD_EXCLUDE_MIN_REPLICAS; - bool DD_VALIDATE_LOCALITY; - int DD_CHECK_INVALID_LOCALITY_DELAY; - bool DD_ENABLE_VERBOSE_TRACING; - int64_t - DD_SS_FAILURE_VERSIONLAG; // Allowed SS version lag from the current read version before marking it as failed. - int64_t DD_SS_ALLOWED_VERSIONLAG; // SS will be marked as healthy if it's version lag goes below this value. - double DD_SS_STUCK_TIME_LIMIT; // If a storage server is not getting new versions for this amount of time, then it - // becomes undesired. - int DD_TEAMS_INFO_PRINT_INTERVAL; - int DD_TEAMS_INFO_PRINT_YIELD_COUNT; - int DD_TEAM_ZERO_SERVER_LEFT_LOG_DELAY; - - // TeamRemover to remove redundant teams - bool TR_FLAG_DISABLE_MACHINE_TEAM_REMOVER; // disable the machineTeamRemover actor - double TR_REMOVE_MACHINE_TEAM_DELAY; // wait for the specified time before try to remove next machine team - bool TR_FLAG_REMOVE_MT_WITH_MOST_TEAMS; // guard to select which machineTeamRemover logic to use - - bool TR_FLAG_DISABLE_SERVER_TEAM_REMOVER; // disable the serverTeamRemover actor - double TR_REMOVE_SERVER_TEAM_DELAY; // wait for the specified time before try to remove next server team - double TR_REMOVE_SERVER_TEAM_EXTRA_DELAY; // serverTeamRemover waits for the delay and check DD healthyness again to - // ensure it runs after machineTeamRemover - - // Remove wrong storage engines - double DD_REMOVE_STORE_ENGINE_DELAY; // wait for the specified time before remove the next batch - - double DD_FAILURE_TIME; - double DD_ZERO_HEALTHY_TEAM_DELAY; - - // Redwood Storage Engine - int PREFIX_TREE_IMMEDIATE_KEY_SIZE_LIMIT; - int PREFIX_TREE_IMMEDIATE_KEY_SIZE_MIN; - - // KeyValueStore SQLITE - int CLEAR_BUFFER_SIZE; - double READ_VALUE_TIME_ESTIMATE; - double READ_RANGE_TIME_ESTIMATE; - double SET_TIME_ESTIMATE; - double CLEAR_TIME_ESTIMATE; - double COMMIT_TIME_ESTIMATE; - int CHECK_FREE_PAGE_AMOUNT; - double DISK_METRIC_LOGGING_INTERVAL; - int64_t SOFT_HEAP_LIMIT; - - int SQLITE_PAGE_SCAN_ERROR_LIMIT; - int SQLITE_BTREE_PAGE_USABLE; - int SQLITE_BTREE_CELL_MAX_LOCAL; - int SQLITE_BTREE_CELL_MIN_LOCAL; - int SQLITE_FRAGMENT_PRIMARY_PAGE_USABLE; - int SQLITE_FRAGMENT_OVERFLOW_PAGE_USABLE; - double SQLITE_FRAGMENT_MIN_SAVINGS; - int SQLITE_CHUNK_SIZE_PAGES; - int SQLITE_CHUNK_SIZE_PAGES_SIM; - int SQLITE_READER_THREADS; - int SQLITE_WRITE_WINDOW_LIMIT; - double SQLITE_WRITE_WINDOW_SECONDS; - - // KeyValueStoreSqlite spring cleaning - double SPRING_CLEANING_NO_ACTION_INTERVAL; - double SPRING_CLEANING_LAZY_DELETE_INTERVAL; - double SPRING_CLEANING_VACUUM_INTERVAL; - double SPRING_CLEANING_LAZY_DELETE_TIME_ESTIMATE; - double SPRING_CLEANING_VACUUM_TIME_ESTIMATE; - double SPRING_CLEANING_VACUUMS_PER_LAZY_DELETE_PAGE; - int SPRING_CLEANING_MIN_LAZY_DELETE_PAGES; - int SPRING_CLEANING_MAX_LAZY_DELETE_PAGES; - int SPRING_CLEANING_LAZY_DELETE_BATCH_SIZE; - int SPRING_CLEANING_MIN_VACUUM_PAGES; - int SPRING_CLEANING_MAX_VACUUM_PAGES; - - // KeyValueStoreMemory - int64_t REPLACE_CONTENTS_BYTES; - - // KeyValueStoreRocksDB - int ROCKSDB_BACKGROUND_PARALLELISM; - int ROCKSDB_READ_PARALLELISM; - int64_t ROCKSDB_MEMTABLE_BYTES; - bool ROCKSDB_UNSAFE_AUTO_FSYNC; - int64_t ROCKSDB_PERIODIC_COMPACTION_SECONDS; - int ROCKSDB_PREFIX_LEN; - int64_t ROCKSDB_BLOCK_CACHE_SIZE; - - // Leader election - int MAX_NOTIFICATIONS; - int MIN_NOTIFICATIONS; - double NOTIFICATION_FULL_CLEAR_TIME; - double CANDIDATE_MIN_DELAY; - double CANDIDATE_MAX_DELAY; - double CANDIDATE_GROWTH_RATE; - double POLLING_FREQUENCY; - double HEARTBEAT_FREQUENCY; - - // Commit CommitProxy - double START_TRANSACTION_BATCH_INTERVAL_MIN; - double START_TRANSACTION_BATCH_INTERVAL_MAX; - double START_TRANSACTION_BATCH_INTERVAL_LATENCY_FRACTION; - double START_TRANSACTION_BATCH_INTERVAL_SMOOTHER_ALPHA; - double START_TRANSACTION_BATCH_QUEUE_CHECK_INTERVAL; - double START_TRANSACTION_MAX_TRANSACTIONS_TO_START; - int START_TRANSACTION_MAX_REQUESTS_TO_START; - double START_TRANSACTION_RATE_WINDOW; - double START_TRANSACTION_MAX_EMPTY_QUEUE_BUDGET; - int START_TRANSACTION_MAX_QUEUE_SIZE; - int KEY_LOCATION_MAX_QUEUE_SIZE; - - double COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE; - double COMMIT_TRANSACTION_BATCH_INTERVAL_MIN; - double COMMIT_TRANSACTION_BATCH_INTERVAL_MAX; - double COMMIT_TRANSACTION_BATCH_INTERVAL_LATENCY_FRACTION; - double COMMIT_TRANSACTION_BATCH_INTERVAL_SMOOTHER_ALPHA; - int COMMIT_TRANSACTION_BATCH_COUNT_MAX; - int COMMIT_TRANSACTION_BATCH_BYTES_MIN; - int COMMIT_TRANSACTION_BATCH_BYTES_MAX; - double COMMIT_TRANSACTION_BATCH_BYTES_SCALE_BASE; - double COMMIT_TRANSACTION_BATCH_BYTES_SCALE_POWER; - int64_t COMMIT_BATCHES_MEM_BYTES_HARD_LIMIT; - double COMMIT_BATCHES_MEM_FRACTION_OF_TOTAL; - double COMMIT_BATCHES_MEM_TO_TOTAL_MEM_SCALE_FACTOR; - - double RESOLVER_COALESCE_TIME; - int BUGGIFIED_ROW_LIMIT; - double PROXY_SPIN_DELAY; - double UPDATE_REMOTE_LOG_VERSION_INTERVAL; - int MAX_TXS_POP_VERSION_HISTORY; - double MIN_CONFIRM_INTERVAL; - double ENFORCED_MIN_RECOVERY_DURATION; - double REQUIRED_MIN_RECOVERY_DURATION; - bool ALWAYS_CAUSAL_READ_RISKY; - int MAX_COMMIT_UPDATES; - double MAX_PROXY_COMPUTE; - double MAX_COMPUTE_PER_OPERATION; - int PROXY_COMPUTE_BUCKETS; - double PROXY_COMPUTE_GROWTH_RATE; - int TXN_STATE_SEND_AMOUNT; - double REPORT_TRANSACTION_COST_ESTIMATION_DELAY; - bool PROXY_REJECT_BATCH_QUEUED_TOO_LONG; - - int RESET_MASTER_BATCHES; - int RESET_RESOLVER_BATCHES; - double RESET_MASTER_DELAY; - double RESET_RESOLVER_DELAY; - - // Master Server - double COMMIT_SLEEP_TIME; - double MIN_BALANCE_TIME; - int64_t MIN_BALANCE_DIFFERENCE; - double SECONDS_BEFORE_NO_FAILURE_DELAY; - int64_t MAX_TXS_SEND_MEMORY; - int64_t MAX_RECOVERY_VERSIONS; - double MAX_RECOVERY_TIME; - double PROVISIONAL_START_DELAY; - double PROVISIONAL_DELAY_GROWTH; - double PROVISIONAL_MAX_DELAY; - double SECONDS_BEFORE_RECRUIT_BACKUP_WORKER; - double CC_INTERFACE_TIMEOUT; - - // Resolver - int64_t KEY_BYTES_PER_SAMPLE; - int64_t SAMPLE_OFFSET_PER_KEY; - double SAMPLE_EXPIRATION_TIME; - double SAMPLE_POLL_TIME; - int64_t RESOLVER_STATE_MEMORY_LIMIT; - - // Backup Worker - double BACKUP_TIMEOUT; // master's reaction time for backup failure - double BACKUP_NOOP_POP_DELAY; - int BACKUP_FILE_BLOCK_BYTES; - int64_t BACKUP_LOCK_BYTES; - double BACKUP_UPLOAD_DELAY; - - // Cluster Controller - double CLUSTER_CONTROLLER_LOGGING_DELAY; - double MASTER_FAILURE_REACTION_TIME; - double MASTER_FAILURE_SLOPE_DURING_RECOVERY; - int WORKER_COORDINATION_PING_DELAY; - double SIM_SHUTDOWN_TIMEOUT; - double SHUTDOWN_TIMEOUT; - double MASTER_SPIN_DELAY; - double CC_CHANGE_DELAY; - double CC_CLASS_DELAY; - double WAIT_FOR_GOOD_RECRUITMENT_DELAY; - double WAIT_FOR_GOOD_REMOTE_RECRUITMENT_DELAY; - double ATTEMPT_RECRUITMENT_DELAY; - double WAIT_FOR_DISTRIBUTOR_JOIN_DELAY; - double WAIT_FOR_RATEKEEPER_JOIN_DELAY; - double WORKER_FAILURE_TIME; - double CHECK_OUTSTANDING_INTERVAL; - double INCOMPATIBLE_PEERS_LOGGING_INTERVAL; - double VERSION_LAG_METRIC_INTERVAL; - int64_t MAX_VERSION_DIFFERENCE; - double FORCE_RECOVERY_CHECK_DELAY; - double RATEKEEPER_FAILURE_TIME; - double REPLACE_INTERFACE_DELAY; - double REPLACE_INTERFACE_CHECK_DELAY; - double COORDINATOR_REGISTER_INTERVAL; - double CLIENT_REGISTER_INTERVAL; - - // Knobs used to select the best policy (via monte carlo) - int POLICY_RATING_TESTS; // number of tests per policy (in order to compare) - int POLICY_GENERATIONS; // number of policies to generate - - int EXPECTED_MASTER_FITNESS; - int EXPECTED_TLOG_FITNESS; - int EXPECTED_LOG_ROUTER_FITNESS; - int EXPECTED_COMMIT_PROXY_FITNESS; - int EXPECTED_GRV_PROXY_FITNESS; - int EXPECTED_RESOLVER_FITNESS; - double RECRUITMENT_TIMEOUT; - int DBINFO_SEND_AMOUNT; - double DBINFO_BATCH_DELAY; - - // Move Keys - double SHARD_READY_DELAY; - double SERVER_READY_QUORUM_INTERVAL; - double SERVER_READY_QUORUM_TIMEOUT; - double REMOVE_RETRY_DELAY; - int MOVE_KEYS_KRM_LIMIT; - int MOVE_KEYS_KRM_LIMIT_BYTES; // This must be sufficiently larger than CLIENT_KNOBS->KEY_SIZE_LIMIT - // (fdbclient/Knobs.h) to ensure that at least two entries will be returned from an - // attempt to read a key range map - int MAX_SKIP_TAGS; - double MAX_ADDED_SOURCES_MULTIPLIER; - - // FdbServer - double MIN_REBOOT_TIME; - double MAX_REBOOT_TIME; - std::string LOG_DIRECTORY; - int64_t SERVER_MEM_LIMIT; - double SYSTEM_MONITOR_FREQUENCY; - - // Ratekeeper - double SMOOTHING_AMOUNT; - double SLOW_SMOOTHING_AMOUNT; - double METRIC_UPDATE_RATE; - double DETAILED_METRIC_UPDATE_RATE; - double LAST_LIMITED_RATIO; - double RATEKEEPER_DEFAULT_LIMIT; - - int64_t TARGET_BYTES_PER_STORAGE_SERVER; - int64_t SPRING_BYTES_STORAGE_SERVER; - int64_t AUTO_TAG_THROTTLE_STORAGE_QUEUE_BYTES; - int64_t TARGET_BYTES_PER_STORAGE_SERVER_BATCH; - int64_t SPRING_BYTES_STORAGE_SERVER_BATCH; - int64_t STORAGE_HARD_LIMIT_BYTES; - int64_t STORAGE_DURABILITY_LAG_HARD_MAX; - int64_t STORAGE_DURABILITY_LAG_SOFT_MAX; - - int64_t LOW_PRIORITY_STORAGE_QUEUE_BYTES; - int64_t LOW_PRIORITY_DURABILITY_LAG; - - int64_t TARGET_BYTES_PER_TLOG; - int64_t SPRING_BYTES_TLOG; - int64_t TARGET_BYTES_PER_TLOG_BATCH; - int64_t SPRING_BYTES_TLOG_BATCH; - int64_t TLOG_SPILL_THRESHOLD; - int64_t TLOG_HARD_LIMIT_BYTES; - int64_t TLOG_RECOVER_MEMORY_LIMIT; - double TLOG_IGNORE_POP_AUTO_ENABLE_DELAY; - - int64_t MAX_MANUAL_THROTTLED_TRANSACTION_TAGS; - int64_t MAX_AUTO_THROTTLED_TRANSACTION_TAGS; - double MIN_TAG_COST; - double AUTO_THROTTLE_TARGET_TAG_BUSYNESS; - double AUTO_THROTTLE_RAMP_TAG_BUSYNESS; - double AUTO_TAG_THROTTLE_RAMP_UP_TIME; - double AUTO_TAG_THROTTLE_DURATION; - double TAG_THROTTLE_PUSH_INTERVAL; - double AUTO_TAG_THROTTLE_START_AGGREGATION_TIME; - double AUTO_TAG_THROTTLE_UPDATE_FREQUENCY; - double TAG_THROTTLE_EXPIRED_CLEANUP_INTERVAL; - bool AUTO_TAG_THROTTLING_ENABLED; - - double MAX_TRANSACTIONS_PER_BYTE; - - int64_t MIN_AVAILABLE_SPACE; - double MIN_AVAILABLE_SPACE_RATIO; - double TARGET_AVAILABLE_SPACE_RATIO; - double AVAILABLE_SPACE_UPDATE_DELAY; - - double MAX_TL_SS_VERSION_DIFFERENCE; // spring starts at half this value - double MAX_TL_SS_VERSION_DIFFERENCE_BATCH; - int MAX_MACHINES_FALLING_BEHIND; - - int MAX_TPS_HISTORY_SAMPLES; - int NEEDED_TPS_HISTORY_SAMPLES; - int64_t TARGET_DURABILITY_LAG_VERSIONS; - int64_t AUTO_TAG_THROTTLE_DURABILITY_LAG_VERSIONS; - int64_t TARGET_DURABILITY_LAG_VERSIONS_BATCH; - int64_t DURABILITY_LAG_UNLIMITED_THRESHOLD; - double INITIAL_DURABILITY_LAG_MULTIPLIER; - double DURABILITY_LAG_REDUCTION_RATE; - double DURABILITY_LAG_INCREASE_RATE; - - double STORAGE_SERVER_LIST_FETCH_TIMEOUT; - - // disk snapshot - int64_t MAX_FORKED_PROCESS_OUTPUT; - double SNAP_CREATE_MAX_TIMEOUT; - - // Storage Metrics - double STORAGE_METRICS_AVERAGE_INTERVAL; - double STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS; - double SPLIT_JITTER_AMOUNT; - int64_t IOPS_UNITS_PER_SAMPLE; - int64_t BANDWIDTH_UNITS_PER_SAMPLE; - int64_t BYTES_READ_UNITS_PER_SAMPLE; - int64_t READ_HOT_SUB_RANGE_CHUNK_SIZE; - int64_t EMPTY_READ_PENALTY; - bool READ_SAMPLING_ENABLED; - - // Storage Server - double STORAGE_LOGGING_DELAY; - double STORAGE_SERVER_POLL_METRICS_DELAY; - double FUTURE_VERSION_DELAY; - int STORAGE_LIMIT_BYTES; - int BUGGIFY_LIMIT_BYTES; - int FETCH_BLOCK_BYTES; - int FETCH_KEYS_PARALLELISM_BYTES; - int FETCH_KEYS_LOWER_PRIORITY; - int BUGGIFY_BLOCK_BYTES; - double STORAGE_DURABILITY_LAG_REJECT_THRESHOLD; - double STORAGE_DURABILITY_LAG_MIN_RATE; - int STORAGE_COMMIT_BYTES; - double STORAGE_COMMIT_INTERVAL; - double UPDATE_SHARD_VERSION_INTERVAL; - int BYTE_SAMPLING_FACTOR; - int BYTE_SAMPLING_OVERHEAD; - int MAX_STORAGE_SERVER_WATCH_BYTES; - int MAX_BYTE_SAMPLE_CLEAR_MAP_SIZE; - double LONG_BYTE_SAMPLE_RECOVERY_DELAY; - int BYTE_SAMPLE_LOAD_PARALLELISM; - double BYTE_SAMPLE_LOAD_DELAY; - double BYTE_SAMPLE_START_DELAY; - double UPDATE_STORAGE_PROCESS_STATS_INTERVAL; - double BEHIND_CHECK_DELAY; - int BEHIND_CHECK_COUNT; - int64_t BEHIND_CHECK_VERSIONS; - double WAIT_METRICS_WRONG_SHARD_CHANCE; - int64_t MIN_TAG_READ_PAGES_RATE; - int64_t MIN_TAG_WRITE_PAGES_RATE; - double TAG_MEASUREMENT_INTERVAL; - int64_t READ_COST_BYTE_FACTOR; - bool PREFIX_COMPRESS_KVS_MEM_SNAPSHOTS; - bool REPORT_DD_METRICS; - double DD_METRICS_REPORT_INTERVAL; - double FETCH_KEYS_TOO_LONG_TIME_CRITERIA; - double MAX_STORAGE_COMMIT_TIME; - - // Wait Failure - int MAX_OUTSTANDING_WAIT_FAILURE_REQUESTS; - double WAIT_FAILURE_DELAY_LIMIT; - - // Worker - double WORKER_LOGGING_INTERVAL; - double HEAP_PROFILER_INTERVAL; - double UNKNOWN_CC_TIMEOUT; - double DEGRADED_RESET_INTERVAL; - double DEGRADED_WARNING_LIMIT; - double DEGRADED_WARNING_RESET_DELAY; - int64_t TRACE_LOG_FLUSH_FAILURE_CHECK_INTERVAL_SECONDS; - double TRACE_LOG_PING_TIMEOUT_SECONDS; - double MIN_DELAY_CC_WORST_FIT_CANDIDACY_SECONDS; // Listen for a leader for N seconds, and if not heard, then try to - // become the leader. - double MAX_DELAY_CC_WORST_FIT_CANDIDACY_SECONDS; - double DBINFO_FAILED_DELAY; - - // Test harness - double WORKER_POLL_DELAY; - - // Coordination - double COORDINATED_STATE_ONCONFLICT_POLL_INTERVAL; - double FORWARD_REQUEST_TOO_OLD; - bool ENABLE_CROSS_CLUSTER_SUPPORT; // Allow a coordinator to serve requests whose connection string does not match - // the local descriptor - - // Buggification - double BUGGIFIED_EVENTUAL_CONSISTENCY; - bool BUGGIFY_ALL_COORDINATION; - - // Status - double STATUS_MIN_TIME_BETWEEN_REQUESTS; - double MAX_STATUS_REQUESTS_PER_SECOND; - int CONFIGURATION_ROWS_TO_FETCH; - bool DISABLE_DUPLICATE_LOG_WARNING; - double HISTOGRAM_REPORT_INTERVAL; - - // IPager - int PAGER_RESERVED_PAGES; - - // IndirectShadowPager - int FREE_PAGE_VACUUM_THRESHOLD; - int VACUUM_QUEUE_SIZE; - int VACUUM_BYTES_PER_SECOND; - - // Timekeeper - int64_t TIME_KEEPER_DELAY; - int64_t TIME_KEEPER_MAX_ENTRIES; - - // Fast Restore - // TODO: After 6.3, review FR knobs, remove unneeded ones and change default value - int64_t FASTRESTORE_FAILURE_TIMEOUT; - int64_t FASTRESTORE_HEARTBEAT_INTERVAL; - double FASTRESTORE_SAMPLING_PERCENT; - int64_t FASTRESTORE_NUM_LOADERS; - int64_t FASTRESTORE_NUM_APPLIERS; - // FASTRESTORE_TXN_BATCH_MAX_BYTES is target txn size used by appliers to apply mutations - double FASTRESTORE_TXN_BATCH_MAX_BYTES; - // FASTRESTORE_VERSIONBATCH_MAX_BYTES is the maximum data size in each version batch - double FASTRESTORE_VERSIONBATCH_MAX_BYTES; - // FASTRESTORE_VB_PARALLELISM is the number of concurrently running version batches - int64_t FASTRESTORE_VB_PARALLELISM; - int64_t FASTRESTORE_VB_MONITOR_DELAY; // How quickly monitor finished version batch - double FASTRESTORE_VB_LAUNCH_DELAY; - int64_t FASTRESTORE_ROLE_LOGGING_DELAY; - int64_t FASTRESTORE_UPDATE_PROCESS_STATS_INTERVAL; // How quickly to update process metrics for restore - int64_t FASTRESTORE_ATOMICOP_WEIGHT; // workload amplication factor for atomic op - int64_t FASTRESTORE_APPLYING_PARALLELISM; // number of outstanding txns writing to dest. DB - int64_t FASTRESTORE_MONITOR_LEADER_DELAY; - int64_t FASTRESTORE_STRAGGLER_THRESHOLD_SECONDS; - bool FASTRESTORE_TRACK_REQUEST_LATENCY; // true to track reply latency of each request in a request batch - bool FASTRESTORE_TRACK_LOADER_SEND_REQUESTS; // track requests of load send mutations to appliers? - int64_t FASTRESTORE_MEMORY_THRESHOLD_MB_SOFT; // threshold when pipelined actors should be delayed - int64_t FASTRESTORE_WAIT_FOR_MEMORY_LATENCY; - int64_t FASTRESTORE_HEARTBEAT_DELAY; // interval for master to ping loaders and appliers - int64_t - FASTRESTORE_HEARTBEAT_MAX_DELAY; // master claim a node is down if no heart beat from the node for this delay - int64_t FASTRESTORE_APPLIER_FETCH_KEYS_SIZE; // number of keys to fetch in a txn on applier - int64_t FASTRESTORE_LOADER_SEND_MUTATION_MSG_BYTES; // desired size of mutation message sent from loader to appliers - bool FASTRESTORE_GET_RANGE_VERSIONS_EXPENSIVE; // parse each range file to get (range, version) it has? - int64_t FASTRESTORE_REQBATCH_PARALLEL; // number of requests to wait on for getBatchReplies() - bool FASTRESTORE_REQBATCH_LOG; // verbose log information for getReplyBatches - int FASTRESTORE_TXN_CLEAR_MAX; // threshold to start tracking each clear op in a txn - int FASTRESTORE_TXN_RETRY_MAX; // threshold to start output error on too many retries - double FASTRESTORE_TXN_EXTRA_DELAY; // extra delay to avoid overwhelming fdb - bool FASTRESTORE_NOT_WRITE_DB; // do not write result to DB. Only for dev testing - bool FASTRESTORE_USE_RANGE_FILE; // use range file in backup - bool FASTRESTORE_USE_LOG_FILE; // use log file in backup - int64_t FASTRESTORE_SAMPLE_MSG_BYTES; // sample message desired size - double FASTRESTORE_SCHED_UPDATE_DELAY; // delay in seconds in updating process metrics - int FASTRESTORE_SCHED_TARGET_CPU_PERCENT; // release as many requests as possible when cpu usage is below the knob - int FASTRESTORE_SCHED_MAX_CPU_PERCENT; // max cpu percent when scheduler shall not release non-urgent requests - int FASTRESTORE_SCHED_INFLIGHT_LOAD_REQS; // number of inflight requests to load backup files - int FASTRESTORE_SCHED_INFLIGHT_SEND_REQS; // number of inflight requests for loaders to send mutations to appliers - int FASTRESTORE_SCHED_LOAD_REQ_BATCHSIZE; // number of load request to release at once - int FASTRESTORE_SCHED_INFLIGHT_SENDPARAM_THRESHOLD; // we can send future VB requests if it is less than this knob - int FASTRESTORE_SCHED_SEND_FUTURE_VB_REQS_BATCH; // number of future VB sendLoadingParam requests to process at once - int FASTRESTORE_NUM_TRACE_EVENTS; - bool FASTRESTORE_EXPENSIVE_VALIDATION; // when set true, performance will be heavily affected - double FASTRESTORE_WRITE_BW_MB; // target aggregated write bandwidth from all appliers - double FASTRESTORE_RATE_UPDATE_SECONDS; // how long to update appliers target write rate - - int REDWOOD_DEFAULT_PAGE_SIZE; // Page size for new Redwood files - int REDWOOD_KVSTORE_CONCURRENT_READS; // Max number of simultaneous point or range reads in progress. - int REDWOOD_COMMIT_CONCURRENT_READS; // Max number of concurrent reads done to support commit operations - double REDWOOD_PAGE_REBUILD_MAX_SLACK; // When rebuilding pages, max slack to allow in page - int REDWOOD_LAZY_CLEAR_BATCH_SIZE_PAGES; // Number of pages to try to pop from the lazy delete queue and process at - // once - int REDWOOD_LAZY_CLEAR_MIN_PAGES; // Minimum number of pages to free before ending a lazy clear cycle, unless the - // queue is empty - int REDWOOD_LAZY_CLEAR_MAX_PAGES; // Maximum number of pages to free before ending a lazy clear cycle, unless the - // queue is empty - int64_t REDWOOD_REMAP_CLEANUP_WINDOW; // Remap remover lag interval in which to coalesce page writes - double REDWOOD_REMAP_CLEANUP_LAG; // Maximum allowed remap remover lag behind the cleanup window as a multiple of - // the window size - double REDWOOD_LOGGING_INTERVAL; - - // Server request latency measurement - int LATENCY_SAMPLE_SIZE; - double LATENCY_METRICS_LOGGING_INTERVAL; - - ServerKnobs(); - void initialize(bool randomize = false, ClientKnobs* clientKnobs = nullptr, bool isSimulated = false); -}; - -extern std::unique_ptr globalServerKnobs; -extern ServerKnobs const* SERVER_KNOBS; - -#endif +#define SERVER_KNOBS (&IKnobCollection::getGlobalKnobCollection().getServerKnobs()) From 34f82e7a152f176a998f21bcdbfbcb7ebf677b96 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Mon, 26 Jul 2021 09:51:44 -0700 Subject: [PATCH 107/225] Do not partially reset a transaction when it is committed or fails to commit with an error. --- bindings/c/test/unit/unit_tests.cpp | 75 +++++++++++++++++++ .../source/api-version-upgrade-guide.rst | 2 + .../release-notes/release-notes-700.rst | 1 + fdbclient/NativeAPI.actor.cpp | 10 ++- 4 files changed, 86 insertions(+), 2 deletions(-) diff --git a/bindings/c/test/unit/unit_tests.cpp b/bindings/c/test/unit/unit_tests.cpp index 64ed2adddd..fe88e6b96f 100644 --- a/bindings/c/test/unit/unit_tests.cpp +++ b/bindings/c/test/unit/unit_tests.cpp @@ -2177,6 +2177,81 @@ TEST_CASE("monitor_network_busyness") { CHECK(containsGreaterZero); } +// Commit a transaction and confirm it has not been reset +TEST_CASE("commit_does_not_reset") { + fdb::Transaction tr(db); + fdb::Transaction tr2(db); + + // Commit two transactions, one that will fail with conflict and the other + // that will succeed. Ensure both transactions are not reset at the end. + while (1) { + fdb::Int64Future tr1GrvFuture = tr.get_read_version(); + fdb_error_t err = wait_future(tr1GrvFuture); + if (err) { + fdb::EmptyFuture tr1OnErrorFuture = tr.on_error(err); + fdb_check(wait_future(tr1OnErrorFuture)); + continue; + } + + int64_t tr1StartVersion; + CHECK(!tr1GrvFuture.get(&tr1StartVersion)); + + fdb::Int64Future tr2GrvFuture = tr2.get_read_version(); + err = wait_future(tr2GrvFuture); + + if (err) { + fdb::EmptyFuture tr2OnErrorFuture = tr2.on_error(err); + fdb_check(wait_future(tr2OnErrorFuture)); + continue; + } + + int64_t tr2StartVersion; + CHECK(!tr2GrvFuture.get(&tr2StartVersion)); + + tr.set(key("foo"), "bar"); + fdb::EmptyFuture tr1CommitFuture = tr.commit(); + err = wait_future(tr1CommitFuture); + if (err) { + fdb::EmptyFuture tr1OnErrorFuture = tr.on_error(err); + fdb_check(wait_future(tr1OnErrorFuture)); + continue; + } + + fdb_check(tr2.add_conflict_range(key("foo"), strinc(key("foo")), FDB_CONFLICT_RANGE_TYPE_READ)); + tr2.set(key("foo"), "bar"); + fdb::EmptyFuture tr2CommitFuture = tr2.commit(); + err = wait_future(tr2CommitFuture); + CHECK(err == 1020); // not_committed + + fdb::Int64Future tr1GrvFuture2 = tr.get_read_version(); + err = wait_future(tr1GrvFuture2); + if (err) { + fdb::EmptyFuture tr1OnErrorFuture = tr.on_error(err); + fdb_check(wait_future(tr1OnErrorFuture)); + continue; + } + + int64_t tr1EndVersion; + CHECK(!tr1GrvFuture2.get(&tr1EndVersion)); + + fdb::Int64Future tr2GrvFuture2 = tr2.get_read_version(); + err = wait_future(tr2GrvFuture2); + if (err) { + fdb::EmptyFuture tr2OnErrorFuture = tr2.on_error(err); + fdb_check(wait_future(tr2OnErrorFuture)); + continue; + } + + int64_t tr2EndVersion; + CHECK(!tr2GrvFuture2.get(&tr2EndVersion)); + + // If we reset the transaction, then the read version will change + CHECK(tr1StartVersion == tr1EndVersion); + CHECK(tr2StartVersion == tr2EndVersion); + break; + } +} + int main(int argc, char** argv) { if (argc < 3) { std::cout << "Unit tests for the FoundationDB C API.\n" diff --git a/documentation/sphinx/source/api-version-upgrade-guide.rst b/documentation/sphinx/source/api-version-upgrade-guide.rst index 707d8e3246..46e5aa6fcc 100644 --- a/documentation/sphinx/source/api-version-upgrade-guide.rst +++ b/documentation/sphinx/source/api-version-upgrade-guide.rst @@ -25,6 +25,8 @@ API version 700 General ------- +* Committing a transaction will no longer partially reset it. In particular, getting the read version from a transaction that has committed or failed to commit with an error will return the original read version. + Python bindings --------------- diff --git a/documentation/sphinx/source/release-notes/release-notes-700.rst b/documentation/sphinx/source/release-notes/release-notes-700.rst index cfc0730e90..44566955ee 100644 --- a/documentation/sphinx/source/release-notes/release-notes-700.rst +++ b/documentation/sphinx/source/release-notes/release-notes-700.rst @@ -91,6 +91,7 @@ Other Changes * The ``foundationdb`` service installed by the RPM packages will now automatically restart ``fdbmonitor`` after 60 seconds when it fails. `(PR #3841) `_ * Capture output of forked snapshot processes in trace events. `(PR #4254) `_ * Add ErrorKind field to Severity 40 trace events. `(PR #4741) `_ +* Committing a transaction will no longer partially reset it as of API version 700. `(PR #) `_ Earlier release notes --------------------- diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 20d2b9343d..0c84400ef7 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -5244,7 +5244,10 @@ ACTOR Future commitAndWatch(Transaction* self) { self->setupWatches(); } - self->reset(); + if (!self->apiVersionAtLeast(700)) { + self->reset(); + } + return Void(); } catch (Error& e) { if (e.code() != error_code_actor_cancelled) { @@ -5253,7 +5256,10 @@ ACTOR Future commitAndWatch(Transaction* self) { } self->versionstampPromise.sendError(transaction_invalid_version()); - self->reset(); + + if (!self->apiVersionAtLeast(700)) { + self->reset(); + } } throw; From e39cfd48c39ed2b6e9662f56d4aaf4a80071e85f Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Sun, 25 Jul 2021 22:37:08 -0700 Subject: [PATCH 108/225] Ignore goodRecruitmentTime and populate default PEER_LATENCY_CHECK_MIN_POPULATION --- fdbclient/ServerKnobs.cpp | 1 + fdbserver/ClusterController.actor.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index 6d74c2f67a..bc568e039b 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -644,6 +644,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( DBINFO_FAILED_DELAY, 1.0 ); init( ENABLE_WORKER_HEALTH_MONITOR, false ); init( WORKER_HEALTH_MONITOR_INTERVAL, 60.0 ); + init( PEER_LATENCY_CHECK_MIN_POPULATION, 30 ); init( PEER_LATENCY_DEGRADATION_PERCENTILE, 0.90 ); init( PEER_LATENCY_DEGRADATION_THRESHOLD, 0.05 ); init( PEER_TIMEOUT_PERCENTAGE_DEGRADATION_THRESHOLD, 0.1 ); diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index 97ef92b1e5..7ed3811e9a 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -4722,7 +4722,7 @@ ACTOR Future workerHealthMonitor(ClusterControllerData* self) { loop { try { while (!self->goodRecruitmentTime.isReady()) { - wait(self->goodRecruitmentTime); + wait(lowPriorityDelay(SERVER_KNOBS->CC_WORKER_HEALTH_CHECKING_INTERVAL)); } self->degradedServers = self->getServersWithDegradedLink(); From d36b5d62dfb0940754754ffbadb926ee12c4c563 Mon Sep 17 00:00:00 2001 From: Sajjad Rahnama Date: Mon, 26 Jul 2021 10:41:17 -0700 Subject: [PATCH 109/225] Fault Injection Active/Deactivation - Edit TSS mode set_config --- fdbserver/SimulatedCluster.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbserver/SimulatedCluster.actor.cpp b/fdbserver/SimulatedCluster.actor.cpp index 56264fa61c..f9916cf1bd 100644 --- a/fdbserver/SimulatedCluster.actor.cpp +++ b/fdbserver/SimulatedCluster.actor.cpp @@ -1648,11 +1648,11 @@ void SimulationConfig::setTss(const TestConfig& testConfig) { tssCount = std::max(0, std::min(tssCount, (db.usableRegions * (machine_count / datacenters) - replication_type) / 2)); - if (!testConfig.config.present() && tssCount > 0) { + if (!testConfig.config.present() && tssCount > 0 && faultInjectionActivated) { std::string confStr = format("tss_count:=%d tss_storage_engine:=%d", tssCount, db.storageServerStoreType); set_config(confStr); double tssRandom = deterministicRandom()->random01(); - if (tssRandom > 0.5 || !faultInjectionActivated) { + if (tssRandom > 0.5) { // normal tss mode g_simulator.tssMode = ISimulator::TSSMode::EnabledNormal; } else if (tssRandom < 0.25 && !testConfig.isFirstTestInRestart) { From 9d6402b7595188cd13b3e723cbb910022b349ac9 Mon Sep 17 00:00:00 2001 From: Sajjad Rahnama Date: Mon, 26 Jul 2021 11:04:18 -0700 Subject: [PATCH 110/225] Fault Injection Active/Deactivation - Edit usage in fdbserver --- fdbserver/fdbserver.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/fdbserver.actor.cpp b/fdbserver/fdbserver.actor.cpp index bc4b8a951e..ba75fe296c 100644 --- a/fdbserver/fdbserver.actor.cpp +++ b/fdbserver/fdbserver.actor.cpp @@ -649,7 +649,7 @@ static void printUsage(const char* name, bool devhelp) { "--kvfile FILE", "Input file (SQLite database file) for use by the 'kvfilegeneratesums' and 'kvfileintegritycheck' roles."); printOptionUsage("-b [on,off], --buggify [on,off]", " Sets Buggify system state, defaults to `off'."); - printOptionUsage("-f [on,off], --fault_injection [on,off]", " Sets fault injection, defaults to `on'."); + printOptionUsage("-fi [on,off], --fault_injection [on,off]", " Sets fault injection, defaults to `on'."); printOptionUsage("--crash", "Crash on serious errors instead of continuing."); printOptionUsage("-N NETWORKIMPL, --network NETWORKIMPL", " Select network implementation, `net2' (default)," From febc26a1ea3cbf58dd79241f596f8722fc9b72db Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Mon, 26 Jul 2021 11:43:07 -0700 Subject: [PATCH 111/225] Fix some cases where we were reusing a committed transaction without resetting it. --- fdbserver/ClusterController.actor.cpp | 2 ++ fdbserver/StorageCache.actor.cpp | 1 + fdbserver/workloads/CommitBugCheck.actor.cpp | 3 +++ .../workloads/DifferentClustersSameRV.actor.cpp | 1 + fdbserver/workloads/RandomSelector.actor.cpp | 13 +++++++++++++ .../workloads/SpecialKeySpaceCorrectness.actor.cpp | 1 + fdbserver/workloads/StatusWorkload.actor.cpp | 1 + 7 files changed, 22 insertions(+) diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index 97ef92b1e5..b02bc0b7c7 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -195,6 +195,8 @@ public: } loop { + tr.reset(); + // Wait for some changes while (!self->anyDelta.get()) wait(self->anyDelta.onChange()); diff --git a/fdbserver/StorageCache.actor.cpp b/fdbserver/StorageCache.actor.cpp index 8f44f054d6..d3f46fa234 100644 --- a/fdbserver/StorageCache.actor.cpp +++ b/fdbserver/StorageCache.actor.cpp @@ -2156,6 +2156,7 @@ ACTOR Future watchInterface(StorageCacheData* self, StorageServerInterface tr.set(storageKey, storageCacheServerValue(ssi)); wait(tr.commit()); } + tr.reset(); break; } catch (Error& e) { wait(tr.onError(e)); diff --git a/fdbserver/workloads/CommitBugCheck.actor.cpp b/fdbserver/workloads/CommitBugCheck.actor.cpp index 1980d605dd..855f4de680 100644 --- a/fdbserver/workloads/CommitBugCheck.actor.cpp +++ b/fdbserver/workloads/CommitBugCheck.actor.cpp @@ -45,6 +45,7 @@ struct CommitBugWorkload : TestWorkload { try { tr.set(key, val1); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { TraceEvent("CommitBugSetVal1Error").error(e); @@ -57,6 +58,7 @@ struct CommitBugWorkload : TestWorkload { try { tr.set(key, val2); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { TraceEvent("CommitBugSetVal2Error").error(e); @@ -85,6 +87,7 @@ struct CommitBugWorkload : TestWorkload { try { tr.clear(key); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { TraceEvent("CommitBugClearValError").error(e); diff --git a/fdbserver/workloads/DifferentClustersSameRV.actor.cpp b/fdbserver/workloads/DifferentClustersSameRV.actor.cpp index 1bcc0afc84..d6c21e4b2e 100644 --- a/fdbserver/workloads/DifferentClustersSameRV.actor.cpp +++ b/fdbserver/workloads/DifferentClustersSameRV.actor.cpp @@ -191,6 +191,7 @@ struct DifferentClustersSameRVWorkload : TestWorkload { serializer(w, x); tr.set(self->keyToRead, w.toValue()); wait(tr.commit()); + tr.reset(); } catch (Error& e) { wait(tr.onError(e)); } diff --git a/fdbserver/workloads/RandomSelector.actor.cpp b/fdbserver/workloads/RandomSelector.actor.cpp index d4c6bd00fe..500ce3b859 100644 --- a/fdbserver/workloads/RandomSelector.actor.cpp +++ b/fdbserver/workloads/RandomSelector.actor.cpp @@ -125,6 +125,7 @@ struct RandomSelectorWorkload : TestWorkload { //TraceEvent("RYOWInit").detail("Key",myKeyA).detail("Value",myValue); } wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { wait(tr.onError(e)); @@ -149,6 +150,7 @@ struct RandomSelectorWorkload : TestWorkload { try { tr.set(StringRef(clientID + "d/" + myKeyA), myValue); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { wait(tr.onError(e)); @@ -163,6 +165,7 @@ struct RandomSelectorWorkload : TestWorkload { try { tr.clear(StringRef(clientID + "d/" + myKeyA)); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { wait(tr.onError(e)); @@ -184,6 +187,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.clear(KeyRangeRef(StringRef(clientID + "d/" + myKeyA), StringRef(clientID + "d/" + myKeyB))); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { wait(tr.onError(e)); @@ -231,6 +235,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::AddValue); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -254,6 +259,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::AppendIfFits); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -277,6 +283,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::And); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -300,6 +307,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::Or); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -323,6 +331,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::Xor); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -346,6 +355,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::Max); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -369,6 +379,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::Min); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -392,6 +403,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::ByteMin); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; @@ -415,6 +427,7 @@ struct RandomSelectorWorkload : TestWorkload { tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef()); tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::ByteMax); wait(tr.commit()); + tr.reset(); break; } catch (Error& e) { error = e; diff --git a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp index 7c6c2006a6..03c1f3bda4 100644 --- a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp +++ b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp @@ -783,6 +783,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { Value(worker.processClass.toString())); // Set it as the same class type as before, thus only // class source will be changed wait(tx->commit()); + tx->reset(); Optional class_source = wait(tx->get( Key("process/class_source/" + address) .withPrefix( diff --git a/fdbserver/workloads/StatusWorkload.actor.cpp b/fdbserver/workloads/StatusWorkload.actor.cpp index 21c568d31e..98eecafef3 100644 --- a/fdbserver/workloads/StatusWorkload.actor.cpp +++ b/fdbserver/workloads/StatusWorkload.actor.cpp @@ -153,6 +153,7 @@ struct StatusWorkload : TestWorkload { tr.set(latencyBandConfigKey, ValueRef(config)); wait(tr.commit()); + tr.reset(); if (deterministicRandom()->random01() < 0.3) { return Void(); From 9f3e5d9bb549b8f622a9000894eb0599be6ee9fe Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Mon, 26 Jul 2021 15:58:41 -0400 Subject: [PATCH 112/225] use a BinaryWriter::toValue and BinaryReader::fromStringRef instead of encoding time using a string --- fdbserver/Coordination.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index fc603746d4..b7caf8e86a 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -456,7 +456,7 @@ struct LeaderRegisterCollection { self->forward[forwardingInfo[i].key.removePrefix(fwdKeys.begin)] = forwardInfo; } for (int i = 0; i < forwardingTime.size(); i++) { - double time = std::stod(forwardingTime[i].value.toString().c_str()); + double time = BinaryReader::fromStringRef(forwardingTime[i].value, Unversioned()); self->forwardStartTime[forwardingTime[i].key.removePrefix(fwdTimeKeys.begin)] = time; } return Void(); @@ -495,7 +495,7 @@ struct LeaderRegisterCollection { self->forwardStartTime[key] = forwardTime; OnDemandStore& store = *self->pStore; store->set(KeyValueRef(key.withPrefix(fwdKeys.begin), conn.toString())); - store->set(KeyValueRef(key.withPrefix(fwdTimeKeys.begin), std::to_string(forwardTime))); + store->set(KeyValueRef(key.withPrefix(fwdTimeKeys.begin), BinaryWriter::toValue(forwardTime, Unversioned()))); wait(store->commit()); return Void(); } From a38db9c6e3296ed60c7ea054f6f12d38797f39cb Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Mon, 26 Jul 2021 13:56:27 -0700 Subject: [PATCH 113/225] Add PR number --- documentation/sphinx/source/release-notes/release-notes-700.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/sphinx/source/release-notes/release-notes-700.rst b/documentation/sphinx/source/release-notes/release-notes-700.rst index 44566955ee..1246d42618 100644 --- a/documentation/sphinx/source/release-notes/release-notes-700.rst +++ b/documentation/sphinx/source/release-notes/release-notes-700.rst @@ -91,7 +91,7 @@ Other Changes * The ``foundationdb`` service installed by the RPM packages will now automatically restart ``fdbmonitor`` after 60 seconds when it fails. `(PR #3841) `_ * Capture output of forked snapshot processes in trace events. `(PR #4254) `_ * Add ErrorKind field to Severity 40 trace events. `(PR #4741) `_ -* Committing a transaction will no longer partially reset it as of API version 700. `(PR #) `_ +* Committing a transaction will no longer partially reset it as of API version 700. `(PR #5271) `_ Earlier release notes --------------------- From ff8a1e0ed2152b9382786513fd5108273a95e370 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Mon, 26 Jul 2021 16:37:55 -0700 Subject: [PATCH 114/225] Ignore warning from valgrind about F_SET_RW_HINT usage. --- contrib/TestHarness/Program.cs.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index 28aa8687c1..e48d441c1b 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -966,6 +966,10 @@ namespace SummarizeTest // When running ASAN we expect to see this message. Boost coroutine should be using the correct asan annotations so that it shouldn't produce any false positives. continue; } + if (err.EndsWith("Warning: unimplemented fcntl command: 1036")) { + // Valgrind produces this warning when F_SET_RW_HINT is used + continue; + } if (stderrSeverity == (int)Magnesium.Severity.SevError) { error = true; From c7ef116c12ac61fbf5ad19707fe139c7d90ad31a Mon Sep 17 00:00:00 2001 From: Sajjad Rahnama Date: Mon, 26 Jul 2021 16:44:10 -0700 Subject: [PATCH 115/225] TestHarness Buggify/FaultInjection Enable/Disable --- contrib/TestHarness/Program.cs.cmake | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index 28aa8687c1..9a15b5ad6c 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -144,7 +144,9 @@ namespace SummarizeTest string oldBinaryFolder = (args.Length > 1) ? args[1] : Path.Combine("/opt", "joshua", "global_data", "oldBinaries"); bool useValgrind = args.Length > 2 && args[2].ToLower() == "true"; int maxTries = (args.Length > 3) ? int.Parse(args[3]) : 3; - return Run(Path.Combine("bin", BINARY), "", "tests", "summary.xml", "error.xml", "tmp", oldBinaryFolder, useValgrind, maxTries, true, Path.Combine("/app", "deploy", "runtime", ".tls_5_1", PLUGIN)); + bool buggifyEnabled = (args.Length > 4) ? bool.Parse(args[4]) : true; + bool faultInjectionEnabled = (args.Length > 5) ? bool.Parse(args[5]) : true; + return Run(Path.Combine("bin", BINARY), "", "tests", "summary.xml", "error.xml", "tmp", oldBinaryFolder, useValgrind, maxTries, true, Path.Combine("/app", "deploy", "runtime", ".tls_5_1", PLUGIN), buggifyEnabled, faultInjectionEnabled); } catch(Exception e) { @@ -240,10 +242,10 @@ namespace SummarizeTest } } - static int Run(string fdbserverName, string tlsPluginFile, string testFolder, string summaryFileName, string errorFileName, string runDir, string oldBinaryFolder, bool useValgrind, int maxTries, bool traceToStdout = false, string tlsPluginFile_5_1 = "") + static int Run(string fdbserverName, string tlsPluginFile, string testFolder, string summaryFileName, string errorFileName, string runDir, string oldBinaryFolder, bool useValgrind, int maxTries, bool traceToStdout = false, string tlsPluginFile_5_1 = "", bool buggifyEnabled = true, bool faultInjectionEnabled = true) { int seed = random.Next(1000000000); - bool buggify = random.NextDouble() < buggifyOnRatio; + bool buggify = buggifyEnabled ? (random.NextDouble() < buggifyOnRatio) : false; string testFile = null; string testDir = ""; string oldServerName = ""; @@ -353,11 +355,11 @@ namespace SummarizeTest bool useNewPlugin = (oldServerName == fdbserverName) || versionGreaterThanOrEqual(oldServerName.Split('-').Last(), "5.2.0"); bool useToml = File.Exists(testFile + "-1.toml"); string testFile1 = useToml ? testFile + "-1.toml" : testFile + "-1.txt"; - result = RunTest(firstServerName, useNewPlugin ? tlsPluginFile : tlsPluginFile_5_1, summaryFileName, errorFileName, seed, buggify, testFile1, runDir, uid, expectedUnseed, out unseed, out retryableError, logOnRetryableError, useValgrind, false, true, oldServerName, traceToStdout, noSim); + result = RunTest(firstServerName, useNewPlugin ? tlsPluginFile : tlsPluginFile_5_1, summaryFileName, errorFileName, seed, buggify, testFile1, runDir, uid, expectedUnseed, out unseed, out retryableError, logOnRetryableError, useValgrind, false, true, oldServerName, traceToStdout, noSim, faultInjectionEnabled); if (result == 0) { string testFile2 = useToml ? testFile + "-2.toml" : testFile + "-2.txt"; - result = RunTest(secondServerName, tlsPluginFile, summaryFileName, errorFileName, seed+1, buggify, testFile2, runDir, uid, expectedUnseed, out unseed, out retryableError, logOnRetryableError, useValgrind, true, false, oldServerName, traceToStdout, noSim); + result = RunTest(secondServerName, tlsPluginFile, summaryFileName, errorFileName, seed+1, buggify, testFile2, runDir, uid, expectedUnseed, out unseed, out retryableError, logOnRetryableError, useValgrind, true, false, oldServerName, traceToStdout, noSim, faultInjectionEnabled); } } else @@ -365,13 +367,13 @@ namespace SummarizeTest int expectedUnseed = -1; if (!useValgrind && unseedCheck) { - result = RunTest(fdbserverName, tlsPluginFile, null, null, seed, buggify, testFile, runDir, Guid.NewGuid().ToString(), -1, out expectedUnseed, out retryableError, logOnRetryableError, false, false, false, "", traceToStdout, noSim); + result = RunTest(fdbserverName, tlsPluginFile, null, null, seed, buggify, testFile, runDir, Guid.NewGuid().ToString(), -1, out expectedUnseed, out retryableError, logOnRetryableError, false, false, false, "", traceToStdout, noSim, faultInjectionEnabled); } if (!retryableError) { int unseed; - result = RunTest(fdbserverName, tlsPluginFile, summaryFileName, errorFileName, seed, buggify, testFile, runDir, Guid.NewGuid().ToString(), expectedUnseed, out unseed, out retryableError, logOnRetryableError, useValgrind, false, false, "", traceToStdout, noSim); + result = RunTest(fdbserverName, tlsPluginFile, summaryFileName, errorFileName, seed, buggify, testFile, runDir, Guid.NewGuid().ToString(), expectedUnseed, out unseed, out retryableError, logOnRetryableError, useValgrind, false, false, "", traceToStdout, noSim, faultInjectionEnabled); } } @@ -386,7 +388,7 @@ namespace SummarizeTest private static int RunTest(string fdbserverName, string tlsPluginFile, string summaryFileName, string errorFileName, int seed, bool buggify, string testFile, string runDir, string uid, int expectedUnseed, out int unseed, out bool retryableError, bool logOnRetryableError, bool useValgrind, bool restarting = false, - bool willRestart = false, string oldBinaryName = "", bool traceToStdout = false, bool noSim = false) + bool willRestart = false, string oldBinaryName = "", bool traceToStdout = false, bool noSim = false, bool faultInjectionEnabled = true) { unseed = -1; @@ -407,7 +409,7 @@ namespace SummarizeTest Directory.CreateDirectory(tempPath); Directory.SetCurrentDirectory(tempPath); - if (!restarting) LogTestPlan(summaryFileName, testFile, seed, buggify, expectedUnseed != -1, uid, oldBinaryName); + if (!restarting) LogTestPlan(summaryFileName, testFile, seed, buggify, expectedUnseed != -1, uid, faultInjectionEnabled, oldBinaryName); string valgrindOutputFile = null; using (var process = new System.Diagnostics.Process()) @@ -424,13 +426,13 @@ namespace SummarizeTest var args = ""; if (willRestart && oldBinaryName.EndsWith("alpha6")) { - args = string.Format("-Rs 1000000000 -r {0} {1} -s {2} -f \"{3}\" -b {4} {5} --crash", - role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", tlsPluginArg); + args = string.Format("-Rs 1000000000 -r {0} {1} -s {2} -f \"{3}\" -b {4} -fi {5} {6} --crash", + role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", faultInjectionEnabled ? "on" : "off", tlsPluginArg); } else { - args = string.Format("-Rs 1GB -r {0} {1} -s {2} -f \"{3}\" -b {4} {5} --crash", - role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", tlsPluginArg); + args = string.Format("-Rs 1GB -r {0} {1} -s {2} -f \"{3}\" -b {4} -fi {5} {6} --crash", + role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", faultInjectionEnabled ? "on" : "off", tlsPluginArg); } if (restarting) args = args + " --restarting"; if (useValgrind && !willRestart) @@ -524,7 +526,7 @@ namespace SummarizeTest var xout = new XElement("UnableToKillProcess", new XAttribute("Severity", (int)Magnesium.Severity.SevWarnAlways)); - AppendXmlMessageToSummary(summaryFileName, xout, traceToStdout, testFile, seed, buggify, expectedUnseed != -1, oldBinaryName); + AppendXmlMessageToSummary(summaryFileName, xout, traceToStdout, testFile, seed, buggify, expectedUnseed != -1, oldBinaryName, faultInjectionEnabled); return 104; } } @@ -549,7 +551,7 @@ namespace SummarizeTest new XAttribute("Plugin", tlsPluginFile), new XAttribute("MachineName", System.Environment.MachineName)); - AppendXmlMessageToSummary(summaryFileName, xout, traceToStdout, testFile, seed, buggify, expectedUnseed != -1, oldBinaryName); + AppendXmlMessageToSummary(summaryFileName, xout, traceToStdout, testFile, seed, buggify, expectedUnseed != -1, oldBinaryName, faultInjectionEnabled); ok = useValgrind ? 0 : 103; } else @@ -588,7 +590,7 @@ namespace SummarizeTest new XAttribute("Severity", (int)Magnesium.Severity.SevError), new XAttribute("ErrorMessage", e.Message)); - AppendXmlMessageToSummary(summaryFileName, xout, traceToStdout, testFile, seed, buggify, expectedUnseed != -1, oldBinaryName); + AppendXmlMessageToSummary(summaryFileName, xout, traceToStdout, testFile, seed, buggify, expectedUnseed != -1, oldBinaryName, faultInjectionEnabled); return 101; } finally @@ -695,13 +697,14 @@ namespace SummarizeTest } } - static void LogTestPlan(string summaryFileName, string testFileName, int randomSeed, bool buggify, bool testDeterminism, string uid, string oldBinary="") + static void LogTestPlan(string summaryFileName, string testFileName, int randomSeed, bool buggify, bool testDeterminism, string uid, bool faultInjectionEnabled, string oldBinary="") { var xout = new XElement("TestPlan", new XAttribute("TestUID", uid), new XAttribute("RandomSeed", randomSeed), new XAttribute("TestFile", testFileName), new XAttribute("BuggifyEnabled", buggify ? "1" : "0"), + new XAttribute("FaultInjectionEnabled", faultInjectionEnabled ? "1" : "0"), new XAttribute("DeterminismCheck", testDeterminism ? "1" : "0"), new XAttribute("OldBinary", Path.GetFileName(oldBinary))); AppendToSummary(summaryFileName, xout); @@ -788,6 +791,7 @@ namespace SummarizeTest new XAttribute("SourceVersion", ev.Details.SourceVersion), new XAttribute("Time", ev.Details.ActualTime), new XAttribute("BuggifyEnabled", ev.Details.BuggifyEnabled), + new XAttribute("FaultInjectionEnabled", ev.Details.FaultInjectionEnabled), new XAttribute("DeterminismCheck", expectedUnseed != -1 ? "1" : "0"), new XAttribute("OldBinary", Path.GetFileName(oldBinaryName))); testBeginFound = true; @@ -1230,7 +1234,7 @@ namespace SummarizeTest } private static void AppendXmlMessageToSummary(string summaryFileName, XElement xout, bool traceToStdout = false, string testFile = null, - int? seed = null, bool? buggify = null, bool? determinismCheck = null, string oldBinaryName = null) + int? seed = null, bool? buggify = null, bool? determinismCheck = null, string oldBinaryName = null, bool? faultInjectionEnabled = null) { var test = new XElement("Test", xout); if(testFile != null) @@ -1239,6 +1243,8 @@ namespace SummarizeTest test.Add(new XAttribute("RandomSeed", seed)); if(buggify != null) test.Add(new XAttribute("BuggifyEnabled", buggify.Value ? "1" : "0")); + if(faultInjectionEnabled != null) + test.Add(new XAttribute("FaultInjectionEnabled", buggify.Value ? "1" : "0")); if(determinismCheck != null) test.Add(new XAttribute("DeterminismCheck", determinismCheck.Value ? "1" : "0")); if(oldBinaryName != null) From b3e22ad57387270d578505014186e90d5c549323 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Mon, 26 Jul 2021 18:10:03 -0700 Subject: [PATCH 116/225] Move stderr exception checking so that ignored output does not count against the error limit. --- contrib/TestHarness/Program.cs.cmake | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index e48d441c1b..8b159ac2b1 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -638,6 +638,15 @@ namespace SummarizeTest { if(!String.IsNullOrEmpty(errLine.Data)) { + if (errLine.Data.EndsWith("WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!")) { + // When running ASAN we expect to see this message. Boost coroutine should be using the correct asan annotations so that it shouldn't produce any false positives. + return; + } + if (errLine.Data.EndsWith("Warning: unimplemented fcntl command: 1036")) { + // Valgrind produces this warning when F_SET_RW_HINT is used + return; + } + hasError = true; if(Errors.Count < maxErrors) { if(errLine.Data.Length > maxErrorLength) { @@ -962,14 +971,6 @@ namespace SummarizeTest int stderrBytes = 0; foreach (string err in outputErrors) { - if (err.EndsWith("WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!")) { - // When running ASAN we expect to see this message. Boost coroutine should be using the correct asan annotations so that it shouldn't produce any false positives. - continue; - } - if (err.EndsWith("Warning: unimplemented fcntl command: 1036")) { - // Valgrind produces this warning when F_SET_RW_HINT is used - continue; - } if (stderrSeverity == (int)Magnesium.Severity.SevError) { error = true; From e68344e0ead47c972908b89ec8aac4a646427474 Mon Sep 17 00:00:00 2001 From: Trevor Clinkenbeard Date: Mon, 26 Jul 2021 19:26:31 -0700 Subject: [PATCH 117/225] Fix header for ConfigNode.h Co-authored-by: Lukas Joswiak --- fdbserver/ConfigNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/ConfigNode.h b/fdbserver/ConfigNode.h index 8e70ae2073..f4fa92b5fd 100644 --- a/fdbserver/ConfigNode.h +++ b/fdbserver/ConfigNode.h @@ -1,5 +1,5 @@ /* - * SimpleConfigDatabaseNode.h + * ConfigNode.h * * This source file is part of the FoundationDB open source project * From 634aa2deae0783d3bc8462842b06b8a325997dee Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 26 Jul 2021 19:37:12 -0700 Subject: [PATCH 118/225] Fix IConfigTransaction::getReadVersion implementations --- fdbclient/PaxosConfigTransaction.actor.cpp | 2 +- fdbclient/SimpleConfigTransaction.actor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index 4c10ec534e..6bff8bc18a 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -112,7 +112,7 @@ public: if (!getGenerationFuture.isValid()) { getGenerationFuture = getGeneration(this); } - return map(getGenerationFuture, [](auto const& gen) { return gen.committedVersion; }); + return map(getGenerationFuture, [](auto const& gen) { return gen.liveVersion; }); } Optional getCachedReadVersion() const { diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index f9e0872e76..c3cef740bf 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -156,7 +156,7 @@ public: Future getReadVersion() { if (!getGenerationFuture.isValid()) getGenerationFuture = getGeneration(this); - return map(getGenerationFuture, [](auto const& gen) { return gen.committedVersion; }); + return map(getGenerationFuture, [](auto const& gen) { return gen.liveVersion; }); } Optional getCachedReadVersion() const { From 507c1f11e362ab967e58b856c0bc1859666509a1 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Mon, 26 Jul 2021 19:55:10 -0700 Subject: [PATCH 119/225] Add .log() to bare TraceEvent() invocations without any .detail()s to avoid clang-tidy warning about immediate destruction of object without use. --- FDBLibTLS/FDBLibTLSPolicy.cpp | 42 ++++++++-------- FDBLibTLS/FDBLibTLSSession.cpp | 16 +++--- fdbbackup/FileDecoder.actor.cpp | 2 +- .../BackupContainerLocalDirectory.actor.cpp | 2 +- fdbclient/DatabaseBackupAgent.actor.cpp | 22 ++++---- fdbclient/FileBackupAgent.actor.cpp | 10 ++-- fdbclient/MultiVersionTransaction.actor.cpp | 2 +- fdbclient/NativeAPI.actor.cpp | 14 +++--- fdbclient/ReadYourWrites.actor.cpp | 2 +- fdbclient/SystemData.cpp | 2 +- fdbrpc/FlowTransport.actor.cpp | 2 +- fdbrpc/sim2.actor.cpp | 4 +- fdbserver/ApplyMetadataMutation.cpp | 2 +- fdbserver/BackupWorker.actor.cpp | 6 +-- fdbserver/ClusterController.actor.cpp | 20 ++++---- fdbserver/CommitProxyServer.actor.cpp | 8 +-- fdbserver/CoordinatedState.actor.cpp | 2 +- fdbserver/CoroFlow.actor.cpp | 6 +-- fdbserver/CoroFlowCoro.actor.cpp | 6 +-- fdbserver/DataDistribution.actor.cpp | 50 +++++++++---------- fdbserver/GrvProxyServer.actor.cpp | 2 +- fdbserver/KeyValueStoreMemory.actor.cpp | 4 +- fdbserver/KeyValueStoreSQLite.actor.cpp | 6 +-- fdbserver/LeaderElection.actor.cpp | 8 +-- fdbserver/LogSystem.h | 2 +- fdbserver/MetricLogger.actor.cpp | 2 +- fdbserver/MoveKeys.actor.cpp | 8 +-- fdbserver/OldTLogServer_4_6.actor.cpp | 4 +- fdbserver/OldTLogServer_6_0.actor.cpp | 22 ++++---- fdbserver/OldTLogServer_6_2.actor.cpp | 20 ++++---- fdbserver/QuietDatabase.actor.cpp | 4 +- fdbserver/Ratekeeper.actor.cpp | 6 +-- fdbserver/RestoreApplier.actor.cpp | 2 +- fdbserver/RestoreApplier.actor.h | 2 +- fdbserver/RestoreController.actor.cpp | 10 ++-- fdbserver/RestoreWorker.actor.cpp | 6 +-- fdbserver/SimulatedCluster.actor.cpp | 4 +- fdbserver/StorageCache.actor.cpp | 6 +-- fdbserver/TLogServer.actor.cpp | 14 +++--- fdbserver/TagPartitionedLogSystem.actor.cpp | 12 ++--- fdbserver/masterserver.actor.cpp | 22 ++++---- fdbserver/storageserver.actor.cpp | 22 ++++---- fdbserver/tester.actor.cpp | 6 +-- fdbserver/worker.actor.cpp | 16 +++--- .../AtomicOpsApiCorrectness.actor.cpp | 18 +++---- fdbserver/workloads/AtomicRestore.actor.cpp | 10 ++-- .../workloads/AtomicSwitchover.actor.cpp | 24 ++++----- ...kupAndParallelRestoreCorrectness.actor.cpp | 2 +- .../workloads/BackupCorrectness.actor.cpp | 2 +- fdbserver/workloads/BackupToDBAbort.actor.cpp | 16 +++--- .../workloads/BackupToDBUpgrade.actor.cpp | 4 +- fdbserver/workloads/BulkSetup.actor.h | 2 +- fdbserver/workloads/ChangeConfig.actor.cpp | 8 +-- fdbserver/workloads/ConflictRange.actor.cpp | 2 +- .../workloads/ConsistencyCheck.actor.cpp | 14 +++--- fdbserver/workloads/CpuProfiler.actor.cpp | 8 +-- fdbserver/workloads/Cycle.actor.cpp | 4 +- fdbserver/workloads/DDMetrics.actor.cpp | 2 +- .../DifferentClustersSameRV.actor.cpp | 16 +++--- .../workloads/ExternalWorkload.actor.cpp | 6 +-- .../workloads/HealthMetricsApi.actor.cpp | 2 +- .../workloads/IncrementalBackup.actor.cpp | 18 +++---- fdbserver/workloads/KVStoreTest.actor.cpp | 4 +- fdbserver/workloads/KillRegion.actor.cpp | 20 ++++---- fdbserver/workloads/LogMetrics.actor.cpp | 2 +- fdbserver/workloads/LowLatency.actor.cpp | 2 +- .../workloads/MachineAttrition.actor.cpp | 10 ++-- fdbserver/workloads/ParallelRestore.actor.cpp | 2 +- fdbserver/workloads/Ping.actor.cpp | 2 +- fdbserver/workloads/PopulateTPCC.actor.cpp | 2 +- fdbserver/workloads/RandomMoveKeys.actor.cpp | 10 ++-- fdbserver/workloads/RestoreBackup.actor.cpp | 2 +- fdbserver/workloads/SimpleAtomicAdd.actor.cpp | 2 +- fdbserver/workloads/SnapTest.actor.cpp | 12 ++--- .../SpecialKeySpaceCorrectness.actor.cpp | 8 +-- fdbserver/workloads/StatusWorkload.actor.cpp | 2 +- fdbserver/workloads/Throttling.actor.cpp | 2 +- .../workloads/TimeKeeperCorrectness.actor.cpp | 6 +-- fdbserver/workloads/TriggerRecovery.actor.cpp | 2 +- fdbserver/workloads/VersionStamp.actor.cpp | 2 +- fdbserver/workloads/WriteDuringRead.actor.cpp | 2 +- .../workloads/WriteTagThrottling.actor.cpp | 2 +- flow/DeterministicRandom.cpp | 2 +- flow/Net2.actor.cpp | 10 ++-- flow/Platform.actor.cpp | 16 +++--- flow/ThreadHelper.actor.h | 4 +- flow/Trace.cpp | 2 +- flow/genericactors.actor.h | 2 +- 88 files changed, 360 insertions(+), 360 deletions(-) diff --git a/FDBLibTLS/FDBLibTLSPolicy.cpp b/FDBLibTLS/FDBLibTLSPolicy.cpp index 1f6b18e2e9..2e3142165d 100644 --- a/FDBLibTLS/FDBLibTLSPolicy.cpp +++ b/FDBLibTLS/FDBLibTLSPolicy.cpp @@ -42,7 +42,7 @@ FDBLibTLSPolicy::FDBLibTLSPolicy(Reference plugin) key_data_set(false), verify_peers_set(false) { if ((tls_cfg = tls_config_new()) == nullptr) { - TraceEvent(SevError, "FDBLibTLSConfigError"); + TraceEvent(SevError, "FDBLibTLSConfigError").log(); throw std::runtime_error("FDBLibTLSConfigError"); } @@ -67,14 +67,14 @@ ITLSSession* FDBLibTLSPolicy::create_session(bool is_client, // servername, since this will be ignored - the servername should be // matched by the verify criteria instead. if (verify_peers_set && servername != nullptr) { - TraceEvent(SevError, "FDBLibTLSVerifyPeersWithServerName"); + TraceEvent(SevError, "FDBLibTLSVerifyPeersWithServerName").log(); return nullptr; } // If verify peers has not been set, then require a server name to // avoid an accidental lack of name validation. if (!verify_peers_set && servername == nullptr) { - TraceEvent(SevError, "FDBLibTLSNoServerName"); + TraceEvent(SevError, "FDBLibTLSNoServerName").log(); return nullptr; } } @@ -123,18 +123,18 @@ struct stack_st_X509* FDBLibTLSPolicy::parse_cert_pem(const uint8_t* cert_pem, s if (cert_pem_len > INT_MAX) goto err; if ((bio = BIO_new_mem_buf((void*)cert_pem, cert_pem_len)) == nullptr) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } if ((certs = sk_X509_new_null()) == nullptr) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } ERR_clear_error(); while ((cert = PEM_read_bio_X509(bio, nullptr, password_cb, nullptr)) != nullptr) { if (!sk_X509_push(certs, cert)) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } } @@ -150,7 +150,7 @@ struct stack_st_X509* FDBLibTLSPolicy::parse_cert_pem(const uint8_t* cert_pem, s } if (sk_X509_num(certs) < 1) { - TraceEvent(SevError, "FDBLibTLSNoCerts"); + TraceEvent(SevError, "FDBLibTLSNoCerts").log(); goto err; } @@ -168,11 +168,11 @@ err: bool FDBLibTLSPolicy::set_ca_data(const uint8_t* ca_data, int ca_len) { if (ca_data_set) { - TraceEvent(SevError, "FDBLibTLSCAAlreadySet"); + TraceEvent(SevError, "FDBLibTLSCAAlreadySet").log(); return false; } if (session_created) { - TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive"); + TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive").log(); return false; } @@ -194,11 +194,11 @@ bool FDBLibTLSPolicy::set_ca_data(const uint8_t* ca_data, int ca_len) { bool FDBLibTLSPolicy::set_cert_data(const uint8_t* cert_data, int cert_len) { if (cert_data_set) { - TraceEvent(SevError, "FDBLibTLSCertAlreadySet"); + TraceEvent(SevError, "FDBLibTLSCertAlreadySet").log(); return false; } if (session_created) { - TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive"); + TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive").log(); return false; } @@ -218,11 +218,11 @@ bool FDBLibTLSPolicy::set_key_data(const uint8_t* key_data, int key_len, const c bool rc = false; if (key_data_set) { - TraceEvent(SevError, "FDBLibTLSKeyAlreadySet"); + TraceEvent(SevError, "FDBLibTLSKeyAlreadySet").log(); goto err; } if (session_created) { - TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive"); + TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive").log(); goto err; } @@ -231,7 +231,7 @@ bool FDBLibTLSPolicy::set_key_data(const uint8_t* key_data, int key_len, const c long len; if ((bio = BIO_new_mem_buf((void*)key_data, key_len)) == nullptr) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } ERR_clear_error(); @@ -241,7 +241,7 @@ bool FDBLibTLSPolicy::set_key_data(const uint8_t* key_data, int key_len, const c if ((ERR_GET_LIB(errnum) == ERR_LIB_PEM && ERR_GET_REASON(errnum) == PEM_R_BAD_DECRYPT) || (ERR_GET_LIB(errnum) == ERR_LIB_EVP && ERR_GET_REASON(errnum) == EVP_R_BAD_DECRYPT)) { - TraceEvent(SevError, "FDBLibTLSIncorrectPassword"); + TraceEvent(SevError, "FDBLibTLSIncorrectPassword").log(); } else { ERR_error_string_n(errnum, errbuf, sizeof(errbuf)); TraceEvent(SevError, "FDBLibTLSPrivateKeyError").detail("LibcryptoErrorMessage", errbuf); @@ -250,15 +250,15 @@ bool FDBLibTLSPolicy::set_key_data(const uint8_t* key_data, int key_len, const c } BIO_free(bio); if ((bio = BIO_new(BIO_s_mem())) == nullptr) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } if (!PEM_write_bio_PrivateKey(bio, key, nullptr, nullptr, 0, nullptr, nullptr)) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } if ((len = BIO_get_mem_data(bio, &data)) <= 0) { - TraceEvent(SevError, "FDBLibTLSOutOfMemory"); + TraceEvent(SevError, "FDBLibTLSOutOfMemory").log(); goto err; } if (tls_config_set_key_mem(tls_cfg, (const uint8_t*)data, len) == -1) { @@ -283,16 +283,16 @@ err: bool FDBLibTLSPolicy::set_verify_peers(int count, const uint8_t* verify_peers[], int verify_peers_len[]) { if (verify_peers_set) { - TraceEvent(SevError, "FDBLibTLSVerifyPeersAlreadySet"); + TraceEvent(SevError, "FDBLibTLSVerifyPeersAlreadySet").log(); return false; } if (session_created) { - TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive"); + TraceEvent(SevError, "FDBLibTLSPolicyAlreadyActive").log(); return false; } if (count < 1) { - TraceEvent(SevError, "FDBLibTLSNoVerifyPeers"); + TraceEvent(SevError, "FDBLibTLSNoVerifyPeers").log(); return false; } diff --git a/FDBLibTLS/FDBLibTLSSession.cpp b/FDBLibTLS/FDBLibTLSSession.cpp index 4c4c8e5bfa..75c60dd049 100644 --- a/FDBLibTLS/FDBLibTLSSession.cpp +++ b/FDBLibTLS/FDBLibTLSSession.cpp @@ -73,7 +73,7 @@ FDBLibTLSSession::FDBLibTLSSession(Reference policy, if (is_client) { if ((tls_ctx = tls_client()) == nullptr) { - TraceEvent(SevError, "FDBLibTLSClientError", uid); + TraceEvent(SevError, "FDBLibTLSClientError", uid).log(); throw std::runtime_error("FDBLibTLSClientError"); } if (tls_configure(tls_ctx, policy->tls_cfg) == -1) { @@ -88,7 +88,7 @@ FDBLibTLSSession::FDBLibTLSSession(Reference policy, } } else { if ((tls_sctx = tls_server()) == nullptr) { - TraceEvent(SevError, "FDBLibTLSServerError", uid); + TraceEvent(SevError, "FDBLibTLSServerError", uid).log(); throw std::runtime_error("FDBLibTLSServerError"); } if (tls_configure(tls_sctx, policy->tls_cfg) == -1) { @@ -250,7 +250,7 @@ std::tuple FDBLibTLSSession::check_verify(Referenceparse_cert_pem(cert_pem, cert_pem_len)) == nullptr) @@ -388,14 +388,14 @@ int FDBLibTLSSession::handshake() { int FDBLibTLSSession::read(uint8_t* data, int length) { if (!handshake_completed) { - TraceEvent(SevError, "FDBLibTLSReadHandshakeError"); + TraceEvent(SevError, "FDBLibTLSReadHandshakeError").log(); return FAILED; } ssize_t n = tls_read(tls_ctx, data, length); if (n > 0) { if (n > INT_MAX) { - TraceEvent(SevError, "FDBLibTLSReadOverflow"); + TraceEvent(SevError, "FDBLibTLSReadOverflow").log(); return FAILED; } return (int)n; @@ -415,14 +415,14 @@ int FDBLibTLSSession::read(uint8_t* data, int length) { int FDBLibTLSSession::write(const uint8_t* data, int length) { if (!handshake_completed) { - TraceEvent(SevError, "FDBLibTLSWriteHandshakeError", uid); + TraceEvent(SevError, "FDBLibTLSWriteHandshakeError", uid).log(); return FAILED; } ssize_t n = tls_write(tls_ctx, data, length); if (n > 0) { if (n > INT_MAX) { - TraceEvent(SevError, "FDBLibTLSWriteOverflow", uid); + TraceEvent(SevError, "FDBLibTLSWriteOverflow", uid).log(); return FAILED; } return (int)n; diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index b8e4bc138f..22e5774bcb 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -571,7 +571,7 @@ int main(int argc, char** argv) { } if (!param.tlsConfig.setupTLS()) { - TraceEvent(SevError, "TLSError"); + TraceEvent(SevError, "TLSError").log(); throw tls_error(); } diff --git a/fdbclient/BackupContainerLocalDirectory.actor.cpp b/fdbclient/BackupContainerLocalDirectory.actor.cpp index b89d085a64..a638ee147a 100644 --- a/fdbclient/BackupContainerLocalDirectory.actor.cpp +++ b/fdbclient/BackupContainerLocalDirectory.actor.cpp @@ -227,7 +227,7 @@ Future> BackupContainerLocalDirectory::readFile(const std: } if (g_simulator.getCurrentProcess()->uid == UID()) { - TraceEvent(SevError, "BackupContainerReadFileOnUnsetProcessID"); + TraceEvent(SevError, "BackupContainerReadFileOnUnsetProcessID").log(); } std::string uniquePath = fullPath + "." + g_simulator.getCurrentProcess()->uid.toString() + ".lnk"; unlink(uniquePath.c_str()); diff --git a/fdbclient/DatabaseBackupAgent.actor.cpp b/fdbclient/DatabaseBackupAgent.actor.cpp index a8de6819dd..deb57d6141 100644 --- a/fdbclient/DatabaseBackupAgent.actor.cpp +++ b/fdbclient/DatabaseBackupAgent.actor.cpp @@ -364,7 +364,7 @@ struct BackupRangeTaskFunc : TaskFuncBase { TEST(true); // range insert delayed because too versionMap is too large if (rangeCount > CLIENT_KNOBS->BACKUP_MAP_KEY_UPPER_LIMIT) - TraceEvent(SevWarnAlways, "DBA_KeyRangeMapTooLarge"); + TraceEvent(SevWarnAlways, "DBA_KeyRangeMapTooLarge").log(); wait(delay(1)); task->params[BackupRangeTaskFunc::keyBackupRangeBeginKey] = rangeBegin; @@ -1882,7 +1882,7 @@ struct CopyDiffLogsUpgradeTaskFunc : TaskFuncBase { state Reference onDone = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); if (task->params[BackupAgentBase::destUid].size() == 0) { - TraceEvent("DBA_CopyDiffLogsUpgradeTaskFuncAbortInUpgrade"); + TraceEvent("DBA_CopyDiffLogsUpgradeTaskFuncAbortInUpgrade").log(); wait(success(AbortOldBackupTaskFunc::addTask(tr, taskBucket, task, TaskCompletionKey::signal(onDone)))); } else { Version beginVersion = @@ -2377,11 +2377,11 @@ void checkAtomicSwitchOverConfig(StatusObjectReader srcStatus, StatusObjectReade try { // Check if src is unlocked and dest is locked if (getLockedStatus(srcStatus) != false) { - TraceEvent(SevWarn, "DBA_AtomicSwitchOverSrcLocked"); + TraceEvent(SevWarn, "DBA_AtomicSwitchOverSrcLocked").log(); throw backup_error(); } if (getLockedStatus(destStatus) != true) { - TraceEvent(SevWarn, "DBA_AtomicSwitchOverDestUnlocked"); + TraceEvent(SevWarn, "DBA_AtomicSwitchOverDestUnlocked").log(); throw backup_error(); } // Check if mutation-stream-id matches @@ -2402,7 +2402,7 @@ void checkAtomicSwitchOverConfig(StatusObjectReader srcStatus, StatusObjectReade destDRAgents.end(), std::inserter(intersectingAgents, intersectingAgents.begin())); if (intersectingAgents.empty()) { - TraceEvent(SevWarn, "DBA_SwitchOverPossibleDRAgentsIncorrectSetup"); + TraceEvent(SevWarn, "DBA_SwitchOverPossibleDRAgentsIncorrectSetup").log(); throw backup_error(); } } catch (std::runtime_error& e) { @@ -2757,7 +2757,7 @@ public: } } - TraceEvent("DBA_SwitchoverReady"); + TraceEvent("DBA_SwitchoverReady").log(); try { wait(backupAgent->discontinueBackup(dest, tagName)); @@ -2768,7 +2768,7 @@ public: wait(success(backupAgent->waitBackup(dest, tagName, StopWhenDone::True))); - TraceEvent("DBA_SwitchoverStopped"); + TraceEvent("DBA_SwitchoverStopped").log(); state ReadYourWritesTransaction tr3(dest); loop { @@ -2789,7 +2789,7 @@ public: } } - TraceEvent("DBA_SwitchoverVersionUpgraded"); + TraceEvent("DBA_SwitchoverVersionUpgraded").log(); try { wait(drAgent.submitBackup(backupAgent->taskBucket->src, @@ -2805,15 +2805,15 @@ public: throw; } - TraceEvent("DBA_SwitchoverSubmitted"); + TraceEvent("DBA_SwitchoverSubmitted").log(); wait(success(drAgent.waitSubmitted(backupAgent->taskBucket->src, tagName))); - TraceEvent("DBA_SwitchoverStarted"); + TraceEvent("DBA_SwitchoverStarted").log(); wait(backupAgent->unlockBackup(dest, tagName)); - TraceEvent("DBA_SwitchoverUnlocked"); + TraceEvent("DBA_SwitchoverUnlocked").log(); return Void(); } diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index 90cc1ab321..8c057aadd2 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -5478,7 +5478,7 @@ public: try { wait(discontinueBackup(backupAgent, ryw_tr, tagName)); wait(ryw_tr->commit()); - TraceEvent("AS_DiscontinuedBackup"); + TraceEvent("AS_DiscontinuedBackup").log(); break; } catch (Error& e) { if (e.code() == error_code_backup_unneeded || e.code() == error_code_backup_duplicate) { @@ -5489,7 +5489,7 @@ public: } wait(success(waitBackup(backupAgent, cx, tagName.toString(), StopWhenDone::True))); - TraceEvent("AS_BackupStopped"); + TraceEvent("AS_BackupStopped").log(); ryw_tr->reset(); loop { @@ -5502,7 +5502,7 @@ public: ryw_tr->clear(range); } wait(ryw_tr->commit()); - TraceEvent("AS_ClearedRange"); + TraceEvent("AS_ClearedRange").log(); break; } catch (Error& e) { wait(ryw_tr->onError(e)); @@ -5512,7 +5512,7 @@ public: Reference bc = wait(backupConfig.backupContainer().getOrThrow(cx)); if (fastRestore) { - TraceEvent("AtomicParallelRestoreStartRestore"); + TraceEvent("AtomicParallelRestoreStartRestore").log(); Version targetVersion = ::invalidVersion; wait(submitParallelRestore(cx, tagName, @@ -5533,7 +5533,7 @@ public: } return -1; } else { - TraceEvent("AS_StartRestore"); + TraceEvent("AS_StartRestore").log(); Version ver = wait(restore(backupAgent, cx, cx, diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index eedacf80aa..663400cebf 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -1521,7 +1521,7 @@ std::vector> MultiVersionApi::copyExternalLibraryPe #else std::vector> MultiVersionApi::copyExternalLibraryPerThread(std::string path) { if (threadCount > 1) { - TraceEvent(SevError, "MultipleClientThreadsUnsupportedOnWindows"); + TraceEvent(SevError, "MultipleClientThreadsUnsupportedOnWindows").log(); throw unsupported_operation(); } std::vector> paths; diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 20d2b9343d..a98cf30adc 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -488,7 +488,7 @@ ACTOR static Future transactionInfoCommitActor(Transaction* tr, std::vecto ACTOR static Future delExcessClntTxnEntriesActor(Transaction* tr, int64_t clientTxInfoSizeLimit) { state const Key clientLatencyName = CLIENT_LATENCY_INFO_PREFIX.withPrefix(fdbClientInfoPrefixRange.begin); state const Key clientLatencyAtomicCtr = CLIENT_LATENCY_INFO_CTR_PREFIX.withPrefix(fdbClientInfoPrefixRange.begin); - TraceEvent(SevInfo, "DelExcessClntTxnEntriesCalled"); + TraceEvent(SevInfo, "DelExcessClntTxnEntriesCalled").log(); loop { try { tr->reset(); @@ -496,7 +496,7 @@ ACTOR static Future delExcessClntTxnEntriesActor(Transaction* tr, int64_t tr->setOption(FDBTransactionOptions::LOCK_AWARE); Optional ctrValue = wait(tr->get(KeyRef(clientLatencyAtomicCtr), Snapshot::True)); if (!ctrValue.present()) { - TraceEvent(SevInfo, "NumClntTxnEntriesNotFound"); + TraceEvent(SevInfo, "NumClntTxnEntriesNotFound").log(); return Void(); } state int64_t txInfoSize = 0; @@ -1627,7 +1627,7 @@ ACTOR static Future switchConnectionFileImpl(Reference Transaction::commitMutations() { if (options.debugDump) { UID u = nondeterministicRandom()->randomUniqueID(); - TraceEvent("TransactionDump", u); + TraceEvent("TransactionDump", u).log(); for (auto i = tr.transaction.mutations.begin(); i != tr.transaction.mutations.end(); ++i) TraceEvent("TransactionMutation", u) .detail("T", i->type) @@ -6326,7 +6326,7 @@ void Transaction::setToken(uint64_t token) { void enableClientInfoLogging() { ASSERT(networkOptions.logClientInfo.present() == false); networkOptions.logClientInfo = true; - TraceEvent(SevInfo, "ClientInfoLoggingEnabled"); + TraceEvent(SevInfo, "ClientInfoLoggingEnabled").log(); } ACTOR Future snapCreate(Database cx, Standalone snapCmd, UID snapUID) { @@ -6380,7 +6380,7 @@ ACTOR Future checkSafeExclusions(Database cx, vector exc } throw; } - TraceEvent("ExclusionSafetyCheckCoordinators"); + TraceEvent("ExclusionSafetyCheckCoordinators").log(); state ClientCoordinators coordinatorList(cx->getConnectionFile()); state vector>> leaderServers; leaderServers.reserve(coordinatorList.clientLeaderServers.size()); @@ -6393,7 +6393,7 @@ ACTOR Future checkSafeExclusions(Database cx, vector exc choose { when(wait(smartQuorum(leaderServers, leaderServers.size() / 2 + 1, 1.0))) {} when(wait(delay(3.0))) { - TraceEvent("ExclusionSafetyCheckNoCoordinatorQuorum"); + TraceEvent("ExclusionSafetyCheckNoCoordinatorQuorum").log(); return false; } } diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index f3f9a391c7..66ca328ea8 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -1164,7 +1164,7 @@ public: if (!ryw->resetPromise.isSet()) ryw->resetPromise.sendError(transaction_timed_out()); wait(delay(deterministicRandom()->random01() * 5)); - TraceEvent("ClientBuggifyInFlightCommit"); + TraceEvent("ClientBuggifyInFlightCommit").log(); wait(ryw->tr.commit()); } diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index eeef762361..c3b7e85343 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -129,7 +129,7 @@ void decodeKeyServersValue(RangeResult result, std::sort(src.begin(), src.end()); std::sort(dest.begin(), dest.end()); if (missingIsError && (src.size() != srcTag.size() || dest.size() != destTag.size())) { - TraceEvent(SevError, "AttemptedToDecodeMissingTag"); + TraceEvent(SevError, "AttemptedToDecodeMissingTag").log(); for (const KeyValueRef& kv : result) { Tag tag = decodeServerTagValue(kv.value); UID serverID = decodeServerTagKey(kv.key); diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index d44483da12..c1bd3726a0 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -1019,7 +1019,7 @@ static void scanPackets(TransportData* transport, BUGGIFY_WITH_PROB(0.0001)) { g_simulator.lastConnectionFailure = g_network->now(); isBuggifyEnabled = true; - TraceEvent(SevInfo, "BitsFlip"); + TraceEvent(SevInfo, "BitsFlip").log(); int flipBits = 32 - (int)floor(log2(deterministicRandom()->randomUInt32())); uint32_t firstFlipByteLocation = deterministicRandom()->randomUInt32() % packetLen; diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index 33da8e7ed6..2b8e4406da 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -470,12 +470,12 @@ public: state TaskPriority currentTaskID = g_network->getCurrentTask(); if (++openCount >= 3000) { - TraceEvent(SevError, "TooManyFiles"); + TraceEvent(SevError, "TooManyFiles").log(); ASSERT(false); } if (openCount == 2000) { - TraceEvent(SevWarnAlways, "DisableConnectionFailures_TooManyFiles"); + TraceEvent(SevWarnAlways, "DisableConnectionFailures_TooManyFiles").log(); g_simulator.speedUpSimulation = true; g_simulator.connectionFailuresDisableDuration = 1e6; } diff --git a/fdbserver/ApplyMetadataMutation.cpp b/fdbserver/ApplyMetadataMutation.cpp index cea35794a9..732766e9a4 100644 --- a/fdbserver/ApplyMetadataMutation.cpp +++ b/fdbserver/ApplyMetadataMutation.cpp @@ -404,7 +404,7 @@ void applyMetadataMutations(SpanID const& spanContext, confChange = true; TEST(true); // Recovering at a higher version. } else if (m.param1 == writeRecoveryKey) { - TraceEvent("WriteRecoveryKeySet", dbgid); + TraceEvent("WriteRecoveryKeySet", dbgid).log(); if (!initialCommit) txnStateStore->set(KeyValueRef(m.param1, m.param2)); TEST(true); // Snapshot created, setting writeRecoveryKey in txnStateStore diff --git a/fdbserver/BackupWorker.actor.cpp b/fdbserver/BackupWorker.actor.cpp index d6bd6a0ebb..8087259e1c 100644 --- a/fdbserver/BackupWorker.actor.cpp +++ b/fdbserver/BackupWorker.actor.cpp @@ -477,7 +477,7 @@ ACTOR Future monitorBackupStartedKeyChanges(BackupData* self, bool present if (present || !watch) return true; } else { - TraceEvent("BackupWorkerEmptyStartKey", self->myId); + TraceEvent("BackupWorkerEmptyStartKey", self->myId).log(); self->onBackupChanges(uidVersions); self->exitEarly = shouldExit; @@ -887,7 +887,7 @@ ACTOR Future pullAsyncData(BackupData* self) { state Version tagAt = std::max(self->pulledVersion.get(), std::max(self->startVersion, self->savedVersion)); state Arena prev; - TraceEvent("BackupWorkerPull", self->myId); + TraceEvent("BackupWorkerPull", self->myId).log(); loop { while (self->paused.get()) { wait(self->paused.onChange()); @@ -1017,7 +1017,7 @@ ACTOR static Future monitorWorkerPause(BackupData* self) { Optional value = wait(tr->get(backupPausedKey)); bool paused = value.present() && value.get() == LiteralStringRef("1"); if (self->paused.get() != paused) { - TraceEvent(paused ? "BackupWorkerPaused" : "BackupWorkerResumed", self->myId); + TraceEvent(paused ? "BackupWorkerPaused" : "BackupWorkerResumed", self->myId).log(); self->paused.set(paused); } diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index 7ed3811e9a..987a8e03a6 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -1962,7 +1962,7 @@ public: } if (bestDC != clusterControllerDcId) { - TraceEvent("BestDCIsNotClusterDC"); + TraceEvent("BestDCIsNotClusterDC").log(); vector> dcPriority; dcPriority.push_back(bestDC); desiredDcIds.set(dcPriority); @@ -3094,7 +3094,7 @@ ACTOR Future clusterWatchDatabase(ClusterControllerData* cluster, ClusterC // When this someday is implemented, make sure forced failures still cause the master to be recruited again loop { - TraceEvent("CCWDB", cluster->id); + TraceEvent("CCWDB", cluster->id).log(); try { state double recoveryStart = now(); TraceEvent("CCWDB", cluster->id).detail("Recruiting", "Master"); @@ -3915,7 +3915,7 @@ ACTOR Future timeKeeperSetVersion(ClusterControllerData* self) { ACTOR Future timeKeeper(ClusterControllerData* self) { state KeyBackedMap versionMap(timeKeeperPrefixRange.begin); - TraceEvent("TimeKeeperStarted"); + TraceEvent("TimeKeeperStarted").log(); wait(timeKeeperSetVersion(self)); @@ -3929,7 +3929,7 @@ ACTOR Future timeKeeper(ClusterControllerData* self) { // how long it is taking to hear responses from each other component. UID debugID = deterministicRandom()->randomUniqueID(); - TraceEvent("TimeKeeperCommit", debugID); + TraceEvent("TimeKeeperCommit", debugID).log(); tr->debugTransaction(debugID); } tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); @@ -4080,7 +4080,7 @@ ACTOR Future monitorProcessClasses(ClusterControllerData* self) { } wait(trVer.commit()); - TraceEvent("ProcessClassUpgrade"); + TraceEvent("ProcessClassUpgrade").log(); break; } catch (Error& e) { wait(trVer.onError(e)); @@ -4509,7 +4509,7 @@ ACTOR Future handleForcedRecoveries(ClusterControllerData* self, ClusterCo } wait(fCommit); } - TraceEvent("ForcedRecoveryFinish", self->id); + TraceEvent("ForcedRecoveryFinish", self->id).log(); self->db.forceRecovery = false; req.reply.send(Void()); } @@ -4518,7 +4518,7 @@ ACTOR Future handleForcedRecoveries(ClusterControllerData* self, ClusterCo ACTOR Future startDataDistributor(ClusterControllerData* self) { wait(delay(0.0)); // If master fails at the same time, give it a chance to clear master PID. - TraceEvent("CCStartDataDistributor", self->id); + TraceEvent("CCStartDataDistributor", self->id).log(); loop { try { state bool no_distributor = !self->db.serverInfo->get().distributor.present(); @@ -4585,7 +4585,7 @@ ACTOR Future monitorDataDistributor(ClusterControllerData* self) { ACTOR Future startRatekeeper(ClusterControllerData* self) { wait(delay(0.0)); // If master fails at the same time, give it a chance to clear master PID. - TraceEvent("CCStartRatekeeper", self->id); + TraceEvent("CCStartRatekeeper", self->id).log(); loop { try { state bool no_ratekeeper = !self->db.serverInfo->get().ratekeeper.present(); @@ -4702,7 +4702,7 @@ ACTOR Future dbInfoUpdater(ClusterControllerData* self) { req.serializedDbInfo = BinaryWriter::toValue(self->db.serverInfo->get(), AssumeVersion(g_network->protocolVersion())); - TraceEvent("DBInfoStartBroadcast", self->id); + TraceEvent("DBInfoStartBroadcast", self->id).log(); choose { when(std::vector notUpdated = wait(broadcastDBInfoRequest(req, SERVER_KNOBS->DBINFO_SEND_AMOUNT, Optional(), false))) { @@ -4757,7 +4757,7 @@ ACTOR Future workerHealthMonitor(ClusterControllerData* self) { } } else { self->excludedDegradedServers.clear(); - TraceEvent("DegradedServerDetectedAndSuggestRecovery"); + TraceEvent("DegradedServerDetectedAndSuggestRecovery").log(); } } } diff --git a/fdbserver/CommitProxyServer.actor.cpp b/fdbserver/CommitProxyServer.actor.cpp index 137bf3f240..e58564ecf8 100644 --- a/fdbserver/CommitProxyServer.actor.cpp +++ b/fdbserver/CommitProxyServer.actor.cpp @@ -1756,7 +1756,7 @@ ACTOR Future proxySnapCreate(ProxySnapRequest snapReq, ProxyCommitData* co ACTOR Future proxyCheckSafeExclusion(Reference const> db, ExclusionSafetyCheckRequest req) { - TraceEvent("SafetyCheckCommitProxyBegin"); + TraceEvent("SafetyCheckCommitProxyBegin").log(); state ExclusionSafetyCheckReply reply(false); if (!db->get().distributor.present()) { TraceEvent(SevWarnAlways, "DataDistributorNotPresent").detail("Operation", "ExclusionSafetyCheck"); @@ -1778,7 +1778,7 @@ ACTOR Future proxyCheckSafeExclusion(Reference cons throw e; } } - TraceEvent("SafetyCheckCommitProxyFinish"); + TraceEvent("SafetyCheckCommitProxyFinish").log(); req.reply.send(reply); return Void(); } @@ -1796,7 +1796,7 @@ ACTOR Future reportTxnTagCommitCost(UID myID, TraceEvent("ProxyRatekeeperChanged", myID).detail("RKID", db->get().ratekeeper.get().id()); nextRequestTimer = Void(); } else { - TraceEvent("ProxyRatekeeperDied", myID); + TraceEvent("ProxyRatekeeperDied", myID).log(); nextRequestTimer = Never(); } } @@ -1936,7 +1936,7 @@ ACTOR Future commitProxyServerCore(CommitProxyInterface proxy, } } when(ProxySnapRequest snapReq = waitNext(proxy.proxySnapReq.getFuture())) { - TraceEvent(SevDebug, "SnapMasterEnqueue"); + TraceEvent(SevDebug, "SnapMasterEnqueue").log(); addActor.send(proxySnapCreate(snapReq, &commitData)); } when(ExclusionSafetyCheckRequest exclCheckReq = waitNext(proxy.exclusionSafetyCheckReq.getFuture())) { diff --git a/fdbserver/CoordinatedState.actor.cpp b/fdbserver/CoordinatedState.actor.cpp index 955e1c88b2..dca378af98 100644 --- a/fdbserver/CoordinatedState.actor.cpp +++ b/fdbserver/CoordinatedState.actor.cpp @@ -316,7 +316,7 @@ struct MovableCoordinatedStateImpl { Value oldQuorumState = wait(cs.read()); if (oldQuorumState != self->lastCSValue.get()) { TEST(true); // Quorum change aborted by concurrent write to old coordination state - TraceEvent("QuorumChangeAbortedByConcurrency"); + TraceEvent("QuorumChangeAbortedByConcurrency").log(); throw coordinated_state_conflict(); } diff --git a/fdbserver/CoroFlow.actor.cpp b/fdbserver/CoroFlow.actor.cpp index cc719423ec..cc453ed3a2 100644 --- a/fdbserver/CoroFlow.actor.cpp +++ b/fdbserver/CoroFlow.actor.cpp @@ -173,7 +173,7 @@ class WorkPool final : public IThreadPool, public ReferenceCountedPRIORITY_TEAM_HEALTHY), wrongConfiguration(false), id(deterministicRandom()->randomUniqueID()) { if (servers.empty()) { - TraceEvent(SevInfo, "ConstructTCTeamFromEmptyServers"); + TraceEvent(SevInfo, "ConstructTCTeamFromEmptyServers").log(); } serverIDs.reserve(servers.size()); for (int i = 0; i < servers.size(); i++) { @@ -445,7 +445,7 @@ ACTOR Future> getInitialDataDistribution(Data } if (!result->mode || !ddEnabledState->isDDEnabled()) { // DD can be disabled persistently (result->mode = 0) or transiently (isDDEnabled() = 0) - TraceEvent(SevDebug, "GetInitialDataDistribution_DisabledDD"); + TraceEvent(SevDebug, "GetInitialDataDistribution_DisabledDD").log(); return result; } @@ -475,7 +475,7 @@ ACTOR Future> getInitialDataDistribution(Data wait(tr.onError(e)); ASSERT(!succeeded); // We shouldn't be retrying if we have already started modifying result in this loop - TraceEvent("GetInitialTeamsRetry", distributorId); + TraceEvent("GetInitialTeamsRetry", distributorId).log(); } } @@ -4160,14 +4160,14 @@ ACTOR Future monitorPerpetualStorageWiggle(DDTeamCollection* teamCollectio &stopWiggleSignal, finishStorageWiggleSignal.getFuture(), teamCollection)); collection.add(perpetualStorageWiggler( &stopWiggleSignal, finishStorageWiggleSignal, teamCollection, ddEnabledState)); - TraceEvent("PerpetualStorageWiggleOpen", teamCollection->distributorId); + TraceEvent("PerpetualStorageWiggleOpen", teamCollection->distributorId).log(); } else if (speed == 0) { if (!stopWiggleSignal.get()) { stopWiggleSignal.set(true); wait(collection.signalAndReset()); teamCollection->pauseWiggle->set(true); } - TraceEvent("PerpetualStorageWiggleClose", teamCollection->distributorId); + TraceEvent("PerpetualStorageWiggleClose", teamCollection->distributorId).log(); } wait(watchFuture); break; @@ -4262,7 +4262,7 @@ ACTOR Future waitHealthyZoneChange(DDTeamCollection* self) { auto p = decodeHealthyZoneValue(val.get()); if (p.first == ignoreSSFailuresZoneString) { // healthyZone is now overloaded for DD diabling purpose, which does not timeout - TraceEvent("DataDistributionDisabledForStorageServerFailuresStart", self->distributorId); + TraceEvent("DataDistributionDisabledForStorageServerFailuresStart", self->distributorId).log(); healthyZoneTimeout = Never(); } else if (p.second > tr.getReadVersion().get()) { double timeoutSeconds = @@ -4277,15 +4277,15 @@ ACTOR Future waitHealthyZoneChange(DDTeamCollection* self) { } } else if (self->healthyZone.get().present()) { // maintenance hits timeout - TraceEvent("MaintenanceZoneEndTimeout", self->distributorId); + TraceEvent("MaintenanceZoneEndTimeout", self->distributorId).log(); self->healthyZone.set(Optional()); } } else if (self->healthyZone.get().present()) { // `healthyZone` has been cleared if (self->healthyZone.get().get() == ignoreSSFailuresZoneString) { - TraceEvent("DataDistributionDisabledForStorageServerFailuresEnd", self->distributorId); + TraceEvent("DataDistributionDisabledForStorageServerFailuresEnd", self->distributorId).log(); } else { - TraceEvent("MaintenanceZoneEndManualClear", self->distributorId); + TraceEvent("MaintenanceZoneEndManualClear", self->distributorId).log(); } self->healthyZone.set(Optional()); } @@ -4432,7 +4432,7 @@ ACTOR Future storageServerFailureTracker(DDTeamCollection* self, status->isFailed = false; } else if (self->clearHealthyZoneFuture.isReady()) { self->clearHealthyZoneFuture = clearHealthyZone(self->cx); - TraceEvent("MaintenanceZoneCleared", self->distributorId); + TraceEvent("MaintenanceZoneCleared", self->distributorId).log(); self->healthyZone.set(Optional()); } } @@ -5491,7 +5491,7 @@ ACTOR Future serverGetTeamRequests(TeamCollectionInterface tci, DDTeamColl } ACTOR Future remoteRecovered(Reference const> db) { - TraceEvent("DDTrackerStarting"); + TraceEvent("DDTrackerStarting").log(); while (db->get().recoveryState < RecoveryState::ALL_LOGS_RECRUITED) { TraceEvent("DDTrackerStarting").detail("RecoveryState", (int)db->get().recoveryState); wait(db->onChange()); @@ -5625,7 +5625,7 @@ ACTOR Future waitForDataDistributionEnabled(Database cx, const DDEnabledSt try { Optional mode = wait(tr.get(dataDistributionModeKey)); if (!mode.present() && ddEnabledState->isDDEnabled()) { - TraceEvent("WaitForDDEnabledSucceeded"); + TraceEvent("WaitForDDEnabledSucceeded").log(); return Void(); } if (mode.present()) { @@ -5636,7 +5636,7 @@ ACTOR Future waitForDataDistributionEnabled(Database cx, const DDEnabledSt .detail("Mode", m) .detail("IsDDEnabled", ddEnabledState->isDDEnabled()); if (m && ddEnabledState->isDDEnabled()) { - TraceEvent("WaitForDDEnabledSucceeded"); + TraceEvent("WaitForDDEnabledSucceeded").log(); return Void(); } } @@ -5711,7 +5711,7 @@ ACTOR Future debugCheckCoalescing(Database cx) { .detail("Value", ranges[j].value); } - TraceEvent("DoneCheckingCoalescing"); + TraceEvent("DoneCheckingCoalescing").log(); return Void(); } catch (Error& e) { wait(tr.onError(e)); @@ -5807,10 +5807,10 @@ ACTOR Future dataDistribution(Reference self, state Promise removeFailedServer; try { loop { - TraceEvent("DDInitTakingMoveKeysLock", self->ddId); + TraceEvent("DDInitTakingMoveKeysLock", self->ddId).log(); MoveKeysLock lock_ = wait(takeMoveKeysLock(cx, self->ddId)); lock = lock_; - TraceEvent("DDInitTookMoveKeysLock", self->ddId); + TraceEvent("DDInitTookMoveKeysLock", self->ddId).log(); DatabaseConfiguration configuration_ = wait(getDatabaseConfiguration(cx)); configuration = configuration_; @@ -5854,7 +5854,7 @@ ACTOR Future dataDistribution(Reference self, } } - TraceEvent("DDInitUpdatedReplicaKeys", self->ddId); + TraceEvent("DDInitUpdatedReplicaKeys", self->ddId).log(); Reference initData_ = wait(getInitialDataDistribution( cx, self->ddId, @@ -5882,7 +5882,7 @@ ACTOR Future dataDistribution(Reference self, // mode may be set true by system operator using fdbcli and isDDEnabled() set to true break; } - TraceEvent("DataDistributionDisabled", self->ddId); + TraceEvent("DataDistributionDisabled", self->ddId).log(); TraceEvent("MovingData", self->ddId) .detail("InFlight", 0) @@ -5919,7 +5919,7 @@ ACTOR Future dataDistribution(Reference self, .trackLatest("TotalDataInFlightRemote"); wait(waitForDataDistributionEnabled(cx, ddEnabledState)); - TraceEvent("DataDistributionEnabled"); + TraceEvent("DataDistributionEnabled").log(); } // When/If this assertion fails, Evan owes Ben a pat on the back for his foresight @@ -6256,7 +6256,7 @@ ACTOR Future ddSnapCreateCore(DistributorSnapRequest snapReq, Reference ddSnapCreate(DistributorSnapRequest snapReq, if (!ddEnabledState->setDDEnabled(false, snapReq.snapUID)) { // disable DD before doing snapCreate, if previous snap req has already disabled DD then this operation fails // here - TraceEvent("SnapDDSetDDEnabledFailedInMemoryCheck"); + TraceEvent("SnapDDSetDDEnabledFailedInMemoryCheck").log(); snapReq.reply.sendError(operation_failed()); return Void(); } @@ -6344,18 +6344,18 @@ bool _exclusionSafetyCheck(vector& excludeServerIDs, DDTeamCollection* team ACTOR Future ddExclusionSafetyCheck(DistributorExclusionSafetyCheckRequest req, Reference self, Database cx) { - TraceEvent("DDExclusionSafetyCheckBegin", self->ddId); + TraceEvent("DDExclusionSafetyCheckBegin", self->ddId).log(); vector ssis = wait(getStorageServers(cx)); DistributorExclusionSafetyCheckReply reply(true); if (!self->teamCollection) { - TraceEvent("DDExclusionSafetyCheckTeamCollectionInvalid", self->ddId); + TraceEvent("DDExclusionSafetyCheckTeamCollectionInvalid", self->ddId).log(); reply.safe = false; req.reply.send(reply); return Void(); } // If there is only 1 team, unsafe to mark failed: team building can get stuck due to lack of servers left if (self->teamCollection->teams.size() <= 1) { - TraceEvent("DDExclusionSafetyCheckNotEnoughTeams", self->ddId); + TraceEvent("DDExclusionSafetyCheckNotEnoughTeams", self->ddId).log(); reply.safe = false; req.reply.send(reply); return Void(); @@ -6371,7 +6371,7 @@ ACTOR Future ddExclusionSafetyCheck(DistributorExclusionSafetyCheckRequest } } reply.safe = _exclusionSafetyCheck(excludeServerIDs, self->teamCollection); - TraceEvent("DDExclusionSafetyCheckFinish", self->ddId); + TraceEvent("DDExclusionSafetyCheckFinish", self->ddId).log(); req.reply.send(reply); return Void(); } diff --git a/fdbserver/GrvProxyServer.actor.cpp b/fdbserver/GrvProxyServer.actor.cpp index 3ebf2931e6..28650ced5a 100644 --- a/fdbserver/GrvProxyServer.actor.cpp +++ b/fdbserver/GrvProxyServer.actor.cpp @@ -300,7 +300,7 @@ ACTOR Future getRate(UID myID, TraceEvent("ProxyRatekeeperChanged", myID).detail("RKID", db->get().ratekeeper.get().id()); nextRequestTimer = Void(); // trigger GetRate request } else { - TraceEvent("ProxyRatekeeperDied", myID); + TraceEvent("ProxyRatekeeperDied", myID).log(); nextRequestTimer = Never(); reply = Never(); } diff --git a/fdbserver/KeyValueStoreMemory.actor.cpp b/fdbserver/KeyValueStoreMemory.actor.cpp index 0008296a96..ff00e29c84 100644 --- a/fdbserver/KeyValueStoreMemory.actor.cpp +++ b/fdbserver/KeyValueStoreMemory.actor.cpp @@ -141,7 +141,7 @@ public: Future commit(bool sequential) override { if (getAvailableSize() <= 0) { - TraceEvent(SevError, "KeyValueStoreMemory_OutOfSpace", id); + TraceEvent(SevError, "KeyValueStoreMemory_OutOfSpace", id).log(); return Never(); } @@ -605,7 +605,7 @@ private: if (zeroFillSize) { if (exactRecovery) { - TraceEvent(SevError, "KVSMemExpectedExact", self->id); + TraceEvent(SevError, "KVSMemExpectedExact", self->id).log(); ASSERT(false); } diff --git a/fdbserver/KeyValueStoreSQLite.actor.cpp b/fdbserver/KeyValueStoreSQLite.actor.cpp index 6e3043f3f3..e0920fc8f5 100644 --- a/fdbserver/KeyValueStoreSQLite.actor.cpp +++ b/fdbserver/KeyValueStoreSQLite.actor.cpp @@ -727,7 +727,7 @@ struct RawCursor { try { db.checkError("BtreeCloseCursor", sqlite3BtreeCloseCursor(cursor)); } catch (...) { - TraceEvent(SevError, "RawCursorDestructionError"); + TraceEvent(SevError, "RawCursorDestructionError").log(); } delete[](char*) cursor; } @@ -1737,9 +1737,9 @@ private: freeListPages(freeListPages), cursor(nullptr), dbgid(dbgid), readThreads(*pReadThreads), checkAllChecksumsOnOpen(checkAllChecksumsOnOpen), checkIntegrityOnOpen(checkIntegrityOnOpen) {} ~Writer() override { - TraceEvent("KVWriterDestroying", dbgid); + TraceEvent("KVWriterDestroying", dbgid).log(); delete cursor; - TraceEvent("KVWriterDestroyed", dbgid); + TraceEvent("KVWriterDestroyed", dbgid).log(); } void init() override { if (checkAllChecksumsOnOpen) { diff --git a/fdbserver/LeaderElection.actor.cpp b/fdbserver/LeaderElection.actor.cpp index 2f0fdaaf3b..29bba2a955 100644 --- a/fdbserver/LeaderElection.actor.cpp +++ b/fdbserver/LeaderElection.actor.cpp @@ -156,7 +156,7 @@ ACTOR Future tryBecomeLeaderInternal(ServerCoordinators coordinators, } if (leader.present() && leader.get().second && leader.get().first.equalInternalId(myInfo)) { - TraceEvent("BecomingLeader", myInfo.changeID); + TraceEvent("BecomingLeader", myInfo.changeID).log(); ASSERT(leader.get().first.serializedInfo == proposedSerializedInterface); outSerializedLeader->set(leader.get().first.serializedInfo); iAmLeader = true; @@ -184,7 +184,7 @@ ACTOR Future tryBecomeLeaderInternal(ServerCoordinators coordinators, when(wait(nominees->onChange())) {} when(wait(badCandidateTimeout.isValid() ? badCandidateTimeout : Never())) { TEST(true); // Bad candidate timeout - TraceEvent("LeaderBadCandidateTimeout", myInfo.changeID); + TraceEvent("LeaderBadCandidateTimeout", myInfo.changeID).log(); break; } when(wait(candidacies)) { ASSERT(false); } @@ -225,7 +225,7 @@ ACTOR Future tryBecomeLeaderInternal(ServerCoordinators coordinators, //TraceEvent("StillLeader", myInfo.changeID); } // We are still leader when(wait(quorum(false_heartbeats, false_heartbeats.size() / 2 + 1))) { - TraceEvent("ReplacedAsLeader", myInfo.changeID); + TraceEvent("ReplacedAsLeader", myInfo.changeID).log(); break; } // We are definitely not leader when(wait(delay(SERVER_KNOBS->POLLING_FREQUENCY))) { @@ -243,7 +243,7 @@ ACTOR Future tryBecomeLeaderInternal(ServerCoordinators coordinators, .detail("Coordinator", coordinators.leaderElectionServers[i].candidacy.getEndpoint().getPrimaryAddress()); } - TraceEvent("ReleasingLeadership", myInfo.changeID); + TraceEvent("ReleasingLeadership", myInfo.changeID).log(); break; } // Give up on being leader, because we apparently have poor communications when(wait(asyncPriorityInfo->onChange())) {} diff --git a/fdbserver/LogSystem.h b/fdbserver/LogSystem.h index 5aa14810de..1a936edf3e 100644 --- a/fdbserver/LogSystem.h +++ b/fdbserver/LogSystem.h @@ -291,7 +291,7 @@ public: if (allLocations) { // special handling for allLocations - TraceEvent("AllLocationsSet"); + TraceEvent("AllLocationsSet").log(); for (int i = 0; i < logServers.size(); i++) { newLocations.push_back(i); } diff --git a/fdbserver/MetricLogger.actor.cpp b/fdbserver/MetricLogger.actor.cpp index aee9ea67d6..e8c8a7ab8f 100644 --- a/fdbserver/MetricLogger.actor.cpp +++ b/fdbserver/MetricLogger.actor.cpp @@ -374,7 +374,7 @@ ACTOR Future updateMetricRegistration(Database cx, MetricsConfig* config, ACTOR Future runMetrics(Future fcx, Key prefix) { // Never log to an empty prefix, it's pretty much always a bad idea. if (prefix.size() == 0) { - TraceEvent(SevWarnAlways, "TDMetricsRefusingEmptyPrefix"); + TraceEvent(SevWarnAlways, "TDMetricsRefusingEmptyPrefix").log(); return Void(); } diff --git a/fdbserver/MoveKeys.actor.cpp b/fdbserver/MoveKeys.actor.cpp index 906bca4b16..55706e458f 100644 --- a/fdbserver/MoveKeys.actor.cpp +++ b/fdbserver/MoveKeys.actor.cpp @@ -100,7 +100,7 @@ ACTOR static Future checkMoveKeysLock(Transaction* tr, const DDEnabledState* ddEnabledState, bool isWrite = true) { if (!ddEnabledState->isDDEnabled()) { - TraceEvent(SevDebug, "DDDisabledByInMemoryCheck"); + TraceEvent(SevDebug, "DDDisabledByInMemoryCheck").log(); throw movekeys_conflict(); } Optional readVal = wait(tr->get(moveKeysLockOwnerKey)); @@ -1143,7 +1143,7 @@ ACTOR Future> addStorageServer(Database cx, StorageServe if (SERVER_KNOBS->TSS_HACK_IDENTITY_MAPPING) { // THIS SHOULD NEVER BE ENABLED IN ANY NON-TESTING ENVIRONMENT - TraceEvent(SevError, "TSSIdentityMappingEnabled"); + TraceEvent(SevError, "TSSIdentityMappingEnabled").log(); tssMapDB.set(tr, server.id(), server.id()); } } @@ -1268,7 +1268,7 @@ ACTOR Future removeStorageServer(Database cx, if (SERVER_KNOBS->TSS_HACK_IDENTITY_MAPPING) { // THIS SHOULD NEVER BE ENABLED IN ANY NON-TESTING ENVIRONMENT - TraceEvent(SevError, "TSSIdentityMappingEnabled"); + TraceEvent(SevError, "TSSIdentityMappingEnabled").log(); tssMapDB.erase(tr, serverID); } else if (tssPairID.present()) { // remove the TSS from the mapping @@ -1440,7 +1440,7 @@ void seedShardServers(Arena& arena, CommitTransactionRef& tr, vectorTSS_HACK_IDENTITY_MAPPING) { // THIS SHOULD NEVER BE ENABLED IN ANY NON-TESTING ENVIRONMENT - TraceEvent(SevError, "TSSIdentityMappingEnabled"); + TraceEvent(SevError, "TSSIdentityMappingEnabled").log(); // hack key-backed map here since we can't really change CommitTransactionRef to a RYW transaction Key uidRef = Codec::pack(s.id()).pack(); tr.set(arena, uidRef.withPrefix(tssMappingKeys.begin), uidRef); diff --git a/fdbserver/OldTLogServer_4_6.actor.cpp b/fdbserver/OldTLogServer_4_6.actor.cpp index ce291e644c..0a561dbf7f 100644 --- a/fdbserver/OldTLogServer_4_6.actor.cpp +++ b/fdbserver/OldTLogServer_4_6.actor.cpp @@ -1387,7 +1387,7 @@ ACTOR Future restorePersistentState(TLogData* self, LocalityData locality) state KeyRange tagKeys; // PERSIST: Read basic state from persistentData; replay persistentQueue but don't erase it - TraceEvent("TLogRestorePersistentState", self->dbgid); + TraceEvent("TLogRestorePersistentState", self->dbgid).log(); IKeyValueStore* storage = self->persistentData; state Future> fFormat = storage->readValue(persistFormat.key); @@ -1575,7 +1575,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, state TLogData self(tlogId, workerID, persistentData, persistentQueue, db); state Future error = actorCollection(self.sharedActors.getFuture()); - TraceEvent("SharedTlog", tlogId); + TraceEvent("SharedTlog", tlogId).log(); try { wait(restorePersistentState(&self, locality)); diff --git a/fdbserver/OldTLogServer_6_0.actor.cpp b/fdbserver/OldTLogServer_6_0.actor.cpp index 35cbc42535..998a65f463 100644 --- a/fdbserver/OldTLogServer_6_0.actor.cpp +++ b/fdbserver/OldTLogServer_6_0.actor.cpp @@ -876,7 +876,7 @@ ACTOR Future tLogPop(TLogData* self, TLogPopRequest req, ReferenceignorePopRequest && (g_network->now() > self->ignorePopDeadline)) { - TraceEvent("EnableTLogPlayAllIgnoredPops"); + TraceEvent("EnableTLogPlayAllIgnoredPops").log(); // use toBePopped and issue all the pops state std::map::iterator it; state vector> ignoredPops; @@ -1666,7 +1666,7 @@ ACTOR Future initPersistentState(TLogData* self, Reference logDat updatePersistentPopped(self, logData, logData->getTagData(tag)); } - TraceEvent("TLogInitCommit", logData->logId); + TraceEvent("TLogInitCommit", logData->logId).log(); wait(ioTimeoutError(self->persistentData->commit(), SERVER_KNOBS->TLOG_MAX_CREATE_DURATION)); return Void(); } @@ -1869,7 +1869,7 @@ ACTOR Future tLogEnablePopReq(TLogEnablePopRequest enablePopReq, TLogData* enablePopReq.reply.sendError(operation_failed()); return Void(); } - TraceEvent("EnableTLogPlayAllIgnoredPops2"); + TraceEvent("EnableTLogPlayAllIgnoredPops2").log(); // use toBePopped and issue all the pops std::map::iterator it; vector> ignoredPops; @@ -1923,7 +1923,7 @@ ACTOR Future serveTLogInterface(TLogData* self, } if (!logData->isPrimary && logData->stopped) { - TraceEvent("TLogAlreadyStopped", self->dbgid); + TraceEvent("TLogAlreadyStopped", self->dbgid).log(); logData->removed = logData->removed && logData->logSystem->get()->endEpoch(); } } else { @@ -2198,22 +2198,22 @@ ACTOR Future tLogCore(TLogData* self, } ACTOR Future checkEmptyQueue(TLogData* self) { - TraceEvent("TLogCheckEmptyQueueBegin", self->dbgid); + TraceEvent("TLogCheckEmptyQueueBegin", self->dbgid).log(); try { TLogQueueEntry r = wait(self->persistentQueue->readNext(self)); throw internal_error(); } catch (Error& e) { if (e.code() != error_code_end_of_stream) throw; - TraceEvent("TLogCheckEmptyQueueEnd", self->dbgid); + TraceEvent("TLogCheckEmptyQueueEnd", self->dbgid).log(); return Void(); } } ACTOR Future checkRecovered(TLogData* self) { - TraceEvent("TLogCheckRecoveredBegin", self->dbgid); + TraceEvent("TLogCheckRecoveredBegin", self->dbgid).log(); Optional v = wait(self->persistentData->readValue(StringRef())); - TraceEvent("TLogCheckRecoveredEnd", self->dbgid); + TraceEvent("TLogCheckRecoveredEnd", self->dbgid).log(); return Void(); } @@ -2227,7 +2227,7 @@ ACTOR Future restorePersistentState(TLogData* self, state KeyRange tagKeys; // PERSIST: Read basic state from persistentData; replay persistentQueue but don't erase it - TraceEvent("TLogRestorePersistentState", self->dbgid); + TraceEvent("TLogRestorePersistentState", self->dbgid).log(); state IKeyValueStore* storage = self->persistentData; wait(storage->init()); @@ -2585,7 +2585,7 @@ ACTOR Future tLogStart(TLogData* self, InitializeTLogRequest req, Locality logData->removed = rejoinMasters(self, recruited, req.epoch, Future(Void()), req.isPrimary); self->queueOrder.push_back(recruited.id()); - TraceEvent("TLogStart", logData->logId); + TraceEvent("TLogStart", logData->logId).log(); state Future updater; state bool pulledRecoveryVersions = false; try { @@ -2730,7 +2730,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, state TLogData self(tlogId, workerID, persistentData, persistentQueue, db, degraded, folder); state Future error = actorCollection(self.sharedActors.getFuture()); - TraceEvent("SharedTlog", tlogId); + TraceEvent("SharedTlog", tlogId).log(); try { if (restoreFromDisk) { wait(restorePersistentState(&self, locality, oldLog, recovered, tlogRequests)); diff --git a/fdbserver/OldTLogServer_6_2.actor.cpp b/fdbserver/OldTLogServer_6_2.actor.cpp index c581560faa..fd2522ec91 100644 --- a/fdbserver/OldTLogServer_6_2.actor.cpp +++ b/fdbserver/OldTLogServer_6_2.actor.cpp @@ -1464,7 +1464,7 @@ ACTOR Future tLogPop(TLogData* self, TLogPopRequest req, ReferenceignorePopRequest && (g_network->now() > self->ignorePopDeadline)) { - TraceEvent("EnableTLogPlayAllIgnoredPops"); + TraceEvent("EnableTLogPlayAllIgnoredPops").log(); // use toBePopped and issue all the pops std::map::iterator it; vector> ignoredPops; @@ -1871,7 +1871,7 @@ ACTOR Future watchDegraded(TLogData* self) { wait(lowPriorityDelay(SERVER_KNOBS->TLOG_DEGRADED_DURATION)); - TraceEvent(SevWarnAlways, "TLogDegraded", self->dbgid); + TraceEvent(SevWarnAlways, "TLogDegraded", self->dbgid).log(); TEST(true); // TLog degraded self->degraded->set(true); return Void(); @@ -2109,7 +2109,7 @@ ACTOR Future initPersistentState(TLogData* self, Reference logDat updatePersistentPopped(self, logData, logData->getTagData(tag)); } - TraceEvent("TLogInitCommit", logData->logId); + TraceEvent("TLogInitCommit", logData->logId).log(); wait(self->persistentData->commit()); return Void(); } @@ -2312,7 +2312,7 @@ ACTOR Future tLogEnablePopReq(TLogEnablePopRequest enablePopReq, TLogData* enablePopReq.reply.sendError(operation_failed()); return Void(); } - TraceEvent("EnableTLogPlayAllIgnoredPops2"); + TraceEvent("EnableTLogPlayAllIgnoredPops2").log(); // use toBePopped and issue all the pops std::map::iterator it; state vector> ignoredPops; @@ -2657,7 +2657,7 @@ ACTOR Future tLogCore(TLogData* self, } ACTOR Future checkEmptyQueue(TLogData* self) { - TraceEvent("TLogCheckEmptyQueueBegin", self->dbgid); + TraceEvent("TLogCheckEmptyQueueBegin", self->dbgid).log(); try { bool recoveryFinished = wait(self->persistentQueue->initializeRecovery(0)); if (recoveryFinished) @@ -2667,15 +2667,15 @@ ACTOR Future checkEmptyQueue(TLogData* self) { } catch (Error& e) { if (e.code() != error_code_end_of_stream) throw; - TraceEvent("TLogCheckEmptyQueueEnd", self->dbgid); + TraceEvent("TLogCheckEmptyQueueEnd", self->dbgid).log(); return Void(); } } ACTOR Future checkRecovered(TLogData* self) { - TraceEvent("TLogCheckRecoveredBegin", self->dbgid); + TraceEvent("TLogCheckRecoveredBegin", self->dbgid).log(); Optional v = wait(self->persistentData->readValue(StringRef())); - TraceEvent("TLogCheckRecoveredEnd", self->dbgid); + TraceEvent("TLogCheckRecoveredEnd", self->dbgid).log(); return Void(); } @@ -2690,7 +2690,7 @@ ACTOR Future restorePersistentState(TLogData* self, state KeyRange tagKeys; // PERSIST: Read basic state from persistentData; replay persistentQueue but don't erase it - TraceEvent("TLogRestorePersistentState", self->dbgid); + TraceEvent("TLogRestorePersistentState", self->dbgid).log(); state IKeyValueStore* storage = self->persistentData; wait(storage->init()); @@ -3219,7 +3219,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, state TLogData self(tlogId, workerID, persistentData, persistentQueue, db, degraded, folder); state Future error = actorCollection(self.sharedActors.getFuture()); - TraceEvent("SharedTlog", tlogId); + TraceEvent("SharedTlog", tlogId).log(); try { if (restoreFromDisk) { wait(restorePersistentState(&self, locality, oldLog, recovered, tlogRequests)); diff --git a/fdbserver/QuietDatabase.actor.cpp b/fdbserver/QuietDatabase.actor.cpp index 359db3245c..dc4f8769a6 100644 --- a/fdbserver/QuietDatabase.actor.cpp +++ b/fdbserver/QuietDatabase.actor.cpp @@ -576,7 +576,7 @@ ACTOR Future repairDeadDatacenter(Database cx, // FIXME: the primary and remote can both be considered dead because excludes are not handled properly by the // datacenterDead function if (primaryDead && remoteDead) { - TraceEvent(SevWarnAlways, "CannotDisableFearlessConfiguration"); + TraceEvent(SevWarnAlways, "CannotDisableFearlessConfiguration").log(); return Void(); } if (primaryDead || remoteDead) { @@ -647,7 +647,7 @@ ACTOR Future waitForQuietDatabase(Database cx, loop { try { - TraceEvent("QuietDatabaseWaitingOnDataDistributor"); + TraceEvent("QuietDatabaseWaitingOnDataDistributor").log(); WorkerInterface distributorWorker = wait(getDataDistributorWorker(cx, dbInfo)); UID distributorUID = dbInfo->get().distributor.get().id(); TraceEvent("QuietDatabaseGotDataDistributor", distributorUID) diff --git a/fdbserver/Ratekeeper.actor.cpp b/fdbserver/Ratekeeper.actor.cpp index a13f9583be..8a09e2f739 100644 --- a/fdbserver/Ratekeeper.actor.cpp +++ b/fdbserver/Ratekeeper.actor.cpp @@ -801,14 +801,14 @@ ACTOR Future monitorThrottlingChanges(RatekeeperData* self) { autoThrottlingEnabled.get().get() == LiteralStringRef("0")) { TEST(true); // Auto-throttling disabled if (self->autoThrottlingEnabled) { - TraceEvent("AutoTagThrottlingDisabled", self->id); + TraceEvent("AutoTagThrottlingDisabled", self->id).log(); } self->autoThrottlingEnabled = false; } else if (autoThrottlingEnabled.get().present() && autoThrottlingEnabled.get().get() == LiteralStringRef("1")) { TEST(true); // Auto-throttling enabled if (!self->autoThrottlingEnabled) { - TraceEvent("AutoTagThrottlingEnabled", self->id); + TraceEvent("AutoTagThrottlingEnabled", self->id).log(); } self->autoThrottlingEnabled = true; } else { @@ -870,7 +870,7 @@ ACTOR Future monitorThrottlingChanges(RatekeeperData* self) { committed = true; wait(watchFuture); - TraceEvent("RatekeeperThrottleSignaled", self->id); + TraceEvent("RatekeeperThrottleSignaled", self->id).log(); TEST(true); // Tag throttle changes detected break; } catch (Error& e) { diff --git a/fdbserver/RestoreApplier.actor.cpp b/fdbserver/RestoreApplier.actor.cpp index e1c638efd7..072aa53a5f 100644 --- a/fdbserver/RestoreApplier.actor.cpp +++ b/fdbserver/RestoreApplier.actor.cpp @@ -473,7 +473,7 @@ ACTOR static Future precomputeMutationsResult(Reference } } - TraceEvent("FastRestoreApplierGetAndComputeStagingKeysWaitOn", applierID); + TraceEvent("FastRestoreApplierGetAndComputeStagingKeysWaitOn", applierID).log(); wait(waitForAll(fGetAndComputeKeys)); // Sanity check all stagingKeys have been precomputed diff --git a/fdbserver/RestoreApplier.actor.h b/fdbserver/RestoreApplier.actor.h index 55a465fb14..bd87cf3799 100644 --- a/fdbserver/RestoreApplier.actor.h +++ b/fdbserver/RestoreApplier.actor.h @@ -317,7 +317,7 @@ struct ApplierBatchData : public ReferenceCounted { return false; } } - TraceEvent("FastRestoreApplierAllKeysPrecomputed"); + TraceEvent("FastRestoreApplierAllKeysPrecomputed").log(); return true; } diff --git a/fdbserver/RestoreController.actor.cpp b/fdbserver/RestoreController.actor.cpp index 4341fbf1cf..ad1bced5f5 100644 --- a/fdbserver/RestoreController.actor.cpp +++ b/fdbserver/RestoreController.actor.cpp @@ -714,7 +714,7 @@ ACTOR static Future> collectRestoreRequests(Database // restoreRequestTriggerKey should already been set loop { try { - TraceEvent("FastRestoreControllerPhaseCollectRestoreRequestsWait"); + TraceEvent("FastRestoreControllerPhaseCollectRestoreRequestsWait").log(); tr.setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr.setOption(FDBTransactionOptions::LOCK_AWARE); @@ -732,7 +732,7 @@ ACTOR static Future> collectRestoreRequests(Database } break; } else { - TraceEvent(SevError, "FastRestoreControllerPhaseCollectRestoreRequestsEmptyRequests"); + TraceEvent(SevError, "FastRestoreControllerPhaseCollectRestoreRequestsEmptyRequests").log(); wait(delay(5.0)); } } catch (Error& e) { @@ -1079,7 +1079,7 @@ ACTOR static Future notifyLoadersVersionBatchFinished(std::map notifyRestoreCompleted(Reference self, bool terminate = false) { std::vector> requests; - TraceEvent("FastRestoreControllerPhaseNotifyRestoreCompletedStart"); + TraceEvent("FastRestoreControllerPhaseNotifyRestoreCompletedStart").log(); for (auto& loader : self->loadersInterf) { requests.emplace_back(loader.first, RestoreFinishRequest(terminate)); } @@ -1099,7 +1099,7 @@ ACTOR static Future notifyRestoreCompleted(Reference signalRestoreCompleted(Reference waitOnRestoreRequests(Database cx, UID nodeID = UID()) state Optional numRequests; // wait for the restoreRequestTriggerKey to be set by the client/test workload - TraceEvent("FastRestoreWaitOnRestoreRequest", nodeID); + TraceEvent("FastRestoreWaitOnRestoreRequest", nodeID).log(); loop { try { tr.reset(); @@ -288,9 +288,9 @@ ACTOR static Future waitOnRestoreRequests(Database cx, UID nodeID = UID()) if (!numRequests.present()) { state Future watchForRestoreRequest = tr.watch(restoreRequestTriggerKey); wait(tr.commit()); - TraceEvent(SevInfo, "FastRestoreWaitOnRestoreRequestTriggerKey", nodeID); + TraceEvent(SevInfo, "FastRestoreWaitOnRestoreRequestTriggerKey", nodeID).log(); wait(watchForRestoreRequest); - TraceEvent(SevInfo, "FastRestoreDetectRestoreRequestTriggerKeyChanged", nodeID); + TraceEvent(SevInfo, "FastRestoreDetectRestoreRequestTriggerKeyChanged", nodeID).log(); } else { TraceEvent(SevInfo, "FastRestoreRestoreRequestTriggerKey", nodeID) .detail("TriggerKey", numRequests.get().toString()); diff --git a/fdbserver/SimulatedCluster.actor.cpp b/fdbserver/SimulatedCluster.actor.cpp index f9916cf1bd..828bcfb93d 100644 --- a/fdbserver/SimulatedCluster.actor.cpp +++ b/fdbserver/SimulatedCluster.actor.cpp @@ -408,7 +408,7 @@ ACTOR Future runDr(Reference connFile) { wait(delay(1.0)); } - TraceEvent("StoppingDrAgents"); + TraceEvent("StoppingDrAgents").log(); for (auto it : agentFutures) { it.cancel(); @@ -2205,7 +2205,7 @@ ACTOR void setupAndRun(std::string dataFolder, TraceEvent(SevError, "SetupAndRunError").error(e); } - TraceEvent("SimulatedSystemDestruct"); + TraceEvent("SimulatedSystemDestruct").log(); g_simulator.stop(); destructed = true; wait(Never()); diff --git a/fdbserver/StorageCache.actor.cpp b/fdbserver/StorageCache.actor.cpp index 8f44f054d6..1485e20633 100644 --- a/fdbserver/StorageCache.actor.cpp +++ b/fdbserver/StorageCache.actor.cpp @@ -425,7 +425,7 @@ ACTOR Future waitForVersion(StorageCacheData* data, Version version) { } if (deterministicRandom()->random01() < 0.001) - TraceEvent("WaitForVersion1000x"); + TraceEvent("WaitForVersion1000x").log(); choose { when(wait(data->version.whenAtLeast(version))) { // FIXME: A bunch of these can block with or without the following delay 0. @@ -1363,7 +1363,7 @@ ACTOR Future fetchKeys(StorageCacheData* data, AddingCacheRange* cacheRang // doesn't fit on this cache. For now, we can just fail this cache role. In future, we should think // about evicting some data to make room for the remaining keys if (this_block.more) { - TraceEvent(SevDebug, "CacheWarmupMoreDataThanLimit", data->thisServerID); + TraceEvent(SevDebug, "CacheWarmupMoreDataThanLimit", data->thisServerID).log(); throw please_reboot(); } @@ -1780,7 +1780,7 @@ private: rollback(data, rollbackVersion, currentVersion); } } else { - TraceEvent(SevWarn, "SCPrivateCacheMutation: Unknown private mutation"); + TraceEvent(SevWarn, "SCPrivateCacheMutation: Unknown private mutation").log(); // ASSERT(false); // Unknown private mutation } } diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index ff5b72ccdc..d8e27a78ba 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -2160,7 +2160,7 @@ ACTOR Future initPersistentState(TLogData* self, Reference logDat updatePersistentPopped(self, logData, logData->getTagData(tag)); } - TraceEvent("TLogInitCommit", logData->logId); + TraceEvent("TLogInitCommit", logData->logId).log(); wait(ioTimeoutError(self->persistentData->commit(), SERVER_KNOBS->TLOG_MAX_CREATE_DURATION)); return Void(); } @@ -2713,7 +2713,7 @@ ACTOR Future tLogCore(TLogData* self, } ACTOR Future checkEmptyQueue(TLogData* self) { - TraceEvent("TLogCheckEmptyQueueBegin", self->dbgid); + TraceEvent("TLogCheckEmptyQueueBegin", self->dbgid).log(); try { bool recoveryFinished = wait(self->persistentQueue->initializeRecovery(0)); if (recoveryFinished) @@ -2723,15 +2723,15 @@ ACTOR Future checkEmptyQueue(TLogData* self) { } catch (Error& e) { if (e.code() != error_code_end_of_stream) throw; - TraceEvent("TLogCheckEmptyQueueEnd", self->dbgid); + TraceEvent("TLogCheckEmptyQueueEnd", self->dbgid).log(); return Void(); } } ACTOR Future checkRecovered(TLogData* self) { - TraceEvent("TLogCheckRecoveredBegin", self->dbgid); + TraceEvent("TLogCheckRecoveredBegin", self->dbgid).log(); Optional v = wait(self->persistentData->readValue(StringRef())); - TraceEvent("TLogCheckRecoveredEnd", self->dbgid); + TraceEvent("TLogCheckRecoveredEnd", self->dbgid).log(); return Void(); } @@ -2746,7 +2746,7 @@ ACTOR Future restorePersistentState(TLogData* self, state KeyRange tagKeys; // PERSIST: Read basic state from persistentData; replay persistentQueue but don't erase it - TraceEvent("TLogRestorePersistentState", self->dbgid); + TraceEvent("TLogRestorePersistentState", self->dbgid).log(); state IKeyValueStore* storage = self->persistentData; wait(storage->init()); @@ -3294,7 +3294,7 @@ ACTOR Future tLog(IKeyValueStore* persistentData, state TLogData self(tlogId, workerID, persistentData, persistentQueue, db, degraded, folder); state Future error = actorCollection(self.sharedActors.getFuture()); - TraceEvent("SharedTlog", tlogId); + TraceEvent("SharedTlog", tlogId).log(); try { if (restoreFromDisk) { wait(restorePersistentState(&self, locality, oldLog, recovered, tlogRequests)); diff --git a/fdbserver/TagPartitionedLogSystem.actor.cpp b/fdbserver/TagPartitionedLogSystem.actor.cpp index 2ab2b18062..d7fffa0ff6 100644 --- a/fdbserver/TagPartitionedLogSystem.actor.cpp +++ b/fdbserver/TagPartitionedLogSystem.actor.cpp @@ -415,7 +415,7 @@ struct TagPartitionedLogSystem : ILogSystem, ReferenceCounted( Reference>>(), txsTag, begin, end, false, false); } @@ -1534,7 +1534,7 @@ struct TagPartitionedLogSystem : ILogSystem, ReferenceCounted allTags) { - TraceEvent("RemoteLogRecruitment_WaitingForWorkers"); + TraceEvent("RemoteLogRecruitment_WaitingForWorkers").log(); state RecruitRemoteFromConfigurationReply remoteWorkers = wait(fRemoteWorkers); state Reference logSet(new LogSet()); @@ -2655,7 +2655,7 @@ struct TagPartitionedLogSystem : ILogSystem, ReferenceCountedremoteRecoveryComplete = waitForAll(recoveryComplete); self->tLogs.push_back(logSet); - TraceEvent("RemoteLogRecruitment_CompletingRecovery"); + TraceEvent("RemoteLogRecruitment_CompletingRecovery").log(); return Void(); } @@ -3149,7 +3149,7 @@ struct TagPartitionedLogSystem : ILogSystem, ReferenceCounted { reportLiveCommittedVersionRequests("ReportLiveCommittedVersionRequests", cc) { logger = traceCounters("MasterMetrics", dbgid, SERVER_KNOBS->WORKER_LOGGING_INTERVAL, &cc, "MasterMetrics"); if (forceRecovery && !myInterface.locality.dcId().present()) { - TraceEvent(SevError, "ForcedRecoveryRequiresDcID"); + TraceEvent(SevError, "ForcedRecoveryRequiresDcID").log(); forceRecovery = false; } } @@ -904,7 +904,7 @@ ACTOR Future readTransactionSystemState(Reference self, // make KeyValueStoreMemory guarantee immediate reads, we should be able to get rid of // the discardCommit() below and not need a writable log adapter - TraceEvent("RTSSComplete", self->dbgid); + TraceEvent("RTSSComplete", self->dbgid).log(); return Void(); } @@ -1087,7 +1087,7 @@ ACTOR Future recoverFrom(Reference self, when(Standalone _req = wait(provisional)) { state Standalone req = _req; // mutable TEST(true); // Emergency transaction processing during recovery - TraceEvent("EmergencyTransaction", self->dbgid); + TraceEvent("EmergencyTransaction", self->dbgid).log(); for (auto m = req.mutations.begin(); m != req.mutations.end(); ++m) TraceEvent("EmergencyTransactionMutation", self->dbgid) .detail("MType", m->type) @@ -1102,7 +1102,7 @@ ACTOR Future recoverFrom(Reference self, initialConfChanges->clear(); if (self->originalConfiguration.isValid() && self->configuration.usableRegions != self->originalConfiguration.usableRegions) { - TraceEvent(SevWarnAlways, "CannotChangeUsableRegions", self->dbgid); + TraceEvent(SevWarnAlways, "CannotChangeUsableRegions", self->dbgid).log(); self->configuration = self->originalConfiguration; } else { initialConfChanges->push_back(req); @@ -1500,7 +1500,7 @@ ACTOR Future trackTlogRecovery(Reference self, if (newState.oldTLogData.size() && configuration.repopulateRegionAntiQuorum > 0 && self->logSystem->remoteStorageRecovered()) { - TraceEvent(SevWarnAlways, "RecruitmentStalled_RemoteStorageRecovered", self->dbgid); + TraceEvent(SevWarnAlways, "RecruitmentStalled_RemoteStorageRecovered", self->dbgid).log(); self->recruitmentStalled->set(true); } self->registrationTrigger.trigger(); @@ -1570,7 +1570,7 @@ ACTOR static Future> getMinBackupVersion(Reference minVersion = minVersion.present() ? std::min(version, minVersion.get()) : version; } } else { - TraceEvent("EmptyBackupStartKey", self->dbgid); + TraceEvent("EmptyBackupStartKey", self->dbgid).log(); } return minVersion; @@ -1663,7 +1663,7 @@ ACTOR static Future recruitBackupWorkers(Reference self, Datab std::vector newRecruits = wait(getAll(initializationReplies)); self->logSystem->setBackupWorkers(newRecruits); - TraceEvent("BackupRecruitmentDone", self->dbgid); + TraceEvent("BackupRecruitmentDone", self->dbgid).log(); self->registrationTrigger.trigger(); return Void(); } @@ -1723,7 +1723,7 @@ ACTOR Future masterCore(Reference self) { if (g_network->isSimulated() && self->cstate.myDBState.oldTLogData.size() > CLIENT_KNOBS->MAX_GENERATIONS_SIM) { g_simulator.connectionFailuresDisableDuration = 1e6; g_simulator.speedUpSimulation = true; - TraceEvent(SevWarnAlways, "DisableConnectionFailures_TooManyGenerations"); + TraceEvent(SevWarnAlways, "DisableConnectionFailures_TooManyGenerations").log(); } } @@ -1812,7 +1812,7 @@ ACTOR Future masterCore(Reference self) { tr.set(recoveryCommitRequest.arena, snapshotEndVersionKey, (bw << self->lastEpochEnd).toValue()); // Pause the backups that got restored in this snapshot to avoid data corruption // Requires further operational work to abort the backup - TraceEvent("MasterRecoveryPauseBackupAgents"); + TraceEvent("MasterRecoveryPauseBackupAgents").log(); Key backupPauseKey = FileBackupAgent::getPauseKey(); tr.set(recoveryCommitRequest.arena, backupPauseKey, StringRef()); // Clear the key so multiple recoveries will not overwrite the first version recorded @@ -1882,7 +1882,7 @@ ACTOR Future masterCore(Reference self) { tr.read_snapshot = self->recoveryTransactionVersion; // lastEpochEnd would make more sense, but isn't in the initial // window of the resolver(s) - TraceEvent("MasterRecoveryCommit", self->dbgid); + TraceEvent("MasterRecoveryCommit", self->dbgid).log(); state Future> recoveryCommit = self->commitProxies[0].commit.tryGetReply(recoveryCommitRequest); self->addActor.send(self->logSystem->onError()); self->addActor.send(waitResolverFailure(self->resolvers)); @@ -1930,7 +1930,7 @@ ACTOR Future masterCore(Reference self) { debug_advanceMinCommittedVersion(UID(), self->recoveryTransactionVersion); if (debugResult) { - TraceEvent(self->forceRecovery ? SevWarn : SevError, "DBRecoveryDurabilityError"); + TraceEvent(self->forceRecovery ? SevWarn : SevError, "DBRecoveryDurabilityError").log(); } TraceEvent("MasterCommittedTLogs", self->dbgid) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index ffd0ee4f40..ae9a37c540 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -1189,7 +1189,7 @@ Future waitForVersion(StorageServer* data, Version version, SpanID span } if (deterministicRandom()->random01() < 0.001) { - TraceEvent("WaitForVersion1000x"); + TraceEvent("WaitForVersion1000x").log(); } return waitForVersionActor(data, version, spanContext); } @@ -3542,10 +3542,10 @@ private: ASSERT(ssId == data->thisServerID); if (m.type == MutationRef::SetValue) { TEST(true); // Putting TSS in quarantine - TraceEvent(SevWarn, "TSSQuarantineStart", data->thisServerID); + TraceEvent(SevWarn, "TSSQuarantineStart", data->thisServerID).log(); data->startTssQuarantine(); } else { - TraceEvent(SevWarn, "TSSQuarantineStop", data->thisServerID); + TraceEvent(SevWarn, "TSSQuarantineStop", data->thisServerID).log(); // dipose of this TSS throw worker_removed(); } @@ -3620,7 +3620,7 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { !g_simulator.speedUpSimulation && data->tssFaultInjectTime.present() && data->tssFaultInjectTime.get() < now()) { if (deterministicRandom()->random01() < 0.01) { - TraceEvent(SevWarnAlways, "TSSInjectDelayForever", data->thisServerID); + TraceEvent(SevWarnAlways, "TSSInjectDelayForever", data->thisServerID).log(); // small random chance to just completely get stuck here, each tss should eventually hit this in this // mode wait(tssDelayForever()); @@ -3835,7 +3835,7 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { } else if (ver != invalidVersion) { // This change belongs to a version < minVersion DEBUG_MUTATION("SSPeek", ver, msg).detail("ServerID", data->thisServerID); if (ver == 1) { - TraceEvent("SSPeekMutation", data->thisServerID); + TraceEvent("SSPeekMutation", data->thisServerID).log(); // The following trace event may produce a value with special characters //TraceEvent("SSPeekMutation", data->thisServerID).detail("Mutation", msg.toString()).detail("Version", cloneCursor2->version().toString()); } @@ -4333,15 +4333,15 @@ ACTOR Future restoreDurableState(StorageServer* data, IKeyValueStore* stor data->byteSampleRecovery = restoreByteSample(data, storage, byteSampleSampleRecovered, startByteSampleRestore.getFuture()); - TraceEvent("ReadingDurableState", data->thisServerID); + TraceEvent("ReadingDurableState", data->thisServerID).log(); wait(waitForAll(std::vector{ fFormat, fID, ftssPairID, fTssQuarantine, fVersion, fLogProtocol, fPrimaryLocality })); wait(waitForAll(std::vector{ fShardAssigned, fShardAvailable })); wait(byteSampleSampleRecovered.getFuture()); - TraceEvent("RestoringDurableState", data->thisServerID); + TraceEvent("RestoringDurableState", data->thisServerID).log(); if (!fFormat.get().present()) { // The DB was never initialized - TraceEvent("DBNeverInitialized", data->thisServerID); + TraceEvent("DBNeverInitialized", data->thisServerID).log(); storage->dispose(); data->thisServerID = UID(); data->sk = Key(); @@ -5262,7 +5262,7 @@ ACTOR Future replaceInterface(StorageServer* self, StorageServerInterface } if (self->history.size() && BUGGIFY) { - TraceEvent("SSHistoryReboot", self->thisServerID); + TraceEvent("SSHistoryReboot", self->thisServerID).log(); throw please_reboot(); } @@ -5337,7 +5337,7 @@ ACTOR Future storageServer(IKeyValueStore* persistentData, try { state double start = now(); - TraceEvent("StorageServerRebootStart", self.thisServerID); + TraceEvent("StorageServerRebootStart", self.thisServerID).log(); wait(self.storage.init()); choose { @@ -5346,7 +5346,7 @@ ACTOR Future storageServer(IKeyValueStore* persistentData, when(wait(self.storage.commit())) {} when(wait(memoryStoreRecover(persistentData, connFile, self.thisServerID))) { - TraceEvent("DisposeStorageServer", self.thisServerID); + TraceEvent("DisposeStorageServer", self.thisServerID).log(); throw worker_removed(); } } diff --git a/fdbserver/tester.actor.cpp b/fdbserver/tester.actor.cpp index 44826b4590..e819267bb1 100644 --- a/fdbserver/tester.actor.cpp +++ b/fdbserver/tester.actor.cpp @@ -817,7 +817,7 @@ ACTOR Future runWorkload(Database cx, std::vector>> checks; - TraceEvent("CheckingResults"); + TraceEvent("CheckingResults").log(); printf("checking test (%s)...\n", printable(spec.title).c_str()); @@ -1016,7 +1016,7 @@ ACTOR Future runTest(Database cx, if (spec.useDB && spec.clearAfterTest) { try { - TraceEvent("TesterClearingDatabase"); + TraceEvent("TesterClearingDatabase").log(); wait(timeoutError(clearData(cx), 1000.0)); } catch (Error& e) { TraceEvent(SevError, "ErrorClearingDatabaseAfterTest").error(e); @@ -1559,7 +1559,7 @@ ACTOR Future runTests(ReferenceonChange())) {} when(wait(testerTimeout)) { - TraceEvent(SevError, "TesterRecruitmentTimeout"); + TraceEvent(SevError, "TesterRecruitmentTimeout").log(); throw timed_out(); } } diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index 28b2398bc1..70dbd39c7c 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -848,7 +848,7 @@ bool checkHighMemory(int64_t threshold, bool* error) { uint64_t page_size = sysconf(_SC_PAGESIZE); int fd = open("/proc/self/statm", O_RDONLY | O_CLOEXEC); if (fd < 0) { - TraceEvent("OpenStatmFileFailure"); + TraceEvent("OpenStatmFileFailure").log(); *error = true; return false; } @@ -857,7 +857,7 @@ bool checkHighMemory(int64_t threshold, bool* error) { char stat_buf[buf_sz]; ssize_t stat_nread = read(fd, stat_buf, buf_sz); if (stat_nread < 0) { - TraceEvent("ReadStatmFileFailure"); + TraceEvent("ReadStatmFileFailure").log(); *error = true; return false; } @@ -869,7 +869,7 @@ bool checkHighMemory(int64_t threshold, bool* error) { return true; } #else - TraceEvent("CheckHighMemoryUnsupported"); + TraceEvent("CheckHighMemoryUnsupported").log(); *error = true; #endif return false; @@ -926,7 +926,7 @@ ACTOR Future storageServerRollbackRebooter(std::set storageCacheRollbackRebooter(Future prevStorageCache, loop { ErrorOr e = wait(errorOr(prevStorageCache)); if (!e.isError()) { - TraceEvent("StorageCacheRequestedReboot1", id); + TraceEvent("StorageCacheRequestedReboot1", id).log(); return Void(); } else if (e.getError().code() != error_code_please_reboot && e.getError().code() != error_code_worker_removed) { @@ -972,7 +972,7 @@ ACTOR Future storageCacheRollbackRebooter(Future prevStorageCache, throw e.getError(); } - TraceEvent("StorageCacheRequestedReboot", id); + TraceEvent("StorageCacheRequestedReboot", id).log(); StorageServerInterface recruited; recruited.uniqueID = deterministicRandom()->randomUniqueID(); // id; @@ -1504,7 +1504,7 @@ ACTOR Future workerServer(Reference connFile, } throw please_reboot(); } else { - TraceEvent("ProcessReboot"); + TraceEvent("ProcessReboot").log(); ASSERT(!rebootReq.deleteData); flushAndExit(0); } @@ -2017,7 +2017,7 @@ ACTOR Future printOnFirstConnected(Referenceget().get().openDatabase.getEndpoint(), FailureStatus(false)) : Never())) { printf("FDBD joined cluster.\n"); - TraceEvent("FDBDConnected"); + TraceEvent("FDBDConnected").log(); return Void(); } when(wait(ci->onChange())) {} diff --git a/fdbserver/workloads/AtomicOpsApiCorrectness.actor.cpp b/fdbserver/workloads/AtomicOpsApiCorrectness.actor.cpp index 38c86a24a0..846c598798 100644 --- a/fdbserver/workloads/AtomicOpsApiCorrectness.actor.cpp +++ b/fdbserver/workloads/AtomicOpsApiCorrectness.actor.cpp @@ -480,7 +480,7 @@ public: TraceEvent("AtomicOpCorrectnessApiWorkload").detail("OpType", "MIN"); // API Version 500 setApiVersion(&cx, 500); - TraceEvent(SevInfo, "Running Atomic Op Min Correctness Test Api Version 500"); + TraceEvent(SevInfo, "Running Atomic Op Min Correctness Test Api Version 500").log(); wait(self->testAtomicOpUnsetOnNonExistingKey(cx, self, MutationRef::Min, key)); wait(self->testAtomicOpApi( cx, self, MutationRef::Min, key, [](uint64_t val1, uint64_t val2) { return val1 < val2 ? val1 : val2; })); @@ -513,7 +513,7 @@ public: ACTOR Future testMax(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_max_"); - TraceEvent(SevInfo, "Running Atomic Op MAX Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op MAX Correctness Current Api Version").log(); wait(self->testAtomicOpSetOnNonExistingKey(cx, self, MutationRef::Max, key)); wait(self->testAtomicOpApi( cx, self, MutationRef::Max, key, [](uint64_t val1, uint64_t val2) { return val1 > val2 ? val1 : val2; })); @@ -530,7 +530,7 @@ public: TraceEvent("AtomicOpCorrectnessApiWorkload").detail("OpType", "AND"); // API Version 500 setApiVersion(&cx, 500); - TraceEvent(SevInfo, "Running Atomic Op AND Correctness Test Api Version 500"); + TraceEvent(SevInfo, "Running Atomic Op AND Correctness Test Api Version 500").log(); wait(self->testAtomicOpUnsetOnNonExistingKey(cx, self, MutationRef::And, key)); wait(self->testAtomicOpApi( cx, self, MutationRef::And, key, [](uint64_t val1, uint64_t val2) { return val1 & val2; })); @@ -563,7 +563,7 @@ public: ACTOR Future testOr(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_or_"); - TraceEvent(SevInfo, "Running Atomic Op OR Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op OR Correctness Current Api Version").log(); wait(self->testAtomicOpSetOnNonExistingKey(cx, self, MutationRef::Or, key)); wait(self->testAtomicOpApi( cx, self, MutationRef::Or, key, [](uint64_t val1, uint64_t val2) { return val1 | val2; })); @@ -576,7 +576,7 @@ public: ACTOR Future testXor(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_xor_"); - TraceEvent(SevInfo, "Running Atomic Op XOR Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op XOR Correctness Current Api Version").log(); wait(self->testAtomicOpSetOnNonExistingKey(cx, self, MutationRef::Xor, key)); wait(self->testAtomicOpApi( cx, self, MutationRef::Xor, key, [](uint64_t val1, uint64_t val2) { return val1 ^ val2; })); @@ -588,7 +588,7 @@ public: ACTOR Future testAdd(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_add_"); - TraceEvent(SevInfo, "Running Atomic Op ADD Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op ADD Correctness Current Api Version").log(); wait(self->testAtomicOpSetOnNonExistingKey(cx, self, MutationRef::AddValue, key)); wait(self->testAtomicOpApi( cx, self, MutationRef::AddValue, key, [](uint64_t val1, uint64_t val2) { return val1 + val2; })); @@ -601,7 +601,7 @@ public: ACTOR Future testCompareAndClear(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_compare_and_clear_"); - TraceEvent(SevInfo, "Running Atomic Op COMPARE_AND_CLEAR Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op COMPARE_AND_CLEAR Correctness Current Api Version").log(); wait(self->testCompareAndClearAtomicOpApi(cx, self, key, true)); wait(self->testCompareAndClearAtomicOpApi(cx, self, key, false)); return Void(); @@ -610,7 +610,7 @@ public: ACTOR Future testByteMin(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_byte_min_"); - TraceEvent(SevInfo, "Running Atomic Op BYTE_MIN Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op BYTE_MIN Correctness Current Api Version").log(); wait(self->testAtomicOpSetOnNonExistingKey(cx, self, MutationRef::ByteMin, key)); wait(self->testAtomicOpApi(cx, self, MutationRef::ByteMin, key, [](uint64_t val1, uint64_t val2) { return StringRef((const uint8_t*)&val1, sizeof(val1)) < StringRef((const uint8_t*)&val2, sizeof(val2)) @@ -626,7 +626,7 @@ public: ACTOR Future testByteMax(Database cx, AtomicOpsApiCorrectnessWorkload* self) { state Key key = self->getTestKey("test_key_byte_max_"); - TraceEvent(SevInfo, "Running Atomic Op BYTE_MAX Correctness Current Api Version"); + TraceEvent(SevInfo, "Running Atomic Op BYTE_MAX Correctness Current Api Version").log(); wait(self->testAtomicOpSetOnNonExistingKey(cx, self, MutationRef::ByteMax, key)); wait(self->testAtomicOpApi(cx, self, MutationRef::ByteMax, key, [](uint64_t val1, uint64_t val2) { return StringRef((const uint8_t*)&val1, sizeof(val1)) > StringRef((const uint8_t*)&val2, sizeof(val2)) diff --git a/fdbserver/workloads/AtomicRestore.actor.cpp b/fdbserver/workloads/AtomicRestore.actor.cpp index 66e35105ab..6035a042f8 100644 --- a/fdbserver/workloads/AtomicRestore.actor.cpp +++ b/fdbserver/workloads/AtomicRestore.actor.cpp @@ -104,14 +104,14 @@ struct AtomicRestoreWorkload : TestWorkload { throw; } - TraceEvent("AtomicRestore_Wait"); + TraceEvent("AtomicRestore_Wait").log(); wait(success(backupAgent.waitBackup(cx, BackupAgentBase::getDefaultTagName(), StopWhenDone::False))); - TraceEvent("AtomicRestore_BackupStart"); + TraceEvent("AtomicRestore_BackupStart").log(); wait(delay(self->restoreAfter * deterministicRandom()->random01())); - TraceEvent("AtomicRestore_RestoreStart"); + TraceEvent("AtomicRestore_RestoreStart").log(); if (self->fastRestore) { // New fast parallel restore - TraceEvent(SevInfo, "AtomicParallelRestore"); + TraceEvent(SevInfo, "AtomicParallelRestore").log(); wait(backupAgent.atomicParallelRestore( cx, BackupAgentBase::getDefaultTag(), self->backupRanges, self->addPrefix, self->removePrefix)); } else { // Old style restore @@ -141,7 +141,7 @@ struct AtomicRestoreWorkload : TestWorkload { g_simulator.backupAgents = ISimulator::BackupAgentType::NoBackupAgents; } - TraceEvent("AtomicRestore_Done"); + TraceEvent("AtomicRestore_Done").log(); return Void(); } }; diff --git a/fdbserver/workloads/AtomicSwitchover.actor.cpp b/fdbserver/workloads/AtomicSwitchover.actor.cpp index 3bb93fb8bf..c20570346b 100644 --- a/fdbserver/workloads/AtomicSwitchover.actor.cpp +++ b/fdbserver/workloads/AtomicSwitchover.actor.cpp @@ -53,7 +53,7 @@ struct AtomicSwitchoverWorkload : TestWorkload { ACTOR static Future _setup(Database cx, AtomicSwitchoverWorkload* self) { state DatabaseBackupAgent backupAgent(cx); try { - TraceEvent("AS_Submit1"); + TraceEvent("AS_Submit1").log(); wait(backupAgent.submitBackup(self->extraDB, BackupAgentBase::getDefaultTag(), self->backupRanges, @@ -61,7 +61,7 @@ struct AtomicSwitchoverWorkload : TestWorkload { StringRef(), StringRef(), LockDB::True)); - TraceEvent("AS_Submit2"); + TraceEvent("AS_Submit2").log(); } catch (Error& e) { if (e.code() != error_code_backup_duplicate) throw; @@ -167,27 +167,27 @@ struct AtomicSwitchoverWorkload : TestWorkload { state DatabaseBackupAgent backupAgent(cx); state DatabaseBackupAgent restoreTool(self->extraDB); - TraceEvent("AS_Wait1"); + TraceEvent("AS_Wait1").log(); wait(success(backupAgent.waitBackup(self->extraDB, BackupAgentBase::getDefaultTag(), StopWhenDone::False))); - TraceEvent("AS_Ready1"); + TraceEvent("AS_Ready1").log(); wait(delay(deterministicRandom()->random01() * self->switch1delay)); - TraceEvent("AS_Switch1"); + TraceEvent("AS_Switch1").log(); wait(backupAgent.atomicSwitchover( self->extraDB, BackupAgentBase::getDefaultTag(), self->backupRanges, StringRef(), StringRef())); - TraceEvent("AS_Wait2"); + TraceEvent("AS_Wait2").log(); wait(success(restoreTool.waitBackup(cx, BackupAgentBase::getDefaultTag(), StopWhenDone::False))); - TraceEvent("AS_Ready2"); + TraceEvent("AS_Ready2").log(); wait(delay(deterministicRandom()->random01() * self->switch2delay)); - TraceEvent("AS_Switch2"); + TraceEvent("AS_Switch2").log(); wait(restoreTool.atomicSwitchover( cx, BackupAgentBase::getDefaultTag(), self->backupRanges, StringRef(), StringRef())); - TraceEvent("AS_Wait3"); + TraceEvent("AS_Wait3").log(); wait(success(backupAgent.waitBackup(self->extraDB, BackupAgentBase::getDefaultTag(), StopWhenDone::False))); - TraceEvent("AS_Ready3"); + TraceEvent("AS_Ready3").log(); wait(delay(deterministicRandom()->random01() * self->stopDelay)); - TraceEvent("AS_Abort"); + TraceEvent("AS_Abort").log(); wait(backupAgent.abortBackup(self->extraDB, BackupAgentBase::getDefaultTag())); - TraceEvent("AS_Done"); + TraceEvent("AS_Done").log(); // SOMEDAY: Remove after backup agents can exist quiescently if (g_simulator.drAgents == ISimulator::BackupAgentType::BackupToDB) { diff --git a/fdbserver/workloads/BackupAndParallelRestoreCorrectness.actor.cpp b/fdbserver/workloads/BackupAndParallelRestoreCorrectness.actor.cpp index b465e49939..a9113cbff0 100644 --- a/fdbserver/workloads/BackupAndParallelRestoreCorrectness.actor.cpp +++ b/fdbserver/workloads/BackupAndParallelRestoreCorrectness.actor.cpp @@ -384,7 +384,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload { Key(), Key(), self->locked))); - TraceEvent(SevError, "BARW_RestoreAllowedOverwrittingDatabase", randomID); + TraceEvent(SevError, "BARW_RestoreAllowedOverwrittingDatabase", randomID).log(); ASSERT(false); } catch (Error& e) { if (e.code() != error_code_restore_destination_not_empty) { diff --git a/fdbserver/workloads/BackupCorrectness.actor.cpp b/fdbserver/workloads/BackupCorrectness.actor.cpp index d655342661..d28bd59ae2 100644 --- a/fdbserver/workloads/BackupCorrectness.actor.cpp +++ b/fdbserver/workloads/BackupCorrectness.actor.cpp @@ -430,7 +430,7 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload { Key(), Key(), self->locked))); - TraceEvent(SevError, "BARW_RestoreAllowedOverwrittingDatabase", randomID); + TraceEvent(SevError, "BARW_RestoreAllowedOverwrittingDatabase", randomID).log(); ASSERT(false); } catch (Error& e) { if (e.code() != error_code_restore_destination_not_empty) { diff --git a/fdbserver/workloads/BackupToDBAbort.actor.cpp b/fdbserver/workloads/BackupToDBAbort.actor.cpp index d2d5c3d02d..ab084ea121 100644 --- a/fdbserver/workloads/BackupToDBAbort.actor.cpp +++ b/fdbserver/workloads/BackupToDBAbort.actor.cpp @@ -52,7 +52,7 @@ struct BackupToDBAbort : TestWorkload { ACTOR static Future _setup(BackupToDBAbort* self, Database cx) { state DatabaseBackupAgent backupAgent(cx); try { - TraceEvent("BDBA_Submit1"); + TraceEvent("BDBA_Submit1").log(); wait(backupAgent.submitBackup(self->extraDB, BackupAgentBase::getDefaultTag(), self->backupRanges, @@ -60,7 +60,7 @@ struct BackupToDBAbort : TestWorkload { StringRef(), StringRef(), LockDB::True)); - TraceEvent("BDBA_Submit2"); + TraceEvent("BDBA_Submit2").log(); } catch (Error& e) { if (e.code() != error_code_backup_duplicate) throw; @@ -79,15 +79,15 @@ struct BackupToDBAbort : TestWorkload { TraceEvent("BDBA_Start").detail("Delay", self->abortDelay); wait(delay(self->abortDelay)); - TraceEvent("BDBA_Wait"); + TraceEvent("BDBA_Wait").log(); wait(success(backupAgent.waitBackup(self->extraDB, BackupAgentBase::getDefaultTag(), StopWhenDone::False))); - TraceEvent("BDBA_Lock"); + TraceEvent("BDBA_Lock").log(); wait(lockDatabase(cx, self->lockid)); - TraceEvent("BDBA_Abort"); + TraceEvent("BDBA_Abort").log(); wait(backupAgent.abortBackup(self->extraDB, BackupAgentBase::getDefaultTag())); - TraceEvent("BDBA_Unlock"); + TraceEvent("BDBA_Unlock").log(); wait(backupAgent.unlockBackup(self->extraDB, BackupAgentBase::getDefaultTag())); - TraceEvent("BDBA_End"); + TraceEvent("BDBA_End").log(); // SOMEDAY: Remove after backup agents can exist quiescently if (g_simulator.drAgents == ISimulator::BackupAgentType::BackupToDB) { @@ -98,7 +98,7 @@ struct BackupToDBAbort : TestWorkload { } ACTOR static Future _check(BackupToDBAbort* self, Database cx) { - TraceEvent("BDBA_UnlockPrimary"); + TraceEvent("BDBA_UnlockPrimary").log(); // Too much of the tester framework expects the primary database to be unlocked, so we unlock it // once all of the workloads have finished. wait(unlockDatabase(cx, self->lockid)); diff --git a/fdbserver/workloads/BackupToDBUpgrade.actor.cpp b/fdbserver/workloads/BackupToDBUpgrade.actor.cpp index e0553058ed..5a2a34e9e7 100644 --- a/fdbserver/workloads/BackupToDBUpgrade.actor.cpp +++ b/fdbserver/workloads/BackupToDBUpgrade.actor.cpp @@ -78,7 +78,7 @@ struct BackupToDBUpgradeWorkload : TestWorkload { auto extraFile = makeReference(*g_simulator.extraDB); extraDB = Database::createDatabase(extraFile, -1); - TraceEvent("DRU_Start"); + TraceEvent("DRU_Start").log(); } std::string description() const override { return "BackupToDBUpgrade"; } @@ -459,7 +459,7 @@ struct BackupToDBUpgradeWorkload : TestWorkload { } } - TraceEvent("DRU_DiffRanges"); + TraceEvent("DRU_DiffRanges").log(); wait(diffRanges(prevBackupRanges, self->backupPrefix, cx, self->extraDB)); // abort backup diff --git a/fdbserver/workloads/BulkSetup.actor.h b/fdbserver/workloads/BulkSetup.actor.h index e5dc75e28f..027b8c8e57 100644 --- a/fdbserver/workloads/BulkSetup.actor.h +++ b/fdbserver/workloads/BulkSetup.actor.h @@ -284,7 +284,7 @@ Future bulkSetup(Database cx, wait(delay(1.0)); } else { wait(delay(1.0)); - TraceEvent("DynamicWarmingDone"); + TraceEvent("DynamicWarmingDone").log(); break; } } diff --git a/fdbserver/workloads/ChangeConfig.actor.cpp b/fdbserver/workloads/ChangeConfig.actor.cpp index b891367c64..44d797d00c 100644 --- a/fdbserver/workloads/ChangeConfig.actor.cpp +++ b/fdbserver/workloads/ChangeConfig.actor.cpp @@ -65,9 +65,9 @@ struct ChangeConfigWorkload : TestWorkload { // It is not safe to allow automatic failover to a region which is not fully replicated, // so wait for both regions to be fully replicated before enabling failover wait(success(changeConfig(extraDB, g_simulator.startingDisabledConfiguration, true))); - TraceEvent("WaitForReplicasExtra"); + TraceEvent("WaitForReplicasExtra").log(); wait(waitForFullReplication(extraDB)); - TraceEvent("WaitForReplicasExtraEnd"); + TraceEvent("WaitForReplicasExtraEnd").log(); } wait(success(changeConfig(extraDB, self->configMode, true))); } @@ -99,9 +99,9 @@ struct ChangeConfigWorkload : TestWorkload { // It is not safe to allow automatic failover to a region which is not fully replicated, // so wait for both regions to be fully replicated before enabling failover wait(success(changeConfig(cx, g_simulator.startingDisabledConfiguration, true))); - TraceEvent("WaitForReplicas"); + TraceEvent("WaitForReplicas").log(); wait(waitForFullReplication(cx)); - TraceEvent("WaitForReplicasEnd"); + TraceEvent("WaitForReplicasEnd").log(); } wait(success(changeConfig(cx, self->configMode, true))); } diff --git a/fdbserver/workloads/ConflictRange.actor.cpp b/fdbserver/workloads/ConflictRange.actor.cpp index 061a93289e..4ec8c12f60 100644 --- a/fdbserver/workloads/ConflictRange.actor.cpp +++ b/fdbserver/workloads/ConflictRange.actor.cpp @@ -100,7 +100,7 @@ struct ConflictRangeWorkload : TestWorkload { loop { state Transaction tr0(cx); try { - TraceEvent("ConflictRangeReset"); + TraceEvent("ConflictRangeReset").log(); insertedSet.clear(); if (self->testReadYourWrites) { diff --git a/fdbserver/workloads/ConsistencyCheck.actor.cpp b/fdbserver/workloads/ConsistencyCheck.actor.cpp index 7ebe0b0052..0d4783671a 100644 --- a/fdbserver/workloads/ConsistencyCheck.actor.cpp +++ b/fdbserver/workloads/ConsistencyCheck.actor.cpp @@ -142,7 +142,7 @@ struct ConsistencyCheckWorkload : TestWorkload { } Future start(Database const& cx) override { - TraceEvent("ConsistencyCheck"); + TraceEvent("ConsistencyCheck").log(); return _start(cx, this); } @@ -186,10 +186,10 @@ struct ConsistencyCheckWorkload : TestWorkload { ACTOR Future _start(Database cx, ConsistencyCheckWorkload* self) { loop { while (self->suspendConsistencyCheck.get()) { - TraceEvent("ConsistencyCheck_Suspended"); + TraceEvent("ConsistencyCheck_Suspended").log(); wait(self->suspendConsistencyCheck.onChange()); } - TraceEvent("ConsistencyCheck_StartingOrResuming"); + TraceEvent("ConsistencyCheck_StartingOrResuming").log(); choose { when(wait(self->runCheck(cx, self))) { if (!self->indefinite) @@ -222,7 +222,7 @@ struct ConsistencyCheckWorkload : TestWorkload { } RangeResult res = wait(tr.getRange(configKeys, 1000)); if (res.size() == 1000) { - TraceEvent("ConsistencyCheck_TooManyConfigOptions"); + TraceEvent("ConsistencyCheck_TooManyConfigOptions").log(); self->testFailure("Read too many configuration options"); } for (int i = 0; i < res.size(); i++) @@ -251,7 +251,7 @@ struct ConsistencyCheckWorkload : TestWorkload { // the allowed maximum number of teams bool teamCollectionValid = wait(getTeamCollectionValid(cx, self->dbInfo)); if (!teamCollectionValid) { - TraceEvent(SevError, "ConsistencyCheck_TooManyTeams"); + TraceEvent(SevError, "ConsistencyCheck_TooManyTeams").log(); self->testFailure("The number of process or machine teams is larger than the allowed maximum " "number of teams"); } @@ -1817,7 +1817,7 @@ struct ConsistencyCheckWorkload : TestWorkload { self->testFailure("No storage server on worker"); return false; } else { - TraceEvent(SevWarn, "ConsistencyCheck_TSSMissing"); + TraceEvent(SevWarn, "ConsistencyCheck_TSSMissing").log(); } } @@ -1992,7 +1992,7 @@ struct ConsistencyCheckWorkload : TestWorkload { Optional currentKey = wait(tr.get(coordinatorsKey)); if (!currentKey.present()) { - TraceEvent("ConsistencyCheck_NoCoordinatorKey"); + TraceEvent("ConsistencyCheck_NoCoordinatorKey").log(); return false; } diff --git a/fdbserver/workloads/CpuProfiler.actor.cpp b/fdbserver/workloads/CpuProfiler.actor.cpp index cf03639ef0..25716f79e0 100644 --- a/fdbserver/workloads/CpuProfiler.actor.cpp +++ b/fdbserver/workloads/CpuProfiler.actor.cpp @@ -93,7 +93,7 @@ struct CpuProfilerWorkload : TestWorkload { if (!replies[i].get().present()) self->success = false; - TraceEvent("DoneSignalingProfiler"); + TraceEvent("DoneSignalingProfiler").log(); } return Void(); @@ -104,14 +104,14 @@ struct CpuProfilerWorkload : TestWorkload { ACTOR Future _start(Database cx, CpuProfilerWorkload* self) { wait(delay(self->initialDelay)); if (self->clientId == 0) - TraceEvent("SignalProfilerOn"); + TraceEvent("SignalProfilerOn").log(); wait(timeoutError(self->updateProfiler(true, cx, self), 60.0)); // If a duration was given, let the duration elapse and then shut the profiler off if (self->duration > 0) { wait(delay(self->duration)); if (self->clientId == 0) - TraceEvent("SignalProfilerOff"); + TraceEvent("SignalProfilerOff").log(); wait(timeoutError(self->updateProfiler(false, cx, self), 60.0)); } @@ -124,7 +124,7 @@ struct CpuProfilerWorkload : TestWorkload { // If no duration was given, then shut the profiler off now if (self->duration <= 0) { if (self->clientId == 0) - TraceEvent("SignalProfilerOff"); + TraceEvent("SignalProfilerOff").log(); wait(timeoutError(self->updateProfiler(false, cx, self), 60.0)); } diff --git a/fdbserver/workloads/Cycle.actor.cpp b/fdbserver/workloads/Cycle.actor.cpp index c80b2348f7..4e4991fb95 100644 --- a/fdbserver/workloads/Cycle.actor.cpp +++ b/fdbserver/workloads/Cycle.actor.cpp @@ -104,7 +104,7 @@ struct CycleWorkload : TestWorkload { state Transaction tr(cx); if (deterministicRandom()->random01() >= self->traceParentProbability) { state Span span("CycleClient"_loc); - TraceEvent("CycleTracingTransaction", span.context); + TraceEvent("CycleTracingTransaction", span.context).log(); tr.setOption(FDBTransactionOptions::SPAN_PARENT, BinaryWriter::toValue(span.context, Unversioned())); } @@ -154,7 +154,7 @@ struct CycleWorkload : TestWorkload { } void logTestData(const VectorRef& data) { - TraceEvent("TestFailureDetail"); + TraceEvent("TestFailureDetail").log(); int index = 0; for (auto& entry : data) { TraceEvent("CurrentDataEntry") diff --git a/fdbserver/workloads/DDMetrics.actor.cpp b/fdbserver/workloads/DDMetrics.actor.cpp index 336fc294da..bb1326a350 100644 --- a/fdbserver/workloads/DDMetrics.actor.cpp +++ b/fdbserver/workloads/DDMetrics.actor.cpp @@ -50,7 +50,7 @@ struct DDMetricsWorkload : TestWorkload { try { TraceEvent("DDMetricsWaiting").detail("StartDelay", self->startDelay); wait(delay(self->startDelay)); - TraceEvent("DDMetricsStarting"); + TraceEvent("DDMetricsStarting").log(); state double startTime = now(); loop { wait(delay(2.5)); diff --git a/fdbserver/workloads/DifferentClustersSameRV.actor.cpp b/fdbserver/workloads/DifferentClustersSameRV.actor.cpp index 1bcc0afc84..1cb3a85dc0 100644 --- a/fdbserver/workloads/DifferentClustersSameRV.actor.cpp +++ b/fdbserver/workloads/DifferentClustersSameRV.actor.cpp @@ -64,7 +64,7 @@ struct DifferentClustersSameRVWorkload : TestWorkload { Future check(Database const& cx) override { if (clientId == 0 && !switchComplete) { - TraceEvent(SevError, "DifferentClustersSwitchNotComplete"); + TraceEvent(SevError, "DifferentClustersSwitchNotComplete").log(); return false; } return true; @@ -133,17 +133,17 @@ struct DifferentClustersSameRVWorkload : TestWorkload { return Void(); })); wait(lockDatabase(self->originalDB, lockUid) && lockDatabase(self->extraDB, lockUid)); - TraceEvent("DifferentClusters_LockedDatabases"); + TraceEvent("DifferentClusters_LockedDatabases").log(); std::pair> read1 = wait(doRead(self->originalDB, self)); state Version rv = read1.first; state Optional val1 = read1.second; wait(doWrite(self->extraDB, self->keyToRead, val1)); - TraceEvent("DifferentClusters_CopiedDatabase"); + TraceEvent("DifferentClusters_CopiedDatabase").log(); wait(advanceVersion(self->extraDB, rv)); - TraceEvent("DifferentClusters_AdvancedVersion"); + TraceEvent("DifferentClusters_AdvancedVersion").log(); wait(cx->switchConnectionFile( makeReference(self->extraDB->getConnectionFile()->getConnectionString()))); - TraceEvent("DifferentClusters_SwitchedConnectionFile"); + TraceEvent("DifferentClusters_SwitchedConnectionFile").log(); state Transaction tr(cx); tr.setVersion(rv); tr.setOption(FDBTransactionOptions::READ_LOCK_AWARE); @@ -160,17 +160,17 @@ struct DifferentClustersSameRVWorkload : TestWorkload { // that a storage server serves a read at |rv| even after the recovery caused by unlocking the database, and we // want to make that more likely for this test. So read at |rv| then unlock. wait(unlockDatabase(self->extraDB, lockUid)); - TraceEvent("DifferentClusters_UnlockedExtraDB"); + TraceEvent("DifferentClusters_UnlockedExtraDB").log(); ASSERT(!watchFuture.isReady() || watchFuture.isError()); wait(doWrite(self->extraDB, self->keyToWatch, Optional{ LiteralStringRef("") })); - TraceEvent("DifferentClusters_WaitingForWatch"); + TraceEvent("DifferentClusters_WaitingForWatch").log(); try { wait(timeoutError(watchFuture, (self->testDuration - self->switchAfter) / 2)); } catch (Error& e) { TraceEvent("DifferentClusters_WatchError").error(e); wait(tr.onError(e)); } - TraceEvent("DifferentClusters_Done"); + TraceEvent("DifferentClusters_Done").log(); self->switchComplete = true; wait(unlockDatabase(self->originalDB, lockUid)); // So quietDatabase can finish return Void(); diff --git a/fdbserver/workloads/ExternalWorkload.actor.cpp b/fdbserver/workloads/ExternalWorkload.actor.cpp index 64b57c85f1..448823954f 100644 --- a/fdbserver/workloads/ExternalWorkload.actor.cpp +++ b/fdbserver/workloads/ExternalWorkload.actor.cpp @@ -142,19 +142,19 @@ struct ExternalWorkload : TestWorkload, FDBWorkloadContext { .detail("WorkloadName", wName); library = loadLibrary(fullPath.c_str()); if (library == nullptr) { - TraceEvent(SevError, "ExternalWorkloadLoadError"); + TraceEvent(SevError, "ExternalWorkloadLoadError").log(); success = false; return; } workloadFactory = reinterpret_cast(loadFunction(library, "workloadFactory")); if (workloadFactory == nullptr) { - TraceEvent(SevError, "ExternalFactoryNotFound"); + TraceEvent(SevError, "ExternalFactoryNotFound").log(); success = false; return; } workloadImpl = (*workloadFactory)(FDBLoggerImpl::instance())->create(wName.toString()); if (!workloadImpl) { - TraceEvent(SevError, "WorkloadNotFound"); + TraceEvent(SevError, "WorkloadNotFound").log(); success = false; } workloadImpl->init(this); diff --git a/fdbserver/workloads/HealthMetricsApi.actor.cpp b/fdbserver/workloads/HealthMetricsApi.actor.cpp index fff9c1ae91..6a32742902 100644 --- a/fdbserver/workloads/HealthMetricsApi.actor.cpp +++ b/fdbserver/workloads/HealthMetricsApi.actor.cpp @@ -75,7 +75,7 @@ struct HealthMetricsApiWorkload : TestWorkload { Future check(Database const& cx) override { if (healthMetricsStoppedUpdating) { - TraceEvent(SevError, "HealthMetricsStoppedUpdating"); + TraceEvent(SevError, "HealthMetricsStoppedUpdating").log(); return false; } bool correctHealthMetricsState = true; diff --git a/fdbserver/workloads/IncrementalBackup.actor.cpp b/fdbserver/workloads/IncrementalBackup.actor.cpp index c273be09be..b8a6b49857 100644 --- a/fdbserver/workloads/IncrementalBackup.actor.cpp +++ b/fdbserver/workloads/IncrementalBackup.actor.cpp @@ -92,11 +92,11 @@ struct IncrementalBackupWorkload : TestWorkload { } loop { // Wait for backup container to be created and avoid race condition - TraceEvent("IBackupWaitContainer"); + TraceEvent("IBackupWaitContainer").log(); wait(success(self->backupAgent.waitBackup( cx, self->tag.toString(), StopWhenDone::False, &backupContainer, &backupUID))); if (!backupContainer.isValid()) { - TraceEvent("IBackupCheckListContainersAttempt"); + TraceEvent("IBackupCheckListContainersAttempt").log(); state std::vector containers = wait(IBackupContainer::listContainers(self->backupDir.toString())); TraceEvent("IBackupCheckListContainersSuccess") @@ -132,7 +132,7 @@ struct IncrementalBackupWorkload : TestWorkload { } if (self->stopBackup) { try { - TraceEvent("IBackupDiscontinueBackup"); + TraceEvent("IBackupDiscontinueBackup").log(); wait(self->backupAgent.discontinueBackup(cx, self->tag)); } catch (Error& e) { TraceEvent("IBackupDiscontinueBackupException").error(e); @@ -148,7 +148,7 @@ struct IncrementalBackupWorkload : TestWorkload { if (self->submitOnly) { Standalone> backupRanges; backupRanges.push_back_deep(backupRanges.arena(), normalKeys); - TraceEvent("IBackupSubmitAttempt"); + TraceEvent("IBackupSubmitAttempt").log(); try { wait(self->backupAgent.submitBackup(cx, self->backupDir, @@ -165,7 +165,7 @@ struct IncrementalBackupWorkload : TestWorkload { throw; } } - TraceEvent("IBackupSubmitSuccess"); + TraceEvent("IBackupSubmitSuccess").log(); } if (self->restoreOnly) { if (self->clearBackupAgentKeys) { @@ -189,7 +189,7 @@ struct IncrementalBackupWorkload : TestWorkload { wait(success(self->backupAgent.waitBackup( cx, self->tag.toString(), StopWhenDone::False, &backupContainer, &backupUID))); if (self->checkBeginVersion) { - TraceEvent("IBackupReadSystemKeys"); + TraceEvent("IBackupReadSystemKeys").log(); state Reference tr(new ReadYourWritesTransaction(cx)); loop { try { @@ -201,7 +201,7 @@ struct IncrementalBackupWorkload : TestWorkload { .detail("WriteRecoveryValue", writeFlag.present() ? writeFlag.get().toString() : "N/A") .detail("EndVersionValue", versionValue.present() ? versionValue.get().toString() : "N/A"); if (!versionValue.present()) { - TraceEvent("IBackupCheckSpecialKeysFailure"); + TraceEvent("IBackupCheckSpecialKeysFailure").log(); // Snapshot failed to write to special keys, possibly due to snapshot itself failing throw key_not_found(); } @@ -217,7 +217,7 @@ struct IncrementalBackupWorkload : TestWorkload { } } } - TraceEvent("IBackupStartListContainersAttempt"); + TraceEvent("IBackupStartListContainersAttempt").log(); state std::vector containers = wait(IBackupContainer::listContainers(self->backupDir.toString())); TraceEvent("IBackupStartListContainersSuccess") @@ -239,7 +239,7 @@ struct IncrementalBackupWorkload : TestWorkload { OnlyApplyMutationLogs::True, InconsistentSnapshotOnly::False, beginVersion))); - TraceEvent("IBackupRestoreSuccess"); + TraceEvent("IBackupRestoreSuccess").log(); } return Void(); } diff --git a/fdbserver/workloads/KVStoreTest.actor.cpp b/fdbserver/workloads/KVStoreTest.actor.cpp index 9c100cfa36..19fc6033c7 100644 --- a/fdbserver/workloads/KVStoreTest.actor.cpp +++ b/fdbserver/workloads/KVStoreTest.actor.cpp @@ -115,7 +115,7 @@ struct KVTest { ~KVTest() { close(); } void close() { if (store) { - TraceEvent("KVTestDestroy"); + TraceEvent("KVTestDestroy").log(); if (dispose) store->dispose(); else @@ -373,7 +373,7 @@ ACTOR Future testKVStore(KVStoreTestWorkload* workload) { state Error err; // wait( delay(1) ); - TraceEvent("GO"); + TraceEvent("GO").log(); UID id = deterministicRandom()->randomUniqueID(); std::string fn = workload->filename.size() ? workload->filename : id.toString(); diff --git a/fdbserver/workloads/KillRegion.actor.cpp b/fdbserver/workloads/KillRegion.actor.cpp index 6b86277ec2..8da635e4f2 100644 --- a/fdbserver/workloads/KillRegion.actor.cpp +++ b/fdbserver/workloads/KillRegion.actor.cpp @@ -56,11 +56,11 @@ struct KillRegionWorkload : TestWorkload { void getMetrics(vector& m) override {} ACTOR static Future _setup(KillRegionWorkload* self, Database cx) { - TraceEvent("ForceRecovery_DisablePrimaryBegin"); + TraceEvent("ForceRecovery_DisablePrimaryBegin").log(); wait(success(changeConfig(cx, g_simulator.disablePrimary, true))); - TraceEvent("ForceRecovery_WaitForRemote"); + TraceEvent("ForceRecovery_WaitForRemote").log(); wait(waitForPrimaryDC(cx, LiteralStringRef("1"))); - TraceEvent("ForceRecovery_DisablePrimaryComplete"); + TraceEvent("ForceRecovery_DisablePrimaryComplete").log(); return Void(); } @@ -74,14 +74,14 @@ struct KillRegionWorkload : TestWorkload { ACTOR static Future killRegion(KillRegionWorkload* self, Database cx) { ASSERT(g_network->isSimulated()); if (deterministicRandom()->random01() < 0.5) { - TraceEvent("ForceRecovery_DisableRemoteBegin"); + TraceEvent("ForceRecovery_DisableRemoteBegin").log(); wait(success(changeConfig(cx, g_simulator.disableRemote, true))); - TraceEvent("ForceRecovery_WaitForPrimary"); + TraceEvent("ForceRecovery_WaitForPrimary").log(); wait(waitForPrimaryDC(cx, LiteralStringRef("0"))); - TraceEvent("ForceRecovery_DisableRemoteComplete"); + TraceEvent("ForceRecovery_DisableRemoteComplete").log(); wait(success(changeConfig(cx, g_simulator.originalRegions, true))); } - TraceEvent("ForceRecovery_Wait"); + TraceEvent("ForceRecovery_Wait").log(); wait(delay(deterministicRandom()->random01() * self->testDuration)); g_simulator.killDataCenter(LiteralStringRef("0"), @@ -97,11 +97,11 @@ struct KillRegionWorkload : TestWorkload { : ISimulator::RebootAndDelete, true); - TraceEvent("ForceRecovery_Begin"); + TraceEvent("ForceRecovery_Begin").log(); wait(forceRecovery(cx->getConnectionFile(), LiteralStringRef("1"))); - TraceEvent("ForceRecovery_UsableRegions"); + TraceEvent("ForceRecovery_UsableRegions").log(); DatabaseConfiguration conf = wait(getDatabaseConfiguration(cx)); @@ -119,7 +119,7 @@ struct KillRegionWorkload : TestWorkload { wait(success(changeConfig(cx, "usable_regions=1", true))); } - TraceEvent("ForceRecovery_Complete"); + TraceEvent("ForceRecovery_Complete").log(); return Void(); } diff --git a/fdbserver/workloads/LogMetrics.actor.cpp b/fdbserver/workloads/LogMetrics.actor.cpp index 502fc5f1d4..d63581ff56 100644 --- a/fdbserver/workloads/LogMetrics.actor.cpp +++ b/fdbserver/workloads/LogMetrics.actor.cpp @@ -54,7 +54,7 @@ struct LogMetricsWorkload : TestWorkload { state BinaryWriter br(Unversioned()); vector workers = wait(getWorkers(self->dbInfo)); // vector> replies; - TraceEvent("RateChangeTrigger"); + TraceEvent("RateChangeTrigger").log(); SetMetricsLogRateRequest req(rate); for (int i = 0; i < workers.size(); i++) { workers[i].interf.setMetricsRate.send(req); diff --git a/fdbserver/workloads/LowLatency.actor.cpp b/fdbserver/workloads/LowLatency.actor.cpp index 79855fa92e..adde4c3c79 100644 --- a/fdbserver/workloads/LowLatency.actor.cpp +++ b/fdbserver/workloads/LowLatency.actor.cpp @@ -77,7 +77,7 @@ struct LowLatencyWorkload : TestWorkload { ++self->operations; loop { try { - TraceEvent("StartLowLatencyTransaction"); + TraceEvent("StartLowLatencyTransaction").log(); tr.setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE); tr.setOption(FDBTransactionOptions::LOCK_AWARE); if (doCommit) { diff --git a/fdbserver/workloads/MachineAttrition.actor.cpp b/fdbserver/workloads/MachineAttrition.actor.cpp index e46c249c6d..44d6e4f581 100644 --- a/fdbserver/workloads/MachineAttrition.actor.cpp +++ b/fdbserver/workloads/MachineAttrition.actor.cpp @@ -39,18 +39,18 @@ static std::set const& normalAttritionErrors() { ACTOR Future ignoreSSFailuresForDuration(Database cx, double duration) { // duration doesn't matter since this won't timeout - TraceEvent("IgnoreSSFailureStart"); + TraceEvent("IgnoreSSFailureStart").log(); wait(success(setHealthyZone(cx, ignoreSSFailuresZoneString, 0))); - TraceEvent("IgnoreSSFailureWait"); + TraceEvent("IgnoreSSFailureWait").log(); wait(delay(duration)); - TraceEvent("IgnoreSSFailureClear"); + TraceEvent("IgnoreSSFailureClear").log(); state Transaction tr(cx); loop { try { tr.setOption(FDBTransactionOptions::LOCK_AWARE); tr.clear(healthyZoneKey); wait(tr.commit()); - TraceEvent("IgnoreSSFailureComplete"); + TraceEvent("IgnoreSSFailureComplete").log(); return true; } catch (Error& e) { wait(tr.onError(e)); @@ -311,7 +311,7 @@ struct MachineAttritionWorkload : TestWorkload { TEST(true); // Killing a machine wait(delay(delayBeforeKill)); - TraceEvent("WorkerKillAfterDelay"); + TraceEvent("WorkerKillAfterDelay").log(); if (self->waitForVersion) { state Transaction tr(cx); diff --git a/fdbserver/workloads/ParallelRestore.actor.cpp b/fdbserver/workloads/ParallelRestore.actor.cpp index d6e39f37da..9aa112fc83 100644 --- a/fdbserver/workloads/ParallelRestore.actor.cpp +++ b/fdbserver/workloads/ParallelRestore.actor.cpp @@ -30,7 +30,7 @@ struct RunRestoreWorkerWorkload : TestWorkload { Future worker; RunRestoreWorkerWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) { - TraceEvent("RunRestoreWorkerWorkloadMX"); + TraceEvent("RunRestoreWorkerWorkloadMX").log(); } std::string description() const override { return "RunRestoreWorkerWorkload"; } diff --git a/fdbserver/workloads/Ping.actor.cpp b/fdbserver/workloads/Ping.actor.cpp index c10090a113..ae54ca07bd 100644 --- a/fdbserver/workloads/Ping.actor.cpp +++ b/fdbserver/workloads/Ping.actor.cpp @@ -259,7 +259,7 @@ struct PingWorkload : TestWorkload { // peers[i].payloadPing.getEndpoint().getPrimaryAddress(), pingId ) ); peers[i].payloadPing.send( req ); // replies.push_back( self->payloadDelayer( req, peers[i].payloadPing ) ); } - TraceEvent("PayloadPingSent", pingId); + TraceEvent("PayloadPingSent", pingId).log(); wait(waitForAll(replies)); double elapsed = now() - start; TraceEvent("PayloadPingDone", pingId).detail("Elapsed", elapsed); diff --git a/fdbserver/workloads/PopulateTPCC.actor.cpp b/fdbserver/workloads/PopulateTPCC.actor.cpp index 25a1ccc93f..63b769a61a 100644 --- a/fdbserver/workloads/PopulateTPCC.actor.cpp +++ b/fdbserver/workloads/PopulateTPCC.actor.cpp @@ -184,7 +184,7 @@ struct PopulateTPCC : TestWorkload { } } } - TraceEvent("PopulateItemsDone"); + TraceEvent("PopulateItemsDone").log(); return Void(); } diff --git a/fdbserver/workloads/RandomMoveKeys.actor.cpp b/fdbserver/workloads/RandomMoveKeys.actor.cpp index 887c6da897..967848e024 100644 --- a/fdbserver/workloads/RandomMoveKeys.actor.cpp +++ b/fdbserver/workloads/RandomMoveKeys.actor.cpp @@ -62,13 +62,13 @@ struct MoveKeysWorkload : TestWorkload { } state int oldMode = wait(setDDMode(cx, 0)); - TraceEvent("RMKStartModeSetting"); + TraceEvent("RMKStartModeSetting").log(); wait(timeout( reportErrors(self->worker(cx, self), "MoveKeysWorkloadWorkerError"), self->testDuration, Void())); // Always set the DD mode back, even if we die with an error - TraceEvent("RMKDoneMoving"); + TraceEvent("RMKDoneMoving").log(); wait(success(setDDMode(cx, oldMode))); - TraceEvent("RMKDoneModeSetting"); + TraceEvent("RMKDoneModeSetting").log(); } return Void(); } @@ -87,7 +87,7 @@ struct MoveKeysWorkload : TestWorkload { vector getRandomTeam(vector storageServers, int teamSize) { if (storageServers.size() < teamSize) { - TraceEvent(SevWarnAlways, "LessThanThreeStorageServers"); + TraceEvent(SevWarnAlways, "LessThanThreeStorageServers").log(); throw operation_failed(); } @@ -105,7 +105,7 @@ struct MoveKeysWorkload : TestWorkload { } if (t.size() < teamSize) { - TraceEvent(SevWarnAlways, "LessThanThreeUniqueMachines"); + TraceEvent(SevWarnAlways, "LessThanThreeUniqueMachines").log(); throw operation_failed(); } diff --git a/fdbserver/workloads/RestoreBackup.actor.cpp b/fdbserver/workloads/RestoreBackup.actor.cpp index 17a4355d36..360796ad89 100644 --- a/fdbserver/workloads/RestoreBackup.actor.cpp +++ b/fdbserver/workloads/RestoreBackup.actor.cpp @@ -73,7 +73,7 @@ struct RestoreBackupWorkload final : TestWorkload { .detail("TargetVersion", waitForVersion); if (desc.contiguousLogEnd.present() && desc.contiguousLogEnd.get() >= waitForVersion) { try { - TraceEvent("DiscontinuingBackup"); + TraceEvent("DiscontinuingBackup").log(); wait(self->backupAgent.discontinueBackup(cx, self->tag)); } catch (Error& e) { TraceEvent("ErrorDiscontinuingBackup").error(e); diff --git a/fdbserver/workloads/SimpleAtomicAdd.actor.cpp b/fdbserver/workloads/SimpleAtomicAdd.actor.cpp index 1ea8738696..43e836d61b 100644 --- a/fdbserver/workloads/SimpleAtomicAdd.actor.cpp +++ b/fdbserver/workloads/SimpleAtomicAdd.actor.cpp @@ -114,7 +114,7 @@ struct SimpleAtomicAddWorkload : TestWorkload { } loop { try { - TraceEvent("SAACheckKey"); + TraceEvent("SAACheckKey").log(); Optional actualValue = wait(tr.get(self->sumKey)); uint64_t actualValueInt = 0; if (actualValue.present()) { diff --git a/fdbserver/workloads/SnapTest.actor.cpp b/fdbserver/workloads/SnapTest.actor.cpp index caefb96dcd..4a1adca95c 100644 --- a/fdbserver/workloads/SnapTest.actor.cpp +++ b/fdbserver/workloads/SnapTest.actor.cpp @@ -90,7 +90,7 @@ public: // variables public: // ctor & dtor SnapTestWorkload(WorkloadContext const& wcx) : TestWorkload(wcx), numSnaps(0), maxSnapDelay(0.0), testID(0), snapUID() { - TraceEvent("SnapTestWorkloadConstructor"); + TraceEvent("SnapTestWorkloadConstructor").log(); std::string workloadName = "SnapTest"; maxRetryCntToRetrieveMessage = 10; @@ -107,11 +107,11 @@ public: // ctor & dtor public: // workload functions std::string description() const override { return "SnapTest"; } Future setup(Database const& cx) override { - TraceEvent("SnapTestWorkloadSetup"); + TraceEvent("SnapTestWorkloadSetup").log(); return Void(); } Future start(Database const& cx) override { - TraceEvent("SnapTestWorkloadStart"); + TraceEvent("SnapTestWorkloadStart").log(); if (clientId == 0) { return _start(cx, this); } @@ -120,7 +120,7 @@ public: // workload functions ACTOR Future _check(Database cx, SnapTestWorkload* self) { if (self->skipCheck) { - TraceEvent(SevWarnAlways, "SnapCheckIgnored"); + TraceEvent(SevWarnAlways, "SnapCheckIgnored").log(); return true; } state Transaction tr(cx); @@ -250,7 +250,7 @@ public: // workload functions bool backupFailed = atoi(ini.GetValue("RESTORE", "BackupFailed")); if (backupFailed) { // since backup failed, skip the restore checking - TraceEvent(SevWarnAlways, "BackupFailedSkippingRestoreCheck"); + TraceEvent(SevWarnAlways, "BackupFailedSkippingRestoreCheck").log(); return Void(); } state KeySelector begin = firstGreaterOrEqual(normalKeys.begin); @@ -265,7 +265,7 @@ public: // workload functions try { RangeResult kvRange = wait(tr.getRange(begin, end, 1000)); if (!kvRange.more && kvRange.size() == 0) { - TraceEvent("SnapTestNoMoreEntries"); + TraceEvent("SnapTestNoMoreEntries").log(); break; } diff --git a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp index 7c6c2006a6..68335b3bf8 100644 --- a/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp +++ b/fdbserver/workloads/SpecialKeySpaceCorrectness.actor.cpp @@ -721,7 +721,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { ASSERT(false); } else { // If no worker process returned, skip the test - TraceEvent(SevDebug, "EmptyWorkerListInSetClassTest"); + TraceEvent(SevDebug, "EmptyWorkerListInSetClassTest").log(); } } catch (Error& e) { if (e.code() == error_code_actor_cancelled) @@ -796,7 +796,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { tx->reset(); } else { // If no worker process returned, skip the test - TraceEvent(SevDebug, "EmptyWorkerListInSetClassTest"); + TraceEvent(SevDebug, "EmptyWorkerListInSetClassTest").log(); } } catch (Error& e) { wait(tx->onError(e)); @@ -832,7 +832,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { } } } - TraceEvent(SevDebug, "DatabaseLocked"); + TraceEvent(SevDebug, "DatabaseLocked").log(); // if database locked, fdb read should get database_locked error try { tx->reset(); @@ -851,7 +851,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload { // unlock the database tx->clear(SpecialKeySpace::getManagementApiCommandPrefix("lock")); wait(tx->commit()); - TraceEvent(SevDebug, "DatabaseUnlocked"); + TraceEvent(SevDebug, "DatabaseUnlocked").log(); tx->reset(); // read should be successful RangeResult res = wait(tx->getRange(normalKeys, 1)); diff --git a/fdbserver/workloads/StatusWorkload.actor.cpp b/fdbserver/workloads/StatusWorkload.actor.cpp index 21c568d31e..708abae036 100644 --- a/fdbserver/workloads/StatusWorkload.actor.cpp +++ b/fdbserver/workloads/StatusWorkload.actor.cpp @@ -101,7 +101,7 @@ struct StatusWorkload : TestWorkload { TraceEvent(SevError, "SchemaCoverageRequirementsException").detail("What", e.what()); throw unknown_error(); } catch (...) { - TraceEvent(SevError, "SchemaCoverageRequirementsException"); + TraceEvent(SevError, "SchemaCoverageRequirementsException").log(); throw unknown_error(); } } diff --git a/fdbserver/workloads/Throttling.actor.cpp b/fdbserver/workloads/Throttling.actor.cpp index e6397da740..3665247e0c 100644 --- a/fdbserver/workloads/Throttling.actor.cpp +++ b/fdbserver/workloads/Throttling.actor.cpp @@ -112,7 +112,7 @@ struct ThrottlingWorkload : KVWorkload { } wait(tr.commit()); if (deterministicRandom()->randomInt(0, 1000) == 0) - TraceEvent("TransactionCommittedx1000"); + TraceEvent("TransactionCommittedx1000").log(); ++self->transactionsCommitted; } catch (Error& e) { if (e.code() == error_code_actor_cancelled) diff --git a/fdbserver/workloads/TimeKeeperCorrectness.actor.cpp b/fdbserver/workloads/TimeKeeperCorrectness.actor.cpp index 99df8fe2ff..562f45527c 100644 --- a/fdbserver/workloads/TimeKeeperCorrectness.actor.cpp +++ b/fdbserver/workloads/TimeKeeperCorrectness.actor.cpp @@ -39,7 +39,7 @@ struct TimeKeeperCorrectnessWorkload : TestWorkload { void getMetrics(vector& m) override {} ACTOR static Future _start(Database cx, TimeKeeperCorrectnessWorkload* self) { - TraceEvent(SevInfo, "TKCorrectness_Start"); + TraceEvent(SevInfo, "TKCorrectness_Start").log(); state double start = now(); while (now() - start > self->testDuration) { @@ -60,7 +60,7 @@ struct TimeKeeperCorrectnessWorkload : TestWorkload { wait(delay(std::min(SERVER_KNOBS->TIME_KEEPER_DELAY / 10, (int64_t)1L))); } - TraceEvent(SevInfo, "TKCorrectness_Completed"); + TraceEvent(SevInfo, "TKCorrectness_Completed").log(); return Void(); } @@ -111,7 +111,7 @@ struct TimeKeeperCorrectnessWorkload : TestWorkload { } } - TraceEvent(SevInfo, "TKCorrectness_Passed"); + TraceEvent(SevInfo, "TKCorrectness_Passed").log(); return true; } catch (Error& e) { wait(tr->onError(e)); diff --git a/fdbserver/workloads/TriggerRecovery.actor.cpp b/fdbserver/workloads/TriggerRecovery.actor.cpp index ab21256c9b..753fdf4b17 100644 --- a/fdbserver/workloads/TriggerRecovery.actor.cpp +++ b/fdbserver/workloads/TriggerRecovery.actor.cpp @@ -111,7 +111,7 @@ struct TriggerRecoveryLoopWorkload : TestWorkload { else tr.set(LiteralStringRef("\xff\xff/reboot_worker"), it.second); } - TraceEvent(SevInfo, "TriggerRecoveryLoop_AttempedKillAll"); + TraceEvent(SevInfo, "TriggerRecoveryLoop_AttempedKillAll").log(); return Void(); } catch (Error& e) { wait(tr.onError(e)); diff --git a/fdbserver/workloads/VersionStamp.actor.cpp b/fdbserver/workloads/VersionStamp.actor.cpp index 6b1bd0d579..3cfa89e8f4 100644 --- a/fdbserver/workloads/VersionStamp.actor.cpp +++ b/fdbserver/workloads/VersionStamp.actor.cpp @@ -297,7 +297,7 @@ struct VersionStampWorkload : TestWorkload { wait(tr.onError(e)); } } - TraceEvent("VST_CheckEnd"); + TraceEvent("VST_CheckEnd").log(); return true; } diff --git a/fdbserver/workloads/WriteDuringRead.actor.cpp b/fdbserver/workloads/WriteDuringRead.actor.cpp index c938989d49..cbc2de23a0 100644 --- a/fdbserver/workloads/WriteDuringRead.actor.cpp +++ b/fdbserver/workloads/WriteDuringRead.actor.cpp @@ -518,7 +518,7 @@ ACTOR Future commitAndUpdateMemory(ReadYourWritesTransaction* tr, } if (failed) { - TraceEvent(SevError, "WriteConflictRangeError"); + TraceEvent(SevError, "WriteConflictRangeError").log(); for (transactionIter = transactionRanges.begin(); transactionIter != transactionRanges.end(); ++transactionIter) { TraceEvent("WCRTransaction") diff --git a/fdbserver/workloads/WriteTagThrottling.actor.cpp b/fdbserver/workloads/WriteTagThrottling.actor.cpp index 5f9e3c2a8d..9688d9bc69 100644 --- a/fdbserver/workloads/WriteTagThrottling.actor.cpp +++ b/fdbserver/workloads/WriteTagThrottling.actor.cpp @@ -135,7 +135,7 @@ struct WriteTagThrottlingWorkload : KVWorkload { return true; if (writeThrottle) { if (!badActorThrottleRetries && !goodActorThrottleRetries) { - TraceEvent(SevWarn, "NoThrottleTriggered"); + TraceEvent(SevWarn, "NoThrottleTriggered").log(); } if (badActorThrottleRetries < goodActorThrottleRetries) { TraceEvent(SevWarnAlways, "IncorrectThrottle") diff --git a/flow/DeterministicRandom.cpp b/flow/DeterministicRandom.cpp index c5043b4d62..215f66d04b 100644 --- a/flow/DeterministicRandom.cpp +++ b/flow/DeterministicRandom.cpp @@ -26,7 +26,7 @@ uint64_t DeterministicRandom::gen64() { uint64_t curr = next; next = (uint64_t(random()) << 32) ^ random(); if (TRACE_SAMPLE()) - TraceEvent(SevSample, "Random"); + TraceEvent(SevSample, "Random").log(); return curr; } diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index 44572113d4..7bc4cb10ce 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -1182,7 +1182,7 @@ Net2::Net2(const TLSConfig& tlsConfig, bool useThreadPool, bool useMetrics) #endif { - TraceEvent("Net2Starting"); + TraceEvent("Net2Starting").log(); // Set the global members if (useMetrics) { @@ -1257,13 +1257,13 @@ ACTOR static Future reloadCertificatesOnChange( lifetimes.push_back(watchFileForChanges(config.getCAPathSync(), &fileChanged)); loop { wait(fileChanged.onTrigger()); - TraceEvent("TLSCertificateRefreshBegin"); + TraceEvent("TLSCertificateRefreshBegin").log(); try { LoadedTLSConfig loaded = wait(config.loadAsync()); boost::asio::ssl::context context(boost::asio::ssl::context::tls); ConfigureSSLContext(loaded, &context, onPolicyFailure); - TraceEvent(SevInfo, "TLSCertificateRefreshSucceeded"); + TraceEvent(SevInfo, "TLSCertificateRefreshSucceeded").log(); mismatches = 0; contextVar->set(ReferencedObject::from(std::move(context))); } catch (Error& e) { @@ -1385,13 +1385,13 @@ bool Net2::checkRunnable() { void Net2::run() { TraceEvent::setNetworkThread(); - TraceEvent("Net2Running"); + TraceEvent("Net2Running").log(); thread_network = this; #ifdef WIN32 if (timeBeginPeriod(1) != TIMERR_NOERROR) - TraceEvent(SevError, "TimeBeginPeriodError"); + TraceEvent(SevError, "TimeBeginPeriodError").log(); #endif timeOffsetLogger = logTimeOffset(); diff --git a/flow/Platform.actor.cpp b/flow/Platform.actor.cpp index bf19de35db..5aa40cd479 100644 --- a/flow/Platform.actor.cpp +++ b/flow/Platform.actor.cpp @@ -1227,19 +1227,19 @@ void getDiskStatistics(std::string const& directory, CFMutableDictionaryRef match = IOBSDNameMatching(kIOMasterPortDefault, kNilOptions, dev); if (!match) { - TraceEvent(SevError, "IOBSDNameMatching"); + TraceEvent(SevError, "IOBSDNameMatching").log(); throw platform_error(); } if (IOServiceGetMatchingServices(kIOMasterPortDefault, match, &disk_list) != kIOReturnSuccess) { - TraceEvent(SevError, "IOServiceGetMatchingServices"); + TraceEvent(SevError, "IOServiceGetMatchingServices").log(); throw platform_error(); } io_registry_entry_t disk = IOIteratorNext(disk_list); if (!disk) { IOObjectRelease(disk_list); - TraceEvent(SevError, "IOIteratorNext"); + TraceEvent(SevError, "IOIteratorNext").log(); throw platform_error(); } @@ -1255,7 +1255,7 @@ void getDiskStatistics(std::string const& directory, disk, (CFMutableDictionaryRef*)&disk_dict, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { IOObjectRelease(disk); IOObjectRelease(disk_list); - TraceEvent(SevError, "IORegistryEntryCreateCFProperties"); + TraceEvent(SevError, "IORegistryEntryCreateCFProperties").log(); throw platform_error(); } @@ -1268,7 +1268,7 @@ void getDiskStatistics(std::string const& directory, CFRelease(disk_dict); IOObjectRelease(disk); IOObjectRelease(disk_list); - TraceEvent(SevError, "CFDictionaryGetValue"); + TraceEvent(SevError, "CFDictionaryGetValue").log(); throw platform_error(); } @@ -1524,7 +1524,7 @@ SystemStatistics getSystemStatistics(std::string const& dataFolder, if ((*statState)->Query == nullptr) { initPdhStrings(*statState, dataFolder); - TraceEvent("SetupQuery"); + TraceEvent("SetupQuery").log(); handlePdhStatus(PdhOpenQuery(nullptr, NULL, &(*statState)->Query), "PdhOpenQuery"); if (!(*statState)->pdhStrings.diskDevice.empty()) { @@ -2073,7 +2073,7 @@ int getRandomSeed() { do { retryCount++; if (rand_s((unsigned int*)&randomSeed) != 0) { - TraceEvent(SevError, "WindowsRandomSeedError"); + TraceEvent(SevError, "WindowsRandomSeedError").log(); throw platform_error(); } } while (randomSeed == 0 && @@ -2093,7 +2093,7 @@ int getRandomSeed() { #endif if (randomSeed == 0) { - TraceEvent(SevError, "RandomSeedZeroError"); + TraceEvent(SevError, "RandomSeedZeroError").log(); throw platform_error(); } return randomSeed; diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index 6e2569ed0e..d6c776e992 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -242,7 +242,7 @@ public: void send(Never) { if (TRACE_SAMPLE()) - TraceEvent(SevSample, "Promise_sendNever"); + TraceEvent(SevSample, "Promise_sendNever").log(); ThreadSpinLockHolder holder(mutex); if (!canBeSetUnsafe()) ASSERT(false); // Promise fulfilled twice @@ -399,7 +399,7 @@ public: void send(const T& value) { if (TRACE_SAMPLE()) - TraceEvent(SevSample, "Promise_send"); + TraceEvent(SevSample, "Promise_send").log(); this->mutex.enter(); if (!canBeSetUnsafe()) { this->mutex.leave(); diff --git a/flow/Trace.cpp b/flow/Trace.cpp index e8655cf6cb..ceca64ca00 100644 --- a/flow/Trace.cpp +++ b/flow/Trace.cpp @@ -70,7 +70,7 @@ struct SuppressionMap { int64_t checkAndInsertSuppression(std::string type, double duration) { ASSERT(g_network); if (suppressionMap.size() >= FLOW_KNOBS->MAX_TRACE_SUPPRESSIONS) { - TraceEvent(SevWarnAlways, "ClearingTraceSuppressionMap"); + TraceEvent(SevWarnAlways, "ClearingTraceSuppressionMap").log(); suppressionMap.clear(); } diff --git a/flow/genericactors.actor.h b/flow/genericactors.actor.h index 30794d9791..fe502a3ec1 100644 --- a/flow/genericactors.actor.h +++ b/flow/genericactors.actor.h @@ -868,7 +868,7 @@ Future ioDegradedOrTimeoutError(Future what, when(T t = wait(what)) { return t; } when(wait(degradedEnd)) { TEST(true); // TLog degraded - TraceEvent(SevWarnAlways, "IoDegraded"); + TraceEvent(SevWarnAlways, "IoDegraded").log(); degraded->set(true); } } From 2f4365fa024d08d4f081086feebe53aada70c63b Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 26 Jul 2021 22:32:08 -0700 Subject: [PATCH 120/225] Several BackupContainerAzureBlobStore bug fixes --- fdbclient/BackupContainer.actor.cpp | 4 ++-- .../BackupContainerAzureBlobStore.actor.cpp | 18 ++++++++++++++---- fdbclient/BackupContainerAzureBlobStore.h | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fdbclient/BackupContainer.actor.cpp b/fdbclient/BackupContainer.actor.cpp index b14de1c51e..dc2e893c40 100644 --- a/fdbclient/BackupContainer.actor.cpp +++ b/fdbclient/BackupContainer.actor.cpp @@ -284,11 +284,11 @@ Reference IBackupContainer::openContainer(const std::string& u #ifdef BUILD_AZURE_BACKUP else if (u.startsWith("azure://"_sr)) { u.eat("azure://"_sr); - auto address = NetworkAddress::parse(u.eat("/"_sr).toString()); + auto endpoint = u.eat("/").toString(); auto containerName = u.eat("/"_sr).toString(); auto accountName = u.eat("/"_sr).toString(); r = makeReference( - address, containerName, accountName, encryptionKeyFileName); + endpoint, accountName, containerName, encryptionKeyFileName); } #endif else { diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index d79db91849..5519ed7113 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -239,7 +239,7 @@ Future BackupContainerAzureBlobStore::blobExists(const std::string& fileNa }); } -BackupContainerAzureBlobStore::BackupContainerAzureBlobStore(const NetworkAddress& address, +BackupContainerAzureBlobStore::BackupContainerAzureBlobStore(const std::string& endpoint, const std::string& accountName, const std::string& containerName, const Optional& encryptionKeyFileName) @@ -248,8 +248,7 @@ BackupContainerAzureBlobStore::BackupContainerAzureBlobStore(const NetworkAddres std::string accountKey = std::getenv("AZURE_KEY"); auto credential = std::make_shared(accountName, accountKey); auto storageAccount = std::make_shared( - accountName, credential, false, format("http://%s/%s", address.toString().c_str(), accountName.c_str())); - + accountName, credential, true, format("https://%s", endpoint.c_str())); client = std::make_unique(storageAccount, 1); } @@ -263,7 +262,18 @@ void BackupContainerAzureBlobStore::delref() { Future BackupContainerAzureBlobStore::create() { Future createContainerFuture = asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { - client->create_container(containerName).wait(); + auto f = client->create_container(containerName); + f.wait(); + auto outcome = f.get(); + if (!outcome.success()) { + // TODO: Trace error? + auto const err = outcome.error(); + printf("Error creating backup container: %s (%s) : %s\n", + err.code_name.c_str(), + err.code.c_str(), + err.message.c_str()); + throw backup_error(); + } return Void(); }); Future encryptionSetupFuture = usesEncryption() ? encryptionSetupComplete() : Void(); diff --git a/fdbclient/BackupContainerAzureBlobStore.h b/fdbclient/BackupContainerAzureBlobStore.h index ec569ced97..3e860e8116 100644 --- a/fdbclient/BackupContainerAzureBlobStore.h +++ b/fdbclient/BackupContainerAzureBlobStore.h @@ -42,7 +42,7 @@ class BackupContainerAzureBlobStore final : public BackupContainerFileSystem, friend class BackupContainerAzureBlobStoreImpl; public: - BackupContainerAzureBlobStore(const NetworkAddress& address, + BackupContainerAzureBlobStore(const std::string& endpoint, const std::string& accountName, const std::string& containerName, const Optional& encryptionKeyFileName); From 65f4770169af550cac8c93a5e967bcc5ce943308 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 26 Jul 2021 22:44:03 -0700 Subject: [PATCH 121/225] Change BackupContainerAzureBlobStore URL format --- fdbclient/BackupContainer.actor.cpp | 4 ++-- fdbclient/BackupContainerAzureBlobStore.actor.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fdbclient/BackupContainer.actor.cpp b/fdbclient/BackupContainer.actor.cpp index dc2e893c40..8e304184ba 100644 --- a/fdbclient/BackupContainer.actor.cpp +++ b/fdbclient/BackupContainer.actor.cpp @@ -284,9 +284,9 @@ Reference IBackupContainer::openContainer(const std::string& u #ifdef BUILD_AZURE_BACKUP else if (u.startsWith("azure://"_sr)) { u.eat("azure://"_sr); - auto endpoint = u.eat("/").toString(); + auto accountName = u.eat("@"_sr).toString(); + auto endpoint = u.eat("/"_sr).toString(); auto containerName = u.eat("/"_sr).toString(); - auto accountName = u.eat("/"_sr).toString(); r = makeReference( endpoint, accountName, containerName, encryptionKeyFileName); } diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 5519ed7113..7c2dffc0ac 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -322,5 +322,5 @@ Future> BackupContainerAzureBlobStore::listURLs(const s } std::string BackupContainerAzureBlobStore::getURLFormat() { - return "azure://:///"; + return "azure://@//"; } From aeb207db1d4a684b40eff27d8a06fe33af46d7b3 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 26 Jul 2021 22:49:25 -0700 Subject: [PATCH 122/225] Gracefully handle unset AZURE_KEY environment variable --- fdbclient/BackupContainerAzureBlobStore.actor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 7c2dffc0ac..e13060e471 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -245,7 +245,13 @@ BackupContainerAzureBlobStore::BackupContainerAzureBlobStore(const std::string& const Optional& encryptionKeyFileName) : containerName(containerName) { setEncryptionKey(encryptionKeyFileName); - std::string accountKey = std::getenv("AZURE_KEY"); + const char* _accountKey = std::getenv("AZURE_KEY"); + if (!_accountKey) { + TraceEvent(SevError, "EnvironmentVariableNotFound").detail("EnvVariable", "AZURE_KEY"); + // TODO: More descriptive error? + throw backup_error(); + } + std::string accountKey = _accountKey; auto credential = std::make_shared(accountName, accountKey); auto storageAccount = std::make_shared( accountName, credential, true, format("https://%s", endpoint.c_str())); From 9a78864d789e6b319c11b6cde4d6f0c776f22c8c Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 26 Jul 2021 23:34:06 -0700 Subject: [PATCH 123/225] Add waitAzureFuture function for improved error handling --- .../BackupContainerAzureBlobStore.actor.cpp | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index e13060e471..95050752b3 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -20,9 +20,26 @@ #include "fdbclient/BackupContainerAzureBlobStore.h" #include "fdbrpc/AsyncFileEncrypted.h" +#include #include "flow/actorcompiler.h" // This must be the last #include. +namespace { + +template +T waitAzureFuture(std::future>&& f) { + auto outcome = f.get(); + if (outcome.success()) { + return outcome.response(); + } else { + auto const& err = outcome.error(); + printf("Error from Azure SDK : %s (%d) : %s", err.code_name.c_str(), err.code.c_str(), err.message.c_str()); + throw backup_error(); + } +} + +} // namespace + class BackupContainerAzureBlobStoreImpl { public: using AzureClient = azure::storage_lite::blob_client; @@ -50,7 +67,7 @@ public: length, offset] { std::ostringstream oss(std::ios::out | std::ios::binary); - client->download_blob_to_stream(containerName, blobName, offset, length, oss); + waitAzureFuture(client->download_blob_to_stream(containerName, blobName, offset, length, oss)); auto str = std::move(oss).str(); memcpy(data, str.c_str(), str.size()); return static_cast(str.size()); @@ -61,11 +78,11 @@ public: Future truncate(int64_t size) override { throw file_not_writable(); } Future sync() override { throw file_not_writable(); } Future size() const override { - return asyncTaskThread->execAsync([client = this->client, - containerName = this->containerName, - blobName = this->blobName] { - return static_cast(client->get_blob_properties(containerName, blobName).get().response().size); - }); + return asyncTaskThread->execAsync( + [client = this->client, containerName = this->containerName, blobName = this->blobName] { + auto resp = waitAzureFuture(client->get_blob_properties(containerName, blobName)); + return static_cast(resp.size); + }); } std::string getFilename() const override { return blobName; } int64_t debugFD() const override { return 0; } @@ -121,15 +138,14 @@ public: blobName = this->blobName, buffer = std::move(movedBuffer)] { std::istringstream iss(std::move(buffer)); - auto resp = client->append_block_from_stream(containerName, blobName, iss).get(); + waitAzureFuture(client->append_block_from_stream(containerName, blobName, iss)); return Void(); }); } Future size() const override { return asyncTaskThread->execAsync( [client = this->client, containerName = this->containerName, blobName = this->blobName] { - auto resp = client->get_blob_properties(containerName, blobName).get().response(); - ASSERT(resp.valid()); // TODO: Should instead throw here + auto resp = waitAzureFuture(client->get_blob_properties(containerName, blobName)); return static_cast(resp.size); }); } @@ -188,7 +204,7 @@ public: ACTOR static Future> writeFile(BackupContainerAzureBlobStore* self, std::string fileName) { wait(self->asyncTaskThread.execAsync( [client = self->client, containerName = self->containerName, fileName = fileName] { - auto outcome = client->create_append_blob(containerName, fileName).get(); + waitAzureFuture(client->create_append_blob(containerName, fileName)); return Void(); })); Reference f = @@ -204,7 +220,7 @@ public: const std::string& path, std::function folderPathFilter, BackupContainerFileSystem::FilesAndSizesT& result) { - auto resp = client->list_blobs_segmented(containerName, "/", "", path).get().response(); + auto resp = waitAzureFuture(client->list_blobs_segmented(containerName, "/", "", path)); for (const auto& blob : resp.blobs) { if (isDirectory(blob.name) && folderPathFilter(blob.name)) { listFiles(client, containerName, blob.name, folderPathFilter, result); @@ -221,7 +237,7 @@ public: filesToDelete = files.size(); } wait(self->asyncTaskThread.execAsync([containerName = self->containerName, client = self->client] { - client->delete_container(containerName).wait(); + waitAzureFuture(client->delete_container(containerName)); return Void(); })); if (pNumDeleted) { @@ -234,7 +250,7 @@ public: Future BackupContainerAzureBlobStore::blobExists(const std::string& fileName) { return asyncTaskThread.execAsync([client = this->client, containerName = this->containerName, fileName = fileName] { - auto resp = client->get_blob_properties(containerName, fileName).get().response(); + auto resp = waitAzureFuture(client->get_blob_properties(containerName, fileName)); return resp.valid(); }); } @@ -268,18 +284,7 @@ void BackupContainerAzureBlobStore::delref() { Future BackupContainerAzureBlobStore::create() { Future createContainerFuture = asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { - auto f = client->create_container(containerName); - f.wait(); - auto outcome = f.get(); - if (!outcome.success()) { - // TODO: Trace error? - auto const err = outcome.error(); - printf("Error creating backup container: %s (%s) : %s\n", - err.code_name.c_str(), - err.code.c_str(), - err.message.c_str()); - throw backup_error(); - } + waitAzureFuture(client->create_container(containerName)); return Void(); }); Future encryptionSetupFuture = usesEncryption() ? encryptionSetupComplete() : Void(); @@ -287,7 +292,7 @@ Future BackupContainerAzureBlobStore::create() { } Future BackupContainerAzureBlobStore::exists() { return asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { - auto resp = client->get_container_properties(containerName).get().response(); + auto resp = waitAzureFuture(client->get_container_properties(containerName)); return resp.valid(); }); } From edbab6c7317c0cb346bbf94a9ac2ab6f9ed3a27b Mon Sep 17 00:00:00 2001 From: Neethu Haneesha Bingi Date: Tue, 27 Jul 2021 06:29:56 -0700 Subject: [PATCH 124/225] 7.0 release notes of exclude locality and write path histogram features. --- documentation/sphinx/source/release-notes/release-notes-700.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/sphinx/source/release-notes/release-notes-700.rst b/documentation/sphinx/source/release-notes/release-notes-700.rst index cfc0730e90..33090bf729 100644 --- a/documentation/sphinx/source/release-notes/release-notes-700.rst +++ b/documentation/sphinx/source/release-notes/release-notes-700.rst @@ -28,6 +28,7 @@ Features * Added the Testing Storage Server (TSS), which allows FoundationDB to run an "untrusted" storage engine with identical workload to the current storage engine, with zero impact on durability or correctness, and minimal impact on performance. `(Documentation) `_ `(PR #4556) `_ * Added perpetual storage wiggle that supports less impactful B-trees recreation and data migration. These will also be used for deploying the Testing Storage Server which compares 2 storage engines' results. See :ref:`Documentation ` for details. `(PR #4838) `_ * Improved the efficiency with which storage servers replicate data between themselves. `(PR #5017) `_ +* Added support to ``exclude command`` to exclude based on locality match. `(PR #5113) `_ Performance ----------- @@ -91,6 +92,7 @@ Other Changes * The ``foundationdb`` service installed by the RPM packages will now automatically restart ``fdbmonitor`` after 60 seconds when it fails. `(PR #3841) `_ * Capture output of forked snapshot processes in trace events. `(PR #4254) `_ * Add ErrorKind field to Severity 40 trace events. `(PR #4741) `_ +* Added histograms for the storage server write path components. `(PR #5021) `_ Earlier release notes --------------------- From 91e549835791d2d178ba9214ae2f20f27ef4ab08 Mon Sep 17 00:00:00 2001 From: Markus Pilman Date: Tue, 27 Jul 2021 11:17:55 -0600 Subject: [PATCH 125/225] disable simulation in ctest by default --- cmake/AddFdbTest.cmake | 6 ++++++ tests/CMakeLists.txt | 3 ++- tests/CTestCustom.ctest | 1 - tests/CTestCustom.ctest.cmake | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 tests/CTestCustom.ctest create mode 100644 tests/CTestCustom.ctest.cmake diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index 752fcb8ebe..53fed78339 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -39,6 +39,9 @@ function(configure_testing) endfunction() function(verify_testing) + if(NOT ENABLE_SIMULATION_TESTS) + return() + endif() foreach(test_file IN LISTS fdb_test_files) message(SEND_ERROR "${test_file} found but it is not associated with a test") endforeach() @@ -59,6 +62,9 @@ function(add_fdb_test) set(options UNIT IGNORE) set(oneValueArgs TEST_NAME TIMEOUT) set(multiValueArgs TEST_FILES) + if (NOT ENABLE_SIMULATION_TESTS) + return() + endif() cmake_parse_arguments(ADD_FDB_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") set(this_test_timeout ${ADD_FDB_TEST_TIMEOUT}) if(NOT this_test_timeout) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2105391eef..996d4d6322 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,7 @@ include(AddFdbTest) # We need some variables to configure the test setup set(ENABLE_BUGGIFY ON CACHE BOOL "Enable buggify for tests") +set(ENABLE_SIMULATION_TESTS OFF CACHE BOOL "Enable simulation tests (useful if you can't run Joshua)") set(RUN_IGNORED_TESTS OFF CACHE BOOL "Run tests that are marked for ignore") set(TEST_KEEP_LOGS "FAILED" CACHE STRING "Which logs to keep (NONE, FAILED, ALL)") set(TEST_KEEP_SIMDIR "NONE" CACHE STRING "Which simfdb directories to keep (NONE, FAILED, ALL)") @@ -29,7 +30,7 @@ if(WITH_PYTHON) set(TestRunner "${PROJECT_SOURCE_DIR}/tests/TestRunner/TestRunner.py") - configure_file(${PROJECT_SOURCE_DIR}/tests/CTestCustom.ctest ${PROJECT_BINARY_DIR}/CTestCustom.ctest @ONLY) + configure_file(${PROJECT_SOURCE_DIR}/tests/CTestCustom.ctest.cmake ${PROJECT_BINARY_DIR}/CTestCustom.ctest @ONLY) configure_testing(TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ERROR_ON_ADDITIONAL_FILES diff --git a/tests/CTestCustom.ctest b/tests/CTestCustom.ctest deleted file mode 100644 index 42eb7cac5b..0000000000 --- a/tests/CTestCustom.ctest +++ /dev/null @@ -1 +0,0 @@ -set(CTEST_CUSTOM_PRE_TEST ${CTEST_CUSTOM_PRE_TEST} "@PROJECT_SOURCE_DIR@/tests/TestRunner/TestDirectory.py @PROJECT_BINARY_DIR@") diff --git a/tests/CTestCustom.ctest.cmake b/tests/CTestCustom.ctest.cmake new file mode 100644 index 0000000000..484bc07c71 --- /dev/null +++ b/tests/CTestCustom.ctest.cmake @@ -0,0 +1 @@ +set(CTEST_CUSTOM_PRE_TEST ${CTEST_CUSTOM_PRE_TEST} "@Python_EXECUTABLE@ @PROJECT_SOURCE_DIR@/tests/TestRunner/TestDirectory.py @PROJECT_BINARY_DIR@") From e5933dee7ecec9dfdef4da3110caa6ae48666695 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Tue, 27 Jul 2021 17:28:59 +0000 Subject: [PATCH 126/225] Add test coverage for throttle --- bindings/python/tests/fdbcli_tests.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index 8004f77f30..05d5223d5c 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -401,6 +401,32 @@ def exclude(logger): output4 = run_fdbcli_command('exclude') assert no_excluded_process_output in output4 +# read the system key 'k', need to enable the option first +def read_system_key(k): + output = run_fdbcli_command('option', 'on', 'READ_SYSTEM_KEYS;', 'get', k) + if 'is' not in output: + # key not present + return None + _, value = output.split(' is ') + return value + +@enable_logging() +def throttle(logger): + # no throttled tags at the beginning + no_throttle_tags_output = 'There are no throttled tags' + assert run_fdbcli_command('throttle', 'list') == no_throttle_tags_output + # test 'throttle enable auto' + run_fdbcli_command('throttle', 'enable', 'auto') + # verify the change is applied by reading the system key + # not an elegant way, may change later + enable_flag = read_system_key('\\xff\\x02/throttledTags/autoThrottlingEnabled') + assert enable_flag == "`1'" + run_fdbcli_command('throttle', 'disable', 'auto') + enable_flag = read_system_key('\\xff\\x02/throttledTags/autoThrottlingEnabled') + # verify disabled + assert enable_flag == "`0'" + # TODO : test manual throttling, not easy to do now + if __name__ == '__main__': # fdbcli_tests.py assert len(sys.argv) == 4, "Please pass arguments: " @@ -420,6 +446,7 @@ if __name__ == '__main__': setclass() suspend() transaction() + throttle() else: assert process_number > 1, "Process number should be positive" coordinators() From e1ec5f9aa4b989ef379a6dacff527d132fdf53fd Mon Sep 17 00:00:00 2001 From: Markus Pilman Date: Tue, 27 Jul 2021 11:38:25 -0600 Subject: [PATCH 127/225] Fix bug where tests wouldn't be added to correctness package --- cmake/AddFdbTest.cmake | 49 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index 53fed78339..8a4f638380 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -62,9 +62,6 @@ function(add_fdb_test) set(options UNIT IGNORE) set(oneValueArgs TEST_NAME TIMEOUT) set(multiValueArgs TEST_FILES) - if (NOT ENABLE_SIMULATION_TESTS) - return() - endif() cmake_parse_arguments(ADD_FDB_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") set(this_test_timeout ${ADD_FDB_TEST_TIMEOUT}) if(NOT this_test_timeout) @@ -125,28 +122,30 @@ function(add_fdb_test) set(VALGRIND_OPTION "--use-valgrind") endif() list(TRANSFORM ADD_FDB_TEST_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") - add_test(NAME ${test_name} - COMMAND $ ${TestRunner} - -n ${test_name} - -b ${PROJECT_BINARY_DIR} - -t ${test_type} - -O ${OLD_FDBSERVER_BINARY} - --crash - --aggregate-traces ${TEST_AGGREGATE_TRACES} - --log-format ${TEST_LOG_FORMAT} - --keep-logs ${TEST_KEEP_LOGS} - --keep-simdirs ${TEST_KEEP_SIMDIR} - --seed ${SEED} - --test-number ${assigned_id} - ${BUGGIFY_OPTION} - ${VALGRIND_OPTION} - ${ADD_FDB_TEST_TEST_FILES} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) - set_tests_properties("${test_name}" PROPERTIES ENVIRONMENT UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1) - get_filename_component(test_dir_full ${first_file} DIRECTORY) - if(NOT ${test_dir_full} STREQUAL "") - get_filename_component(test_dir ${test_dir_full} NAME) - set_tests_properties(${test_name} PROPERTIES TIMEOUT ${this_test_timeout} LABELS "${test_dir}") + if (ENABLE_SIMULATION_TESTS) + add_test(NAME ${test_name} + COMMAND $ ${TestRunner} + -n ${test_name} + -b ${PROJECT_BINARY_DIR} + -t ${test_type} + -O ${OLD_FDBSERVER_BINARY} + --crash + --aggregate-traces ${TEST_AGGREGATE_TRACES} + --log-format ${TEST_LOG_FORMAT} + --keep-logs ${TEST_KEEP_LOGS} + --keep-simdirs ${TEST_KEEP_SIMDIR} + --seed ${SEED} + --test-number ${assigned_id} + ${BUGGIFY_OPTION} + ${VALGRIND_OPTION} + ${ADD_FDB_TEST_TEST_FILES} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + set_tests_properties("${test_name}" PROPERTIES ENVIRONMENT UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1) + get_filename_component(test_dir_full ${first_file} DIRECTORY) + if(NOT ${test_dir_full} STREQUAL "") + get_filename_component(test_dir ${test_dir_full} NAME) + set_tests_properties(${test_name} PROPERTIES TIMEOUT ${this_test_timeout} LABELS "${test_dir}") + endif() endif() # set variables used for generating test packages set(TEST_NAMES ${TEST_NAMES} ${test_name} PARENT_SCOPE) From d49bd6807ff991c62435217d0971d9141f0fc60e Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Tue, 27 Jul 2021 17:51:57 +0000 Subject: [PATCH 128/225] Fix a comment typo in safeThreadFutureToFuture --- flow/ThreadHelper.actor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index 6e2569ed0e..60ee7c2548 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -574,7 +574,7 @@ private: void* userdata; }; -// The underlying actor that converts ThreadFuture from Future +// The underlying actor that converts ThreadFuture to Future // Note: should be used from main thread // The cancellation here works both way // If the underlying "threadFuture" is cancelled, this actor will get actor_cancelled. From 28128d79b11c28f6fde84e8d0a587cc853f2bf31 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Tue, 27 Jul 2021 17:58:11 +0000 Subject: [PATCH 129/225] Refactor throttle command --- fdbcli/CMakeLists.txt | 1 + fdbcli/ThrottleCommand.actor.cpp | 645 +++++++++++++++++++++++++++++++ fdbcli/fdbcli.actor.cpp | 299 +------------- fdbcli/fdbcli.actor.h | 2 + 4 files changed, 651 insertions(+), 296 deletions(-) create mode 100644 fdbcli/ThrottleCommand.actor.cpp diff --git a/fdbcli/CMakeLists.txt b/fdbcli/CMakeLists.txt index 7b14ebd6a9..7e43f57c31 100644 --- a/fdbcli/CMakeLists.txt +++ b/fdbcli/CMakeLists.txt @@ -8,6 +8,7 @@ set(FDBCLI_SRCS ForceRecoveryWithDataLossCommand.actor.cpp MaintenanceCommand.actor.cpp SnapshotCommand.actor.cpp + ThrottleCommand.actor.cpp Util.cpp linenoise/linenoise.h) diff --git a/fdbcli/ThrottleCommand.actor.cpp b/fdbcli/ThrottleCommand.actor.cpp new file mode 100644 index 0000000000..7692c17b69 --- /dev/null +++ b/fdbcli/ThrottleCommand.actor.cpp @@ -0,0 +1,645 @@ +/* + * ThrottleCommand.actor.cpp + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2021 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. + */ + +#include "fdbcli/fdbcli.actor.h" + +#include "fdbclient/IClientApi.h" +#include "fdbclient/TagThrottle.h" +#include "fdbclient/Knobs.h" +#include "fdbclient/SystemData.h" +#include "fdbclient/CommitTransaction.h" + +#include "flow/Arena.h" +#include "flow/FastRef.h" +#include "flow/ThreadHelper.actor.h" +#include "flow/genericactors.actor.h" +#include "flow/actorcompiler.h" // This must be the last #include. + +namespace { + +// Helper functions copied from TagThrottle.actor.cpp +// The only difference is transactions are changed to go through MultiversionTransaction, +// instead of the native Transaction(i.e., RYWTransaction) + +ACTOR Future getValidAutoEnabled(Reference tr) { + state bool result; + loop { + Optional value = wait(safeThreadFutureToFuture(tr->get(tagThrottleAutoEnabledKey))); + if (!value.present()) { + tr->reset(); + wait(delay(CLIENT_KNOBS->DEFAULT_BACKOFF)); + continue; + } else if (value.get() == LiteralStringRef("1")) { + result = true; + } else if (value.get() == LiteralStringRef("0")) { + result = false; + } else { + TraceEvent(SevWarnAlways, "InvalidAutoTagThrottlingValue").detail("Value", value.get()); + tr->reset(); + wait(delay(CLIENT_KNOBS->DEFAULT_BACKOFF)); + continue; + } + return result; + }; +} + +ACTOR Future> getThrottledTags(Reference db, + int limit, + bool containsRecommend = false) { + state Reference tr = db->createTransaction(); + state bool reportAuto = containsRecommend; + loop { + tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS); + try { + if (!containsRecommend) { + wait(store(reportAuto, getValidAutoEnabled(tr))); + } + state ThreadFuture f = tr->getRange( + reportAuto ? tagThrottleKeys : KeyRangeRef(tagThrottleKeysPrefix, tagThrottleAutoKeysPrefix), limit); + RangeResult throttles = wait(safeThreadFutureToFuture(f)); + std::vector results; + for (auto throttle : throttles) { + results.push_back(TagThrottleInfo(TagThrottleKey::fromKey(throttle.key), + TagThrottleValue::fromValue(throttle.value))); + } + return results; + } catch (Error& e) { + wait(safeThreadFutureToFuture(tr->onError(e))); + } + } +} + +ACTOR Future> getRecommendedTags(Reference db, int limit) { + state Reference tr = db->createTransaction(); + loop { + tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS); + try { + bool enableAuto = wait(getValidAutoEnabled(tr)); + if (enableAuto) { + return std::vector(); + } + state ThreadFuture f = + tr->getRange(KeyRangeRef(tagThrottleAutoKeysPrefix, tagThrottleKeys.end), limit); + RangeResult throttles = wait(safeThreadFutureToFuture(f)); + std::vector results; + for (auto throttle : throttles) { + results.push_back(TagThrottleInfo(TagThrottleKey::fromKey(throttle.key), + TagThrottleValue::fromValue(throttle.value))); + } + return results; + } catch (Error& e) { + wait(safeThreadFutureToFuture(tr->onError(e))); + } + } +} + +ACTOR Future updateThrottleCount(Reference tr, int64_t delta) { + state ThreadFuture> countVal = tr->get(tagThrottleCountKey); + state ThreadFuture> limitVal = tr->get(tagThrottleLimitKey); + + wait(success(safeThreadFutureToFuture(countVal)) && success(safeThreadFutureToFuture(limitVal))); + + int64_t count = 0; + int64_t limit = 0; + + if (countVal.get().present()) { + BinaryReader reader(countVal.get().get(), Unversioned()); + reader >> count; + } + + if (limitVal.get().present()) { + BinaryReader reader(limitVal.get().get(), Unversioned()); + reader >> limit; + } + + count += delta; + + if (count > limit) { + throw too_many_tag_throttles(); + } + + BinaryWriter writer(Unversioned()); + writer << count; + + tr->set(tagThrottleCountKey, writer.toValue()); + return Void(); +} + +void signalThrottleChange(Reference tr) { + tr->atomicOp( + tagThrottleSignalKey, LiteralStringRef("XXXXXXXXXX\x00\x00\x00\x00"), MutationRef::SetVersionstampedValue); +} + +ACTOR Future throttleTags(Reference db, + TagSet tags, + double tpsRate, + double initialDuration, + TagThrottleType throttleType, + TransactionPriority priority, + Optional expirationTime = Optional(), + Optional reason = Optional()) { + state Reference tr = db->createTransaction(); + state Key key = TagThrottleKey(tags, throttleType, priority).toKey(); + + ASSERT(initialDuration > 0); + + if (throttleType == TagThrottleType::MANUAL) { + reason = TagThrottledReason::MANUAL; + } + TagThrottleValue throttle(tpsRate, + expirationTime.present() ? expirationTime.get() : 0, + initialDuration, + reason.present() ? reason.get() : TagThrottledReason::UNSET); + BinaryWriter wr(IncludeVersion(ProtocolVersion::withTagThrottleValueReason())); + wr << throttle; + state Value value = wr.toValue(); + + loop { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + try { + if (throttleType == TagThrottleType::MANUAL) { + Optional oldThrottle = wait(safeThreadFutureToFuture(tr->get(key))); + if (!oldThrottle.present()) { + wait(updateThrottleCount(tr, 1)); + } + } + + tr->set(key, value); + + if (throttleType == TagThrottleType::MANUAL) { + signalThrottleChange(tr); + } + + wait(safeThreadFutureToFuture(tr->commit())); + return Void(); + } catch (Error& e) { + wait(safeThreadFutureToFuture(tr->onError(e))); + } + } +} + +ACTOR Future unthrottleTags(Reference db, + TagSet tags, + Optional throttleType, + Optional priority) { + state Reference tr = db->createTransaction(); + + state std::vector keys; + for (auto p : allTransactionPriorities) { + if (!priority.present() || priority.get() == p) { + if (!throttleType.present() || throttleType.get() == TagThrottleType::AUTO) { + keys.push_back(TagThrottleKey(tags, TagThrottleType::AUTO, p).toKey()); + } + if (!throttleType.present() || throttleType.get() == TagThrottleType::MANUAL) { + keys.push_back(TagThrottleKey(tags, TagThrottleType::MANUAL, p).toKey()); + } + } + } + + state bool removed = false; + + loop { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + try { + state std::vector>> values; + values.reserve(keys.size()); + for (auto key : keys) { + values.push_back(safeThreadFutureToFuture(tr->get(key))); + } + + wait(waitForAll(values)); + + int delta = 0; + for (int i = 0; i < values.size(); ++i) { + if (values[i].get().present()) { + if (TagThrottleKey::fromKey(keys[i]).throttleType == TagThrottleType::MANUAL) { + delta -= 1; + } + + tr->clear(keys[i]); + + // Report that we are removing this tag if we ever see it present. + // This protects us from getting confused if the transaction is maybe committed. + // It's ok if someone else actually ends up removing this tag at the same time + // and we aren't the ones to actually do it. + removed = true; + } + } + + if (delta != 0) { + wait(updateThrottleCount(tr, delta)); + } + if (removed) { + signalThrottleChange(tr); + wait(safeThreadFutureToFuture(tr->commit())); + } + + return removed; + } catch (Error& e) { + wait(safeThreadFutureToFuture(tr->onError(e))); + } + } +} + +ACTOR Future enableAuto(Reference db, bool enabled) { + state Reference tr = db->createTransaction(); + + loop { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + try { + Optional value = wait(safeThreadFutureToFuture(tr->get(tagThrottleAutoEnabledKey))); + if (!value.present() || (enabled && value.get() != LiteralStringRef("1")) || + (!enabled && value.get() != LiteralStringRef("0"))) { + tr->set(tagThrottleAutoEnabledKey, LiteralStringRef(enabled ? "1" : "0")); + signalThrottleChange(tr); + + wait(safeThreadFutureToFuture(tr->commit())); + } + return Void(); + } catch (Error& e) { + wait(safeThreadFutureToFuture(tr->onError(e))); + } + } +} + +ACTOR Future unthrottleMatchingThrottles(Reference db, + KeyRef beginKey, + KeyRef endKey, + Optional priority, + bool onlyExpiredThrottles) { + state Reference tr = db->createTransaction(); + + state KeySelector begin = firstGreaterOrEqual(beginKey); + state KeySelector end = firstGreaterOrEqual(endKey); + + state bool removed = false; + + loop { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + try { + // holds memory of the RangeResult + state ThreadFuture f = tr->getRange(begin, end, 1000); + state RangeResult tags = wait(safeThreadFutureToFuture(f)); + state uint64_t unthrottledTags = 0; + uint64_t manualUnthrottledTags = 0; + for (auto tag : tags) { + if (onlyExpiredThrottles) { + double expirationTime = TagThrottleValue::fromValue(tag.value).expirationTime; + if (expirationTime == 0 || expirationTime > now()) { + continue; + } + } + + TagThrottleKey key = TagThrottleKey::fromKey(tag.key); + if (priority.present() && key.priority != priority.get()) { + continue; + } + + if (key.throttleType == TagThrottleType::MANUAL) { + ++manualUnthrottledTags; + } + + removed = true; + tr->clear(tag.key); + unthrottledTags++; + } + + if (manualUnthrottledTags > 0) { + wait(updateThrottleCount(tr, -manualUnthrottledTags)); + } + + if (unthrottledTags > 0) { + signalThrottleChange(tr); + } + + wait(safeThreadFutureToFuture(tr->commit())); + + if (!tags.more) { + return removed; + } + + ASSERT(tags.size() > 0); + begin = KeySelector(firstGreaterThan(tags[tags.size() - 1].key), tags.arena()); + } catch (Error& e) { + wait(safeThreadFutureToFuture(tr->onError(e))); + } + } +} + +Future unthrottleAll(Reference db, + Optional tagThrottleType, + Optional priority) { + KeyRef begin = tagThrottleKeys.begin; + KeyRef end = tagThrottleKeys.end; + + if (tagThrottleType.present() && tagThrottleType == TagThrottleType::AUTO) { + begin = tagThrottleAutoKeysPrefix; + } else if (tagThrottleType.present() && tagThrottleType == TagThrottleType::MANUAL) { + end = tagThrottleAutoKeysPrefix; + } + + return unthrottleMatchingThrottles(db, begin, end, priority, false); +} + +} // namespace + +namespace fdb_cli { + +ACTOR Future throttleCommandActor(Reference db, std::vector tokens) { + + if (tokens.size() == 1) { + printUsage(tokens[0]); + return false; + } else if (tokencmp(tokens[1], "list")) { + if (tokens.size() > 4) { + printf("Usage: throttle list [throttled|recommended|all] [LIMIT]\n"); + printf("\n"); + printf("Lists tags that are currently throttled.\n"); + printf("The default LIMIT is 100 tags.\n"); + return false; + } + + state bool reportThrottled = true; + state bool reportRecommended = false; + if (tokens.size() >= 3) { + if (tokencmp(tokens[2], "recommended")) { + reportThrottled = false; + reportRecommended = true; + } else if (tokencmp(tokens[2], "all")) { + reportThrottled = true; + reportRecommended = true; + } else if (!tokencmp(tokens[2], "throttled")) { + printf("ERROR: failed to parse `%s'.\n", printable(tokens[2]).c_str()); + return false; + } + } + + state int throttleListLimit = 100; + if (tokens.size() >= 4) { + char* end; + throttleListLimit = std::strtol((const char*)tokens[3].begin(), &end, 10); + if ((tokens.size() > 4 && !std::isspace(*end)) || (tokens.size() == 4 && *end != '\0')) { + fprintf(stderr, "ERROR: failed to parse limit `%s'.\n", printable(tokens[3]).c_str()); + return false; + } + } + + state std::vector tags; + if (reportThrottled && reportRecommended) { + wait(store(tags, getThrottledTags(db, throttleListLimit, true))); + } else if (reportThrottled) { + wait(store(tags, getThrottledTags(db, throttleListLimit))); + } else if (reportRecommended) { + wait(store(tags, getRecommendedTags(db, throttleListLimit))); + } + + bool anyLogged = false; + for (auto itr = tags.begin(); itr != tags.end(); ++itr) { + if (itr->expirationTime > now()) { + if (!anyLogged) { + printf("Throttled tags:\n\n"); + printf(" Rate (txn/s) | Expiration (s) | Priority | Type | Reason |Tag\n"); + printf(" --------------+----------------+-----------+--------+------------+------\n"); + + anyLogged = true; + } + + std::string reasonStr = "unset"; + if (itr->reason == TagThrottledReason::MANUAL) { + reasonStr = "manual"; + } else if (itr->reason == TagThrottledReason::BUSY_WRITE) { + reasonStr = "busy write"; + } else if (itr->reason == TagThrottledReason::BUSY_READ) { + reasonStr = "busy read"; + } + + printf(" %12d | %13ds | %9s | %6s | %10s |%s\n", + (int)(itr->tpsRate), + std::min((int)(itr->expirationTime - now()), (int)(itr->initialDuration)), + transactionPriorityToString(itr->priority, false), + itr->throttleType == TagThrottleType::AUTO ? "auto" : "manual", + reasonStr.c_str(), + itr->tag.toString().c_str()); + } + } + + if (tags.size() == throttleListLimit) { + printf("\nThe tag limit `%d' was reached. Use the [LIMIT] argument to view additional tags.\n", + throttleListLimit); + printf("Usage: throttle list [LIMIT]\n"); + } + if (!anyLogged) { + printf("There are no %s tags\n", reportThrottled ? "throttled" : "recommended"); + } + } else if (tokencmp(tokens[1], "on")) { + if (tokens.size() < 4 || !tokencmp(tokens[2], "tag") || tokens.size() > 7) { + printf("Usage: throttle on tag [RATE] [DURATION] [PRIORITY]\n"); + printf("\n"); + printf("Enables throttling for transactions with the specified tag.\n"); + printf("An optional transactions per second rate can be specified (default 0).\n"); + printf("An optional duration can be specified, which must include a time suffix (s, m, h, " + "d) (default 1h).\n"); + printf("An optional priority can be specified. Choices are `default', `immediate', and " + "`batch' (default `default').\n"); + return false; + } + + double tpsRate = 0.0; + uint64_t duration = 3600; + TransactionPriority priority = TransactionPriority::DEFAULT; + + if (tokens.size() >= 5) { + char* end; + tpsRate = std::strtod((const char*)tokens[4].begin(), &end); + if ((tokens.size() > 5 && !std::isspace(*end)) || (tokens.size() == 5 && *end != '\0')) { + fprintf(stderr, "ERROR: failed to parse rate `%s'.\n", printable(tokens[4]).c_str()); + return false; + } + if (tpsRate < 0) { + fprintf(stderr, "ERROR: rate cannot be negative `%f'\n", tpsRate); + return false; + } + } + if (tokens.size() == 6) { + Optional parsedDuration = parseDuration(tokens[5].toString()); + if (!parsedDuration.present()) { + fprintf(stderr, "ERROR: failed to parse duration `%s'.\n", printable(tokens[5]).c_str()); + return false; + } + duration = parsedDuration.get(); + + if (duration == 0) { + fprintf(stderr, "ERROR: throttle duration cannot be 0\n"); + return false; + } + } + if (tokens.size() == 7) { + if (tokens[6] == LiteralStringRef("default")) { + priority = TransactionPriority::DEFAULT; + } else if (tokens[6] == LiteralStringRef("immediate")) { + priority = TransactionPriority::IMMEDIATE; + } else if (tokens[6] == LiteralStringRef("batch")) { + priority = TransactionPriority::BATCH; + } else { + fprintf(stderr, + "ERROR: unrecognized priority `%s'. Must be one of `default',\n `immediate', " + "or `batch'.\n", + tokens[6].toString().c_str()); + return false; + } + } + + TagSet tags; + tags.addTag(tokens[3]); + + wait(throttleTags(db, tags, tpsRate, duration, TagThrottleType::MANUAL, priority)); + printf("Tag `%s' has been throttled\n", tokens[3].toString().c_str()); + } else if (tokencmp(tokens[1], "off")) { + int nextIndex = 2; + TagSet tags; + bool throttleTypeSpecified = false; + bool is_error = false; + Optional throttleType = TagThrottleType::MANUAL; + Optional priority; + + if (tokens.size() == 2) { + is_error = true; + } + + while (nextIndex < tokens.size() && !is_error) { + if (tokencmp(tokens[nextIndex], "all")) { + if (throttleTypeSpecified) { + is_error = true; + continue; + } + throttleTypeSpecified = true; + throttleType = Optional(); + ++nextIndex; + } else if (tokencmp(tokens[nextIndex], "auto")) { + if (throttleTypeSpecified) { + is_error = true; + continue; + } + throttleTypeSpecified = true; + throttleType = TagThrottleType::AUTO; + ++nextIndex; + } else if (tokencmp(tokens[nextIndex], "manual")) { + if (throttleTypeSpecified) { + is_error = true; + continue; + } + throttleTypeSpecified = true; + throttleType = TagThrottleType::MANUAL; + ++nextIndex; + } else if (tokencmp(tokens[nextIndex], "default")) { + if (priority.present()) { + is_error = true; + continue; + } + priority = TransactionPriority::DEFAULT; + ++nextIndex; + } else if (tokencmp(tokens[nextIndex], "immediate")) { + if (priority.present()) { + is_error = true; + continue; + } + priority = TransactionPriority::IMMEDIATE; + ++nextIndex; + } else if (tokencmp(tokens[nextIndex], "batch")) { + if (priority.present()) { + is_error = true; + continue; + } + priority = TransactionPriority::BATCH; + ++nextIndex; + } else if (tokencmp(tokens[nextIndex], "tag")) { + if (tags.size() > 0 || nextIndex == tokens.size() - 1) { + is_error = true; + continue; + } + tags.addTag(tokens[nextIndex + 1]); + nextIndex += 2; + } + } + + if (!is_error) { + state const char* throttleTypeString = + !throttleType.present() ? "" : (throttleType.get() == TagThrottleType::AUTO ? "auto-" : "manually "); + state std::string priorityString = + priority.present() ? format(" at %s priority", transactionPriorityToString(priority.get(), false)) : ""; + + if (tags.size() > 0) { + bool success = wait(unthrottleTags(db, tags, throttleType, priority)); + if (success) { + printf("Unthrottled tag `%s'%s\n", tokens[3].toString().c_str(), priorityString.c_str()); + } else { + printf("Tag `%s' was not %sthrottled%s\n", + tokens[3].toString().c_str(), + throttleTypeString, + priorityString.c_str()); + } + } else { + bool unthrottled = wait(unthrottleAll(db, throttleType, priority)); + if (unthrottled) { + printf("Unthrottled all %sthrottled tags%s\n", throttleTypeString, priorityString.c_str()); + } else { + printf("There were no tags being %sthrottled%s\n", throttleTypeString, priorityString.c_str()); + } + } + } else { + printf("Usage: throttle off [all|auto|manual] [tag ] [PRIORITY]\n"); + printf("\n"); + printf("Disables throttling for throttles matching the specified filters. At least one " + "filter must be used.\n\n"); + printf("An optional qualifier `all', `auto', or `manual' can be used to specify the type " + "of throttle\n"); + printf("affected. `all' targets all throttles, `auto' targets those created by the " + "cluster, and\n"); + printf("`manual' targets those created manually (default `manual').\n\n"); + printf("The `tag' filter can be use to turn off only a specific tag.\n\n"); + printf("The priority filter can be used to turn off only throttles at specific priorities. " + "Choices are\n"); + printf("`default', `immediate', or `batch'. By default, all priorities are targeted.\n"); + } + } else if (tokencmp(tokens[1], "enable") || tokencmp(tokens[1], "disable")) { + if (tokens.size() != 3 || !tokencmp(tokens[2], "auto")) { + printf("Usage: throttle auto\n"); + printf("\n"); + printf("Enables or disable automatic tag throttling.\n"); + return false; + } + state bool autoTagThrottlingEnabled = tokencmp(tokens[1], "enable"); + wait(enableAuto(db, autoTagThrottlingEnabled)); + printf("Automatic tag throttling has been %s\n", autoTagThrottlingEnabled ? "enabled" : "disabled"); + } else { + printUsage(tokens[0]); + return false; + } + + return true; +} + +CommandFactory throttleFactory( + "throttle", + CommandHelp("throttle [ARGS]", + "view and control throttled tags", + "Use `on' and `off' to manually throttle or unthrottle tags. Use `enable auto' or `disable auto' " + "to enable or disable automatic tag throttling. Use `list' to print the list of throttled tags.\n")); +} // namespace fdb_cli diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index bef9e3d43c..d298d79382 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -648,11 +648,6 @@ void initHelp() { "namespace for all the profiling-related commands.", "Different types support different actions. Run `profile` to get a list of " "types, and iteratively explore the help.\n"); - helpMap["throttle"] = - CommandHelp("throttle [ARGS]", - "view and control throttled tags", - "Use `on' and `off' to manually throttle or unthrottle tags. Use `enable auto' or `disable auto' " - "to enable or disable automatic tag throttling. Use `list' to print the list of throttled tags.\n"); helpMap["cache_range"] = CommandHelp( "cache_range ", "Mark a key range to add to or remove from storage caches.", @@ -4494,300 +4489,12 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { } if (tokencmp(tokens[0], "throttle")) { - if (tokens.size() == 1) { - printUsage(tokens[0]); + bool _result = wait(throttleCommandActor(db2, tokens)); + if (!_result) is_error = true; - continue; - } else if (tokencmp(tokens[1], "list")) { - if (tokens.size() > 4) { - printf("Usage: throttle list [throttled|recommended|all] [LIMIT]\n"); - printf("\n"); - printf("Lists tags that are currently throttled.\n"); - printf("The default LIMIT is 100 tags.\n"); - is_error = true; - continue; - } - - state bool reportThrottled = true; - state bool reportRecommended = false; - if (tokens.size() >= 3) { - if (tokencmp(tokens[2], "recommended")) { - reportThrottled = false; - reportRecommended = true; - } else if (tokencmp(tokens[2], "all")) { - reportThrottled = true; - reportRecommended = true; - } else if (!tokencmp(tokens[2], "throttled")) { - printf("ERROR: failed to parse `%s'.\n", printable(tokens[2]).c_str()); - is_error = true; - continue; - } - } - - state int throttleListLimit = 100; - if (tokens.size() >= 4) { - char* end; - throttleListLimit = std::strtol((const char*)tokens[3].begin(), &end, 10); - if ((tokens.size() > 4 && !std::isspace(*end)) || (tokens.size() == 4 && *end != '\0')) { - fprintf(stderr, "ERROR: failed to parse limit `%s'.\n", printable(tokens[3]).c_str()); - is_error = true; - continue; - } - } - - state std::vector tags; - if (reportThrottled && reportRecommended) { - wait(store(tags, ThrottleApi::getThrottledTags(db, throttleListLimit, true))); - } else if (reportThrottled) { - wait(store(tags, ThrottleApi::getThrottledTags(db, throttleListLimit))); - } else if (reportRecommended) { - wait(store(tags, ThrottleApi::getRecommendedTags(db, throttleListLimit))); - } - - bool anyLogged = false; - for (auto itr = tags.begin(); itr != tags.end(); ++itr) { - if (itr->expirationTime > now()) { - if (!anyLogged) { - printf("Throttled tags:\n\n"); - printf(" Rate (txn/s) | Expiration (s) | Priority | Type | Reason |Tag\n"); - printf( - " --------------+----------------+-----------+--------+------------+------\n"); - - anyLogged = true; - } - - std::string reasonStr = "unset"; - if (itr->reason == TagThrottledReason::MANUAL) { - reasonStr = "manual"; - } else if (itr->reason == TagThrottledReason::BUSY_WRITE) { - reasonStr = "busy write"; - } else if (itr->reason == TagThrottledReason::BUSY_READ) { - reasonStr = "busy read"; - } - - printf(" %12d | %13ds | %9s | %6s | %10s |%s\n", - (int)(itr->tpsRate), - std::min((int)(itr->expirationTime - now()), (int)(itr->initialDuration)), - transactionPriorityToString(itr->priority, false), - itr->throttleType == TagThrottleType::AUTO ? "auto" : "manual", - reasonStr.c_str(), - itr->tag.toString().c_str()); - } - } - - if (tags.size() == throttleListLimit) { - printf( - "\nThe tag limit `%d' was reached. Use the [LIMIT] argument to view additional tags.\n", - throttleListLimit); - printf("Usage: throttle list [LIMIT]\n"); - } - if (!anyLogged) { - printf("There are no %s tags\n", reportThrottled ? "throttled" : "recommended"); - } - } else if (tokencmp(tokens[1], "on")) { - if (tokens.size() < 4 || !tokencmp(tokens[2], "tag") || tokens.size() > 7) { - printf("Usage: throttle on tag [RATE] [DURATION] [PRIORITY]\n"); - printf("\n"); - printf("Enables throttling for transactions with the specified tag.\n"); - printf("An optional transactions per second rate can be specified (default 0).\n"); - printf("An optional duration can be specified, which must include a time suffix (s, m, h, " - "d) (default 1h).\n"); - printf("An optional priority can be specified. Choices are `default', `immediate', and " - "`batch' (default `default').\n"); - is_error = true; - continue; - } - - double tpsRate = 0.0; - uint64_t duration = 3600; - TransactionPriority priority = TransactionPriority::DEFAULT; - - if (tokens.size() >= 5) { - char* end; - tpsRate = std::strtod((const char*)tokens[4].begin(), &end); - if ((tokens.size() > 5 && !std::isspace(*end)) || (tokens.size() == 5 && *end != '\0')) { - fprintf(stderr, "ERROR: failed to parse rate `%s'.\n", printable(tokens[4]).c_str()); - is_error = true; - continue; - } - if (tpsRate < 0) { - fprintf(stderr, "ERROR: rate cannot be negative `%f'\n", tpsRate); - is_error = true; - continue; - } - } - if (tokens.size() == 6) { - Optional parsedDuration = parseDuration(tokens[5].toString()); - if (!parsedDuration.present()) { - fprintf( - stderr, "ERROR: failed to parse duration `%s'.\n", printable(tokens[5]).c_str()); - is_error = true; - continue; - } - duration = parsedDuration.get(); - - if (duration == 0) { - fprintf(stderr, "ERROR: throttle duration cannot be 0\n"); - is_error = true; - continue; - } - } - if (tokens.size() == 7) { - if (tokens[6] == LiteralStringRef("default")) { - priority = TransactionPriority::DEFAULT; - } else if (tokens[6] == LiteralStringRef("immediate")) { - priority = TransactionPriority::IMMEDIATE; - } else if (tokens[6] == LiteralStringRef("batch")) { - priority = TransactionPriority::BATCH; - } else { - fprintf(stderr, - "ERROR: unrecognized priority `%s'. Must be one of `default',\n `immediate', " - "or `batch'.\n", - tokens[6].toString().c_str()); - is_error = true; - continue; - } - } - - TagSet tags; - tags.addTag(tokens[3]); - - wait(ThrottleApi::throttleTags(db, tags, tpsRate, duration, TagThrottleType::MANUAL, priority)); - printf("Tag `%s' has been throttled\n", tokens[3].toString().c_str()); - } else if (tokencmp(tokens[1], "off")) { - int nextIndex = 2; - TagSet tags; - bool throttleTypeSpecified = false; - Optional throttleType = TagThrottleType::MANUAL; - Optional priority; - - if (tokens.size() == 2) { - is_error = true; - } - - while (nextIndex < tokens.size() && !is_error) { - if (tokencmp(tokens[nextIndex], "all")) { - if (throttleTypeSpecified) { - is_error = true; - continue; - } - throttleTypeSpecified = true; - throttleType = Optional(); - ++nextIndex; - } else if (tokencmp(tokens[nextIndex], "auto")) { - if (throttleTypeSpecified) { - is_error = true; - continue; - } - throttleTypeSpecified = true; - throttleType = TagThrottleType::AUTO; - ++nextIndex; - } else if (tokencmp(tokens[nextIndex], "manual")) { - if (throttleTypeSpecified) { - is_error = true; - continue; - } - throttleTypeSpecified = true; - throttleType = TagThrottleType::MANUAL; - ++nextIndex; - } else if (tokencmp(tokens[nextIndex], "default")) { - if (priority.present()) { - is_error = true; - continue; - } - priority = TransactionPriority::DEFAULT; - ++nextIndex; - } else if (tokencmp(tokens[nextIndex], "immediate")) { - if (priority.present()) { - is_error = true; - continue; - } - priority = TransactionPriority::IMMEDIATE; - ++nextIndex; - } else if (tokencmp(tokens[nextIndex], "batch")) { - if (priority.present()) { - is_error = true; - continue; - } - priority = TransactionPriority::BATCH; - ++nextIndex; - } else if (tokencmp(tokens[nextIndex], "tag")) { - if (tags.size() > 0 || nextIndex == tokens.size() - 1) { - is_error = true; - continue; - } - tags.addTag(tokens[nextIndex + 1]); - nextIndex += 2; - } - } - - if (!is_error) { - state const char* throttleTypeString = - !throttleType.present() - ? "" - : (throttleType.get() == TagThrottleType::AUTO ? "auto-" : "manually "); - state std::string priorityString = - priority.present() - ? format(" at %s priority", transactionPriorityToString(priority.get(), false)) - : ""; - - if (tags.size() > 0) { - bool success = wait(ThrottleApi::unthrottleTags(db, tags, throttleType, priority)); - if (success) { - printf("Unthrottled tag `%s'%s\n", - tokens[3].toString().c_str(), - priorityString.c_str()); - } else { - printf("Tag `%s' was not %sthrottled%s\n", - tokens[3].toString().c_str(), - throttleTypeString, - priorityString.c_str()); - } - } else { - bool unthrottled = wait(ThrottleApi::unthrottleAll(db, throttleType, priority)); - if (unthrottled) { - printf("Unthrottled all %sthrottled tags%s\n", - throttleTypeString, - priorityString.c_str()); - } else { - printf("There were no tags being %sthrottled%s\n", - throttleTypeString, - priorityString.c_str()); - } - } - } else { - printf("Usage: throttle off [all|auto|manual] [tag ] [PRIORITY]\n"); - printf("\n"); - printf("Disables throttling for throttles matching the specified filters. At least one " - "filter must be used.\n\n"); - printf("An optional qualifier `all', `auto', or `manual' can be used to specify the type " - "of throttle\n"); - printf("affected. `all' targets all throttles, `auto' targets those created by the " - "cluster, and\n"); - printf("`manual' targets those created manually (default `manual').\n\n"); - printf("The `tag' filter can be use to turn off only a specific tag.\n\n"); - printf("The priority filter can be used to turn off only throttles at specific priorities. " - "Choices are\n"); - printf("`default', `immediate', or `batch'. By default, all priorities are targeted.\n"); - } - } else if (tokencmp(tokens[1], "enable") || tokencmp(tokens[1], "disable")) { - if (tokens.size() != 3 || !tokencmp(tokens[2], "auto")) { - printf("Usage: throttle auto\n"); - printf("\n"); - printf("Enables or disable automatic tag throttling.\n"); - is_error = true; - continue; - } - state bool autoTagThrottlingEnabled = tokencmp(tokens[1], "enable"); - wait(ThrottleApi::enableAuto(db, autoTagThrottlingEnabled)); - printf("Automatic tag throttling has been %s\n", - autoTagThrottlingEnabled ? "enabled" : "disabled"); - } else { - printUsage(tokens[0]); - is_error = true; - } continue; } + if (tokencmp(tokens[0], "cache_range")) { if (tokens.size() != 4) { printUsage(tokens[0]); diff --git a/fdbcli/fdbcli.actor.h b/fdbcli/fdbcli.actor.h index 6d69f2879e..8ab228ea6d 100644 --- a/fdbcli/fdbcli.actor.h +++ b/fdbcli/fdbcli.actor.h @@ -83,6 +83,8 @@ ACTOR Future forceRecoveryWithDataLossCommandActor(Reference db ACTOR Future maintenanceCommandActor(Reference db, std::vector tokens); // snapshot command ACTOR Future snapshotCommandActor(Reference db, std::vector tokens); +// throttle command +ACTOR Future throttleCommandActor(Reference db, std::vector tokens); } // namespace fdb_cli From d7fb3da607e7d93d0090209bd577cc90a7b7803f Mon Sep 17 00:00:00 2001 From: Xiaoge Su Date: Tue, 27 Jul 2021 02:00:52 -0700 Subject: [PATCH 130/225] Add libatomic for building FDB using Clang --- flow/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flow/CMakeLists.txt b/flow/CMakeLists.txt index 78d097517f..215fee3cad 100644 --- a/flow/CMakeLists.txt +++ b/flow/CMakeLists.txt @@ -137,6 +137,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") target_link_libraries(flow PUBLIC ${EIO}) endif() endif() + +# For Clang in Linux environment, libatomic is required +if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$") + set (FLOW_LIBS ${FLOW_LIBS} atomic) +endif () + target_link_libraries(flow PRIVATE ${FLOW_LIBS}) if(USE_VALGRIND) target_link_libraries(flow PUBLIC Valgrind) From 256a18e43b324a236d8c132635439ac3e77ef139 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Tue, 27 Jul 2021 12:01:32 -0700 Subject: [PATCH 131/225] Flow transport uses an ordered delay to avoid out of order reply promise stream messages --- fdbrpc/FlowTests.actor.cpp | 2 ++ fdbrpc/FlowTransport.actor.cpp | 6 +++--- fdbrpc/fdbrpc.h | 15 ++++++--------- fdbrpc/sim2.actor.cpp | 10 +++++++--- flow/Net2.actor.cpp | 6 ++++++ flow/flow.h | 3 +++ flow/network.h | 5 ++++- 7 files changed, 31 insertions(+), 16 deletions(-) diff --git a/fdbrpc/FlowTests.actor.cpp b/fdbrpc/FlowTests.actor.cpp index d3cf206c8f..04d6cae700 100644 --- a/fdbrpc/FlowTests.actor.cpp +++ b/fdbrpc/FlowTests.actor.cpp @@ -234,6 +234,8 @@ struct YieldMockNetwork final : INetwork, ReferenceCounted { Future delay(double seconds, TaskPriority taskID) override { return nextTick.getFuture(); } + Future orderedDelay(double seconds, TaskPriority taskID) override { return nextTick.getFuture(); } + Future yield(TaskPriority taskID) override { if (check_yield(taskID)) return delay(0, taskID); diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index 8a6b32df56..e5c5a30632 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -922,9 +922,9 @@ ACTOR static void deliver(TransportData* self, // We want to run the task at the right priority. If the priority is higher than the current priority (which is // ReadSocket) we can just upgrade. Otherwise we'll context switch so that we don't block other tasks that might run // with a higher priority. ReplyPromiseStream needs to guarentee that messages are recieved in the order they were - // sent, so even in the case of local delivery those messages need to skip this delay. - if (priority < TaskPriority::ReadSocket || (priority != TaskPriority::NoDeliverDelay && !inReadSocket)) { - wait(delay(0, priority)); + // sent, so we are using orderedDelay. + if (priority < TaskPriority::ReadSocket || !inReadSocket) { + wait(orderedDelay(0, priority)); } else { g_network->setCurrentTask(priority); } diff --git a/fdbrpc/fdbrpc.h b/fdbrpc/fdbrpc.h index b66773307e..eeac5e9bed 100644 --- a/fdbrpc/fdbrpc.h +++ b/fdbrpc/fdbrpc.h @@ -361,7 +361,7 @@ struct NetNotifiedQueueWithAcknowledgements final : NotifiedQueue, FlowTransport::transport().sendUnreliable( SerializeSource>( AcknowledgementReply(acknowledgements.bytesAcknowledged)), - acknowledgements.getEndpoint(TaskPriority::NoDeliverDelay), + acknowledgements.getEndpoint(TaskPriority::ReadSocket), false); } } @@ -378,7 +378,7 @@ struct NetNotifiedQueueWithAcknowledgements final : NotifiedQueue, acknowledgements.bytesAcknowledged += res.expectedSize(); FlowTransport::transport().sendUnreliable(SerializeSource>( AcknowledgementReply(acknowledgements.bytesAcknowledged)), - acknowledgements.getEndpoint(TaskPriority::NoDeliverDelay), + acknowledgements.getEndpoint(TaskPriority::ReadSocket), false); } return res; @@ -389,13 +389,13 @@ struct NetNotifiedQueueWithAcknowledgements final : NotifiedQueue, // Notify the server that a client is not using this ReplyPromiseStream anymore FlowTransport::transport().sendUnreliable( SerializeSource>(operation_obsolete()), - acknowledgements.getEndpoint(TaskPriority::NoDeliverDelay), + acknowledgements.getEndpoint(TaskPriority::ReadSocket), false); } if (isRemoteEndpoint() && !sentError && !acknowledgements.failures.isReady()) { // The ReplyPromiseStream was cancelled before sending an error, so the storage server must have died FlowTransport::transport().sendUnreliable(SerializeSource>>(broken_promise()), - getEndpoint(TaskPriority::NoDeliverDelay), + getEndpoint(TaskPriority::ReadSocket), false); } } @@ -406,9 +406,6 @@ struct NetNotifiedQueueWithAcknowledgements final : NotifiedQueue, template class ReplyPromiseStream { public: - // The endpoints of a ReplyPromiseStream must be initialized at Task::NoDeliverDelay, because a - // delay(0) in FlowTransport deliver can cause out of order delivery. - // stream.send( request ) // Unreliable at most once delivery: Delivers request unless there is a connection failure (zero or one times) @@ -416,7 +413,7 @@ public: void send(U&& value) const { if (queue->isRemoteEndpoint()) { if (!queue->acknowledgements.getRawEndpoint().isValid()) { - value.acknowledgeToken = queue->acknowledgements.getEndpoint(TaskPriority::NoDeliverDelay).token; + value.acknowledgeToken = queue->acknowledgements.getEndpoint(TaskPriority::ReadSocket).token; } queue->acknowledgements.bytesSent += value.expectedSize(); FlowTransport::transport().sendUnreliable( @@ -477,7 +474,7 @@ public: errors->delPromiseRef(); } - const Endpoint& getEndpoint() const { return queue->getEndpoint(TaskPriority::NoDeliverDelay); } + const Endpoint& getEndpoint() const { return queue->getEndpoint(TaskPriority::ReadSocket); } bool operator==(const ReplyPromiseStream& rhs) const { return queue == rhs.queue; } bool isEmpty() const { return !queue->isReady(); } diff --git a/fdbrpc/sim2.actor.cpp b/fdbrpc/sim2.actor.cpp index fe7ded16e5..2d03d2b08e 100644 --- a/fdbrpc/sim2.actor.cpp +++ b/fdbrpc/sim2.actor.cpp @@ -858,13 +858,17 @@ public: ASSERT(taskID >= TaskPriority::Min && taskID <= TaskPriority::Max); return delay(seconds, taskID, currentProcess); } - Future delay(double seconds, TaskPriority taskID, ProcessInfo* machine) { + Future orderedDelay(double seconds, TaskPriority taskID) override { + ASSERT(taskID >= TaskPriority::Min && taskID <= TaskPriority::Max); + return delay(seconds, taskID, currentProcess, true); + } + Future delay(double seconds, TaskPriority taskID, ProcessInfo* machine, bool ordered = false) { ASSERT(seconds >= -0.0001); seconds = std::max(0.0, seconds); Future f; - if (!currentProcess->rebooting && machine == currentProcess && !currentProcess->shutdownSignal.isSet() && - FLOW_KNOBS->MAX_BUGGIFIED_DELAY > 0 && + if (!ordered && !currentProcess->rebooting && machine == currentProcess && + !currentProcess->shutdownSignal.isSet() && FLOW_KNOBS->MAX_BUGGIFIED_DELAY > 0 && deterministicRandom()->random01() < 0.25) { // FIXME: why doesnt this work when we are changing machines? seconds += FLOW_KNOBS->MAX_BUGGIFIED_DELAY * pow(deterministicRandom()->random01(), 1000.0); } diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index 44572113d4..4a938e126c 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -161,6 +161,7 @@ public: double timer() override { return ::timer(); }; double timer_monotonic() override { return ::timer_monotonic(); }; Future delay(double seconds, TaskPriority taskId) override; + Future orderedDelay(double seconds, TaskPriority taskId) override; Future yield(TaskPriority taskID) override; bool check_yield(TaskPriority taskId) override; TaskPriority getCurrentTask() const override { return currentTaskID; } @@ -1750,6 +1751,11 @@ Future Net2::delay(double seconds, TaskPriority taskId) { return t->promise.getFuture(); } +Future Net2::orderedDelay(double seconds, TaskPriority taskId) { + // The regular delay already provides the required ordering property + return delay(seconds, taskId); +} + void Net2::onMainThread(Promise&& signal, TaskPriority taskID) { if (stopped) return; diff --git a/flow/flow.h b/flow/flow.h index b598f82987..4a08d37b93 100644 --- a/flow/flow.h +++ b/flow/flow.h @@ -1087,6 +1087,9 @@ inline double now() { inline Future delay(double seconds, TaskPriority taskID = TaskPriority::DefaultDelay) { return g_network->delay(seconds, taskID); } +inline Future orderedDelay(double seconds, TaskPriority taskID = TaskPriority::DefaultDelay) { + return g_network->orderedDelay(seconds, taskID); +} inline Future delayUntil(double time, TaskPriority taskID = TaskPriority::DefaultDelay) { return g_network->delay(std::max(0.0, time - g_network->now()), taskID); } diff --git a/flow/network.h b/flow/network.h index 0d0f8a2d34..77d61ca1e8 100644 --- a/flow/network.h +++ b/flow/network.h @@ -45,7 +45,6 @@ enum class TaskPriority { WriteSocket = 10000, PollEIO = 9900, DiskIOComplete = 9150, - NoDeliverDelay = 9100, LoadBalancedEndpoint = 9000, ReadSocket = 9000, AcceptSocket = 8950, @@ -507,6 +506,10 @@ public: virtual Future delay(double seconds, TaskPriority taskID) = 0; // The given future will be set after seconds have elapsed + virtual Future orderedDelay(double seconds, TaskPriority taskID) = 0; + // The given future will be set after seconds have elapsed, delays with the same time and TaskPriority will be + // executed in the order they were issues + virtual Future yield(TaskPriority taskID) = 0; // The given future will be set immediately or after higher-priority tasks have executed From 9031a09772503807627ff073752e472cd7a3b1fd Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 27 Jul 2021 12:02:41 -0700 Subject: [PATCH 132/225] Add debug tracing for BackupContainerAzureBlobStore --- .../BackupContainerAzureBlobStore.actor.cpp | 82 ++++++++++++++----- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 95050752b3..a1cdb1d807 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -27,13 +27,17 @@ namespace { template -T waitAzureFuture(std::future>&& f) { +T waitAzureFuture(std::future>&& f, std::string const& operationName) { auto outcome = f.get(); if (outcome.success()) { return outcome.response(); } else { auto const& err = outcome.error(); - printf("Error from Azure SDK : %s (%d) : %s", err.code_name.c_str(), err.code.c_str(), err.message.c_str()); + printf("(%s) : Error from Azure SDK : %s (%s) : %s", + operationName.c_str(), + err.code_name.c_str(), + err.code.c_str(), + err.message.c_str()); throw backup_error(); } } @@ -60,6 +64,11 @@ public: void addref() override { ReferenceCounted::addref(); } void delref() override { ReferenceCounted::delref(); } Future read(void* data, int length, int64_t offset) override { + TraceEvent(SevDebug, "BCAzureBlobStoreRead") + .detail("Length", length) + .detail("Offset", offset) + .detail("ContainerName", containerName) + .detail("BlobName", blobName); return asyncTaskThread->execAsync([client = this->client, containerName = this->containerName, blobName = this->blobName, @@ -67,7 +76,8 @@ public: length, offset] { std::ostringstream oss(std::ios::out | std::ios::binary); - waitAzureFuture(client->download_blob_to_stream(containerName, blobName, offset, length, oss)); + waitAzureFuture(client->download_blob_to_stream(containerName, blobName, offset, length, oss), + "download_blob_to_stream"); auto str = std::move(oss).str(); memcpy(data, str.c_str(), str.size()); return static_cast(str.size()); @@ -78,9 +88,13 @@ public: Future truncate(int64_t size) override { throw file_not_writable(); } Future sync() override { throw file_not_writable(); } Future size() const override { + TraceEvent(SevDebug, "BCAzureBlobStoreReadFileSize") + .detail("ContainerName", containerName) + .detail("BlobName", blobName); return asyncTaskThread->execAsync( [client = this->client, containerName = this->containerName, blobName = this->blobName] { - auto resp = waitAzureFuture(client->get_blob_properties(containerName, blobName)); + auto resp = + waitAzureFuture(client->get_blob_properties(containerName, blobName), "get_blob_properties"); return static_cast(resp.size); }); } @@ -131,21 +145,33 @@ public: return Void(); } Future sync() override { + TraceEvent(SevDebug, "BCAzureBlobStoreSync") + .detail("Length", buffer.size()) + .detail("ContainerName", containerName) + .detail("BlobName", blobName); auto movedBuffer = std::move(buffer); - buffer.clear(); - return asyncTaskThread->execAsync([client = this->client, - containerName = this->containerName, - blobName = this->blobName, - buffer = std::move(movedBuffer)] { - std::istringstream iss(std::move(buffer)); - waitAzureFuture(client->append_block_from_stream(containerName, blobName, iss)); - return Void(); - }); + buffer = {}; + if (!movedBuffer.empty()) { + return asyncTaskThread->execAsync([client = this->client, + containerName = this->containerName, + blobName = this->blobName, + buffer = std::move(movedBuffer)] { + std::istringstream iss(std::move(buffer)); + waitAzureFuture(client->append_block_from_stream(containerName, blobName, iss), + "append_block_from_stream"); + return Void(); + }); + } + return Void(); } Future size() const override { + TraceEvent(SevDebug, "BCAzureBlobStoreSize") + .detail("ContainerName", containerName) + .detail("BlobName", blobName); return asyncTaskThread->execAsync( [client = this->client, containerName = this->containerName, blobName = this->blobName] { - auto resp = waitAzureFuture(client->get_blob_properties(containerName, blobName)); + auto resp = + waitAzureFuture(client->get_blob_properties(containerName, blobName), "get_blob_properties"); return static_cast(resp.size); }); } @@ -202,9 +228,12 @@ public: } ACTOR static Future> writeFile(BackupContainerAzureBlobStore* self, std::string fileName) { + TraceEvent(SevDebug, "BCAzureBlobStoreCreateWriteFile") + .detail("ContainerName", self->containerName) + .detail("FileName", fileName); wait(self->asyncTaskThread.execAsync( [client = self->client, containerName = self->containerName, fileName = fileName] { - waitAzureFuture(client->create_append_blob(containerName, fileName)); + waitAzureFuture(client->create_append_blob(containerName, fileName), "create_append_blob"); return Void(); })); Reference f = @@ -220,7 +249,7 @@ public: const std::string& path, std::function folderPathFilter, BackupContainerFileSystem::FilesAndSizesT& result) { - auto resp = waitAzureFuture(client->list_blobs_segmented(containerName, "/", "", path)); + auto resp = waitAzureFuture(client->list_blobs_segmented(containerName, "/", "", path), "list_blobs_segmented"); for (const auto& blob : resp.blobs) { if (isDirectory(blob.name) && folderPathFilter(blob.name)) { listFiles(client, containerName, blob.name, folderPathFilter, result); @@ -236,8 +265,12 @@ public: BackupContainerFileSystem::FilesAndSizesT files = wait(self->listFiles()); filesToDelete = files.size(); } + TraceEvent(SevDebug, "BCAzureBlobStoreDeleteContainer") + .detail("FilesToDelete", filesToDelete) + .detail("ContainerName", self->containerName) + .detail("TrackNumDeleted", pNumDeleted != nullptr); wait(self->asyncTaskThread.execAsync([containerName = self->containerName, client = self->client] { - waitAzureFuture(client->delete_container(containerName)); + waitAzureFuture(client->delete_container(containerName), "delete_container"); return Void(); })); if (pNumDeleted) { @@ -249,8 +282,11 @@ public: }; Future BackupContainerAzureBlobStore::blobExists(const std::string& fileName) { + TraceEvent(SevDebug, "BCAzureBlobStoreCheckExists") + .detail("FileName", fileName) + .detail("ContainerName", containerName); return asyncTaskThread.execAsync([client = this->client, containerName = this->containerName, fileName = fileName] { - auto resp = waitAzureFuture(client->get_blob_properties(containerName, fileName)); + auto resp = waitAzureFuture(client->get_blob_properties(containerName, fileName), "get_blob_properties"); return resp.valid(); }); } @@ -282,17 +318,19 @@ void BackupContainerAzureBlobStore::delref() { } Future BackupContainerAzureBlobStore::create() { + TraceEvent(SevDebug, "BCAzureBlobStoreCreateContainer").detail("ContainerName", containerName); Future createContainerFuture = asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { - waitAzureFuture(client->create_container(containerName)); + waitAzureFuture(client->create_container(containerName), "create_container"); return Void(); }); Future encryptionSetupFuture = usesEncryption() ? encryptionSetupComplete() : Void(); return createContainerFuture && encryptionSetupFuture; } Future BackupContainerAzureBlobStore::exists() { + TraceEvent(SevDebug, "BCAzureBlobStoreCheckContainerExists").detail("ContainerName", containerName); return asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { - auto resp = waitAzureFuture(client->get_container_properties(containerName)); + auto resp = waitAzureFuture(client->get_container_properties(containerName), "get_container_properties"); return resp.valid(); }); } @@ -308,6 +346,7 @@ Future> BackupContainerAzureBlobStore::writeFile(const st Future BackupContainerAzureBlobStore::listFiles( const std::string& path, std::function folderPathFilter) { + TraceEvent(SevDebug, "BCAzureBlobStoreListFiles").detail("ContainerName", containerName).detail("Path", path); return asyncTaskThread.execAsync( [client = this->client, containerName = this->containerName, path = path, folderPathFilter = folderPathFilter] { FilesAndSizesT result; @@ -317,6 +356,9 @@ Future BackupContainerAzureBlobStore: } Future BackupContainerAzureBlobStore::deleteFile(const std::string& fileName) { + TraceEvent(SevDebug, "BCAzureBlobStoreDeleteFile") + .detail("ContainerName", containerName) + .detail("FileName", fileName); return asyncTaskThread.execAsync([containerName = this->containerName, fileName = fileName, client = client]() { client->delete_blob(containerName, fileName).wait(); return Void(); From fa6fc0a0f2f753bcd7ec843d976e4f3dd1622a2f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 27 Jul 2021 13:56:38 -0700 Subject: [PATCH 133/225] Bring back optimization that avoids hop to network thread --- flow/ThreadHelper.actor.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index d6c776e992..489ac5a206 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -335,11 +335,16 @@ public: void setCancel(Future&& cf) { cancelFuture = std::move(cf); } virtual void cancel() { - onMainThreadVoid( - [this]() { - this->cancelFuture.cancel(); - this->delref(); - }); + if (isReady()) { + // Avoiding going to the network thread here is an important optimization. Without this we see lower + // throughput for e.g. GRV workloads. + delref(); + } else { + onMainThreadVoid([this]() { + this->cancelFuture.cancel(); + this->delref(); + }); + } } void releaseMemory() { From 52940d38d97c059cad673880ff503fe57a6ebdbb Mon Sep 17 00:00:00 2001 From: Lukas Joswiak Date: Tue, 27 Jul 2021 14:12:01 -0700 Subject: [PATCH 134/225] Fix issue where GlobalConfig wasn't initialized in time when running fdbcli --exec --- fdbcli/fdbcli.actor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index bef9e3d43c..bcddfbc7f3 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3323,6 +3323,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { try { db = Database::createDatabase(ccf, -1, IsInternal::False); + wait(GlobalConfig::globalConfig().onInitialized()); if (!opt.exec.present()) { printf("Using cluster file `%s'.\n", ccf->getFilename().c_str()); } From d7a03cc703084a01cee5f94323358677a2622dd0 Mon Sep 17 00:00:00 2001 From: Lukas Joswiak Date: Tue, 27 Jul 2021 14:12:17 -0700 Subject: [PATCH 135/225] Add GlobalConfig TraceEvents for easier debugging --- fdbclient/GlobalConfig.actor.cpp | 3 +++ fdbclient/GlobalConfig.actor.h | 1 + 2 files changed, 4 insertions(+) diff --git a/fdbclient/GlobalConfig.actor.cpp b/fdbclient/GlobalConfig.actor.cpp index a5b4febdea..2f2b82c332 100644 --- a/fdbclient/GlobalConfig.actor.cpp +++ b/fdbclient/GlobalConfig.actor.cpp @@ -77,6 +77,7 @@ void GlobalConfig::trigger(KeyRef key, std::functionfirst)) { @@ -174,6 +176,7 @@ ACTOR Future GlobalConfig::migrate(GlobalConfig* self) { // Updates local copy of global configuration by reading the entire key-range // from storage. ACTOR Future GlobalConfig::refresh(GlobalConfig* self) { + TraceEvent trace(SevInfo, "GlobalConfig_Refresh"); self->erase(KeyRangeRef(""_sr, "\xff"_sr)); Transaction tr(self->cx); diff --git a/fdbclient/GlobalConfig.actor.h b/fdbclient/GlobalConfig.actor.h index 444f1ab697..3c5811486b 100644 --- a/fdbclient/GlobalConfig.actor.h +++ b/fdbclient/GlobalConfig.actor.h @@ -108,6 +108,7 @@ public: // the key. template {}, bool>::type = true> const T get(KeyRef name, T defaultVal) { + TraceEvent(SevInfo, "GlobalConfig_Get").detail("Key", name); try { auto configValue = get(name); if (configValue.isValid()) { From acfb9adbd2e8763ec1b553276a230d9e2cef6360 Mon Sep 17 00:00:00 2001 From: Lukas Joswiak Date: Tue, 27 Jul 2021 15:10:49 -0700 Subject: [PATCH 136/225] Fix ctest timeouts --- fdbcli/fdbcli.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index bcddfbc7f3..a573ffdd29 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3323,7 +3323,6 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { try { db = Database::createDatabase(ccf, -1, IsInternal::False); - wait(GlobalConfig::globalConfig().onInitialized()); if (!opt.exec.present()) { printf("Using cluster file `%s'.\n", ccf->getFilename().c_str()); } @@ -3961,6 +3960,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { is_error = true; continue; } + wait(GlobalConfig::globalConfig().onInitialized()); if (tokencmp(tokens[2], "get")) { if (tokens.size() != 3) { fprintf(stderr, "ERROR: Addtional arguments to `get` are not supported.\n"); From 08bc78735674f5e5e5f23e869eeeb1106168499a Mon Sep 17 00:00:00 2001 From: Lukas Joswiak Date: Tue, 27 Jul 2021 15:22:01 -0700 Subject: [PATCH 137/225] Add timeout --- fdbcli/fdbcli.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index a573ffdd29..7b5adedaab 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3960,7 +3960,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { is_error = true; continue; } - wait(GlobalConfig::globalConfig().onInitialized()); + wait(timeout(GlobalConfig::globalConfig().onInitialized(), 3, Void())); if (tokencmp(tokens[2], "get")) { if (tokens.size() != 3) { fprintf(stderr, "ERROR: Addtional arguments to `get` are not supported.\n"); From b423432ee1411e3e0bc0266fb0ea91b63ee50744 Mon Sep 17 00:00:00 2001 From: Lukas Joswiak Date: Tue, 27 Jul 2021 15:45:35 -0700 Subject: [PATCH 138/225] Make wait interruptable --- fdbcli/fdbcli.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 7b5adedaab..9982a576d0 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3960,7 +3960,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { is_error = true; continue; } - wait(timeout(GlobalConfig::globalConfig().onInitialized(), 3, Void())); + wait(makeInterruptable(GlobalConfig::globalConfig().onInitialized())); if (tokencmp(tokens[2], "get")) { if (tokens.size() != 3) { fprintf(stderr, "ERROR: Addtional arguments to `get` are not supported.\n"); From 088ae1f0dab504534554c53084b4e9b5de2c647f Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 27 Jul 2021 16:23:33 -0700 Subject: [PATCH 139/225] Avoid applying empty filter in BackupContainerAzureBlobStore::listFiles --- fdbclient/BackupContainerAzureBlobStore.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index a1cdb1d807..35acfe8f81 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -251,7 +251,7 @@ public: BackupContainerFileSystem::FilesAndSizesT& result) { auto resp = waitAzureFuture(client->list_blobs_segmented(containerName, "/", "", path), "list_blobs_segmented"); for (const auto& blob : resp.blobs) { - if (isDirectory(blob.name) && folderPathFilter(blob.name)) { + if (isDirectory(blob.name) && (!folderPathFilter || folderPathFilter(blob.name))) { listFiles(client, containerName, blob.name, folderPathFilter, result); } else { result.emplace_back(blob.name, blob.content_length); From 16e5fe470ab25a7c7605be8eb6b9a9653ccc8312 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Tue, 27 Jul 2021 18:31:36 -0700 Subject: [PATCH 140/225] Improve BackupContainerAzureBlobStore handling of 404 errors --- .../BackupContainerAzureBlobStore.actor.cpp | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/fdbclient/BackupContainerAzureBlobStore.actor.cpp b/fdbclient/BackupContainerAzureBlobStore.actor.cpp index 35acfe8f81..763104dc3f 100644 --- a/fdbclient/BackupContainerAzureBlobStore.actor.cpp +++ b/fdbclient/BackupContainerAzureBlobStore.actor.cpp @@ -26,18 +26,23 @@ namespace { +std::string const notFoundErrorCode = "404"; + +void printAzureError(std::string const& operationName, azure::storage_lite::storage_error const& err) { + printf("(%s) : Error from Azure SDK : %s (%s) : %s", + operationName.c_str(), + err.code_name.c_str(), + err.code.c_str(), + err.message.c_str()); +} + template T waitAzureFuture(std::future>&& f, std::string const& operationName) { auto outcome = f.get(); if (outcome.success()) { return outcome.response(); } else { - auto const& err = outcome.error(); - printf("(%s) : Error from Azure SDK : %s (%s) : %s", - operationName.c_str(), - err.code_name.c_str(), - err.code.c_str(), - err.message.c_str()); + printAzureError(operationName, outcome.error()); throw backup_error(); } } @@ -286,8 +291,18 @@ Future BackupContainerAzureBlobStore::blobExists(const std::string& fileNa .detail("FileName", fileName) .detail("ContainerName", containerName); return asyncTaskThread.execAsync([client = this->client, containerName = this->containerName, fileName = fileName] { - auto resp = waitAzureFuture(client->get_blob_properties(containerName, fileName), "get_blob_properties"); - return resp.valid(); + auto outcome = client->get_blob_properties(containerName, fileName).get(); + if (outcome.success()) { + return true; + } else { + auto const& err = outcome.error(); + if (err.code == notFoundErrorCode) { + return false; + } else { + printAzureError("get_blob_properties", err); + throw backup_error(); + } + } }); } @@ -330,8 +345,18 @@ Future BackupContainerAzureBlobStore::create() { Future BackupContainerAzureBlobStore::exists() { TraceEvent(SevDebug, "BCAzureBlobStoreCheckContainerExists").detail("ContainerName", containerName); return asyncTaskThread.execAsync([containerName = this->containerName, client = this->client] { - auto resp = waitAzureFuture(client->get_container_properties(containerName), "get_container_properties"); - return resp.valid(); + auto outcome = client->get_container_properties(containerName).get(); + if (outcome.success()) { + return true; + } else { + auto const& err = outcome.error(); + if (err.code == notFoundErrorCode) { + return false; + } else { + printAzureError("got_container_properties", err); + throw backup_error(); + } + } }); } From a55e849da0eac803f3be0e668dcd255c6d79ce15 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Wed, 28 Jul 2021 13:04:05 -0700 Subject: [PATCH 141/225] Add some documentation to ConfigGeneration and fix getReadVersion implementations --- fdbclient/ConfigTransactionInterface.h | 3 +++ fdbclient/PaxosConfigTransaction.actor.cpp | 4 ++-- fdbclient/SimpleConfigTransaction.actor.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fdbclient/ConfigTransactionInterface.h b/fdbclient/ConfigTransactionInterface.h index d2e19ad0ab..ff85760a3f 100644 --- a/fdbclient/ConfigTransactionInterface.h +++ b/fdbclient/ConfigTransactionInterface.h @@ -28,7 +28,10 @@ #include "flow/flow.h" struct ConfigGeneration { + // The live version of each node is monotonically increasing Version liveVersion{ 0 }; + // The committedVersion of each node is the version of the last commit made durable. + // Each committedVersion was previously given to clients as a liveVersion, prior to commit. Version committedVersion{ 0 }; bool operator==(ConfigGeneration const&) const; diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index 6bff8bc18a..d47cf26ae3 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -112,12 +112,12 @@ public: if (!getGenerationFuture.isValid()) { getGenerationFuture = getGeneration(this); } - return map(getGenerationFuture, [](auto const& gen) { return gen.liveVersion; }); + return map(getGenerationFuture, [](auto const& gen) { return gen.committedVersion; }); } Optional getCachedReadVersion() const { if (getGenerationFuture.isValid() && getGenerationFuture.isReady() && !getGenerationFuture.isError()) { - return getGenerationFuture.get().liveVersion; + return getGenerationFuture.get().committedVersion; } else { return {}; } diff --git a/fdbclient/SimpleConfigTransaction.actor.cpp b/fdbclient/SimpleConfigTransaction.actor.cpp index c3cef740bf..fee12a3fd2 100644 --- a/fdbclient/SimpleConfigTransaction.actor.cpp +++ b/fdbclient/SimpleConfigTransaction.actor.cpp @@ -156,12 +156,12 @@ public: Future getReadVersion() { if (!getGenerationFuture.isValid()) getGenerationFuture = getGeneration(this); - return map(getGenerationFuture, [](auto const& gen) { return gen.liveVersion; }); + return map(getGenerationFuture, [](auto const& gen) { return gen.committedVersion; }); } Optional getCachedReadVersion() const { if (getGenerationFuture.isValid() && getGenerationFuture.isReady() && !getGenerationFuture.isError()) { - return getGenerationFuture.get().liveVersion; + return getGenerationFuture.get().committedVersion; } else { return {}; } From e9409b02fe2136ddd73be1c96c3ebfab26c20624 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Wed, 28 Jul 2021 14:02:12 -0700 Subject: [PATCH 142/225] fixed the build --- fdbclient/NativeAPI.actor.cpp | 6 +++--- fdbclient/StorageServerInterface.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index dc281b5c61..a509f7f6c4 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -6532,7 +6532,7 @@ ACTOR Future>> getRangeFeedMutations wait(getKeyRangeLocations(cx, keys, 100, - false, + Reverse::False, &StorageServerInterface::rangeFeed, TransactionInfo(TaskPriority::DefaultEndpoint, span.context))); @@ -6548,7 +6548,7 @@ ACTOR Future>> getRangeFeedMutations &StorageServerInterface::rangeFeed, req, TaskPriority::DefaultPromiseEndpoint, - false, + AtMostOnce::False, cx->enableLocalityLoadBalance ? &cx->queueModel : nullptr)); return Standalone>(rep.mutations, rep.arena); } @@ -6571,7 +6571,7 @@ ACTOR Future popRangeFeedMutationsActor(Reference db, Str wait(getKeyRangeLocations(cx, keys, 100, - false, + Reverse::False, &StorageServerInterface::rangeFeed, TransactionInfo(TaskPriority::DefaultEndpoint, span.context))); diff --git a/fdbclient/StorageServerInterface.cpp b/fdbclient/StorageServerInterface.cpp index d379a0fa69..b52ca0a8cd 100644 --- a/fdbclient/StorageServerInterface.cpp +++ b/fdbclient/StorageServerInterface.cpp @@ -296,6 +296,27 @@ void TSS_traceMismatch(TraceEvent& event, ASSERT(false); } +// split range +template <> +bool TSS_doCompare(const RangeFeedReply& src, const RangeFeedReply& tss) { + ASSERT(false); + return true; +} + +template <> +const char* TSS_mismatchTraceName(const RangeFeedRequest& req) { + ASSERT(false); + return ""; +} + +template <> +void TSS_traceMismatch(TraceEvent& event, + const RangeFeedRequest& req, + const RangeFeedReply& src, + const RangeFeedReply& tss) { + ASSERT(false); +} + // only record metrics for data reads template <> @@ -334,6 +355,9 @@ void TSSMetrics::recordLatency(const SplitRangeRequest& req, double ssLatency, d template <> void TSSMetrics::recordLatency(const GetKeyValuesStreamRequest& req, double ssLatency, double tssLatency) {} +template <> +void TSSMetrics::recordLatency(const RangeFeedRequest& req, double ssLatency, double tssLatency) {} + // ------------------- TEST_CASE("/StorageServerInterface/TSSCompare/TestComparison") { From b29f47a0a06e4fff60d28b7e5917a64c1b05e802 Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Mon, 26 Jul 2021 16:15:56 -0700 Subject: [PATCH 143/225] Release notes for 6.3.17 --- .../sphinx/source/release-notes/release-notes-630.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/documentation/sphinx/source/release-notes/release-notes-630.rst b/documentation/sphinx/source/release-notes/release-notes-630.rst index 4f51bc273f..9e46569496 100644 --- a/documentation/sphinx/source/release-notes/release-notes-630.rst +++ b/documentation/sphinx/source/release-notes/release-notes-630.rst @@ -7,6 +7,16 @@ Release Notes * The multi-version client API would not propagate errors that occurred when creating databases on external clients. This could result in a invalid memory accesses. `(PR #5221) `_ * Fixed a race between the multi-version client connecting to a cluster and destroying the database that could cause an assertion failure. `(PR #5221) `_ +6.3.17 +====== +* Made readValuePrefix consistent regarding error messages. `(PR #5160) `_ +* Added ``TLogPopDetails`` trace event to tLog pop. `(PR #5134) `_ +* Added ``CommitBatchingEmptyMessageRatio`` metric to track the ratio of empty messages to tlogs. `(PR #5087) `_ +* Observability improvements in ProxyStats. `(PR #5046) `_ +* Added ``RecoveryInternal`` and ``ProxyReplies`` trace events to recovery_transaction step in recovery. `(PR #5038) `_ +* Multi-threaded client documentation improvements. `(PR #5033) `_ +* Added ``ClusterControllerWorkerFailed`` trace event when a worker is removed from cluster controller. `(PR #5035) `_ +* Added histograms for storage server write path components. `(PR #5019) `_ 6.3.15 ====== From e0a7891d671bcab9ef1a8991ba3f3d11c7d3464c Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Mon, 26 Jul 2021 18:19:16 -0700 Subject: [PATCH 144/225] Include proxies in the local worker list --- fdbserver/worker.actor.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index 28b2398bc1..1ba254dbb5 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -613,6 +613,19 @@ bool addressInDbAndPrimaryDc(const NetworkAddress& address, Referenceget().master.locality.dcId(); }; @@ -667,10 +680,23 @@ TEST_CASE("/fdbserver/worker/addressInDbAndPrimaryDc") { testDbInfo.logSystemConfig.tLogs.back().tLogs.push_back(OptionalInterface(localTlog)); ASSERT(addressInDbAndPrimaryDc(g_network->getLocalAddress(), makeReference>(testDbInfo))); - // Last, use the master's address to test, which should be considered as in local DC. + // Use the master's address to test, which should be considered as in local DC. testDbInfo.logSystemConfig.tLogs.clear(); ASSERT(addressInDbAndPrimaryDc(testAddress, makeReference>(testDbInfo))); + // Last, tests that proxies included in the ClientDbInfo are considered as local. + NetworkAddress grvProxyAddress(IPAddress(0x26262626), 1); + GrvProxyInterface grvProxyInterf; + grvProxyInterf.getConsistentReadVersion = RequestStream(Endpoint({ grvProxyAddress }, UID(1, 2))); + testDbInfo.client.grvProxies.push_back(grvProxyInterf); + ASSERT(addressInDbAndPrimaryDc(grvProxyAddress, makeReference>(testDbInfo))); + + NetworkAddress commitProxyAddress(IPAddress(0x37373737), 1); + CommitProxyInterface commitProxyInterf; + commitProxyInterf.commit = RequestStream(Endpoint({ commitProxyAddress }, UID(1, 2))); + testDbInfo.client.commitProxies.push_back(commitProxyInterf); + ASSERT(addressInDbAndPrimaryDc(commitProxyAddress, makeReference>(testDbInfo))); + return Void(); } From d0dce4e651f494bec792e0e32ea3ddffa248c1db Mon Sep 17 00:00:00 2001 From: Xiaoxi Wang Date: Wed, 28 Jul 2021 14:42:12 -0700 Subject: [PATCH 145/225] modify ha-write-path.rst --- documentation/sphinx/source/ha-write-path.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation/sphinx/source/ha-write-path.rst b/documentation/sphinx/source/ha-write-path.rst index 6af0db134b..0a78f44e28 100644 --- a/documentation/sphinx/source/ha-write-path.rst +++ b/documentation/sphinx/source/ha-write-path.rst @@ -43,7 +43,7 @@ Tag is an overloaded term in FDB. In the early history of FDB, a tag is a number * As FDB scales and we work to reduce the recovery time, a special tag for transaction state store (txnStateStore) is introduced; -* and so on. +* FDB also have transaction tags which are used for transaction throttling, not for the tag-partitioned log system mentioned in this article. See :ref:`transaction-tagging` To distinguish the types of tags used for different purposes at different locations (primary DC or remote DC), we introduce Tag structure, which has two fields: @@ -86,7 +86,7 @@ At Proxy * 1 tag for log router. Assume it is (-2, 3), where -2 is the locality value for all log router tags. The tag id is randomly chosen by proxy as well. -* No tag for satellite tLog. The "satellite TLog locality" -5 in the code is used when recruiting a satellite TLog to tell it that it is a satellite TLog. This causes the TLog to only index log router tags (-2) and not bother indexing any of the >0 tags. +* No tag for satellite tLog. The "satellite TLog locality" -5 in the code is used when recruiting a satellite TLog to tell it that it is a satellite TLog. This causes the satellite TLog to only index log router tags (-2) and not bother indexing any of the >0 tags. Why do we need log routers? Why cannot we let remote tLog directly pull data from primary tLogs? @@ -98,7 +98,7 @@ Another alternative is to use remote SSes’ tags to decide which satellite tLog Proxy groups mutations with the same tag as messages. Proxy then synchronously pushes these mutation messages to tLogs based on the tags. Proxy cannot acknowledge that the transaction is committed until the message has been durable on all primary and satellite tLogs. -**Commit empty messages to tLogs.** When a proxy commits a tagged mutation message at version V1 to tLogs, it also has to commit an empty message at the same version V1 to the rest of tLogs. This makes sure every tLog has the same versions of messages, even though some messages are empty. This is a trick used in FDB to let all tLogs march at the same versions. The reason why FDB does the trick is because the master hands out segments of versions as 'from v1 to v2', and the TLogs need to be able to piece all of them back together into one consistent timeline. It may or may not be a good design decision, because a slow tLog can delay other tLogs of the same kind. We may want to revisit the design later. +**Commit empty messages to tLogs.** When a proxy commits a tagged mutation message at version V1 to tLogs, it also has to commit an empty message at the same version V1 to the rest of tLogs. This makes sure every tLog has the same versions of messages, even though some messages are empty. This is a trick used in FDB to let all tLogs march at the same versions. The reason why FDB does the trick is that the master hands out segments of versions as 'from v1 to v2', and the TLogs need to be able to piece all of them back together into one consistent timeline. It may or may not be a good design decision, because a slow tLog can delay other tLogs of the same kind. We may want to revisit the design later. At primary tLogs and satellite tLogs From 0173d86be311be1ca43e3757d84e4f6397a112ac Mon Sep 17 00:00:00 2001 From: Xiaoge Su Date: Wed, 28 Jul 2021 15:43:24 -0700 Subject: [PATCH 146/225] Revert "Merge pull request #5286 from xis19/master" This reverts commit f533317b73aa0a12b46b441d451642d4e8989518, reversing changes made to 82603ff7645c7eabba320beb5d22ed6e36bd7f2a. --- flow/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/flow/CMakeLists.txt b/flow/CMakeLists.txt index 215fee3cad..78d097517f 100644 --- a/flow/CMakeLists.txt +++ b/flow/CMakeLists.txt @@ -137,12 +137,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") target_link_libraries(flow PUBLIC ${EIO}) endif() endif() - -# For Clang in Linux environment, libatomic is required -if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$") - set (FLOW_LIBS ${FLOW_LIBS} atomic) -endif () - target_link_libraries(flow PRIVATE ${FLOW_LIBS}) if(USE_VALGRIND) target_link_libraries(flow PUBLIC Valgrind) From 12e1a5fe9217612e1eb55863d723b43094f8b86c Mon Sep 17 00:00:00 2001 From: Sajjad Rahnama Date: Thu, 29 Jul 2021 11:26:14 -0700 Subject: [PATCH 147/225] TestHarness Buggify/FaultInjection Enable/Disable - Update Old Binaries arguments --- contrib/TestHarness/Program.cs.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index 9a15b5ad6c..01199a175a 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -424,15 +424,16 @@ namespace SummarizeTest process.StartInfo.RedirectStandardOutput = true; string role = (noSim) ? "test" : "simulation"; var args = ""; + string faultInjectionArg = string.IsNullOrEmpty(oldBinaryName) ? string.Format("-fi {0}", faultInjectionEnabled ? "on" : "off") : ""; if (willRestart && oldBinaryName.EndsWith("alpha6")) { - args = string.Format("-Rs 1000000000 -r {0} {1} -s {2} -f \"{3}\" -b {4} -fi {5} {6} --crash", - role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", faultInjectionEnabled ? "on" : "off", tlsPluginArg); + args = string.Format("-Rs 1000000000 -r {0} {1} -s {2} -f \"{3}\" -b {4} {5} {6} --crash", + role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", faultInjectionArg, tlsPluginArg); } else { - args = string.Format("-Rs 1GB -r {0} {1} -s {2} -f \"{3}\" -b {4} -fi {5} {6} --crash", - role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", faultInjectionEnabled ? "on" : "off", tlsPluginArg); + args = string.Format("-Rs 1GB -r {0} {1} -s {2} -f \"{3}\" -b {4} {5} {6} --crash", + role, IsRunningOnMono() ? "" : "-q", seed, testFile, buggify ? "on" : "off", faultInjectionArg, tlsPluginArg); } if (restarting) args = args + " --restarting"; if (useValgrind && !willRestart) @@ -791,10 +792,11 @@ namespace SummarizeTest new XAttribute("SourceVersion", ev.Details.SourceVersion), new XAttribute("Time", ev.Details.ActualTime), new XAttribute("BuggifyEnabled", ev.Details.BuggifyEnabled), - new XAttribute("FaultInjectionEnabled", ev.Details.FaultInjectionEnabled), new XAttribute("DeterminismCheck", expectedUnseed != -1 ? "1" : "0"), new XAttribute("OldBinary", Path.GetFileName(oldBinaryName))); testBeginFound = true; + if (ev.DDetails.ContainsKey("FaultInjectionEnabled")) + xout.Add(new XAttribute("FaultInjectionEnabled", ev.Details.FaultInjectionEnabled)); } if (ev.Type == "Simulation") { From d5174b2d98ecd12b476defe7d59180f6bc46290d Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 28 Jul 2021 16:23:36 -0400 Subject: [PATCH 148/225] Update RocksDB version --- cmake/CompileRocksDB.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CompileRocksDB.cmake b/cmake/CompileRocksDB.cmake index 4fcf78a334..6d6e959fd5 100644 --- a/cmake/CompileRocksDB.cmake +++ b/cmake/CompileRocksDB.cmake @@ -36,8 +36,8 @@ if (RocksDB_FOUND) ${BINARY_DIR}/librocksdb.a) else() ExternalProject_Add(rocksdb - URL https://github.com/facebook/rocksdb/archive/v6.10.1.tar.gz - URL_HASH SHA256=d573d2f15cdda883714f7e0bc87b814a8d4a53a82edde558f08f940e905541ee + URL https://github.com/facebook/rocksdb/archive/v6.22.1.tar.gz + URL_HASH SHA256=2df8f34a44eda182e22cf84dee7a14f17f55d305ff79c06fb3cd1e5f8831e00d CMAKE_ARGS -DUSE_RTTI=1 -DPORTABLE=${PORTABLE_ROCKSDB} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} From 5b191fccfec84ee7ff48dd6a934a70c4e1238bda Mon Sep 17 00:00:00 2001 From: Sajjad Date: Thu, 29 Jul 2021 23:18:15 -0700 Subject: [PATCH 149/225] Update contrib/TestHarness/Program.cs.cmake - Minor change Co-authored-by: Jingyu Zhou --- contrib/TestHarness/Program.cs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index 01199a175a..eb8d0ffd75 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -1246,7 +1246,7 @@ namespace SummarizeTest if(buggify != null) test.Add(new XAttribute("BuggifyEnabled", buggify.Value ? "1" : "0")); if(faultInjectionEnabled != null) - test.Add(new XAttribute("FaultInjectionEnabled", buggify.Value ? "1" : "0")); + test.Add(new XAttribute("FaultInjectionEnabled", faultInjectionEnabled.Value ? "1" : "0")); if(determinismCheck != null) test.Add(new XAttribute("DeterminismCheck", determinismCheck.Value ? "1" : "0")); if(oldBinaryName != null) From a26dbba66f59950981086f1f99b43bd2838cc46c Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 22 Jun 2021 18:37:37 -0400 Subject: [PATCH 150/225] Add RocksDB metrics --- fdbclient/ServerKnobs.cpp | 1 + fdbclient/ServerKnobs.h | 1 + fdbserver/KeyValueStoreRocksDB.actor.cpp | 125 ++++++++++++++++++++--- 3 files changed, 112 insertions(+), 15 deletions(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index 543fc8fe9f..3437186209 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -342,6 +342,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( ROCKSDB_PERIODIC_COMPACTION_SECONDS, 0 ); init( ROCKSDB_PREFIX_LEN, 0 ); init( ROCKSDB_BLOCK_CACHE_SIZE, 0 ); + init( ROCKSDB_METRICS_DELAY, 60.0 ); // Leader election bool longLeaderElection = randomize && BUGGIFY; diff --git a/fdbclient/ServerKnobs.h b/fdbclient/ServerKnobs.h index 1baefd0695..82dbd227b0 100644 --- a/fdbclient/ServerKnobs.h +++ b/fdbclient/ServerKnobs.h @@ -274,6 +274,7 @@ public: int64_t ROCKSDB_PERIODIC_COMPACTION_SECONDS; int ROCKSDB_PREFIX_LEN; int64_t ROCKSDB_BLOCK_CACHE_SIZE; + double ROCKSDB_METRICS_DELAY; // Leader election int MAX_NOTIFICATIONS; diff --git a/fdbserver/KeyValueStoreRocksDB.actor.cpp b/fdbserver/KeyValueStoreRocksDB.actor.cpp index 08dee91f04..e3de68ed08 100644 --- a/fdbserver/KeyValueStoreRocksDB.actor.cpp +++ b/fdbserver/KeyValueStoreRocksDB.actor.cpp @@ -5,11 +5,17 @@ #include #include #include +#include #include #include #include "fdbserver/CoroFlow.h" #include "flow/flow.h" #include "flow/IThreadPool.h" +#include "flow/ThreadHelper.actor.h" + +#include +#include +#include #endif // SSD_ROCKSDB_EXPERIMENTAL @@ -48,6 +54,9 @@ rocksdb::Options getOptions() { options.IncreaseParallelism(SERVER_KNOBS->ROCKSDB_BACKGROUND_PARALLELISM); } + options.statistics = rocksdb::CreateDBStatistics(); + options.statistics->set_stats_level(rocksdb::kExceptHistogramOrTimers); + rocksdb::BlockBasedTableOptions bbOpts; // TODO: Add a knob for the block cache size. (Default is 8 MB) if (SERVER_KNOBS->ROCKSDB_PREFIX_LEN > 0) { @@ -89,6 +98,88 @@ rocksdb::ReadOptions getReadOptions() { return options; } +ACTOR Future rocksDBMetricLogger(std::shared_ptr statistics, rocksdb::DB* db) { + state std::vector> tickerStats = { + { "StallMicros", rocksdb::STALL_MICROS, 0 }, + { "BytesRead", rocksdb::BYTES_READ, 0 }, + { "IterBytesRead", rocksdb::ITER_BYTES_READ, 0 }, + { "BytesWritten", rocksdb::BYTES_WRITTEN, 0 }, + { "BlockCacheMisses", rocksdb::BLOCK_CACHE_MISS, 0 }, + { "BlockCacheHits", rocksdb::BLOCK_CACHE_HIT, 0 }, + { "BloomFilterUseful", rocksdb::BLOOM_FILTER_USEFUL, 0 }, + { "BloomFilterFullPositive", rocksdb::BLOOM_FILTER_FULL_POSITIVE, 0 }, + { "BloomFilterTruePositive", rocksdb::BLOOM_FILTER_FULL_TRUE_POSITIVE, 0 }, + { "BloomFilterMicros", rocksdb::BLOOM_FILTER_MICROS, 0 }, + { "MemtableHit", rocksdb::MEMTABLE_HIT, 0 }, + { "MemtableMiss", rocksdb::MEMTABLE_MISS, 0 }, + { "GetHitL0", rocksdb::GET_HIT_L0, 0 }, + { "GetHitL1", rocksdb::GET_HIT_L1, 0 }, + { "GetHitL2AndUp", rocksdb::GET_HIT_L2_AND_UP, 0 }, + { "CountKeysWritten", rocksdb::NUMBER_KEYS_WRITTEN, 0 }, + { "CountKeysWritten", rocksdb::NUMBER_KEYS_READ, 0 }, + { "CountDBSeek", rocksdb::NUMBER_DB_SEEK, 0 }, + { "CountDBNext", rocksdb::NUMBER_DB_NEXT, 0 }, + { "CountDBPrev", rocksdb::NUMBER_DB_PREV, 0 }, + { "BloomFilterPrefixChecked", rocksdb::BLOOM_FILTER_PREFIX_CHECKED, 0 }, + { "BloomFilterPrefixUseful", rocksdb::BLOOM_FILTER_PREFIX_USEFUL, 0 }, + { "BlockCacheCompressedMiss", rocksdb::BLOCK_CACHE_COMPRESSED_MISS, 0 }, + { "BlockCacheCompressedHit", rocksdb::BLOCK_CACHE_COMPRESSED_HIT, 0 }, + { "CountWalFileSyncs", rocksdb::WAL_FILE_SYNCED, 0 }, + { "CountWalFileBytes", rocksdb::WAL_FILE_BYTES, 0 }, + { "CompactReadBytes", rocksdb::COMPACT_READ_BYTES, 0 }, + { "CompactWriteBytes", rocksdb::COMPACT_WRITE_BYTES, 0 }, + { "FlushWriteBytes", rocksdb::FLUSH_WRITE_BYTES, 0 }, + { "CountBlocksCompressed", rocksdb::NUMBER_BLOCK_COMPRESSED, 0 }, + { "CountBlocksDecompressed", rocksdb::NUMBER_BLOCK_DECOMPRESSED, 0 }, + { "RowCacheHit", rocksdb::ROW_CACHE_HIT, 0 }, + { "RowCacheMiss", rocksdb::ROW_CACHE_MISS, 0 }, + { "CountIterSkippedKeys", rocksdb::NUMBER_ITER_SKIP, 0 }, + + }; + state std::vector> propertyStats = { + { "NumCompactionsRunning", rocksdb::DB::Properties::kNumRunningCompactions }, + { "NumImmutableMemtables", rocksdb::DB::Properties::kNumImmutableMemTable }, + { "NumImmutableMemtablesFlushed", rocksdb::DB::Properties::kNumImmutableMemTableFlushed }, + { "IsMemtableFlushPending", rocksdb::DB::Properties::kMemTableFlushPending }, + { "NumRunningFlushes", rocksdb::DB::Properties::kNumRunningFlushes }, + { "IsCompactionPending", rocksdb::DB::Properties::kCompactionPending }, + { "NumRunningCompactions", rocksdb::DB::Properties::kNumRunningCompactions }, + { "CumulativeBackgroundErrors", rocksdb::DB::Properties::kBackgroundErrors }, + { "CurrentSizeActiveMemtable", rocksdb::DB::Properties::kCurSizeActiveMemTable }, + { "AllMemtablesBytes", rocksdb::DB::Properties::kCurSizeAllMemTables }, + { "ActiveMemtableBytes", rocksdb::DB::Properties::kSizeAllMemTables }, + { "CountEntriesActiveMemtable", rocksdb::DB::Properties::kNumEntriesActiveMemTable }, + { "CountEntriesImmutMemtables", rocksdb::DB::Properties::kNumEntriesImmMemTables }, + { "CountDeletesActiveMemtable", rocksdb::DB::Properties::kNumDeletesActiveMemTable }, + { "CountDeletesImmutMemtables", rocksdb::DB::Properties::kNumDeletesImmMemTables }, + { "EstimatedCountKeys", rocksdb::DB::Properties::kEstimateNumKeys }, + { "EstimateSstReaderBytes", rocksdb::DB::Properties::kEstimateTableReadersMem }, + { "CountActiveSnapshots", rocksdb::DB::Properties::kNumSnapshots }, + { "OldestSnapshotTime", rocksdb::DB::Properties::kOldestSnapshotTime }, + { "CountLiveVersions", rocksdb::DB::Properties::kNumLiveVersions }, + { "EstimateLiveDataSize", rocksdb::DB::Properties::kEstimateLiveDataSize }, + { "BaseLevel", rocksdb::DB::Properties::kBaseLevel }, + { "EstPendCompactBytes", rocksdb::DB::Properties::kEstimatePendingCompactionBytes }, + }; + loop { + wait(delay(SERVER_KNOBS->ROCKSDB_METRICS_DELAY)); + TraceEvent e("RocksDBMetrics"); + for (auto& t : tickerStats) { + auto& [name, ticker, cum] = t; + uint64_t val = statistics->getTickerCount(ticker); + e.detail(name, val - cum); + cum = val; + } + + for (auto& p : propertyStats) { + auto& [name, property] = p; + uint64_t stat = 0; + ASSERT(db->GetIntProperty(property, &stat)); + e.detail(name, stat); + } + } +} + struct RocksDBKeyValueStore : IKeyValueStore { using DB = rocksdb::DB*; using CF = rocksdb::ColumnFamilyHandle*; @@ -118,29 +209,26 @@ struct RocksDBKeyValueStore : IKeyValueStore { struct OpenAction : TypedAction { std::string path; ThreadReturnPromise done; + Optional>& metrics; + OpenAction(std::string path, Optional>& metrics) : path(std::move(path)), metrics(metrics) {} double getTimeEstimate() const override { return SERVER_KNOBS->COMMIT_TIME_ESTIMATE; } }; void action(OpenAction& a) { - // If the DB has already been initialized, this should be a no-op. - if (db != nullptr) { - TraceEvent(SevInfo, "RocksDB") - .detail("Path", a.path) - .detail("Method", "Open") - .detail("Skipping", "Already Open"); - a.done.send(Void()); - return; - } - std::vector defaultCF = { rocksdb::ColumnFamilyDescriptor{ "default", getCFOptions() } }; std::vector handle; - auto status = rocksdb::DB::Open(getOptions(), a.path, defaultCF, &handle, &db); + auto options = getOptions(); + auto status = rocksdb::DB::Open(options, a.path, defaultCF, &handle, &db); if (!status.ok()) { TraceEvent(SevError, "RocksDBError").detail("Error", status.ToString()).detail("Method", "Open"); a.done.sendError(statusToError(status)); } else { TraceEvent(SevInfo, "RocksDB").detail("Path", a.path).detail("Method", "Open"); + onMainThread([&] { + a.metrics = rocksDBMetricLogger(options.statistics, db); + return Future(true); + }).blockUntilReady(); a.done.send(Void()); } } @@ -367,7 +455,9 @@ struct RocksDBKeyValueStore : IKeyValueStore { Reference readThreads; Promise errorPromise; Promise closePromise; + Future openFuture; std::unique_ptr writeBatch; + Optional> metrics; explicit RocksDBKeyValueStore(const std::string& path, UID id) : path(path), id(id) { // In simluation, run the reader/writer threads as Coro threads (i.e. in the network thread. The storage engine @@ -396,6 +486,9 @@ struct RocksDBKeyValueStore : IKeyValueStore { Future getError() override { return errorPromise.getFuture(); } ACTOR static void doClose(RocksDBKeyValueStore* self, bool deleteOnClose) { + // The metrics future retains a reference to the DB, so stop it before we delete it. + self->metrics.reset(); + wait(self->readThreads->stop()); auto a = new Writer::CloseAction(self->path, deleteOnClose); auto f = a->done.getFuture(); @@ -418,11 +511,13 @@ struct RocksDBKeyValueStore : IKeyValueStore { KeyValueStoreType getType() const override { return KeyValueStoreType(KeyValueStoreType::SSD_ROCKSDB_V1); } Future init() override { - std::unique_ptr a(new Writer::OpenAction()); - a->path = path; - auto res = a->done.getFuture(); + if (openFuture.isValid()) { + return openFuture; + } + auto a = std::make_unique(path, metrics); + openFuture = a->done.getFuture(); writeThread->post(a.release()); - return res; + return openFuture; } void set(KeyValueRef kv, const Arena*) override { From adc466acb65bf0fb26ee649233489c81a06fed78 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Sat, 17 Jul 2021 16:37:27 -0400 Subject: [PATCH 151/225] Fix key name --- fdbserver/KeyValueStoreRocksDB.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/KeyValueStoreRocksDB.actor.cpp b/fdbserver/KeyValueStoreRocksDB.actor.cpp index e3de68ed08..e2f88f86a3 100644 --- a/fdbserver/KeyValueStoreRocksDB.actor.cpp +++ b/fdbserver/KeyValueStoreRocksDB.actor.cpp @@ -116,7 +116,7 @@ ACTOR Future rocksDBMetricLogger(std::shared_ptr stat { "GetHitL1", rocksdb::GET_HIT_L1, 0 }, { "GetHitL2AndUp", rocksdb::GET_HIT_L2_AND_UP, 0 }, { "CountKeysWritten", rocksdb::NUMBER_KEYS_WRITTEN, 0 }, - { "CountKeysWritten", rocksdb::NUMBER_KEYS_READ, 0 }, + { "CountKeysRead", rocksdb::NUMBER_KEYS_READ, 0 }, { "CountDBSeek", rocksdb::NUMBER_DB_SEEK, 0 }, { "CountDBNext", rocksdb::NUMBER_DB_NEXT, 0 }, { "CountDBPrev", rocksdb::NUMBER_DB_PREV, 0 }, From 0989c28a6b191cfe4d95c22889900d0507259f38 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 30 Jul 2021 15:23:42 -0700 Subject: [PATCH 152/225] made range feeds durable on the storage server --- fdbcli/fdbcli.actor.cpp | 6 +- fdbclient/DatabaseContext.h | 2 +- fdbclient/NativeAPI.actor.cpp | 8 +- fdbclient/StorageServerInterface.h | 24 +++--- fdbclient/SystemData.cpp | 30 ++++++++ fdbclient/SystemData.h | 8 ++ fdbserver/storageserver.actor.cpp | 115 +++++++++++++++++++++++++++-- 7 files changed, 167 insertions(+), 26 deletions(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 142850c7fc..4c57fbc3f8 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3585,9 +3585,11 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { is_error = true; continue; } - Standalone> res = wait(db->getRangeFeedMutations(tokens[2])); + Standalone> res = wait(db->getRangeFeedMutations(tokens[2])); for (auto& it : res) { - printf("%lld %s\n", it.version, it.mutation.toString().c_str()); + for (auto& it2 : it.mutations) { + printf("%lld %s\n", it.version, it2.toString().c_str()); + } } } else if (tokencmp(tokens[1], "pop")) { if (tokens.size() != 4) { diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index afb4f3a299..e28cff582c 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -252,7 +252,7 @@ public: // Management API, create snapshot Future createSnapshot(StringRef uid, StringRef snapshot_command); - Future>> getRangeFeedMutations(StringRef rangeID); + Future>> getRangeFeedMutations(StringRef rangeID); Future popRangeFeedMutations(StringRef rangeID, Version version); // private: diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index a509f7f6c4..fb292cf361 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -6517,8 +6517,8 @@ Future DatabaseContext::createSnapshot(StringRef uid, StringRef snapshot_c return createSnapshotActor(this, UID::fromString(uid_str), snapshot_command); } -ACTOR Future>> getRangeFeedMutationsActor(Reference db, - StringRef rangeID) { +ACTOR Future>> getRangeFeedMutationsActor(Reference db, + StringRef rangeID) { state Database cx(db); state Transaction tr(cx); state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); @@ -6550,10 +6550,10 @@ ACTOR Future>> getRangeFeedMutations TaskPriority::DefaultPromiseEndpoint, AtMostOnce::False, cx->enableLocalityLoadBalance ? &cx->queueModel : nullptr)); - return Standalone>(rep.mutations, rep.arena); + return Standalone>(rep.mutations, rep.arena); } -Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID) { +Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID) { return getRangeFeedMutationsActor(Reference::addRef(this), rangeID); } diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 86745cb182..999bbb4054 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -623,27 +623,29 @@ struct SplitRangeRequest { } }; -struct MutationRefAndVersion { - MutationRef mutation; +struct MutationsAndVersionRef { + VectorRef mutations; Version version; - MutationRefAndVersion() {} - MutationRefAndVersion(MutationRef mutation, Version version) : mutation(mutation), version(version) {} - MutationRefAndVersion(Arena& to, MutationRef mutation, Version version) - : mutation(to, mutation), version(version) {} - MutationRefAndVersion(Arena& to, const MutationRefAndVersion& from) - : mutation(to, from.mutation), version(from.version) {} - int expectedSize() const { return mutation.expectedSize(); } + MutationsAndVersionRef() {} + explicit MutationsAndVersionRef(Version version) : version(version) {} + MutationsAndVersionRef(VectorRef mutations, Version version) + : mutations(mutations), version(version) {} + MutationsAndVersionRef(Arena& to, VectorRef mutations, Version version) + : mutations(to, mutations), version(version) {} + MutationsAndVersionRef(Arena& to, const MutationsAndVersionRef& from) + : mutations(to, from.mutations), version(from.version) {} + int expectedSize() const { return mutations.expectedSize(); } template void serialize(Ar& ar) { - serializer(ar, mutation, version); + serializer(ar, mutations, version); } }; struct RangeFeedReply { constexpr static FileIdentifier file_identifier = 11815134; - VectorRef mutations; + VectorRef mutations; bool cached; Arena arena; diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 02c7f358c0..1a0fbc662b 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -1046,6 +1046,36 @@ KeyRange decodeRangeFeedValue(ValueRef const& value) { return range; } +const KeyRangeRef rangeFeedDurableKeys(LiteralStringRef("\xff\xff/rf/"), LiteralStringRef("\xff\xff/rf0")); +const KeyRef rangeFeedDurablePrefix = rangeFeedDurableKeys.begin; + +const Value rangeFeedDurableKey(Key const& feed, Version const& version) { + BinaryWriter wr(Unversioned()); + wr.serializeBytes(rangeFeedDurablePrefix); + wr << feed; + wr << version; + return wr.toValue(); +} +std::pair decodeRangeFeedDurableKey(ValueRef const& key) { + Key feed; + Version version; + BinaryReader reader(key.removePrefix(rangeFeedDurablePrefix), Unversioned()); + reader >> feed; + reader >> version; + return std::make_pair(feed, version); +} +const Value rangeFeedDurableValue(Standalone> const& mutations) { + BinaryWriter wr(IncludeVersion(ProtocolVersion::withRangeFeed())); + wr << mutations; + return wr.toValue(); +} +Standalone> decodeRangeFeedDurableValue(ValueRef const& value) { + Standalone> mutations; + BinaryReader reader(value, IncludeVersion()); + reader >> mutations; + return mutations; +} + const KeyRef configTransactionDescriptionKey = "\xff\xff/description"_sr; const KeyRange globalConfigKnobKeys = singleKeyRange("\xff\xff/globalKnobs"_sr); const KeyRangeRef configKnobKeys("\xff\xff/knobs/"_sr, "\xff\xff/knobs0"_sr); diff --git a/fdbclient/SystemData.h b/fdbclient/SystemData.h index ddc82287e4..316c528405 100644 --- a/fdbclient/SystemData.h +++ b/fdbclient/SystemData.h @@ -501,6 +501,14 @@ KeyRange decodeRangeFeedValue(ValueRef const& value); extern const KeyRef rangeFeedPrefix; extern const KeyRef rangeFeedPrivatePrefix; +extern const KeyRangeRef rangeFeedDurableKeys; +extern const KeyRef rangeFeedDurablePrefix; + +const Value rangeFeedDurableKey(Key const& feed, Version const& version); +std::pair decodeRangeFeedDurableKey(ValueRef const& key); +const Value rangeFeedDurableValue(Standalone> const& mutations); +Standalone> decodeRangeFeedDurableValue(ValueRef const& value); + // Configuration database special keys extern const KeyRef configTransactionDescriptionKey; extern const KeyRange globalConfigKnobKeys; diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 8c8919b180..3ee30ce625 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -310,7 +310,8 @@ struct FetchInjectionInfo { }; struct RangeFeedInfo : ReferenceCounted { - std::deque> mutations; + std::deque> mutations; + Version durableVersion = invalidVersion; KeyRange range; Key id; }; @@ -581,6 +582,8 @@ public: KeyRangeMap>> keyRangeFeed; std::map> uidRangeFeed; + Deque, Version>> rangeFeedVersions; + std::set currentRangeFeeds; // newestAvailableVersion[k] // == invalidVersion -> k is unavailable at all versions @@ -1504,11 +1507,37 @@ ACTOR Future watchValueSendReply(StorageServer* data, } ACTOR Future rangeFeedQ(StorageServer* data, RangeFeedRequest req) { + state RangeFeedReply reply; wait(delay(0)); - RangeFeedReply reply; - for (auto& it : data->uidRangeFeed[req.rangeID]->mutations) { - reply.mutations.push_back(reply.arena, it); + auto& feedInfo = data->uidRangeFeed[req.rangeID]; + if (feedInfo->durableVersion == invalidVersion) { + for (auto& it : data->uidRangeFeed[req.rangeID]->mutations) { + reply.mutations.push_back(reply.arena, it); + } + } else { + state std::deque> mutationsDeque = + data->uidRangeFeed[req.rangeID]->mutations; + RangeResult res = wait(data->storage.readRange( + KeyRangeRef(rangeFeedDurableKey(req.rangeID, 0), rangeFeedDurableKey(req.rangeID, data->version.get())))); + if (res.empty()) { + data->uidRangeFeed[req.rangeID]->durableVersion = invalidVersion; + } + Version lastVersion = invalidVersion; + for (auto& kv : res) { + Key id; + Version version; + std::tie(id, version) = decodeRangeFeedDurableKey(kv.key); + auto mutations = decodeRangeFeedDurableValue(kv.value); + reply.mutations.push_back(reply.arena, MutationsAndVersionRef(mutations, version)); + lastVersion = version; + } + for (auto& it : mutationsDeque) { + if (it.version > lastVersion) { + reply.mutations.push_back(reply.arena, it); + } + } } + TraceEvent("RangeFeedQuery", data->thisServerID) .detail("RangeID", req.rangeID.printable()) .detail("Mutations", reply.mutations.size()); @@ -2628,7 +2657,11 @@ void applyMutation(StorageServer* self, self->watches.trigger(m.param1); for (auto& it : self->keyRangeFeed[m.param1]) { - it->mutations.push_back(MutationRefAndVersion(m, version)); + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), m); + self->currentRangeFeeds.insert(it->id); } } else if (m.type == MutationRef::ClearRange) { data.erase(m.param1, m.param2); @@ -2640,7 +2673,11 @@ void applyMutation(StorageServer* self, auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); for (auto& r : ranges) { for (auto& it : r.value()) { - it->mutations.push_back(MutationRefAndVersion(m, version)); + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), m); + self->currentRangeFeeds.insert(it->id); } } } @@ -3434,6 +3471,8 @@ static const KeyRangeRef persistByteSampleSampleKeys = LiteralStringRef(PERSIST_PREFIX "BS/" PERSIST_PREFIX "BS0")); static const KeyRef persistLogProtocol = LiteralStringRef(PERSIST_PREFIX "LogProtocol"); static const KeyRef persistPrimaryLocality = LiteralStringRef(PERSIST_PREFIX "PrimaryLocality"); +static const KeyRangeRef persistRangeFeedKeys = + KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "RF/"), LiteralStringRef(PERSIST_PREFIX "RF0")); // data keys are unmangled (but never start with PERSIST_PREFIX because they are always in allKeys) class StorageUpdater { @@ -3575,6 +3614,11 @@ private: r->value().push_back(rangeFeedInfo); } data->keyRangeFeed.coalesce(rangeFeedRange.contents()); + auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); + data->addMutationToMutationLog(mLV, + MutationRef(MutationRef::SetValue, + persistRangeFeedKeys.begin.toString() + rangeFeedId.toString(), + m.param2)); } else if (m.param1.substr(1).startsWith(tssMappingKeys.begin) && (m.type == MutationRef::SetValue || m.type == MutationRef::ClearRange)) { if (!data->isTss()) { @@ -3962,6 +4006,12 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { .trackLatest(data->thisServerID.toString() + "/StorageServerSourceTLogID"); } + if (data->currentRangeFeeds.size()) { + data->rangeFeedVersions.push_back(std::make_pair( + std::vector(data->currentRangeFeeds.begin(), data->currentRangeFeeds.end()), ver)); + data->currentRangeFeeds.clear(); + } + data->noRecentUpdates.set(false); data->lastUpdate = now(); data->version.set(ver); // Triggers replies to waiting gets for new version(s) @@ -4060,6 +4110,26 @@ ACTOR Future updateStorage(StorageServer* data) { break; } + std::set modifiedRangeFeeds; + while (data->rangeFeedVersions.front().second < newOldestVersion) { + modifiedRangeFeeds.insert(data->rangeFeedVersions.front().first.begin(), + data->rangeFeedVersions.front().first.end()); + data->rangeFeedVersions.pop_front(); + } + + state std::vector updatedRangeFeeds(modifiedRangeFeeds.begin(), modifiedRangeFeeds.end()); + state int curFeed = 0; + while (curFeed < updatedRangeFeeds.size()) { + auto info = data->uidRangeFeed[updatedRangeFeeds[curFeed]]; + while (info->mutations.front().version < newOldestVersion) { + data->storage.writeKeyValue(KeyValueRef(rangeFeedDurableKey(info->id, info->mutations.front().version), + rangeFeedDurableValue(info->mutations.front().mutations))); + info->durableVersion = info->mutations.front().version; + info->mutations.pop_front(); + } + wait(yield(TaskPriority::UpdateStorage)); + } + // Set the new durable version as part of the outstanding change set, before commit if (startOldestVersion != newOldestVersion) data->storage.makeVersionDurable(newOldestVersion); @@ -4379,6 +4449,7 @@ ACTOR Future restoreDurableState(StorageServer* data, IKeyValueStore* stor state Future> fPrimaryLocality = storage->readValue(persistPrimaryLocality); state Future fShardAssigned = storage->readRange(persistShardAssignedKeys); state Future fShardAvailable = storage->readRange(persistShardAvailableKeys); + state Future fRangeFeeds = storage->readRange(persistRangeFeedKeys); state Promise byteSampleSampleRecovered; state Promise startByteSampleRestore; @@ -4387,7 +4458,7 @@ ACTOR Future restoreDurableState(StorageServer* data, IKeyValueStore* stor TraceEvent("ReadingDurableState", data->thisServerID).log(); wait(waitForAll(std::vector{ fFormat, fID, ftssPairID, fTssQuarantine, fVersion, fLogProtocol, fPrimaryLocality })); - wait(waitForAll(std::vector{ fShardAssigned, fShardAvailable })); + wait(waitForAll(std::vector{ fShardAssigned, fShardAvailable, fRangeFeeds })); wait(byteSampleSampleRecovered.getFuture()); TraceEvent("RestoringDurableState", data->thisServerID).log(); @@ -4465,6 +4536,26 @@ ACTOR Future restoreDurableState(StorageServer* data, IKeyValueStore* stor wait(yield()); } + state RangeResult rangeFeeds = fRangeFeeds.get(); + state int feedLoc; + for (feedLoc = 0; feedLoc < rangeFeeds.size(); feedLoc++) { + Key rangeFeedId = rangeFeeds[feedLoc].key.removePrefix(persistRangeFeedKeys.begin); + KeyRange rangeFeedRange = decodeRangeFeedValue(rangeFeeds[feedLoc].value); + TraceEvent("RestoringRangeFeed", data->thisServerID) + .detail("RangeID", rangeFeedId.printable()) + .detail("Range", rangeFeedRange.toString()); + Reference rangeFeedInfo(new RangeFeedInfo()); + rangeFeedInfo->range = rangeFeedRange; + rangeFeedInfo->id = rangeFeedId; + rangeFeedInfo->durableVersion = version; + data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; + auto rs = data->keyRangeFeed.modify(rangeFeedRange); + for (auto r = rs.begin(); r != rs.end(); ++r) { + r->value().push_back(rangeFeedInfo); + } + wait(yield()); + } + data->keyRangeFeed.coalesce(allKeys); // TODO: why is this seemingly random delay here? wait(delay(0.0001)); @@ -4982,9 +5073,17 @@ ACTOR Future serveRangeFeedRequests(StorageServer* self, FutureStream serveRangeFeedPopRequests(StorageServer* self, FutureStream rangeFeedPops) { loop { RangeFeedPopRequest req = waitNext(rangeFeedPops); - while (self->uidRangeFeed[req.rangeID]->mutations.front().version < req.version) { + auto& feed = self->uidRangeFeed[req.rangeID]; + while (feed->mutations.front().version < req.version) { self->uidRangeFeed[req.rangeID]->mutations.pop_front(); } + if (feed->durableVersion != invalidVersion) { + self->storage.clearRange( + KeyRangeRef(rangeFeedDurableKey(feed->id, 0), rangeFeedDurableKey(feed->id, req.version))); + if (req.version > feed->durableVersion) { + feed->durableVersion = invalidVersion; + } + } TraceEvent("RangeFeedPopQuery", self->thisServerID) .detail("RangeID", req.rangeID.printable()) .detail("Version", req.version); From c21fadeaead926c3c77b8f3d650f99c67d04f66a Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Fri, 30 Jul 2021 15:58:22 -0700 Subject: [PATCH 153/225] Add begin and end version filtering for files --- fdbbackup/FileConverter.h | 8 ++++++ fdbbackup/FileDecoder.actor.cpp | 47 ++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/fdbbackup/FileConverter.h b/fdbbackup/FileConverter.h index e3890cb476..a18fe47614 100644 --- a/fdbbackup/FileConverter.h +++ b/fdbbackup/FileConverter.h @@ -41,6 +41,10 @@ enum { OPT_TRACE_LOG_GROUP, OPT_INPUT_FILE, OPT_BUILD_FLAGS, + OPT_LIST_ONLY, + OPT_KEY_PREFIX, + OPT_BEGIN_VERSION_FILTER, + OPT_END_VERSION_FILTER, OPT_HELP }; @@ -62,6 +66,10 @@ CSimpleOpt::SOption gConverterOptions[] = { { OPT_CONTAINER, "-r", SO_REQ_SEP }, TLS_OPTION_FLAGS #endif { OPT_BUILD_FLAGS, "--build_flags", SO_NONE }, + { OPT_LIST_ONLY, "--list_only", SO_NONE }, + { OPT_KEY_PREFIX, "-k", SO_REQ_SEP }, + { OPT_BEGIN_VERSION_FILTER, "--begin_version_filter", SO_REQ_SEP }, + { OPT_END_VERSION_FILTER, "--end_version_filter", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index c36a6384b1..7ba4394ec9 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -19,7 +19,10 @@ */ #include +#include #include +#include +#include #include #include "fdbbackup/BackupTLSConfig.h" @@ -65,6 +68,12 @@ void printDecodeUsage() { TLS_HELP #endif " --build_flags Print build information and exit.\n" + " --list_only Print file list and exit.\n" + " -k KEY_PREFIX Use the prefix for filtering mutations\n" + " --begin_version_filter BEGIN_VERSION\n" + " The version range's begin version (inclusive) for filtering.\n" + " --end_version_filter END_VERSION\n" + " The version range's end version (exclusive) for filtering.\n" "\n"; return; } @@ -79,6 +88,16 @@ struct DecodeParams { bool log_enabled = false; std::string log_dir, trace_format, trace_log_group; BackupTLSConfig tlsConfig; + bool list_only = false; + std::string prefix; // Key prefix for filtering + Version beginVersionFilter = 0; + Version endVersionFilter = std::numeric_limits::max(); + + // Returns if [begin, end) overlap with the filter range + bool overlap(Version begin, Version end) const { + // Filter [100, 200), [50,75) [200, 300) + return !(begin >= endVersionFilter || end <= beginVersionFilter); + } std::string toString() { std::string s; @@ -97,6 +116,13 @@ struct DecodeParams { s.append(" LogGroup:").append(trace_log_group); } } + s.append(", list_only: ").append(list_only ? "true" : "false"); + if (beginVersionFilter != 0) { + s.append(", beginVersionFilter: ").append(std::to_string(beginVersionFilter)); + } + if (endVersionFilter < std::numeric_limits::max()) { + s.append(", endVersionFilter: ").append(std::to_string(endVersionFilter)); + } return s; } @@ -124,6 +150,22 @@ int parseDecodeCommandLine(DecodeParams* param, CSimpleOpt* args) { param->container_url = args->OptionArg(); break; + case OPT_LIST_ONLY: + param->list_only = true; + break; + + case OPT_KEY_PREFIX: + ASSERT(false); // TODO + break; + + case OPT_BEGIN_VERSION_FILTER: + param->beginVersionFilter = std::atoll(args->OptionArg()); + break; + + case OPT_END_VERSION_FILTER: + param->endVersionFilter = std::atoll(args->OptionArg()); + break; + case OPT_CRASHONERROR: g_crashOnError = true; break; @@ -202,7 +244,8 @@ void printLogFiles(std::string msg, const std::vector& files) { std::vector getRelevantLogFiles(const std::vector& files, const DecodeParams& params) { std::vector filtered; for (const auto& file : files) { - if (file.fileName.find(params.fileFilter) != std::string::npos) { + if (file.fileName.find(params.fileFilter) != std::string::npos && + params.overlap(file.beginVersion, file.endVersion + 1)) { filtered.push_back(file); } } @@ -520,6 +563,8 @@ ACTOR Future decode_logs(DecodeParams params) { state std::vector logs = getRelevantLogFiles(listing.logs, params); printLogFiles("Relevant files are: ", logs); + if (params.list_only) return Void(); + state int i = 0; // Previous file's unfinished version data state std::vector left; From 125241743deb37d284f3b4a33cd95e8283300a4b Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 30 Jul 2021 16:01:46 -0700 Subject: [PATCH 154/225] added support for removing range feeds --- fdbserver/storageserver.actor.cpp | 52 ++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 3ee30ce625..46646d968b 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -3599,26 +3599,40 @@ private: data->primaryLocality = BinaryReader::fromStringRef(m.param2, Unversioned()); auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); data->addMutationToMutationLog(mLV, MutationRef(MutationRef::SetValue, persistPrimaryLocality, m.param2)); - } else if (m.type == MutationRef::SetValue && m.param1.startsWith(rangeFeedPrivatePrefix)) { - Key rangeFeedId = m.param1.removePrefix(rangeFeedPrivatePrefix); - KeyRange rangeFeedRange = decodeRangeFeedValue(m.param2); - TraceEvent("AddingRangeFeed", data->thisServerID) - .detail("RangeID", rangeFeedId.printable()) - .detail("Range", rangeFeedRange.toString()); - Reference rangeFeedInfo(new RangeFeedInfo()); - rangeFeedInfo->range = rangeFeedRange; - rangeFeedInfo->id = rangeFeedId; - data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; - auto rs = data->keyRangeFeed.modify(rangeFeedRange); - for (auto r = rs.begin(); r != rs.end(); ++r) { - r->value().push_back(rangeFeedInfo); + } else if ((m.type == MutationRef::SetValue || m.type == MutationRef::ClearRange) && + m.param1.startsWith(rangeFeedPrivatePrefix)) { + if (m.type == MutationRef::SetValue) { + Key rangeFeedId = m.param1.removePrefix(rangeFeedPrivatePrefix); + KeyRange rangeFeedRange = decodeRangeFeedValue(m.param2); + TraceEvent("AddingRangeFeed", data->thisServerID) + .detail("RangeID", rangeFeedId.printable()) + .detail("Range", rangeFeedRange.toString()); + Reference rangeFeedInfo(new RangeFeedInfo()); + rangeFeedInfo->range = rangeFeedRange; + rangeFeedInfo->id = rangeFeedId; + data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; + auto rs = data->keyRangeFeed.modify(rangeFeedRange); + for (auto r = rs.begin(); r != rs.end(); ++r) { + r->value().push_back(rangeFeedInfo); + } + data->keyRangeFeed.coalesce(rangeFeedRange.contents()); + auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); + data->addMutationToMutationLog( + mLV, + MutationRef(MutationRef::SetValue, + persistRangeFeedKeys.begin.toString() + rangeFeedId.toString(), + m.param2)); + } else { + auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); + auto beginFeed = m.param1.removePrefix(rangeFeedPrivatePrefix); + auto endFeed = m.param2.removePrefix(rangeFeedPrivatePrefix); + data->addMutationToMutationLog(mLV, + MutationRef(MutationRef::ClearRange, + persistRangeFeedKeys.begin.toString() + beginFeed.toString(), + persistRangeFeedKeys.begin.toString() + endFeed.toString())); + data->uidRangeFeed.erase(data->uidRangeFeed.lower_bound(beginFeed), + data->uidRangeFeed.lower_bound(endFeed)); } - data->keyRangeFeed.coalesce(rangeFeedRange.contents()); - auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); - data->addMutationToMutationLog(mLV, - MutationRef(MutationRef::SetValue, - persistRangeFeedKeys.begin.toString() + rangeFeedId.toString(), - m.param2)); } else if (m.param1.substr(1).startsWith(tssMappingKeys.begin) && (m.type == MutationRef::SetValue || m.type == MutationRef::ClearRange)) { if (!data->isTss()) { From 1a4f6a4ccfc1f93d6b7e6a4a1e9522d37965eb76 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Fri, 30 Jul 2021 16:31:53 -0700 Subject: [PATCH 155/225] Implement prefix key filter --- fdbbackup/FileDecoder.actor.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 7ba4394ec9..a63369d7f3 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -29,6 +29,8 @@ #include "fdbclient/BackupAgent.actor.h" #include "fdbclient/BackupContainer.h" #include "fdbbackup/FileConverter.h" +#include "fdbclient/CommitTransaction.h" +#include "fdbclient/FDBTypes.h" #include "fdbclient/MutationList.h" #include "flow/Trace.h" #include "flow/flow.h" @@ -155,7 +157,7 @@ int parseDecodeCommandLine(DecodeParams* param, CSimpleOpt* args) { break; case OPT_KEY_PREFIX: - ASSERT(false); // TODO + param->prefix = args->OptionArg(); break; case OPT_BEGIN_VERSION_FILTER: @@ -577,7 +579,23 @@ ACTOR Future decode_logs(DecodeParams params) { while (!progress.finished()) { VersionedMutations vms = wait(progress.getNextBatch()); for (const auto& m : vms.mutations) { - std::cout << vms.version << " " << m.toString() << "\n"; + if (params.prefix.empty()) { // no filtering + std::cout << vms.version << " " << m.toString() << "\n"; + continue; + } + + if (isSingleKeyMutation((MutationRef::Type)m.type)) { + if (m.param1.startsWith(params.prefix)) { + std::cout << vms.version << " " << m.toString() << "\n"; + } + } else if (m.type == MutationRef::ClearRange) { + KeyRange range(KeyRangeRef(m.param1, m.param2)); + if (range.contains(params.prefix)) { + std::cout << vms.version << " " << m.toString() << "\n"; + } + } else { + ASSERT(false); + } } } left = std::move(progress).getUnfinishedBuffer(); From 52368eafbc4992c46f270d70379e64d027757c86 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Fri, 30 Jul 2021 17:45:21 -0700 Subject: [PATCH 156/225] Filter by version for mutations as well --- fdbbackup/FileDecoder.actor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index a63369d7f3..018ddd3251 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -578,6 +578,10 @@ ACTOR Future decode_logs(DecodeParams params) { wait(progress.openFile(container)); while (!progress.finished()) { VersionedMutations vms = wait(progress.getNextBatch()); + if (vms.version < params.beginVersionFilter || vms.version >= params.endVersionFilter) { + continue; + } + for (const auto& m : vms.mutations) { if (params.prefix.empty()) { // no filtering std::cout << vms.version << " " << m.toString() << "\n"; From 74a7da0179a6119b6e7c8c1073f939faa9b081d4 Mon Sep 17 00:00:00 2001 From: Yao Xiao Date: Mon, 26 Jul 2021 17:40:34 -0700 Subject: [PATCH 157/225] Add histogram in GrvProxyServer. --- fdbserver/GrvProxyServer.actor.cpp | 13 +++++++++++++ flow/Histogram.cpp | 3 +++ 2 files changed, 16 insertions(+) diff --git a/fdbserver/GrvProxyServer.actor.cpp b/fdbserver/GrvProxyServer.actor.cpp index 002989a14c..b1799d0acd 100644 --- a/fdbserver/GrvProxyServer.actor.cpp +++ b/fdbserver/GrvProxyServer.actor.cpp @@ -57,6 +57,8 @@ struct GrvProxyStats { Deque requestBuckets; double lastBucketBegin; double bucketInterval; + Reference grvConfirmEpochLiveDist; + Reference grvRawDist; void updateRequestBuckets() { while (now() - lastBucketBegin > bucketInterval) { @@ -113,6 +115,12 @@ struct GrvProxyStats { SERVER_KNOBS->LATENCY_SAMPLE_SIZE), recentRequests(0), lastBucketBegin(now()), bucketInterval(FLOW_KNOBS->BASIC_LOAD_BALANCE_UPDATE_RATE / FLOW_KNOBS->BASIC_LOAD_BALANCE_BUCKETS) { + grvConfirmEpochLiveDist(Histogram::getHistogram(LiteralStringRef("GrvProxy"), + LiteralStringRef("grvConfirmEpochLive"), + Histogram::Unit::microseconds)), + grvRawDist(Histogram::getHistogram(LiteralStringRef("GrvProxy"), + LiteralStringRef("grvRawRpc"), + Histogram::Unit::microseconds)) { // The rate at which the limit(budget) is allowed to grow. specialCounter(cc, "SystemGRVQueueSize", [this]() { return this->systemGRVQueueSize; }); specialCounter(cc, "DefaultGRVQueueSize", [this]() { return this->defaultGRVQueueSize; }); @@ -526,6 +534,8 @@ ACTOR Future getLiveCommittedVersion(SpanID parentSpan, // and no other proxy could have already committed anything without first ending the epoch state Span span("GP:getLiveCommittedVersion"_loc, parentSpan); ++grvProxyData->stats.txnStartBatch; + + state double grvStart = now(); state Future replyFromMasterFuture; replyFromMasterFuture = grvProxyData->master.getLiveCommittedVersion.getReply( GetRawCommittedVersionRequest(span.context, debugID), TaskPriority::GetLiveCommittedVersionReply); @@ -537,6 +547,8 @@ ACTOR Future getLiveCommittedVersion(SpanID parentSpan, wait(grvProxyData->lastCommitTime.whenAtLeast(now() - SERVER_KNOBS->REQUIRED_MIN_RECOVERY_DURATION)); } + state double grvConfirmEpochLive = now(); + grvProxyData->stats.grvConfirmEpochLiveDist->sampleSeconds(grvConfirmEpochLive - grvStart); if (debugID.present()) { g_traceBatch.addEvent( "TransactionDebug", debugID.get().first(), "GrvProxyServer.getLiveCommittedVersion.confirmEpochLive"); @@ -546,6 +558,7 @@ ACTOR Future getLiveCommittedVersion(SpanID parentSpan, grvProxyData->minKnownCommittedVersion = std::max(grvProxyData->minKnownCommittedVersion, repFromMaster.minKnownCommittedVersion); + grvProxyData->stats.grvRawDist->sampleSeconds(now() - grvConfirmEpochLive); GetReadVersionReply rep; rep.version = repFromMaster.version; rep.locked = repFromMaster.locked; diff --git a/flow/Histogram.cpp b/flow/Histogram.cpp index 74dc252212..8063b4d409 100644 --- a/flow/Histogram.cpp +++ b/flow/Histogram.cpp @@ -117,10 +117,12 @@ void Histogram::writeToLog() { TraceEvent e(SevInfo, "Histogram"); e.detail("Group", group).detail("Op", op).detail("Unit", UnitToStringMapper[(size_t)unit]); + int totalCount = 0; for (uint32_t i = 0; i < 32; i++) { uint64_t value = uint64_t(1) << (i + 1); if (buckets[i]) { + totalCount += buckets[i]; switch (unit) { case Unit::microseconds: e.detail(format("LessThan%u.%03u", value / 1000, value % 1000), buckets[i]); @@ -140,6 +142,7 @@ void Histogram::writeToLog() { } } } + e.detail("TotalCount", totalCount); } std::string Histogram::drawHistogram() { From 82be496ba32091b9b35dc6e78f64e44792e95232 Mon Sep 17 00:00:00 2001 From: Yao Xiao Date: Wed, 28 Jul 2021 11:38:39 -0700 Subject: [PATCH 158/225] Updated grvRawDist to grvGetCommittedVersionRpcDist. --- fdbserver/GrvProxyServer.actor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fdbserver/GrvProxyServer.actor.cpp b/fdbserver/GrvProxyServer.actor.cpp index b1799d0acd..3a4295ab21 100644 --- a/fdbserver/GrvProxyServer.actor.cpp +++ b/fdbserver/GrvProxyServer.actor.cpp @@ -58,7 +58,7 @@ struct GrvProxyStats { double lastBucketBegin; double bucketInterval; Reference grvConfirmEpochLiveDist; - Reference grvRawDist; + Reference grvGetCommittedVersionRpcDist; void updateRequestBuckets() { while (now() - lastBucketBegin > bucketInterval) { @@ -114,12 +114,12 @@ struct GrvProxyStats { SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL, SERVER_KNOBS->LATENCY_SAMPLE_SIZE), recentRequests(0), lastBucketBegin(now()), - bucketInterval(FLOW_KNOBS->BASIC_LOAD_BALANCE_UPDATE_RATE / FLOW_KNOBS->BASIC_LOAD_BALANCE_BUCKETS) { + bucketInterval(FLOW_KNOBS->BASIC_LOAD_BALANCE_UPDATE_RATE / FLOW_KNOBS->BASIC_LOAD_BALANCE_BUCKETS), grvConfirmEpochLiveDist(Histogram::getHistogram(LiteralStringRef("GrvProxy"), LiteralStringRef("grvConfirmEpochLive"), Histogram::Unit::microseconds)), - grvRawDist(Histogram::getHistogram(LiteralStringRef("GrvProxy"), - LiteralStringRef("grvRawRpc"), + grvGetCommittedVersionRpcDist(Histogram::getHistogram(LiteralStringRef("GrvProxy"), + LiteralStringRef("grvGetCommittedVersionRpc"), Histogram::Unit::microseconds)) { // The rate at which the limit(budget) is allowed to grow. specialCounter(cc, "SystemGRVQueueSize", [this]() { return this->systemGRVQueueSize; }); @@ -558,7 +558,7 @@ ACTOR Future getLiveCommittedVersion(SpanID parentSpan, grvProxyData->minKnownCommittedVersion = std::max(grvProxyData->minKnownCommittedVersion, repFromMaster.minKnownCommittedVersion); - grvProxyData->stats.grvRawDist->sampleSeconds(now() - grvConfirmEpochLive); + grvProxyData->stats.grvGetCommittedVersionRpcDist->sampleSeconds(now() - grvConfirmEpochLive); GetReadVersionReply rep; rep.version = repFromMaster.version; rep.locked = repFromMaster.locked; From 0ea432a638ff7cf6124eb0a27427a658529ec068 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Fri, 30 Jul 2021 18:26:34 -0700 Subject: [PATCH 159/225] Add traceevent for all printed mutations --- fdbbackup/FileDecoder.actor.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 018ddd3251..e2c337a7d8 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -583,22 +583,21 @@ ACTOR Future decode_logs(DecodeParams params) { } for (const auto& m : vms.mutations) { - if (params.prefix.empty()) { // no filtering - std::cout << vms.version << " " << m.toString() << "\n"; - continue; - } + bool print = params.prefix.empty(); // no filtering - if (isSingleKeyMutation((MutationRef::Type)m.type)) { - if (m.param1.startsWith(params.prefix)) { - std::cout << vms.version << " " << m.toString() << "\n"; + if (!print) { + if (isSingleKeyMutation((MutationRef::Type)m.type)) { + print = m.param1.startsWith(params.prefix); + } else if (m.type == MutationRef::ClearRange) { + KeyRange range(KeyRangeRef(m.param1, m.param2)); + print = range.contains(params.prefix); + } else { + ASSERT(false); } - } else if (m.type == MutationRef::ClearRange) { - KeyRange range(KeyRangeRef(m.param1, m.param2)); - if (range.contains(params.prefix)) { - std::cout << vms.version << " " << m.toString() << "\n"; - } - } else { - ASSERT(false); + } + if (print) { + TraceEvent("Mutation").detail("Version", vms.version).detail("M", m.toString()); + std::cout << vms.version << " " << m.toString() << "\n"; } } } @@ -607,6 +606,7 @@ ACTOR Future decode_logs(DecodeParams params) { TraceEvent("UnfinishedFile").detail("File", logs[i].fileName).detail("Q", left.size()); } } + TraceEvent("DecodeDone"); return Void(); } From cc7081c04463fc67515dfafb03d28c2ae4732500 Mon Sep 17 00:00:00 2001 From: Xiaoxi Wang Date: Fri, 30 Jul 2021 19:10:13 -0700 Subject: [PATCH 160/225] add information print --- fdbserver/QuietDatabase.actor.cpp | 4 +++- fdbserver/tester.actor.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fdbserver/QuietDatabase.actor.cpp b/fdbserver/QuietDatabase.actor.cpp index dc4f8769a6..5e8ec3b976 100644 --- a/fdbserver/QuietDatabase.actor.cpp +++ b/fdbserver/QuietDatabase.actor.cpp @@ -640,8 +640,10 @@ ACTOR Future waitForQuietDatabase(Database cx, // The quiet database check (which runs at the end of every test) will always time out due to active data movement. // To get around this, quiet Database will disable the perpetual wiggle in the setup phase. + printf("Set perpetual_storage_wiggle=0 ...\n"); wait(setPerpetualStorageWiggle(cx, false, LockAware::True)); - + printf("Set perpetual_storage_wiggle=0 Done.\n"); + // Require 3 consecutive successful quiet database checks spaced 2 second apart state int numSuccesses = 0; diff --git a/fdbserver/tester.actor.cpp b/fdbserver/tester.actor.cpp index e819267bb1..e3ecd480e7 100644 --- a/fdbserver/tester.actor.cpp +++ b/fdbserver/tester.actor.cpp @@ -1481,7 +1481,9 @@ ACTOR Future runTests(Reference Date: Sat, 31 Jul 2021 11:28:13 -0700 Subject: [PATCH 161/225] Set max field length for long mutations --- fdbbackup/FileDecoder.actor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index e2c337a7d8..697d600acc 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -596,7 +596,10 @@ ACTOR Future decode_logs(DecodeParams params) { } } if (print) { - TraceEvent("Mutation").detail("Version", vms.version).detail("M", m.toString()); + TraceEvent("Mutation") + .detail("Version", vms.version) + .setMaxFieldLength(10000) + .detail("M", m.toString()); std::cout << vms.version << " " << m.toString() << "\n"; } } @@ -655,6 +658,11 @@ int main(int argc, char** argv) { auto f = stopAfter(decode_logs(param)); runNetwork(); + + flushTraceFileVoid(); + fflush(stdout); + closeTraceFile(); + return status; } catch (Error& e) { std::cerr << "ERROR: " << e.what() << "\n"; From 494acf7a54c114c231e73afdbe514befa60ecc03 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Sat, 31 Jul 2021 11:33:53 -0700 Subject: [PATCH 162/225] Bug fixes with block memory lifetime and handling reads that cross the end of file barrier. --- fdbrpc/AsyncFileEncrypted.actor.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fdbrpc/AsyncFileEncrypted.actor.cpp b/fdbrpc/AsyncFileEncrypted.actor.cpp index 1df9345998..a354a8074e 100644 --- a/fdbrpc/AsyncFileEncrypted.actor.cpp +++ b/fdbrpc/AsyncFileEncrypted.actor.cpp @@ -53,7 +53,7 @@ public: return Standalone(decrypted, arena); } - ACTOR static Future read(AsyncFileEncrypted* self, void* data, int length, int offset) { + ACTOR static Future read(AsyncFileEncrypted* self, void* data, int length, int64_t offset) { state const uint16_t firstBlock = offset / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; state const uint16_t lastBlock = (offset + length - 1) / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; state uint16_t block; @@ -61,15 +61,14 @@ public: state int bytesRead = 0; ASSERT(self->mode == AsyncFileEncrypted::Mode::READ_ONLY); for (block = firstBlock; block <= lastBlock; ++block) { - state StringRef plaintext; + state Standalone plaintext; auto cachedBlock = self->readBuffers.get(block); if (cachedBlock.present()) { plaintext = cachedBlock.get(); } else { - Standalone _plaintext = wait(readBlock(self, block)); - self->readBuffers.insert(block, _plaintext); - plaintext = _plaintext; + wait(store(plaintext, readBlock(self, block))); + self->readBuffers.insert(block, plaintext); } auto start = (block == firstBlock) ? plaintext.begin() + (offset % FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE) : plaintext.begin(); @@ -79,6 +78,14 @@ public: if ((offset + length) % FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE == 0) { end = plaintext.end(); } + + // The block could be short if it includes or is after the end of the file. + end = std::min(end, plaintext.end()); + // If the start position is at or after the end of the block, the read is complete. + if (start == end || start >= plaintext.end()) { + break; + } + std::copy(start, end, output); output += (end - start); bytesRead += (end - start); From 256e9ba4871d6da4eb3274e3a48c2e264ce5a374 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Sat, 31 Jul 2021 11:35:02 -0700 Subject: [PATCH 163/225] Fixed warnings in IDE, applied clang-format. --- fdbclient/BackupContainerFileSystem.actor.cpp | 18 ++++++++++-------- fdbrpc/AsyncFileEncrypted.actor.cpp | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/fdbclient/BackupContainerFileSystem.actor.cpp b/fdbclient/BackupContainerFileSystem.actor.cpp index 040c759956..31d9260084 100644 --- a/fdbclient/BackupContainerFileSystem.actor.cpp +++ b/fdbclient/BackupContainerFileSystem.actor.cpp @@ -163,7 +163,6 @@ public: state Version maxVer = 0; state RangeFile rf; state json_spirit::mArray fileArray; - state int i; // Validate each filename, update version range for (const auto& f : fileNames) { @@ -1488,7 +1487,7 @@ void BackupContainerFileSystem::setEncryptionKey(Optional const& en #endif } } -Future BackupContainerFileSystem::createTestEncryptionKeyFile(std::string const &filename) { +Future BackupContainerFileSystem::createTestEncryptionKeyFile(std::string const& filename) { #if ENCRYPTION_ENABLED return BackupContainerFileSystemImpl::createTestEncryptionKeyFile(filename); #else @@ -1507,13 +1506,16 @@ int chooseFileSize(std::vector& sizes) { return deterministicRandom()->randomInt(0, 2e6); } -ACTOR Future writeAndVerifyFile(Reference c, Reference f, int size, FlowLock* lock) { +ACTOR Future writeAndVerifyFile(Reference c, + Reference f, + int size, + FlowLock* lock) { state Standalone> content; wait(lock->take(TaskPriority::DefaultYield, size)); - state FlowLock::Releaser releaser(*lock, size); + state FlowLock::Releaser releaser(*lock, size); - printf("writeAndVerify size=%d file=%s\n", size, f->getFileName().c_str()); + printf("writeAndVerify size=%d file=%s\n", size, f->getFileName().c_str()); content.resize(content.arena(), size); for (int i = 0; i < content.size(); ++i) { content[i] = (uint8_t)deterministicRandom()->randomInt(0, 256); @@ -1601,9 +1603,9 @@ ACTOR Future testBackupContainer(std::string url, Optional en // List of sizes to use to test edge cases on underlying file implementations state std::vector fileSizes = { 0 }; if (StringRef(url).startsWith(LiteralStringRef("blob"))) { - fileSizes.push_back(CLIENT_KNOBS->BLOBSTORE_MULTIPART_MIN_PART_SIZE); - fileSizes.push_back(CLIENT_KNOBS->BLOBSTORE_MULTIPART_MIN_PART_SIZE + 10); - } + fileSizes.push_back(CLIENT_KNOBS->BLOBSTORE_MULTIPART_MIN_PART_SIZE); + fileSizes.push_back(CLIENT_KNOBS->BLOBSTORE_MULTIPART_MIN_PART_SIZE + 10); + } loop { state Version logStart = v; diff --git a/fdbrpc/AsyncFileEncrypted.actor.cpp b/fdbrpc/AsyncFileEncrypted.actor.cpp index a354a8074e..c30b8dbf2b 100644 --- a/fdbrpc/AsyncFileEncrypted.actor.cpp +++ b/fdbrpc/AsyncFileEncrypted.actor.cpp @@ -262,6 +262,7 @@ TEST_CASE("fdbrpc/AsyncFileEncrypted") { state Reference file = wait(IAsyncFileSystem::filesystem()->open(joinPath(params.getDataDir(), "test-encrypted-file"), flags, 0600)); state int bytesWritten = 0; + state int chunkSize; while (bytesWritten < bytes) { chunkSize = std::min(deterministicRandom()->randomInt(0, 100), bytes - bytesWritten); wait(file->write(&writeBuffer[bytesWritten], chunkSize, bytesWritten)); @@ -269,7 +270,6 @@ TEST_CASE("fdbrpc/AsyncFileEncrypted") { } wait(file->sync()); state int bytesRead = 0; - state int chunkSize; while (bytesRead < bytes) { chunkSize = std::min(deterministicRandom()->randomInt(0, 100), bytes - bytesRead); int bytesReadInChunk = wait(file->read(&readBuffer[bytesRead], chunkSize, bytesRead)); From 15f5e4e4a51dcccb4c40bbb19194109c8537f90d Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Sat, 31 Jul 2021 11:39:28 -0700 Subject: [PATCH 164/225] Fixed file size limitation caused by block id being only 16 bits, now 32. --- fdbrpc/AsyncFileEncrypted.actor.cpp | 16 ++++++++-------- fdbrpc/AsyncFileEncrypted.h | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fdbrpc/AsyncFileEncrypted.actor.cpp b/fdbrpc/AsyncFileEncrypted.actor.cpp index c30b8dbf2b..865e2b10b4 100644 --- a/fdbrpc/AsyncFileEncrypted.actor.cpp +++ b/fdbrpc/AsyncFileEncrypted.actor.cpp @@ -43,7 +43,7 @@ public: } // Read a single block of size ENCRYPTION_BLOCK_SIZE bytes, and decrypt. - ACTOR static Future> readBlock(AsyncFileEncrypted* self, uint16_t block) { + ACTOR static Future> readBlock(AsyncFileEncrypted* self, uint32_t block) { state Arena arena; state unsigned char* encrypted = new (arena) unsigned char[FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE]; int bytes = wait( @@ -54,9 +54,9 @@ public: } ACTOR static Future read(AsyncFileEncrypted* self, void* data, int length, int64_t offset) { - state const uint16_t firstBlock = offset / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; - state const uint16_t lastBlock = (offset + length - 1) / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; - state uint16_t block; + state const uint32_t firstBlock = offset / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; + state const uint32_t lastBlock = (offset + length - 1) / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; + state uint32_t block; state unsigned char* output = reinterpret_cast(data); state int bytesRead = 0; ASSERT(self->mode == AsyncFileEncrypted::Mode::READ_ONLY); @@ -110,7 +110,7 @@ public: if (self->offsetInBlock == FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE) { wait(self->writeLastBlockToFile()); self->offsetInBlock = 0; - ASSERT_LT(self->currentBlock, std::numeric_limits::max()); + ASSERT_LT(self->currentBlock, std::numeric_limits::max()); ++self->currentBlock; self->encryptor = std::make_unique(StreamCipher::Key::getKey(), self->getIV(self->currentBlock)); @@ -203,7 +203,7 @@ int64_t AsyncFileEncrypted::debugFD() const { return file->debugFD(); } -StreamCipher::IV AsyncFileEncrypted::getIV(uint16_t block) const { +StreamCipher::IV AsyncFileEncrypted::getIV(uint32_t block) const { auto iv = firstBlockIV; iv[14] = block / 256; iv[15] = block % 256; @@ -225,7 +225,7 @@ AsyncFileEncrypted::RandomCache::RandomCache(size_t maxSize) : maxSize(maxSize) vec.reserve(maxSize); } -void AsyncFileEncrypted::RandomCache::insert(uint16_t block, const Standalone& value) { +void AsyncFileEncrypted::RandomCache::insert(uint32_t block, const Standalone& value) { auto [_, found] = hashMap.insert({ block, value }); if (found) { return; @@ -237,7 +237,7 @@ void AsyncFileEncrypted::RandomCache::insert(uint16_t block, const Standalone> AsyncFileEncrypted::RandomCache::get(uint16_t block) const { +Optional> AsyncFileEncrypted::RandomCache::get(uint32_t block) const { auto it = hashMap.find(block); if (it == hashMap.end()) { return {}; diff --git a/fdbrpc/AsyncFileEncrypted.h b/fdbrpc/AsyncFileEncrypted.h index 0d1d407a3d..bc345d043c 100644 --- a/fdbrpc/AsyncFileEncrypted.h +++ b/fdbrpc/AsyncFileEncrypted.h @@ -40,7 +40,7 @@ public: private: Reference file; StreamCipher::IV firstBlockIV; - StreamCipher::IV getIV(uint16_t block) const; + StreamCipher::IV getIV(uint32_t block) const; Mode mode; Future writeLastBlockToFile(); friend class AsyncFileEncryptedImpl; @@ -48,19 +48,19 @@ private: // Reading: class RandomCache { size_t maxSize; - std::vector vec; - std::unordered_map> hashMap; + std::vector vec; + std::unordered_map> hashMap; size_t evict(); public: RandomCache(size_t maxSize); - void insert(uint16_t block, const Standalone& value); - Optional> get(uint16_t block) const; + void insert(uint32_t block, const Standalone& value); + Optional> get(uint32_t block) const; } readBuffers; // Writing (append only): std::unique_ptr encryptor; - uint16_t currentBlock{ 0 }; + uint32_t currentBlock{ 0 }; int offsetInBlock{ 0 }; std::vector writeBuffer; Future initialize(); From 0a98c7674708ca2ec1b08f24c1c0c8832121c011 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sat, 31 Jul 2021 12:24:59 -0700 Subject: [PATCH 165/225] Fix trace event throttling by using different types --- fdbbackup/FileDecoder.actor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 697d600acc..a8d461639e 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -582,7 +582,9 @@ ACTOR Future decode_logs(DecodeParams params) { continue; } + int i = 0; for (const auto& m : vms.mutations) { + i++; // sub sequence number starts at 1 bool print = params.prefix.empty(); // no filtering if (!print) { @@ -596,7 +598,7 @@ ACTOR Future decode_logs(DecodeParams params) { } } if (print) { - TraceEvent("Mutation") + TraceEvent(format("Mutation_%d_%d", vms.version, i).c_str()) .detail("Version", vms.version) .setMaxFieldLength(10000) .detail("M", m.toString()); @@ -652,7 +654,7 @@ int main(int argc, char** argv) { setupNetwork(0, UseMetrics::True); TraceEvent::setNetworkThread(); - openTraceFile(NetworkAddress(), 10 << 20, 10 << 20, param.log_dir, "decode", param.trace_log_group); + openTraceFile(NetworkAddress(), 10 << 20, 500 << 20, param.log_dir, "decode", param.trace_log_group); param.tlsConfig.setupBlobCredentials(); auto f = stopAfter(decode_logs(param)); From cc68800d2ab946dcca3f4ae1ef5bc8d8eddcddfc Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Sat, 31 Jul 2021 12:27:58 -0700 Subject: [PATCH 166/225] Update IV functions to use 32 bit block size. --- fdbrpc/AsyncFileEncrypted.actor.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fdbrpc/AsyncFileEncrypted.actor.cpp b/fdbrpc/AsyncFileEncrypted.actor.cpp index 865e2b10b4..9f0aa8f76d 100644 --- a/fdbrpc/AsyncFileEncrypted.actor.cpp +++ b/fdbrpc/AsyncFileEncrypted.actor.cpp @@ -34,11 +34,13 @@ public: auto pos = salt.find('.'); salt = salt.substr(0, pos); auto hash = XXH3_128bits(salt.c_str(), salt.size()); - auto high = reinterpret_cast(&hash.high64); - auto low = reinterpret_cast(&hash.low64); - std::copy(high, high + 8, &iv[0]); - std::copy(low, low + 6, &iv[8]); - iv[14] = iv[15] = 0; // last 16 bits identify block + auto pHigh = reinterpret_cast(&hash.high64); + auto pLow = reinterpret_cast(&hash.low64); + std::copy(pHigh, pHigh + 8, &iv[0]); + std::copy(pLow, pLow + 4, &iv[8]); + uint32_t blockZero = 0; + auto pBlock = reinterpret_cast(&blockZero); + std::copy(pBlock, pBlock + 4, &iv[12]); return iv; } @@ -205,8 +207,10 @@ int64_t AsyncFileEncrypted::debugFD() const { StreamCipher::IV AsyncFileEncrypted::getIV(uint32_t block) const { auto iv = firstBlockIV; - iv[14] = block / 256; - iv[15] = block % 256; + + auto pBlock = reinterpret_cast(&block); + std::copy(pBlock, pBlock + 4, &iv[12]); + return iv; } From 114508754307e098daea8a3ecedb6ca3efde049a Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sat, 31 Jul 2021 12:45:47 -0700 Subject: [PATCH 167/225] Add UID to the events for decoders --- fdbbackup/FileDecoder.actor.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index a8d461639e..7f82fb0823 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -32,6 +32,7 @@ #include "fdbclient/CommitTransaction.h" #include "fdbclient/FDBTypes.h" #include "fdbclient/MutationList.h" +#include "flow/IRandom.h" #include "flow/Trace.h" #include "flow/flow.h" #include "flow/serialize.h" @@ -546,7 +547,7 @@ public: ACTOR Future decode_logs(DecodeParams params) { state Reference container = IBackupContainer::openContainer(params.container_url); - + state UID uid = deterministicRandom()->randomUniqueID(); state BackupFileList listing = wait(container->dumpFileList()); // remove partitioned logs listing.logs.erase(std::remove_if(listing.logs.begin(), @@ -557,7 +558,8 @@ ACTOR Future decode_logs(DecodeParams params) { }), listing.logs.end()); std::sort(listing.logs.begin(), listing.logs.end()); - TraceEvent("Container").detail("URL", params.container_url).detail("Logs", listing.logs.size()); + TraceEvent("Container", uid).detail("URL", params.container_url).detail("Logs", listing.logs.size()); + TraceEvent("DecodeParam", uid).setMaxFieldLength(100000).detail("Value", params.toString()); BackupDescription desc = wait(container->describeBackup()); std::cout << "\n" << desc.toString() << "\n"; @@ -598,7 +600,7 @@ ACTOR Future decode_logs(DecodeParams params) { } } if (print) { - TraceEvent(format("Mutation_%d_%d", vms.version, i).c_str()) + TraceEvent(format("Mutation_%d_%d", vms.version, i).c_str(), uid) .detail("Version", vms.version) .setMaxFieldLength(10000) .detail("M", m.toString()); @@ -611,7 +613,7 @@ ACTOR Future decode_logs(DecodeParams params) { TraceEvent("UnfinishedFile").detail("File", logs[i].fileName).detail("Q", left.size()); } } - TraceEvent("DecodeDone"); + TraceEvent("DecodeDone", uid); return Void(); } From b930faf52012a7e6081fead345d2bf50b4c3eb1a Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sat, 31 Jul 2021 12:52:39 -0700 Subject: [PATCH 168/225] Log prefix filter --- fdbbackup/FileDecoder.actor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 7f82fb0823..b96e6a68c1 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -126,6 +126,9 @@ struct DecodeParams { if (endVersionFilter < std::numeric_limits::max()) { s.append(", endVersionFilter: ").append(std::to_string(endVersionFilter)); } + if (!prefix.empty()) { + s.append(", KeyPrefix: ").append(printable(prefix)); + } return s; } From 9e4bee9e30dfa66393cf7e84e36f8aa136bb9fc5 Mon Sep 17 00:00:00 2001 From: Meng Xu Date: Sun, 1 Aug 2021 01:50:33 +0000 Subject: [PATCH 169/225] Handle ascii special characters --- fdbbackup/FileDecoder.actor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index b96e6a68c1..50e99784c7 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -127,7 +127,7 @@ struct DecodeParams { s.append(", endVersionFilter: ").append(std::to_string(endVersionFilter)); } if (!prefix.empty()) { - s.append(", KeyPrefix: ").append(printable(prefix)); + s.append(", KeyPrefix: ").append(printable(KeyRef(prefix))); } return s; } @@ -594,10 +594,10 @@ ACTOR Future decode_logs(DecodeParams params) { if (!print) { if (isSingleKeyMutation((MutationRef::Type)m.type)) { - print = m.param1.startsWith(params.prefix); + print = m.param1.startsWith(StringRef(params.prefix)); } else if (m.type == MutationRef::ClearRange) { KeyRange range(KeyRangeRef(m.param1, m.param2)); - print = range.contains(params.prefix); + print = range.contains(StringRef(params.prefix)); } else { ASSERT(false); } From 2282d8455a3827c93b64e52fe4ba730304d55529 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sat, 31 Jul 2021 15:30:30 -0700 Subject: [PATCH 170/225] Fix trace format json --- fdbbackup/FileDecoder.actor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 50e99784c7..461f42ea31 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -88,7 +88,7 @@ void printBuildInformation() { struct DecodeParams { std::string container_url; std::string fileFilter; // only files match the filter will be decoded - bool log_enabled = false; + bool log_enabled = true; std::string log_dir, trace_format, trace_log_group; BackupTLSConfig tlsConfig; bool list_only = false; @@ -189,7 +189,7 @@ int parseDecodeCommandLine(DecodeParams* param, CSimpleOpt* args) { break; case OPT_TRACE_FORMAT: - if (!validateTraceFormat(args->OptionArg())) { + if (!selectTraceFormatter(args->OptionArg())) { std::cerr << "ERROR: Unrecognized trace format " << args->OptionArg() << "\n"; return FDB_EXIT_ERROR; } @@ -641,6 +641,8 @@ int main(int argc, char** argv) { } if (!param.trace_format.empty()) { setNetworkOption(FDBNetworkOptions::TRACE_FORMAT, StringRef(param.trace_format)); + } else { + setNetworkOption(FDBNetworkOptions::TRACE_FORMAT, "json"_sr); } if (!param.trace_log_group.empty()) { setNetworkOption(FDBNetworkOptions::TRACE_LOG_GROUP, StringRef(param.trace_log_group)); From de1e9000a22f5a0bc72a3d72bc3ef17a1f384122 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sat, 31 Jul 2021 21:00:07 -0700 Subject: [PATCH 171/225] Add --hex_prefix flag --- fdbbackup/FileConverter.h | 2 ++ fdbbackup/FileDecoder.actor.cpp | 57 +++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/fdbbackup/FileConverter.h b/fdbbackup/FileConverter.h index a18fe47614..9bb1036a2f 100644 --- a/fdbbackup/FileConverter.h +++ b/fdbbackup/FileConverter.h @@ -43,6 +43,7 @@ enum { OPT_BUILD_FLAGS, OPT_LIST_ONLY, OPT_KEY_PREFIX, + OPT_HEX_KEY_PREFIX, OPT_BEGIN_VERSION_FILTER, OPT_END_VERSION_FILTER, OPT_HELP @@ -68,6 +69,7 @@ CSimpleOpt::SOption gConverterOptions[] = { { OPT_CONTAINER, "-r", SO_REQ_SEP }, { OPT_BUILD_FLAGS, "--build_flags", SO_NONE }, { OPT_LIST_ONLY, "--list_only", SO_NONE }, { OPT_KEY_PREFIX, "-k", SO_REQ_SEP }, + { OPT_HEX_KEY_PREFIX, "--hex_prefix", SO_REQ_SEP }, { OPT_BEGIN_VERSION_FILTER, "--begin_version_filter", SO_REQ_SEP }, { OPT_END_VERSION_FILTER, "--end_version_filter", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 461f42ea31..0ec8e39e73 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -73,6 +73,8 @@ void printDecodeUsage() { " --build_flags Print build information and exit.\n" " --list_only Print file list and exit.\n" " -k KEY_PREFIX Use the prefix for filtering mutations\n" + " --hex_prefix HEX_PREFIX\n" + " The prefix specified in HEX format, e.g., \\x05\\x01.\n" " --begin_version_filter BEGIN_VERSION\n" " The version range's begin version (inclusive) for filtering.\n" " --end_version_filter END_VERSION\n" @@ -131,10 +133,57 @@ struct DecodeParams { } return s; } - - }; +// Decode an ASCII string, e.g., "\x15\x1b\x19\x04\xaf\x0c\x28\x0a", +// into the binary string. +std::string decode_hex_string(std::string line) { + size_t i = 0; + std::string ret; + + while (i <= line.length()) { + switch (line[i]) { + case '\\': + if (i + 2 > line.length()) { + std::cerr << "Invalid hex string at: " << i << "\n"; + return ret; + } + switch (line[i + 1]) { + char ent, save; + case '"': + case '\\': + case ' ': + case ';': + line.erase(i, 1); + break; + case 'x': + if (i + 4 > line.length()) { + std::cerr << "Invalid hex string at: " << i << "\n"; + return ret; + } + char* pEnd; + save = line[i + 4]; + line[i + 4] = 0; + ent = char(strtoul(line.data() + i + 2, &pEnd, 16)); + if (*pEnd) { + std::cerr << "Invalid hex string at: " << i << "\n"; + return ret; + } + line[i + 4] = save; + line.replace(i, 4, 1, ent); + break; + default: + std::cerr << "Invalid hex string at: " << i << "\n"; + return ret; + } + default: + i++; + } + } + + return line.substr(0, i); +} + int parseDecodeCommandLine(DecodeParams* param, CSimpleOpt* args) { while (args->Next()) { auto lastError = args->LastError(); @@ -164,6 +213,10 @@ int parseDecodeCommandLine(DecodeParams* param, CSimpleOpt* args) { param->prefix = args->OptionArg(); break; + case OPT_HEX_KEY_PREFIX: + param->prefix = decode_hex_string(args->OptionArg()); + break; + case OPT_BEGIN_VERSION_FILTER: param->beginVersionFilter = std::atoll(args->OptionArg()); break; From d7ac5830e6e66ebd7102b16925834a78588bb5a3 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sun, 1 Aug 2021 13:48:45 -0700 Subject: [PATCH 172/225] Fix decoder bug of shadowing loop index --- fdbbackup/FileDecoder.actor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 0ec8e39e73..2ccb01a61f 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -640,9 +640,9 @@ ACTOR Future decode_logs(DecodeParams params) { continue; } - int i = 0; + int sub = 0; for (const auto& m : vms.mutations) { - i++; // sub sequence number starts at 1 + sub++; // sub sequence number starts at 1 bool print = params.prefix.empty(); // no filtering if (!print) { @@ -656,7 +656,7 @@ ACTOR Future decode_logs(DecodeParams params) { } } if (print) { - TraceEvent(format("Mutation_%d_%d", vms.version, i).c_str(), uid) + TraceEvent(format("Mutation_%d_%d", vms.version, sub).c_str(), uid) .detail("Version", vms.version) .setMaxFieldLength(10000) .detail("M", m.toString()); From e3629ef356b523fc949c4033392e9f7f9ca29950 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sun, 1 Aug 2021 14:08:54 -0700 Subject: [PATCH 173/225] Refactor decoder --- fdbbackup/FileDecoder.actor.cpp | 491 +++++++++++++++++++------------- 1 file changed, 291 insertions(+), 200 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 2ccb01a61f..7a93db7857 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -363,20 +363,190 @@ std::vector decode_value(const StringRef& value) { return mutations; } + +// Decodes a mutation log key, which contains (hash, commitVersion, chunkNumber) and +// returns (commitVersion, chunkNumber) +std::pair decodeLogKey(const StringRef& key) { + ASSERT(key.size() == sizeof(uint8_t) + sizeof(Version) + sizeof(int32_t)); + + uint8_t hash; + Version version; + int32_t part; + BinaryReader rd(key, Unversioned()); + rd >> hash >> version >> part; + version = bigEndian64(version); + part = bigEndian32(part); + + int32_t v = version / CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE; + ASSERT(((uint8_t)hashlittle(&v, sizeof(v), 0)) == hash); + + return std::make_pair(version, part); +} + +// Decodes an encoded list of mutations in the format of: +// [includeVersion:uint64_t][val_length:uint32_t][mutation_1][mutation_2]...[mutation_k], +// where a mutation is encoded as: +// [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][param1][param2] +std::vector decodeLogValue(const StringRef& value) { + StringRefReader reader(value, restore_corrupted_data()); + + Version protocolVersion = reader.consume(); + if (protocolVersion <= 0x0FDB00A200090001) { + throw incompatible_protocol_version(); + } + + uint32_t val_length = reader.consume(); + if (val_length != value.size() - sizeof(uint64_t) - sizeof(uint32_t)) { + TraceEvent(SevError, "FileRestoreLogValueError") + .detail("ValueLen", val_length) + .detail("ValueSize", value.size()) + .detail("Value", printable(value)); + } + + std::vector mutations; + while (1) { + if (reader.eof()) + break; + + // Deserialization of a MutationRef, which was packed by MutationListRef::push_back_deep() + uint32_t type, p1len, p2len; + type = reader.consume(); + p1len = reader.consume(); + p2len = reader.consume(); + + const uint8_t* key = reader.consume(p1len); + const uint8_t* val = reader.consume(p2len); + + mutations.emplace_back((MutationRef::Type)type, StringRef(key, p1len), StringRef(val, p2len)); + } + return mutations; +} + +// Accumulates mutation log value chunks, as both a vector of chunks and as a combined chunk, +// in chunk order, and can check the chunk set for completion or intersection with a set +// of ranges. +struct AccumulatedMutations { + AccumulatedMutations() : lastChunkNumber(-1) {} + + // Add a KV pair for this mutation chunk set + // It will be accumulated onto serializedMutations if the chunk number is + // the next expected value. + void addChunk(int chunkNumber, const KeyValueRef& kv) { + if (chunkNumber == lastChunkNumber + 1) { + lastChunkNumber = chunkNumber; + serializedMutations += kv.value.toString(); + } else { + lastChunkNumber = -2; + serializedMutations.clear(); + } + kvs.push_back(kv); + } + + // Returns true if both + // - 1 or more chunks were added to this set + // - The header of the first chunk contains a valid protocol version and a length + // that matches the bytes after the header in the combined value in serializedMutations + bool isComplete() const { + if (lastChunkNumber >= 0) { + StringRefReader reader(serializedMutations, restore_corrupted_data()); + + Version protocolVersion = reader.consume(); + if (protocolVersion <= 0x0FDB00A200090001) { + throw incompatible_protocol_version(); + } + + uint32_t vLen = reader.consume(); + return vLen == reader.remainder().size(); + } + + return false; + } + + // Returns true if a complete chunk contains any MutationRefs which intersect with any + // range in ranges. + // It is undefined behavior to run this if isComplete() does not return true. + bool matchesAnyRange(const std::vector& ranges) const { + std::vector mutations = decodeLogValue(serializedMutations); + for (auto& m : mutations) { + for (auto& r : ranges) { + if (m.type == MutationRef::ClearRange) { + if (r.intersects(KeyRangeRef(m.param1, m.param2))) { + return true; + } + } else { + if (r.contains(m.param1)) { + return true; + } + } + } + } + + return false; + } + + std::vector kvs; + std::string serializedMutations; + int lastChunkNumber; +}; + + + struct VersionedMutations { Version version; std::vector mutations; Arena arena; // The arena that contains the mutations. + std::string serializedMutations; // buffer that contains mutations }; -struct VersionedKVPart { - Arena arena; - Version version; - int32_t part; - StringRef kv; - VersionedKVPart(Arena arena, Version version, int32_t part, StringRef kv) - : arena(arena), version(version), part(part), kv(kv) {} -}; +ACTOR Future>> decodeLogFileBlock(Reference file, + int64_t offset, + int len) { + state Standalone buf = makeString(len); + int rLen = wait(file->read(mutateString(buf), len, offset)); + if (rLen != len) + throw restore_bad_read(); + + Standalone> results({}, buf.arena()); + state StringRefReader reader(buf, restore_corrupted_data()); + + try { + // Read header, currently only decoding version BACKUP_AGENT_MLOG_VERSION + if (reader.consume() != BACKUP_AGENT_MLOG_VERSION) + throw restore_unsupported_file_version(); + + // Read k/v pairs. Block ends either at end of last value exactly or with 0xFF as first key len byte. + while (1) { + // If eof reached or first key len bytes is 0xFF then end of block was reached. + if (reader.eof() || *reader.rptr == 0xFF) + break; + + // Read key and value. If anything throws then there is a problem. + uint32_t kLen = reader.consumeNetworkUInt32(); + const uint8_t* k = reader.consume(kLen); + uint32_t vLen = reader.consumeNetworkUInt32(); + const uint8_t* v = reader.consume(vLen); + + results.push_back(results.arena(), KeyValueRef(KeyRef(k, kLen), ValueRef(v, vLen))); + } + + // Make sure any remaining bytes in the block are 0xFF + for (auto b : reader.remainder()) + if (b != 0xFF) + throw restore_corrupted_data_padding(); + + return results; + + } catch (Error& e) { + TraceEvent(SevWarn, "FileRestoreCorruptLogFileBlock") + .error(e) + .detail("Filename", file->getFilename()) + .detail("BlockOffset", offset) + .detail("BlockLen", len) + .detail("ErrorRelativeOffset", reader.rptr - buf.begin()) + .detail("ErrorAbsoluteOffset", reader.rptr - buf.begin() + offset); + throw; + } +} /* * Model a decoding progress for a mutation file. Usage is: @@ -395,174 +565,78 @@ struct VersionedKVPart { * at any time this object might have two blocks of data in memory. */ class DecodeProgress { - std::vector keyValues; + Standalone> blocks; + std::unordered_map mutationBlocksByVersion; public: DecodeProgress() = default; - template - DecodeProgress(const LogFile& file, U&& values) : keyValues(std::forward(values)), file(file) {} + DecodeProgress(const LogFile& file) : file(file) {} // If there are no more mutations to pull from the file. - // However, we could have unfinished version in the buffer when EOF is true, - // which means we should look for data in the next file. The caller - // should call getUnfinishedBuffer() to get these left data. - bool finished() const { return (eof && keyValues.empty()) || (leftover && !keyValues.empty()); } - - std::vector&& getUnfinishedBuffer() && { return std::move(keyValues); } - - // Returns all mutations of the next version in a batch. - Future getNextBatch() { return getNextBatchImpl(this); } + bool finished() const { return done; } + // Open and loads file into memory Future openFile(Reference container) { return openFileImpl(this, container); } // The following are private APIs: - // Returns true if value contains complete data. - static bool isValueComplete(StringRef value) { - StringRefReader reader(value, restore_corrupted_data()); - - reader.consume(); // Consume the includeVersion - uint32_t val_length = reader.consume(); - return val_length == value.size() - sizeof(uint64_t) - sizeof(uint32_t); - } - // PRECONDITION: finished() must return false before calling this function. // Returns the next batch of mutations along with the arena backing it. // Note the returned batch can be empty when the file has unfinished // version batch data that are in the next file. - ACTOR static Future getNextBatchImpl(DecodeProgress* self) { - ASSERT(!self->finished()); + VersionedMutations getNextBatch() { + ASSERT(!finished()); - loop { - if (self->keyValues.size() <= 1) { - // Try to decode another block when less than one left - wait(readAndDecodeFile(self)); - } - - const auto& kv = self->keyValues[0]; - ASSERT(kv.part == 0); - - // decode next versions, check if they are continuous parts - int idx = 1; // next kv pair in "keyValues" - int bufSize = kv.kv.size(); - for (int lastPart = 0; idx < self->keyValues.size(); idx++, lastPart++) { - if (idx == self->keyValues.size()) - break; - - const auto& nextKV = self->keyValues[idx]; - if (kv.version != nextKV.version) { - break; - } - - if (lastPart + 1 != nextKV.part) { - TraceEvent("DecodeError").detail("Part1", lastPart).detail("Part2", nextKV.part); - throw restore_corrupted_data(); - } - bufSize += nextKV.kv.size(); - } - - VersionedMutations m; - m.version = kv.version; - TraceEvent("Decode").detail("Version", m.version).detail("Idx", idx).detail("Q", self->keyValues.size()); - StringRef value = kv.kv; - if (idx > 1) { - // Stitch parts into one and then decode one by one - Standalone buf = self->combineValues(idx, bufSize); - value = buf; - m.arena = buf.arena(); - } - if (isValueComplete(value)) { - m.mutations = decode_value(value); - if (m.arena.getSize() == 0) { - m.arena = kv.arena; - } - self->keyValues.erase(self->keyValues.begin(), self->keyValues.begin() + idx); - return m; - } else if (!self->eof) { - // Read one more block, hopefully the missing part of the value can be found. - wait(readAndDecodeFile(self)); - } else { - TraceEvent(SevWarn, "MissingValue").detail("Version", m.version); - self->leftover = true; - return m; // Empty mutations + VersionedMutations vms; + for (auto& [version, m] : mutationBlocksByVersion) { + if (m.isComplete()) { + vms.version = version; + std::vector mutations = decodeLogValue(m.serializedMutations); + TraceEvent("Decode").detail("version", vms.version).detail("N", mutations.size()); + vms.mutations.insert(vms.mutations.end(), mutations.begin(), mutations.end()); + vms.arena = blocks.arena(); + vms.serializedMutations = m.serializedMutations; + mutationBlocksByVersion.erase(version); + return vms; } } - } - // Returns a buffer which stitches first "idx" values into one. - // "len" MUST equal the summation of these values. - Standalone combineValues(const int idx, const int len) { - ASSERT(idx <= keyValues.size() && idx > 1); - - Standalone buf = makeString(len); - int n = 0; - for (int i = 0; i < idx; i++) { - const auto& value = keyValues[i].kv; - memcpy(mutateString(buf) + n, value.begin(), value.size()); - n += value.size(); - } - - ASSERT(n == len); - return buf; - } - - // Decodes a block into KeyValueRef stored in "keyValues". - void decode_block(const Standalone& buf, int len) { - StringRef block(buf.begin(), len); - StringRefReader reader(block, restore_corrupted_data()); - - try { - // Read header, currently only decoding version BACKUP_AGENT_MLOG_VERSION - if (reader.consume() != BACKUP_AGENT_MLOG_VERSION) - throw restore_unsupported_file_version(); - - // Read k/v pairs. Block ends either at end of last value exactly or with 0xFF as first key len byte. - while (1) { - // If eof reached or first key len bytes is 0xFF then end of block was reached. - if (reader.eof() || *reader.rptr == 0xFF) - break; - - // Read key and value. If anything throws then there is a problem. - uint32_t kLen = reader.consumeNetworkUInt32(); - const uint8_t* k = reader.consume(kLen); - std::pair version_part = decode_key(StringRef(k, kLen)); - uint32_t vLen = reader.consumeNetworkUInt32(); - const uint8_t* v = reader.consume(vLen); - TraceEvent(SevDecodeInfo, "Block") - .detail("KeySize", kLen) - .detail("valueSize", vLen) - .detail("Offset", reader.rptr - buf.begin()) - .detail("Version", version_part.first) - .detail("Part", version_part.second); - keyValues.emplace_back(buf.arena(), version_part.first, version_part.second, StringRef(v, vLen)); - } - - // Make sure any remaining bytes in the block are 0xFF - for (auto b : reader.remainder()) { - if (b != 0xFF) - throw restore_corrupted_data_padding(); - } - - // The (version, part) in a block can be out of order, i.e., (3, 0) - // can be followed by (4, 0), and then (3, 1). So we need to sort them - // first by version, and then by part number. - std::sort(keyValues.begin(), keyValues.end(), [](const VersionedKVPart& a, const VersionedKVPart& b) { - return a.version == b.version ? a.part < b.part : a.version < b.version; - }); - return; - } catch (Error& e) { - TraceEvent(SevWarn, "CorruptBlock").error(e).detail("Offset", reader.rptr - buf.begin()); - throw; - } + // No complete versions + TraceEvent(SevWarn, "UnfishedBlocks").detail("NumberOfVersions", mutationBlocksByVersion.size()); + done = true; + return vms; } ACTOR static Future openFileImpl(DecodeProgress* self, Reference container) { Reference fd = wait(container->readFile(self->file.fileName)); self->fd = fd; - wait(readAndDecodeFile(self)); + while (!self->eof) { + wait(readAndDecodeFile(self)); + } return Void(); } + // Add blocks to mutationBlocksByVersion + void filterLogMutationKVPairs(VectorRef blocks) { + for (auto& kv : blocks) { + auto versionAndChunkNumber = decodeLogKey(kv.key); + mutationBlocksByVersion[versionAndChunkNumber.first].addChunk(versionAndChunkNumber.second, kv); + } +/* + std::vector output; + + for (auto& vb : mutationBlocksByVersion) { + AccumulatedMutations& m = vb.second; + + // If the mutations are incomplete or match one of the ranges, include in results. + if (!m.isComplete() || m.matchesAnyRange(ranges)) { + output.insert(output.end(), m.kvs.begin(), m.kvs.end()); + } + } + + return output;*/ + } + // Reads a file block, decodes it into key/value pairs, and stores these pairs. ACTOR static Future readAndDecodeFile(DecodeProgress* self) { try { @@ -572,17 +646,21 @@ public: return Void(); } - state Standalone buf = makeString(len); - state int rLen = wait(self->fd->read(mutateString(buf), len, self->offset)); + // Decode a file block into log_key and log_value pairs + Standalone> blocks = wait(decodeLogFileBlock(self->fd, self->offset, len)); + // This is memory inefficient, but we don't know if blocks are complete version data + self->blocks.reserve(self->blocks.arena(), self->blocks.size() + blocks.size()); + for (int i = 0; i < blocks.size(); i++) { + self->blocks.push_back_deep(self->blocks.arena(), blocks[i]); + } + TraceEvent("ReadFile") .detail("Name", self->file.fileName) - .detail("Len", rLen) + .detail("Len", len) .detail("Offset", self->offset); - if (rLen != len) { - throw restore_corrupted_data(); - } - self->decode_block(buf, rLen); - self->offset += rLen; + self->filterLogMutationKVPairs(blocks); + self->offset += len; + return Void(); } catch (Error& e) { TraceEvent(SevWarn, "CorruptLogFileBlock") @@ -598,9 +676,55 @@ public: Reference fd; int64_t offset = 0; bool eof = false; - bool leftover = false; // Done but has unfinished version batch data left + bool done = false; }; +ACTOR Future process_file(Reference container, LogFile file, UID uid, DecodeParams params) { + TraceEvent("ProcessFile").detail("Name", file.fileName); + std::cout << "ProcessFile " << file.fileName << "\n"; + if (file.fileSize == 0) { + TraceEvent("SkipEmptyFile").detail("Name", file.fileName); + return Void(); + } + + state DecodeProgress progress(file); + wait(progress.openFile(container)); + while (!progress.finished()) { + VersionedMutations vms = progress.getNextBatch(); + if (vms.version < params.beginVersionFilter || vms.version >= params.endVersionFilter) { + TraceEvent("SkipVersion").detail("Version", vms.version); + continue; + } + + int sub = 0; + for (const auto& m : vms.mutations) { + sub++; // sub sequence number starts at 1 + bool print = params.prefix.empty(); // no filtering + + if (!print) { + if (isSingleKeyMutation((MutationRef::Type)m.type)) { + print = m.param1.startsWith(StringRef(params.prefix)); + } else if (m.type == MutationRef::ClearRange) { + KeyRange range(KeyRangeRef(m.param1, m.param2)); + print = range.contains(StringRef(params.prefix)); + } else { + ASSERT(false); + } + } + if (print) { + TraceEvent(format("Mutation_%d_%d", vms.version, sub).c_str(), uid) + .detail("Version", vms.version) + .setMaxFieldLength(10000) + .detail("M", m.toString()); + std::cout << vms.version << " " << m.toString() << "\n"; + } + } + } + TraceEvent("ProcessFileDone").detail("File", file.fileName); + std::cout << "ProcessFileDone " << file.fileName << "\n"; + return Void(); +} + ACTOR Future decode_logs(DecodeParams params) { state Reference container = IBackupContainer::openContainer(params.container_url); state UID uid = deterministicRandom()->randomUniqueID(); @@ -625,49 +749,16 @@ ACTOR Future decode_logs(DecodeParams params) { if (params.list_only) return Void(); - state int i = 0; - // Previous file's unfinished version data - state std::vector left; - for (; i < logs.size(); i++) { - if (logs[i].fileSize == 0) - continue; + state int idx = 0; + while (idx < logs.size()) { + TraceEvent("ProcessFileI").detail("Name", logs[idx].fileName).detail("I", idx); + std::cout << "ProcessFileI " << logs[idx].fileName << " " << idx << "\n"; - state DecodeProgress progress(logs[i], std::move(left)); - wait(progress.openFile(container)); - while (!progress.finished()) { - VersionedMutations vms = wait(progress.getNextBatch()); - if (vms.version < params.beginVersionFilter || vms.version >= params.endVersionFilter) { - continue; - } + wait(process_file(container, logs[idx], uid, params)); - int sub = 0; - for (const auto& m : vms.mutations) { - sub++; // sub sequence number starts at 1 - bool print = params.prefix.empty(); // no filtering - - if (!print) { - if (isSingleKeyMutation((MutationRef::Type)m.type)) { - print = m.param1.startsWith(StringRef(params.prefix)); - } else if (m.type == MutationRef::ClearRange) { - KeyRange range(KeyRangeRef(m.param1, m.param2)); - print = range.contains(StringRef(params.prefix)); - } else { - ASSERT(false); - } - } - if (print) { - TraceEvent(format("Mutation_%d_%d", vms.version, sub).c_str(), uid) - .detail("Version", vms.version) - .setMaxFieldLength(10000) - .detail("M", m.toString()); - std::cout << vms.version << " " << m.toString() << "\n"; - } - } - } - left = std::move(progress).getUnfinishedBuffer(); - if (!left.empty()) { - TraceEvent("UnfinishedFile").detail("File", logs[i].fileName).detail("Q", left.size()); - } + TraceEvent("ProcessFileIDone").detail("I", idx); + std::cout << "ProcessFileIDone " << idx << "\n"; + idx++; } TraceEvent("DecodeDone", uid); return Void(); From 4f5bcaf05069d33ba1afc58c3c70ca41e5609b83 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sun, 1 Aug 2021 19:11:23 -0700 Subject: [PATCH 174/225] Remove verbose stdout messages --- fdbbackup/FileDecoder.actor.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 7a93db7857..703d54bf53 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -681,7 +681,6 @@ public: ACTOR Future process_file(Reference container, LogFile file, UID uid, DecodeParams params) { TraceEvent("ProcessFile").detail("Name", file.fileName); - std::cout << "ProcessFile " << file.fileName << "\n"; if (file.fileSize == 0) { TraceEvent("SkipEmptyFile").detail("Name", file.fileName); return Void(); @@ -721,7 +720,6 @@ ACTOR Future process_file(Reference container, LogFile f } } TraceEvent("ProcessFileDone").detail("File", file.fileName); - std::cout << "ProcessFileDone " << file.fileName << "\n"; return Void(); } @@ -752,12 +750,10 @@ ACTOR Future decode_logs(DecodeParams params) { state int idx = 0; while (idx < logs.size()) { TraceEvent("ProcessFileI").detail("Name", logs[idx].fileName).detail("I", idx); - std::cout << "ProcessFileI " << logs[idx].fileName << " " << idx << "\n"; wait(process_file(container, logs[idx], uid, params)); TraceEvent("ProcessFileIDone").detail("I", idx); - std::cout << "ProcessFileIDone " << idx << "\n"; idx++; } TraceEvent("DecodeDone", uid); From 1a97c3942a0de0eff92cb2a1d6866b212beebcee Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sun, 1 Aug 2021 19:25:39 -0700 Subject: [PATCH 175/225] Fix trace events --- fdbbackup/FileDecoder.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 703d54bf53..0e795e0427 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -592,7 +592,7 @@ public: if (m.isComplete()) { vms.version = version; std::vector mutations = decodeLogValue(m.serializedMutations); - TraceEvent("Decode").detail("version", vms.version).detail("N", mutations.size()); + TraceEvent("Decode").detail("Version", vms.version).detail("N", mutations.size()); vms.mutations.insert(vms.mutations.end(), mutations.begin(), mutations.end()); vms.arena = blocks.arena(); vms.serializedMutations = m.serializedMutations; @@ -711,7 +711,7 @@ ACTOR Future process_file(Reference container, LogFile f } } if (print) { - TraceEvent(format("Mutation_%d_%d", vms.version, sub).c_str(), uid) + TraceEvent(format("Mutation_%llu_%d", vms.version, sub).c_str(), uid) .detail("Version", vms.version) .setMaxFieldLength(10000) .detail("M", m.toString()); From 8f1946f522ef558df46405fd3b28d3831b8931b8 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sun, 1 Aug 2021 21:55:39 -0700 Subject: [PATCH 176/225] Remove unused code --- fdbbackup/FileDecoder.actor.cpp | 82 ++------------------------------- 1 file changed, 5 insertions(+), 77 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 0e795e0427..41ffeb4cb8 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -311,59 +311,6 @@ std::vector getRelevantLogFiles(const std::vector& files, cons return filtered; } -std::pair decode_key(const StringRef& key) { - ASSERT(key.size() == sizeof(uint8_t) + sizeof(Version) + sizeof(int32_t)); - - uint8_t hash; - Version version; - int32_t part; - BinaryReader rd(key, Unversioned()); - rd >> hash >> version >> part; - version = bigEndian64(version); - part = bigEndian32(part); - - int32_t v = version / CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE; - ASSERT(((uint8_t)hashlittle(&v, sizeof(v), 0)) == hash); - - return std::make_pair(version, part); -} - -// Decodes an encoded list of mutations in the format of: -// [includeVersion:uint64_t][val_length:uint32_t][mutation_1][mutation_2]...[mutation_k], -// where a mutation is encoded as: -// [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][key][value] -std::vector decode_value(const StringRef& value) { - StringRefReader reader(value, restore_corrupted_data()); - - reader.consume(); // Consume the includeVersion - uint32_t val_length = reader.consume(); - if (val_length != value.size() - sizeof(uint64_t) - sizeof(uint32_t)) { - TraceEvent(SevError, "ValueError") - .detail("ValueLen", val_length) - .detail("ValueSize", value.size()) - .detail("Value", printable(value)); - } - - std::vector mutations; - while (1) { - if (reader.eof()) - break; - - // Deserialization of a MutationRef, which was packed by MutationListRef::push_back_deep() - uint32_t type, p1len, p2len; - type = reader.consume(); - p1len = reader.consume(); - p2len = reader.consume(); - - const uint8_t* key = reader.consume(p1len); - const uint8_t* val = reader.consume(p2len); - - mutations.emplace_back((MutationRef::Type)type, StringRef(key, p1len), StringRef(val, p2len)); - } - return mutations; -} - - // Decodes a mutation log key, which contains (hash, commitVersion, chunkNumber) and // returns (commitVersion, chunkNumber) std::pair decodeLogKey(const StringRef& key) { @@ -489,8 +436,6 @@ struct AccumulatedMutations { int lastChunkNumber; }; - - struct VersionedMutations { Version version; std::vector mutations; @@ -617,24 +562,11 @@ public: } // Add blocks to mutationBlocksByVersion - void filterLogMutationKVPairs(VectorRef blocks) { + void addBlockKVPairs(VectorRef blocks) { for (auto& kv : blocks) { auto versionAndChunkNumber = decodeLogKey(kv.key); mutationBlocksByVersion[versionAndChunkNumber.first].addChunk(versionAndChunkNumber.second, kv); } -/* - std::vector output; - - for (auto& vb : mutationBlocksByVersion) { - AccumulatedMutations& m = vb.second; - - // If the mutations are incomplete or match one of the ranges, include in results. - if (!m.isComplete() || m.matchesAnyRange(ranges)) { - output.insert(output.end(), m.kvs.begin(), m.kvs.end()); - } - } - - return output;*/ } // Reads a file block, decodes it into key/value pairs, and stores these pairs. @@ -658,7 +590,7 @@ public: .detail("Name", self->file.fileName) .detail("Len", len) .detail("Offset", self->offset); - self->filterLogMutationKVPairs(blocks); + self->addBlockKVPairs(blocks); self->offset += len; return Void(); @@ -680,9 +612,8 @@ public: }; ACTOR Future process_file(Reference container, LogFile file, UID uid, DecodeParams params) { - TraceEvent("ProcessFile").detail("Name", file.fileName); if (file.fileSize == 0) { - TraceEvent("SkipEmptyFile").detail("Name", file.fileName); + TraceEvent("SkipEmptyFile", uid).detail("Name", file.fileName); return Void(); } @@ -719,7 +650,7 @@ ACTOR Future process_file(Reference container, LogFile f } } } - TraceEvent("ProcessFileDone").detail("File", file.fileName); + TraceEvent("ProcessFileDone", uid).detail("File", file.fileName); return Void(); } @@ -749,11 +680,8 @@ ACTOR Future decode_logs(DecodeParams params) { state int idx = 0; while (idx < logs.size()) { - TraceEvent("ProcessFileI").detail("Name", logs[idx].fileName).detail("I", idx); - + TraceEvent("ProcessFile").detail("Name", logs[idx].fileName).detail("I", idx); wait(process_file(container, logs[idx], uid, params)); - - TraceEvent("ProcessFileIDone").detail("I", idx); idx++; } TraceEvent("DecodeDone", uid); From 426e906a8786c61c369107e28c160d877b20a9e9 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Sun, 1 Aug 2021 22:39:28 -0700 Subject: [PATCH 177/225] Remove duplicated code --- fdbbackup/FileDecoder.actor.cpp | 184 +--------------------------- fdbclient/BackupAgent.actor.h | 5 + fdbclient/BackupContainer.h | 39 ++++++ fdbclient/FileBackupAgent.actor.cpp | 104 +++++++--------- 4 files changed, 92 insertions(+), 240 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 41ffeb4cb8..73e6d9f615 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -311,131 +311,6 @@ std::vector getRelevantLogFiles(const std::vector& files, cons return filtered; } -// Decodes a mutation log key, which contains (hash, commitVersion, chunkNumber) and -// returns (commitVersion, chunkNumber) -std::pair decodeLogKey(const StringRef& key) { - ASSERT(key.size() == sizeof(uint8_t) + sizeof(Version) + sizeof(int32_t)); - - uint8_t hash; - Version version; - int32_t part; - BinaryReader rd(key, Unversioned()); - rd >> hash >> version >> part; - version = bigEndian64(version); - part = bigEndian32(part); - - int32_t v = version / CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE; - ASSERT(((uint8_t)hashlittle(&v, sizeof(v), 0)) == hash); - - return std::make_pair(version, part); -} - -// Decodes an encoded list of mutations in the format of: -// [includeVersion:uint64_t][val_length:uint32_t][mutation_1][mutation_2]...[mutation_k], -// where a mutation is encoded as: -// [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][param1][param2] -std::vector decodeLogValue(const StringRef& value) { - StringRefReader reader(value, restore_corrupted_data()); - - Version protocolVersion = reader.consume(); - if (protocolVersion <= 0x0FDB00A200090001) { - throw incompatible_protocol_version(); - } - - uint32_t val_length = reader.consume(); - if (val_length != value.size() - sizeof(uint64_t) - sizeof(uint32_t)) { - TraceEvent(SevError, "FileRestoreLogValueError") - .detail("ValueLen", val_length) - .detail("ValueSize", value.size()) - .detail("Value", printable(value)); - } - - std::vector mutations; - while (1) { - if (reader.eof()) - break; - - // Deserialization of a MutationRef, which was packed by MutationListRef::push_back_deep() - uint32_t type, p1len, p2len; - type = reader.consume(); - p1len = reader.consume(); - p2len = reader.consume(); - - const uint8_t* key = reader.consume(p1len); - const uint8_t* val = reader.consume(p2len); - - mutations.emplace_back((MutationRef::Type)type, StringRef(key, p1len), StringRef(val, p2len)); - } - return mutations; -} - -// Accumulates mutation log value chunks, as both a vector of chunks and as a combined chunk, -// in chunk order, and can check the chunk set for completion or intersection with a set -// of ranges. -struct AccumulatedMutations { - AccumulatedMutations() : lastChunkNumber(-1) {} - - // Add a KV pair for this mutation chunk set - // It will be accumulated onto serializedMutations if the chunk number is - // the next expected value. - void addChunk(int chunkNumber, const KeyValueRef& kv) { - if (chunkNumber == lastChunkNumber + 1) { - lastChunkNumber = chunkNumber; - serializedMutations += kv.value.toString(); - } else { - lastChunkNumber = -2; - serializedMutations.clear(); - } - kvs.push_back(kv); - } - - // Returns true if both - // - 1 or more chunks were added to this set - // - The header of the first chunk contains a valid protocol version and a length - // that matches the bytes after the header in the combined value in serializedMutations - bool isComplete() const { - if (lastChunkNumber >= 0) { - StringRefReader reader(serializedMutations, restore_corrupted_data()); - - Version protocolVersion = reader.consume(); - if (protocolVersion <= 0x0FDB00A200090001) { - throw incompatible_protocol_version(); - } - - uint32_t vLen = reader.consume(); - return vLen == reader.remainder().size(); - } - - return false; - } - - // Returns true if a complete chunk contains any MutationRefs which intersect with any - // range in ranges. - // It is undefined behavior to run this if isComplete() does not return true. - bool matchesAnyRange(const std::vector& ranges) const { - std::vector mutations = decodeLogValue(serializedMutations); - for (auto& m : mutations) { - for (auto& r : ranges) { - if (m.type == MutationRef::ClearRange) { - if (r.intersects(KeyRangeRef(m.param1, m.param2))) { - return true; - } - } else { - if (r.contains(m.param1)) { - return true; - } - } - } - } - - return false; - } - - std::vector kvs; - std::string serializedMutations; - int lastChunkNumber; -}; - struct VersionedMutations { Version version; std::vector mutations; @@ -443,56 +318,6 @@ struct VersionedMutations { std::string serializedMutations; // buffer that contains mutations }; -ACTOR Future>> decodeLogFileBlock(Reference file, - int64_t offset, - int len) { - state Standalone buf = makeString(len); - int rLen = wait(file->read(mutateString(buf), len, offset)); - if (rLen != len) - throw restore_bad_read(); - - Standalone> results({}, buf.arena()); - state StringRefReader reader(buf, restore_corrupted_data()); - - try { - // Read header, currently only decoding version BACKUP_AGENT_MLOG_VERSION - if (reader.consume() != BACKUP_AGENT_MLOG_VERSION) - throw restore_unsupported_file_version(); - - // Read k/v pairs. Block ends either at end of last value exactly or with 0xFF as first key len byte. - while (1) { - // If eof reached or first key len bytes is 0xFF then end of block was reached. - if (reader.eof() || *reader.rptr == 0xFF) - break; - - // Read key and value. If anything throws then there is a problem. - uint32_t kLen = reader.consumeNetworkUInt32(); - const uint8_t* k = reader.consume(kLen); - uint32_t vLen = reader.consumeNetworkUInt32(); - const uint8_t* v = reader.consume(vLen); - - results.push_back(results.arena(), KeyValueRef(KeyRef(k, kLen), ValueRef(v, vLen))); - } - - // Make sure any remaining bytes in the block are 0xFF - for (auto b : reader.remainder()) - if (b != 0xFF) - throw restore_corrupted_data_padding(); - - return results; - - } catch (Error& e) { - TraceEvent(SevWarn, "FileRestoreCorruptLogFileBlock") - .error(e) - .detail("Filename", file->getFilename()) - .detail("BlockOffset", offset) - .detail("BlockLen", len) - .detail("ErrorRelativeOffset", reader.rptr - buf.begin()) - .detail("ErrorAbsoluteOffset", reader.rptr - buf.begin() + offset); - throw; - } -} - /* * Model a decoding progress for a mutation file. Usage is: * @@ -511,7 +336,7 @@ ACTOR Future>> decodeLogFileBlock(Reference> blocks; - std::unordered_map mutationBlocksByVersion; + std::unordered_map mutationBlocksByVersion; public: DecodeProgress() = default; @@ -536,7 +361,7 @@ public: for (auto& [version, m] : mutationBlocksByVersion) { if (m.isComplete()) { vms.version = version; - std::vector mutations = decodeLogValue(m.serializedMutations); + std::vector mutations = fileBackup::decodeMutationLogValue(m.serializedMutations); TraceEvent("Decode").detail("Version", vms.version).detail("N", mutations.size()); vms.mutations.insert(vms.mutations.end(), mutations.begin(), mutations.end()); vms.arena = blocks.arena(); @@ -564,7 +389,7 @@ public: // Add blocks to mutationBlocksByVersion void addBlockKVPairs(VectorRef blocks) { for (auto& kv : blocks) { - auto versionAndChunkNumber = decodeLogKey(kv.key); + auto versionAndChunkNumber = fileBackup::decodeMutationLogKey(kv.key); mutationBlocksByVersion[versionAndChunkNumber.first].addChunk(versionAndChunkNumber.second, kv); } } @@ -579,7 +404,8 @@ public: } // Decode a file block into log_key and log_value pairs - Standalone> blocks = wait(decodeLogFileBlock(self->fd, self->offset, len)); + Standalone> blocks = + wait(fileBackup::decodeMutationLogFileBlock(self->fd, self->offset, len)); // This is memory inefficient, but we don't know if blocks are complete version data self->blocks.reserve(self->blocks.arena(), self->blocks.size() + blocks.size()); for (int i = 0; i < blocks.size(); i++) { diff --git a/fdbclient/BackupAgent.actor.h b/fdbclient/BackupAgent.actor.h index 856e7a62f5..c1dc08f0f6 100644 --- a/fdbclient/BackupAgent.actor.h +++ b/fdbclient/BackupAgent.actor.h @@ -970,6 +970,11 @@ ACTOR Future>> decodeRangeFileBlock(Reference< int64_t offset, int len); +// Reads a mutation log block from file and parses into batch mutation blocks for further parsing. +ACTOR Future>> decodeMutationLogFileBlock(Reference file, + int64_t offset, + int len); + // Return a block of contiguous padding bytes "\0xff" for backup files, growing if needed. Value makePadding(int size); } // namespace fileBackup diff --git a/fdbclient/BackupContainer.h b/fdbclient/BackupContainer.h index 5a9af3d1d9..94adc7ad67 100644 --- a/fdbclient/BackupContainer.h +++ b/fdbclient/BackupContainer.h @@ -306,4 +306,43 @@ private: std::string URL; }; +namespace fileBackup { +// Accumulates mutation log value chunks, as both a vector of chunks and as a combined chunk, +// in chunk order, and can check the chunk set for completion or intersection with a set +// of ranges. +struct AccumulatedMutations { + AccumulatedMutations() : lastChunkNumber(-1) {} + + // Add a KV pair for this mutation chunk set + // It will be accumulated onto serializedMutations if the chunk number is + // the next expected value. + void addChunk(int chunkNumber, const KeyValueRef& kv); + + // Returns true if both + // - 1 or more chunks were added to this set + // - The header of the first chunk contains a valid protocol version and a length + // that matches the bytes after the header in the combined value in serializedMutations + bool isComplete() const; + + // Returns true if a complete chunk contains any MutationRefs which intersect with any + // range in ranges. + // It is undefined behavior to run this if isComplete() does not return true. + bool matchesAnyRange(const std::vector& ranges) const; + + std::vector kvs; + std::string serializedMutations; + int lastChunkNumber; +}; + +// Decodes a mutation log key, which contains (hash, commitVersion, chunkNumber) and +// returns (commitVersion, chunkNumber) +std::pair decodeMutationLogKey(const StringRef& key); + +// Decodes an encoded list of mutations in the format of: +// [includeVersion:uint64_t][val_length:uint32_t][mutation_1][mutation_2]...[mutation_k], +// where a mutation is encoded as: +// [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][param1][param2] +std::vector decodeMutationLogValue(const StringRef& value); +} // namespace fileBackup + #endif diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index 8c057aadd2..a487c527ac 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -691,9 +691,9 @@ private: int64_t blockEnd; }; -ACTOR Future>> decodeLogFileBlock(Reference file, - int64_t offset, - int len) { +ACTOR Future>> decodeMutationLogFileBlock(Reference file, + int64_t offset, + int len) { state Standalone buf = makeString(len); int rLen = wait(file->read(mutateString(buf), len, offset)); if (rLen != len) @@ -3244,7 +3244,7 @@ REGISTER_TASKFUNC(RestoreRangeTaskFunc); // Decodes a mutation log key, which contains (hash, commitVersion, chunkNumber) and // returns (commitVersion, chunkNumber) -std::pair decodeLogKey(const StringRef& key) { +std::pair decodeMutationLogKey(const StringRef& key) { ASSERT(key.size() == sizeof(uint8_t) + sizeof(Version) + sizeof(int32_t)); uint8_t hash; @@ -3265,7 +3265,7 @@ std::pair decodeLogKey(const StringRef& key) { // [includeVersion:uint64_t][val_length:uint32_t][mutation_1][mutation_2]...[mutation_k], // where a mutation is encoded as: // [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][param1][param2] -std::vector decodeLogValue(const StringRef& value) { +std::vector decodeMutationLogValue(const StringRef& value) { StringRefReader reader(value, restore_corrupted_data()); Version protocolVersion = reader.consume(); @@ -3300,72 +3300,54 @@ std::vector decodeLogValue(const StringRef& value) { return mutations; } -// Accumulates mutation log value chunks, as both a vector of chunks and as a combined chunk, -// in chunk order, and can check the chunk set for completion or intersection with a set -// of ranges. -struct AccumulatedMutations { - AccumulatedMutations() : lastChunkNumber(-1) {} - - // Add a KV pair for this mutation chunk set - // It will be accumulated onto serializedMutations if the chunk number is - // the next expected value. - void addChunk(int chunkNumber, const KeyValueRef& kv) { - if (chunkNumber == lastChunkNumber + 1) { - lastChunkNumber = chunkNumber; - serializedMutations += kv.value.toString(); - } else { - lastChunkNumber = -2; - serializedMutations.clear(); - } - kvs.push_back(kv); +void AccumulatedMutations::addChunk(int chunkNumber, const KeyValueRef& kv) { + if (chunkNumber == lastChunkNumber + 1) { + lastChunkNumber = chunkNumber; + serializedMutations += kv.value.toString(); + } else { + lastChunkNumber = -2; + serializedMutations.clear(); } + kvs.push_back(kv); +} - // Returns true if both - // - 1 or more chunks were added to this set - // - The header of the first chunk contains a valid protocol version and a length - // that matches the bytes after the header in the combined value in serializedMutations - bool isComplete() const { - if (lastChunkNumber >= 0) { - StringRefReader reader(serializedMutations, restore_corrupted_data()); +bool AccumulatedMutations::isComplete() const { + if (lastChunkNumber >= 0) { + StringRefReader reader(serializedMutations, restore_corrupted_data()); - Version protocolVersion = reader.consume(); - if (protocolVersion <= 0x0FDB00A200090001) { - throw incompatible_protocol_version(); - } - - uint32_t vLen = reader.consume(); - return vLen == reader.remainder().size(); + Version protocolVersion = reader.consume(); + if (protocolVersion <= 0x0FDB00A200090001) { + throw incompatible_protocol_version(); } - return false; + uint32_t vLen = reader.consume(); + return vLen == reader.remainder().size(); } - // Returns true if a complete chunk contains any MutationRefs which intersect with any - // range in ranges. - // It is undefined behavior to run this if isComplete() does not return true. - bool matchesAnyRange(const std::vector& ranges) const { - std::vector mutations = decodeLogValue(serializedMutations); - for (auto& m : mutations) { - for (auto& r : ranges) { - if (m.type == MutationRef::ClearRange) { - if (r.intersects(KeyRangeRef(m.param1, m.param2))) { - return true; - } - } else { - if (r.contains(m.param1)) { - return true; - } + return false; +} + +// Returns true if a complete chunk contains any MutationRefs which intersect with any +// range in ranges. +// It is undefined behavior to run this if isComplete() does not return true. +bool AccumulatedMutations::matchesAnyRange(const std::vector& ranges) const { + std::vector mutations = decodeMutationLogValue(serializedMutations); + for (auto& m : mutations) { + for (auto& r : ranges) { + if (m.type == MutationRef::ClearRange) { + if (r.intersects(KeyRangeRef(m.param1, m.param2))) { + return true; + } + } else { + if (r.contains(m.param1)) { + return true; } } } - - return false; } - std::vector kvs; - std::string serializedMutations; - int lastChunkNumber; -}; + return false; +} // Returns a vector of filtered KV refs from data which are either part of incomplete mutation groups OR complete // and have data relevant to one of the KV ranges in ranges @@ -3373,7 +3355,7 @@ std::vector filterLogMutationKVPairs(VectorRef data, c std::unordered_map mutationBlocksByVersion; for (auto& kv : data) { - auto versionAndChunkNumber = decodeLogKey(kv.key); + auto versionAndChunkNumber = decodeMutationLogKey(kv.key); mutationBlocksByVersion[versionAndChunkNumber.first].addChunk(versionAndChunkNumber.second, kv); } @@ -3444,7 +3426,7 @@ struct RestoreLogDataTaskFunc : RestoreFileTaskFuncBase { state Key mutationLogPrefix = restore.mutationLogPrefix(); state Reference inFile = wait(bc->readFile(logFile.fileName)); - state Standalone> dataOriginal = wait(decodeLogFileBlock(inFile, readOffset, readLen)); + state Standalone> dataOriginal = wait(decodeMutationLogFileBlock(inFile, readOffset, readLen)); // Filter the KV pairs extracted from the log file block to remove any records known to not be needed for this // restore based on the restore range set. From 072ed78a3e358339928eab1430a21ae4cc04fac5 Mon Sep 17 00:00:00 2001 From: Pierre Zemb Date: Mon, 2 Aug 2021 10:59:50 +0200 Subject: [PATCH 178/225] allow build folder as $BUILD_DIR --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4edd5690c3..0bc9db88ec 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ bindings/java/foundationdb-client*.jar bindings/java/foundationdb-tests*.jar bindings/java/fdb-java-*-sources.jar packaging/msi/FDBInstaller.msi -builds/ +build/ cmake-build-debug/ # Generated source, build, and packaging files *.g.cpp From 2c08d1797520f561411d82de75d5529ad604008f Mon Sep 17 00:00:00 2001 From: Zhe Wu Date: Fri, 30 Jul 2021 21:48:30 -0700 Subject: [PATCH 179/225] Account for the case where TLogInterface may not present in ServerDbInfo in worker health monitor --- fdbserver/worker.actor.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index e977a05abd..d15379d2e5 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -632,6 +632,10 @@ bool addressInDbAndPrimaryDc(const NetworkAddress& address, Reference(Endpoint({ testAddress }, UID(1, 2))); - // First, create a remote TLog. Although the remote TLog also uses the local address, it shouldn't be considered as + // First, create an empty TLogInterface, and check that it shouldn't be considered as in primary DC. + testDbInfo.logSystemConfig.tLogs.push_back(TLogSet()); + testDbInfo.logSystemConfig.tLogs.back().tLogs.push_back(OptionalInterface()); + ASSERT(!addressInDbAndPrimaryDc(g_network->getLocalAddress(), makeReference>(testDbInfo))); + + // Create a remote TLog. Although the remote TLog also uses the local address, it shouldn't be considered as // in primary DC given the remote locality. LocalityData fakeRemote; fakeRemote.set(LiteralStringRef("dcid"), StringRef(std::to_string(2))); TLogInterface remoteTlog(fakeRemote); remoteTlog.initEndpoints(); - testDbInfo.logSystemConfig.tLogs.push_back(TLogSet()); testDbInfo.logSystemConfig.tLogs.back().tLogs.push_back(OptionalInterface(remoteTlog)); ASSERT(!addressInDbAndPrimaryDc(g_network->getLocalAddress(), makeReference>(testDbInfo))); From 31a64106fba11061c0eaba4de7e3969a12290d1c Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Mon, 2 Aug 2021 09:21:33 -0700 Subject: [PATCH 180/225] Avoid memory copies after decoding a new file block --- fdbbackup/FileDecoder.actor.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index 73e6d9f615..b516869810 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -314,7 +314,6 @@ std::vector getRelevantLogFiles(const std::vector& files, cons struct VersionedMutations { Version version; std::vector mutations; - Arena arena; // The arena that contains the mutations. std::string serializedMutations; // buffer that contains mutations }; @@ -335,7 +334,7 @@ struct VersionedMutations { * at any time this object might have two blocks of data in memory. */ class DecodeProgress { - Standalone> blocks; + std::vector>> blocks; std::unordered_map mutationBlocksByVersion; public: @@ -364,7 +363,6 @@ public: std::vector mutations = fileBackup::decodeMutationLogValue(m.serializedMutations); TraceEvent("Decode").detail("Version", vms.version).detail("N", mutations.size()); vms.mutations.insert(vms.mutations.end(), mutations.begin(), mutations.end()); - vms.arena = blocks.arena(); vms.serializedMutations = m.serializedMutations; mutationBlocksByVersion.erase(version); return vms; @@ -386,9 +384,9 @@ public: return Void(); } - // Add blocks to mutationBlocksByVersion - void addBlockKVPairs(VectorRef blocks) { - for (auto& kv : blocks) { + // Add chunks to mutationBlocksByVersion + void addBlockKVPairs(VectorRef chunks) { + for (auto& kv : chunks) { auto versionAndChunkNumber = fileBackup::decodeMutationLogKey(kv.key); mutationBlocksByVersion[versionAndChunkNumber.first].addChunk(versionAndChunkNumber.second, kv); } @@ -403,20 +401,16 @@ public: return Void(); } - // Decode a file block into log_key and log_value pairs - Standalone> blocks = + // Decode a file block into log_key and log_value chunks + Standalone> chunks = wait(fileBackup::decodeMutationLogFileBlock(self->fd, self->offset, len)); - // This is memory inefficient, but we don't know if blocks are complete version data - self->blocks.reserve(self->blocks.arena(), self->blocks.size() + blocks.size()); - for (int i = 0; i < blocks.size(); i++) { - self->blocks.push_back_deep(self->blocks.arena(), blocks[i]); - } + self->blocks.push_back(chunks); TraceEvent("ReadFile") .detail("Name", self->file.fileName) .detail("Len", len) .detail("Offset", self->offset); - self->addBlockKVPairs(blocks); + self->addBlockKVPairs(chunks); self->offset += len; return Void(); From 5346213e7f0c82a85bb9d1a61782f0ae8e5ad5a6 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Mon, 2 Aug 2021 09:26:42 -0700 Subject: [PATCH 181/225] Fix trace event UnfishedBlocks --- fdbbackup/FileDecoder.actor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fdbbackup/FileDecoder.actor.cpp b/fdbbackup/FileDecoder.actor.cpp index b516869810..19dbaf4f80 100644 --- a/fdbbackup/FileDecoder.actor.cpp +++ b/fdbbackup/FileDecoder.actor.cpp @@ -370,7 +370,9 @@ public: } // No complete versions - TraceEvent(SevWarn, "UnfishedBlocks").detail("NumberOfVersions", mutationBlocksByVersion.size()); + if (!mutationBlocksByVersion.empty()) { + TraceEvent(SevWarn, "UnfishedBlocks").detail("NumberOfVersions", mutationBlocksByVersion.size()); + } done = true; return vms; } From 1b1cd1e856f2f742ee94432c5ab06abbaf4179fe Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 2 Aug 2021 13:37:09 -0700 Subject: [PATCH 182/225] Fix releaseMemory deadlock and add comments --- flow/ThreadHelper.actor.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index 489ac5a206..da295914d7 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -171,7 +171,7 @@ public: enum Status { Unset, NeverSet, Set, ErrorSet }; // order is important // volatile long referenceCount; ThreadSpinLock mutex; - Status status; + std::atomic status; Error error; ThreadCallback* callback; @@ -335,9 +335,11 @@ public: void setCancel(Future&& cf) { cancelFuture = std::move(cf); } virtual void cancel() { - if (isReady()) { - // Avoiding going to the network thread here is an important optimization. Without this we see lower - // throughput for e.g. GRV workloads. + // Cancels the action and decrements the reference count by 1 The if statement is just an optimization. It's ok + // if we take the "wrong path" if we call this while someone else holds |mutex|. We can't take |mutex| since + // this is called from releaseMemory. Trying to avoid going to the network thread here is an important - without + // this we see lower throughput on the client for e.g. GRV workloads. + if (isReadyUnsafe()) { delref(); } else { onMainThreadVoid([this]() { @@ -359,6 +361,24 @@ private: protected: // The caller of any of these *Unsafe functions should be holding |mutex| + // + // |status| is an atomic, so these are not unsafe in the "data race" + // sense. It appears that there are some class invariants (e.g. that + // callback should be null if the future is ready), so we should still + // hold |mutex| when calling these functions. One exception is for + // cancel, which mustn't try to acquire |mutex| since it's called from + // releaseMemory while holding the |mutex|. In cancel, we only need to + // know if there's possibly work to cancel on the main thread, so it's safe to + // call without holding |mutex|. + // + // A bit of history: the original implementation of cancel was not + // thread safe (in practice it behaved as intended, but TSAN didn't like + // it, and it was definitely a data race.) The first attempt to fix this[1] + // was simply to cancel on the main thread, but this turns out to cause + // a performance regression on the client. Now we simply make |status| + // atomic so that it behaves (legally) how the original author intended. + // + // [1]: https://github.com/apple/foundationdb/pull/3750 bool isReadyUnsafe() const { return status >= Set; } bool isErrorUnsafe() const { return status == ErrorSet; } bool canBeSetUnsafe() const { return status == Unset; } From ba13b86bff8a5f7f74d46591c32a3d840e904a7d Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 2 Aug 2021 13:41:03 -0700 Subject: [PATCH 183/225] Fix comment grammar (add a period) --- fdbclient/NativeAPI.actor.cpp | 3 +-- fdbclient/NativeAPI.actor.h | 3 +++ flow/ThreadHelper.actor.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index a98cf30adc..46363ce7c3 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -4089,8 +4089,7 @@ SpanID generateSpanID(int transactionTracingEnabled) { } } -Transaction::Transaction() - : info(TaskPriority::DefaultEndpoint, generateSpanID(true)), span(info.spanID, "Transaction"_loc) {} +Transaction::Transaction() = default; Transaction::Transaction(Database const& cx) : cx(cx), info(cx->taskID, generateSpanID(cx->transactionTracingEnabled)), backoff(CLIENT_KNOBS->DEFAULT_BACKOFF), diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h index 6357bb7d80..85d97c6be0 100644 --- a/fdbclient/NativeAPI.actor.h +++ b/fdbclient/NativeAPI.actor.h @@ -179,6 +179,9 @@ struct TransactionInfo { // prefix/ : '0' - any keys equal or larger than this key are (definitely) not conflicting keys std::shared_ptr> conflictingKeys; + // Only available so that Transaction can have a default constructor, for use in state variables + TransactionInfo() : taskID(), spanID(), useProvisionalProxies() {} + explicit TransactionInfo(TaskPriority taskID, SpanID spanID) : taskID(taskID), spanID(spanID), useProvisionalProxies(false) {} }; diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index da295914d7..6f06a8e925 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -335,7 +335,7 @@ public: void setCancel(Future&& cf) { cancelFuture = std::move(cf); } virtual void cancel() { - // Cancels the action and decrements the reference count by 1 The if statement is just an optimization. It's ok + // Cancels the action and decrements the reference count by 1. The if statement is just an optimization. It's ok // if we take the "wrong path" if we call this while someone else holds |mutex|. We can't take |mutex| since // this is called from releaseMemory. Trying to avoid going to the network thread here is an important - without // this we see lower throughput on the client for e.g. GRV workloads. From 1d64a53b347671677acbd71fb6478eb761e52fcd Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 2 Aug 2021 13:42:30 -0700 Subject: [PATCH 184/225] Apply suggestions from code review Co-authored-by: A.J. Beamon --- flow/ThreadHelper.actor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/ThreadHelper.actor.h b/flow/ThreadHelper.actor.h index 6f06a8e925..2b0ae611c6 100644 --- a/flow/ThreadHelper.actor.h +++ b/flow/ThreadHelper.actor.h @@ -337,7 +337,7 @@ public: virtual void cancel() { // Cancels the action and decrements the reference count by 1. The if statement is just an optimization. It's ok // if we take the "wrong path" if we call this while someone else holds |mutex|. We can't take |mutex| since - // this is called from releaseMemory. Trying to avoid going to the network thread here is an important - without + // this is called from releaseMemory. Trying to avoid going to the network thread here is important - without // this we see lower throughput on the client for e.g. GRV workloads. if (isReadyUnsafe()) { delref(); From 0e9048398daa1d746513d48f1875a1c4e9aded04 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 2 Aug 2021 13:43:13 -0700 Subject: [PATCH 185/225] Revert drive-by TSAN fix --- fdbclient/NativeAPI.actor.cpp | 3 ++- fdbclient/NativeAPI.actor.h | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 46363ce7c3..a98cf30adc 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -4089,7 +4089,8 @@ SpanID generateSpanID(int transactionTracingEnabled) { } } -Transaction::Transaction() = default; +Transaction::Transaction() + : info(TaskPriority::DefaultEndpoint, generateSpanID(true)), span(info.spanID, "Transaction"_loc) {} Transaction::Transaction(Database const& cx) : cx(cx), info(cx->taskID, generateSpanID(cx->transactionTracingEnabled)), backoff(CLIENT_KNOBS->DEFAULT_BACKOFF), diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h index 85d97c6be0..6357bb7d80 100644 --- a/fdbclient/NativeAPI.actor.h +++ b/fdbclient/NativeAPI.actor.h @@ -179,9 +179,6 @@ struct TransactionInfo { // prefix/ : '0' - any keys equal or larger than this key are (definitely) not conflicting keys std::shared_ptr> conflictingKeys; - // Only available so that Transaction can have a default constructor, for use in state variables - TransactionInfo() : taskID(), spanID(), useProvisionalProxies() {} - explicit TransactionInfo(TaskPriority taskID, SpanID spanID) : taskID(taskID), spanID(spanID), useProvisionalProxies(false) {} }; From e9c3da1f0f22870c8e7c1e32bce38cbc150adf87 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Mon, 2 Aug 2021 13:47:37 -0700 Subject: [PATCH 186/225] Disable rocksdb selection for VALGRIND builds. --- fdbserver/SimulatedCluster.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/SimulatedCluster.actor.cpp b/fdbserver/SimulatedCluster.actor.cpp index 828bcfb93d..432ac561af 100644 --- a/fdbserver/SimulatedCluster.actor.cpp +++ b/fdbserver/SimulatedCluster.actor.cpp @@ -2097,7 +2097,7 @@ void setupSimulatedSystem(vector>* systemActors, using namespace std::literals; -#ifdef SSD_ROCKSDB_EXPERIMENTAL +#if defined(SSD_ROCKSDB_EXPERIMENTAL) && !VALGRIND bool rocksDBEnabled = true; #else bool rocksDBEnabled = false; From 20f0a5a1f2f11b2ffb192727f8ae68540e1aab66 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Mon, 2 Aug 2021 21:55:07 +0000 Subject: [PATCH 187/225] Disable multiprocess fdbcli tests while debugging flakiness --- bindings/python/tests/fdbcli_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index 05d5223d5c..f00e0e2b57 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -449,7 +449,7 @@ if __name__ == '__main__': throttle() else: assert process_number > 1, "Process number should be positive" - coordinators() - exclude() + #coordinators() + #exclude() From a32cff08eb73d38ed7f9d104bb7b9bb531a83642 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Mon, 2 Aug 2021 22:34:08 +0000 Subject: [PATCH 188/225] Add comments for the change --- bindings/python/tests/fdbcli_tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index f00e0e2b57..0084a8b9ce 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -449,6 +449,9 @@ if __name__ == '__main__': throttle() else: assert process_number > 1, "Process number should be positive" + # the kill command which used to list processes seems to not work as expected sometime + # which makes the test flaky. + # We need to figure out the reason and then re-enable these tests #coordinators() #exclude() From 5301e1a865eb895b3f82eedc9e0355064e0b6f32 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 2 Aug 2021 19:29:56 -0700 Subject: [PATCH 189/225] Add trace_partial_file_suffix_test --- bindings/c/CMakeLists.txt | 10 ++ .../unit/trace_partial_file_suffix_test.cpp | 101 ++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 bindings/c/test/unit/trace_partial_file_suffix_test.cpp diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 561ab8d740..be4caf8240 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -79,6 +79,7 @@ if(NOT WIN32) test/unit/fdb_api.hpp) set(UNIT_TEST_VERSION_510_SRCS test/unit/unit_tests_version_510.cpp) + set(TRACE_PARTIAL_FILE_SUFFIX_TEST_SRCS test/unit/trace_partial_file_suffix_test.cpp) if(OPEN_FOR_IDE) add_library(fdb_c_performance_test OBJECT test/performance_test.c test/test.h) @@ -88,6 +89,7 @@ if(NOT WIN32) add_library(fdb_c_setup_tests OBJECT test/unit/setup_tests.cpp) add_library(fdb_c_unit_tests OBJECT ${UNIT_TEST_SRCS}) add_library(fdb_c_unit_tests_version_510 OBJECT ${UNIT_TEST_VERSION_510_SRCS}) + add_library(trace_partial_file_suffix_test OBJECT ${TRACE_PARTIAL_FILE_SUFFIX_TEST_SRCS}) else() add_executable(fdb_c_performance_test test/performance_test.c test/test.h) add_executable(fdb_c_ryw_benchmark test/ryw_benchmark.c test/test.h) @@ -96,6 +98,7 @@ if(NOT WIN32) add_executable(fdb_c_setup_tests test/unit/setup_tests.cpp) add_executable(fdb_c_unit_tests ${UNIT_TEST_SRCS}) add_executable(fdb_c_unit_tests_version_510 ${UNIT_TEST_VERSION_510_SRCS}) + add_executable(trace_partial_file_suffix_test ${TRACE_PARTIAL_FILE_SUFFIX_TEST_SRCS}) strip_debug_symbols(fdb_c_performance_test) strip_debug_symbols(fdb_c_ryw_benchmark) strip_debug_symbols(fdb_c_txn_size_test) @@ -106,12 +109,14 @@ if(NOT WIN32) add_dependencies(fdb_c_setup_tests doctest) add_dependencies(fdb_c_unit_tests doctest) + add_dependencies(fdb_c_unit_tests_version_510 doctest) target_include_directories(fdb_c_setup_tests PUBLIC ${DOCTEST_INCLUDE_DIR}) target_include_directories(fdb_c_unit_tests PUBLIC ${DOCTEST_INCLUDE_DIR}) target_include_directories(fdb_c_unit_tests_version_510 PUBLIC ${DOCTEST_INCLUDE_DIR}) target_link_libraries(fdb_c_setup_tests PRIVATE fdb_c Threads::Threads) target_link_libraries(fdb_c_unit_tests PRIVATE fdb_c Threads::Threads) target_link_libraries(fdb_c_unit_tests_version_510 PRIVATE fdb_c Threads::Threads) + target_link_libraries(trace_partial_file_suffix_test PRIVATE fdb_c Threads::Threads) # do not set RPATH for mako set_property(TARGET mako PROPERTY SKIP_BUILD_RPATH TRUE) @@ -146,6 +151,11 @@ if(NOT WIN32) COMMAND $ @CLUSTER_FILE@ fdb) + add_fdbclient_test( + NAME trace_partial_file_suffix_test + COMMAND $ + @CLUSTER_FILE@ + fdb) add_fdbclient_test( NAME fdb_c_external_client_unit_tests COMMAND $ diff --git a/bindings/c/test/unit/trace_partial_file_suffix_test.cpp b/bindings/c/test/unit/trace_partial_file_suffix_test.cpp new file mode 100644 index 0000000000..d3be3c79e7 --- /dev/null +++ b/bindings/c/test/unit/trace_partial_file_suffix_test.cpp @@ -0,0 +1,101 @@ +/* + * trace_partial_file_suffix_test.cpp + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2021 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. + */ + +#include +#include +#include +#include + +#define FDB_API_VERSION 710 +#include "foundationdb/fdb_c.h" + +#undef NDEBUG +#include + +void fdb_check(fdb_error_t e) { + if (e) { + std::cerr << fdb_get_error(e) << std::endl; + std::abort(); + } +} + +void set_net_opt(FDBNetworkOption option, const std::string& value) { + fdb_check(fdb_network_set_option(option, reinterpret_cast(value.c_str()), value.size())); +} + +bool file_exists(const char* path) { + FILE* f = fopen(path, "r"); + if (f) { + fclose(f); + return true; + } + return false; +} + +int main(int argc, char** argv) { + fdb_check(fdb_select_api_version(710)); + + std::string file_identifier = "trace_partial_file_suffix_test" + std::to_string(std::random_device{}()); + // std::string trace_partial_file_suffix = ".tmp"; + std::string trace_partial_file_suffix = ""; + + set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_ENABLE, ""); + set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_FILE_IDENTIFIER, file_identifier); + // set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_PARTIAL_FILE_SUFFIX, trace_partial_file_suffix); + + fdb_check(fdb_setup_network()); + std::thread network_thread{ &fdb_run_network }; + + // Apparently you need to open a database to initialize logging + FDBDatabase* out; + fdb_check(fdb_create_database(nullptr, &out)); + fdb_database_destroy(out); + + // Eventually there's a trace file for this test ending in .tmp + std::string name; + for (;;) { + for (const auto& entry : std::filesystem::directory_iterator(".")) { + auto path = entry.path().string(); + if (path.find(file_identifier) != std::string::npos) { + assert(path.substr(path.size() - trace_partial_file_suffix.size()) == trace_partial_file_suffix); + name = path; + break; + } + } + if (!name.empty()) { + break; + } + } + + // Need to do one round trip to the network thread to make sure the trace file gets opened + + fdb_check(fdb_stop_network()); + network_thread.join(); + + // After shutting down, the trace file's suffix is (eventually) removed + if (!trace_partial_file_suffix.empty()) { + while (file_exists(name.c_str())) { + } + } + + auto new_name = name.substr(0, name.size() - trace_partial_file_suffix.size()); + assert(file_exists(new_name.c_str())); + remove(new_name.c_str()); +} From 39eff8c5696206839addf8bcd649ec92f42aaa78 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 3 Aug 2021 09:43:42 -0700 Subject: [PATCH 190/225] Add trace_partial_file_suffix network option --- .../unit/trace_partial_file_suffix_test.cpp | 5 ++-- fdbclient/NativeAPI.actor.cpp | 7 +++++- fdbclient/NativeAPI.actor.h | 1 + fdbclient/vexillographer/fdb.options | 3 +++ flow/FileTraceLogWriter.cpp | 23 +++++++++++++++---- flow/FileTraceLogWriter.h | 3 +++ flow/Trace.cpp | 12 +++++++--- flow/Trace.h | 3 ++- 8 files changed, 44 insertions(+), 13 deletions(-) diff --git a/bindings/c/test/unit/trace_partial_file_suffix_test.cpp b/bindings/c/test/unit/trace_partial_file_suffix_test.cpp index d3be3c79e7..6462d84f5b 100644 --- a/bindings/c/test/unit/trace_partial_file_suffix_test.cpp +++ b/bindings/c/test/unit/trace_partial_file_suffix_test.cpp @@ -53,12 +53,11 @@ int main(int argc, char** argv) { fdb_check(fdb_select_api_version(710)); std::string file_identifier = "trace_partial_file_suffix_test" + std::to_string(std::random_device{}()); - // std::string trace_partial_file_suffix = ".tmp"; - std::string trace_partial_file_suffix = ""; + std::string trace_partial_file_suffix = ".tmp"; set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_ENABLE, ""); set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_FILE_IDENTIFIER, file_identifier); - // set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_PARTIAL_FILE_SUFFIX, trace_partial_file_suffix); + set_net_opt(FDBNetworkOption::FDB_NET_OPTION_TRACE_PARTIAL_FILE_SUFFIX, trace_partial_file_suffix); fdb_check(fdb_setup_network()); std::thread network_thread{ &fdb_run_network }; diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 0d05f33c58..0a6a474249 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -1698,7 +1698,8 @@ Database Database::createDatabase(Reference connFile, networkOptions.traceDirectory.get(), "trace", networkOptions.traceLogGroup, - networkOptions.traceFileIdentifier); + networkOptions.traceFileIdentifier, + networkOptions.tracePartialFileSuffix); TraceEvent("ClientStart") .detail("SourceVersion", getSourceVersion()) @@ -1856,6 +1857,10 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional valu throw invalid_option_value(); } break; + case FDBNetworkOptions::TRACE_PARTIAL_FILE_SUFFIX: + validateOptionValuePresent(value); + networkOptions.tracePartialFileSuffix = value.get().toString(); + break; case FDBNetworkOptions::KNOB: { validateOptionValuePresent(value); diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h index e671bac8c1..3636b30c46 100644 --- a/fdbclient/NativeAPI.actor.h +++ b/fdbclient/NativeAPI.actor.h @@ -68,6 +68,7 @@ struct NetworkOptions { std::string traceFormat; std::string traceClockSource; std::string traceFileIdentifier; + std::string tracePartialFileSuffix; Optional logClientInfo; Reference>>> supportedVersions; bool runLoopProfilingEnabled; diff --git a/fdbclient/vexillographer/fdb.options b/fdbclient/vexillographer/fdb.options index e0f908a69c..27fa43aa8f 100644 --- a/fdbclient/vexillographer/fdb.options +++ b/fdbclient/vexillographer/fdb.options @@ -57,6 +57,9 @@ description is not currently required but encouraged.

]", + "change the class of a process", + "If no address and class are specified, lists the classes of all servers.\n\nSetting the class to " + "`default' resets the process class to the class specified on the command line. The available " + "classes are `unset', `storage', `transaction', `resolution', `commit_proxy', `grv_proxy', " + "`master', `test', " + "`stateless', `log', `router', `cluster_controller', `fast_restore', `data_distributor', " + "`coordinator', `ratekeeper', `storage_cache', `backup', and `default'.")); + +} // namespace fdb_cli \ No newline at end of file diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 6af3a49b17..7aebb1efad 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -566,15 +566,6 @@ void initHelp() { "pair in or any LocalityData (like dcid, zoneid, machineid, processid), removes any " "matching exclusions from the excluded servers and localities list. " "(A specified IP will match all IP:* exclusion entries)"); - helpMap["setclass"] = - CommandHelp("setclass [
]", - "change the class of a process", - "If no address and class are specified, lists the classes of all servers.\n\nSetting the class to " - "`default' resets the process class to the class specified on the command line. The available " - "classes are `unset', `storage', `transaction', `resolution', `commit_proxy', `grv_proxy', " - "`master', `test', " - "`stateless', `log', `router', `cluster_controller', `fast_restore', `data_distributor', " - "`coordinator', `ratekeeper', `storage_cache', `backup', and `default'."); helpMap["status"] = CommandHelp("status [minimal|details|json]", "get the status of a FoundationDB cluster", @@ -2742,45 +2733,6 @@ ACTOR Future createSnapshot(Database db, std::vector tokens) { return false; } -ACTOR Future setClass(Database db, std::vector tokens) { - if (tokens.size() == 1) { - vector _workers = wait(makeInterruptable(getWorkers(db))); - auto workers = _workers; // strip const - - if (!workers.size()) { - printf("No processes are registered in the database.\n"); - return false; - } - - std::sort(workers.begin(), workers.end(), ProcessData::sort_by_address()); - - printf("There are currently %zu processes in the database:\n", workers.size()); - for (const auto& w : workers) - printf(" %s: %s (%s)\n", - w.address.toString().c_str(), - w.processClass.toString().c_str(), - w.processClass.sourceString().c_str()); - return false; - } - - AddressExclusion addr = AddressExclusion::parse(tokens[1]); - if (!addr.isValid()) { - fprintf(stderr, "ERROR: '%s' is not a valid network endpoint address\n", tokens[1].toString().c_str()); - if (tokens[1].toString().find(":tls") != std::string::npos) - printf(" Do not include the `:tls' suffix when naming a process\n"); - return true; - } - - ProcessClass processClass(tokens[2].toString(), ProcessClass::DBSource); - if (processClass.classType() == ProcessClass::InvalidClass && tokens[2] != LiteralStringRef("default")) { - fprintf(stderr, "ERROR: '%s' is not a valid process class\n", tokens[2].toString().c_str()); - return true; - } - - wait(makeInterruptable(setClass(db, addr, processClass))); - return false; -}; - Reference getTransaction(Database db, Reference& tr, FdbOptions* options, @@ -3689,14 +3641,9 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { } if (tokencmp(tokens[0], "setclass")) { - if (tokens.size() != 3 && tokens.size() != 1) { - printUsage(tokens[0]); + bool _result = wait(makeInterruptable(setClassCommandActor(db2, tokens))); + if (!_result) is_error = true; - } else { - bool err = wait(setClass(db, tokens)); - if (err) - is_error = true; - } continue; } diff --git a/fdbcli/fdbcli.actor.h b/fdbcli/fdbcli.actor.h index 8ab228ea6d..85c0526308 100644 --- a/fdbcli/fdbcli.actor.h +++ b/fdbcli/fdbcli.actor.h @@ -22,6 +22,7 @@ // When actually compiled (NO_INTELLISENSE), include the generated // version of this file. In intellisense use the source version. +#include "flow/FastRef.h" #if defined(NO_INTELLISENSE) && !defined(FDBCLI_FDBCLI_ACTOR_G_H) #define FDBCLI_FDBCLI_ACTOR_G_H #include "fdbcli/fdbcli.actor.g.h" @@ -64,7 +65,9 @@ extern const KeyRef consistencyCheckSpecialKey; // maintenance extern const KeyRangeRef maintenanceSpecialKeyRange; extern const KeyRef ignoreSSFailureSpecialKey; - +// setclass +extern const KeyRangeRef processClassSourceSpecialKeyRange; +extern const KeyRangeRef processClassTypeSpecialKeyRange; // help functions (Copied from fdbcli.actor.cpp) // compare StringRef with the given c string @@ -81,6 +84,8 @@ ACTOR Future consistencyCheckCommandActor(Reference tr, std: ACTOR Future forceRecoveryWithDataLossCommandActor(Reference db, std::vector tokens); // maintenance command ACTOR Future maintenanceCommandActor(Reference db, std::vector tokens); +// setclass command +ACTOR Future setClassCommandActor(Reference db, std::vector tokens); // snapshot command ACTOR Future snapshotCommandActor(Reference db, std::vector tokens); // throttle command From bbc2ffe527a115aee70ae8ec17fa6257bd9ff856 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Thu, 5 Aug 2021 19:29:01 +0000 Subject: [PATCH 214/225] Remove unnecessay header, add new line at the end of the file --- fdbcli/SetClassCommand.actor.cpp | 2 +- fdbcli/fdbcli.actor.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fdbcli/SetClassCommand.actor.cpp b/fdbcli/SetClassCommand.actor.cpp index c66cccb114..b46f837385 100644 --- a/fdbcli/SetClassCommand.actor.cpp +++ b/fdbcli/SetClassCommand.actor.cpp @@ -120,4 +120,4 @@ CommandFactory setClassFactory( "`stateless', `log', `router', `cluster_controller', `fast_restore', `data_distributor', " "`coordinator', `ratekeeper', `storage_cache', `backup', and `default'.")); -} // namespace fdb_cli \ No newline at end of file +} // namespace fdb_cli diff --git a/fdbcli/fdbcli.actor.h b/fdbcli/fdbcli.actor.h index 85c0526308..d1955f0629 100644 --- a/fdbcli/fdbcli.actor.h +++ b/fdbcli/fdbcli.actor.h @@ -22,7 +22,6 @@ // When actually compiled (NO_INTELLISENSE), include the generated // version of this file. In intellisense use the source version. -#include "flow/FastRef.h" #if defined(NO_INTELLISENSE) && !defined(FDBCLI_FDBCLI_ACTOR_G_H) #define FDBCLI_FDBCLI_ACTOR_G_H #include "fdbcli/fdbcli.actor.g.h" From 10484c426ca139e1a6a9235df65328cc45572921 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Thu, 5 Aug 2021 19:31:33 +0000 Subject: [PATCH 215/225] Disable advanceversion ctest --- bindings/python/tests/fdbcli_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index 0084a8b9ce..14224a6ca8 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -436,7 +436,8 @@ if __name__ == '__main__': # assertions will fail if fdbcli does not work as expected process_number = int(sys.argv[3]) if process_number == 1: - advanceversion() + # TODO: disable for now, the change can cause the database unavailable + #advanceversion() cache_range() consistencycheck() datadistribution() From 415bf2afc007c0b6b3b3fffca58fb02cb751b918 Mon Sep 17 00:00:00 2001 From: Pierre Zemb Date: Thu, 5 Aug 2021 15:31:15 +0200 Subject: [PATCH 216/225] add CMake's option for bindings --- CMakeLists.txt | 2 +- bindings/CMakeLists.txt | 10 ++-- cmake/AddFdbTest.cmake | 4 +- cmake/FDBComponents.cmake | 117 +++++++++++++++++++++++++------------- 4 files changed, 88 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff0c2c704..a23b5c304b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,7 +171,7 @@ add_subdirectory(fdbbackup) add_subdirectory(contrib) add_subdirectory(tests) add_subdirectory(flowbench EXCLUDE_FROM_ALL) -if(WITH_PYTHON) +if(WITH_PYTHON AND WITH_C_BINDING) add_subdirectory(bindings) endif() if(WITH_DOCUMENTATION) diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 378ea504b1..dfcf279b1d 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -3,14 +3,16 @@ if(NOT OPEN_FOR_IDE) add_subdirectory(c) add_subdirectory(flow) endif() -add_subdirectory(python) -if(WITH_JAVA) +if(WITH_PYTHON_BINDING) + add_subdirectory(python) +endif() +if(WITH_JAVA_BINDING) add_subdirectory(java) endif() -if(WITH_GO AND NOT OPEN_FOR_IDE) +if(WITH_GO_BINDING AND NOT OPEN_FOR_IDE) add_subdirectory(go) endif() -if(WITH_RUBY) +if(WITH_RUBY_BINDING) add_subdirectory(ruby) endif() if(NOT WIN32 AND NOT OPEN_FOR_IDE) diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index 8a4f638380..7f0ebc049c 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -352,7 +352,7 @@ function(package_bindingtester) COMMENT "Copy Flow tester for bindingtester") set(generated_binding_files python/fdb/fdboptions.py) - if(WITH_JAVA) + if(WITH_JAVA_BINDING) if(NOT FDB_RELEASE) set(prerelease_string "-PRERELEASE") else() @@ -369,7 +369,7 @@ function(package_bindingtester) set(generated_binding_files ${generated_binding_files} java/foundationdb-tests.jar) endif() - if(WITH_GO AND NOT OPEN_FOR_IDE) + if(WITH_GO_BINDING AND NOT OPEN_FOR_IDE) add_dependencies(copy_binding_output_files fdb_go_tester fdb_go) add_custom_command( TARGET copy_binding_output_files diff --git a/cmake/FDBComponents.cmake b/cmake/FDBComponents.cmake index bfde36f2ee..2aac3985eb 100644 --- a/cmake/FDBComponents.cmake +++ b/cmake/FDBComponents.cmake @@ -47,22 +47,6 @@ else() endif() endif() -################################################################################ -# Java Bindings -################################################################################ - -set(WITH_JAVA OFF) -find_package(JNI 1.8) -find_package(Java 1.8 COMPONENTS Development) -# leave FreeBSD JVM compat for later -if(JNI_FOUND AND Java_FOUND AND Java_Development_FOUND AND NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")) - set(WITH_JAVA ON) - include(UseJava) - enable_language(Java) -else() - set(WITH_JAVA OFF) -endif() - ################################################################################ # Python Bindings ################################################################################ @@ -75,12 +59,57 @@ else() set(WITH_PYTHON OFF) endif() +option(BUILD_PYTHON_BINDING "build python binding" ON) +if(NOT BUILD_PYTHON_BINDING OR NOT WITH_PYTHON) + set(WITH_PYTHON_BINDING OFF) +else() + if(WITH_PYTHON) + set(WITH_PYTHON_BINDING ON) + else() + #message(FATAL_ERROR "Could not found a suitable python interpreter") + set(WITH_PYTHON_BINDING OFF) + endif() +endif() + +################################################################################ +# C Bindings +################################################################################ + +option(BUILD_C_BINDING "build C binding" ON) +if(BUILD_C_BINDING AND WITH_PYTHON) + set(WITH_C_BINDING ON) +else() + set(WITH_C_BINDING OFF) +endif() + +################################################################################ +# Java Bindings +################################################################################ + +option(BUILD_JAVA_BINDING "build java binding" ON) +if(NOT BUILD_JAVA_BINDING OR NOT WITH_C_BINDING) + set(WITH_JAVA_BINDING OFF) +else() + set(WITH_JAVA_BINDING OFF) + find_package(JNI 1.8) + find_package(Java 1.8 COMPONENTS Development) + # leave FreeBSD JVM compat for later + if(JNI_FOUND AND Java_FOUND AND Java_Development_FOUND AND NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") AND WITH_C_BINDING) + set(WITH_JAVA_BINDING ON) + include(UseJava) + enable_language(Java) + else() + set(WITH_JAVA_BINDING OFF) + endif() +endif() + ################################################################################ # Pip ################################################################################ +option(BUILD_DOCUMENTATION "build documentation" ON) find_package(Python3 COMPONENTS Interpreter) -if (Python3_Interpreter_FOUND) +if (WITH_PYTHON AND Python3_Interpreter_FOUND AND BUILD_DOCUMENTATION) set(WITH_DOCUMENTATION ON) else() set(WITH_DOCUMENTATION OFF) @@ -90,27 +119,37 @@ endif() # GO ################################################################################ -find_program(GO_EXECUTABLE go) -# building the go binaries is currently not supported on Windows -if(GO_EXECUTABLE AND NOT WIN32) - set(WITH_GO ON) +option(BUILD_GO_BINDING "build go binding" ON) +if(NOT BUILD_GO_BINDING OR NOT BUILD_C_BINDING) + set(WITH_GO_BINDING OFF) else() - set(WITH_GO OFF) -endif() -if (USE_SANITIZER) - # Disable building go for sanitizers, since _stacktester doesn't link properly - set(WITH_GO OFF) + find_program(GO_EXECUTABLE go) + # building the go binaries is currently not supported on Windows + if(GO_EXECUTABLE AND NOT WIN32 AND WITH_C_BINDING) + set(WITH_GO_BINDING ON) + else() + set(WITH_GO_BINDING OFF) + endif() + if (USE_SANITIZER) + # Disable building go for sanitizers, since _stacktester doesn't link properly + set(WITH_GO_BINDING OFF) + endif() endif() ################################################################################ # Ruby ################################################################################ -find_program(GEM_EXECUTABLE gem) -set(WITH_RUBY OFF) -if(GEM_EXECUTABLE) - set(GEM_COMMAND ${RUBY_EXECUTABLE} ${GEM_EXECUTABLE}) - set(WITH_RUBY ON) +option(BUILD_RUBY_BINDING "build ruby binding" ON) +if(NOT BUILD_RUBY_BINDING OR NOT BUILD_C_BINDING) + set(WITH_RUBY_BINDING OFF) +else() + find_program(GEM_EXECUTABLE gem) + set(WITH_RUBY_BINDING OFF) + if(GEM_EXECUTABLE AND WITH_C_BINDING) + set(GEM_COMMAND ${RUBY_EXECUTABLE} ${GEM_EXECUTABLE}) + set(WITH_RUBY_BINDING ON) + endif() endif() ################################################################################ @@ -160,20 +199,22 @@ function(print_components) message(STATUS "=========================================") message(STATUS " Components Build Overview ") message(STATUS "=========================================") - message(STATUS "Build Java Bindings: ${WITH_JAVA}") - message(STATUS "Build with TLS support: ${WITH_TLS}") - message(STATUS "Build Go bindings: ${WITH_GO}") - message(STATUS "Build Ruby bindings: ${WITH_RUBY}") - message(STATUS "Build Python sdist (make package): ${WITH_PYTHON}") - message(STATUS "Build Documentation (make html): ${WITH_DOCUMENTATION}") message(STATUS "Build Bindings (depends on Python): ${WITH_PYTHON}") + message(STATUS "Build C Bindings: ${WITH_C_BINDING}") + message(STATUS "Build Python Bindings: ${WITH_PYTHON_BINDING}") + message(STATUS "Build Java Bindings: ${WITH_JAVA_BINDING}") + message(STATUS "Build Go bindings: ${WITH_GO_BINDING}") + message(STATUS "Build Ruby bindings: ${WITH_RUBY_BINDING}") + message(STATUS "Build with TLS support: ${WITH_TLS}") + message(STATUS "Build Documentation (make html): ${WITH_DOCUMENTATION}") + message(STATUS "Build Python sdist (make package): ${WITH_PYTHON_BINDING}") message(STATUS "Configure CTest (depends on Python): ${WITH_PYTHON}") message(STATUS "Build with RocksDB: ${WITH_ROCKSDB_EXPERIMENTAL}") message(STATUS "=========================================") endfunction() if(FORCE_ALL_COMPONENTS) - if(NOT WITH_JAVA OR NOT WITH_TLS OR NOT WITH_GO OR NOT WITH_RUBY OR NOT WITH_PYTHON OR NOT WITH_DOCUMENTATION) + if(NOT WITH_C_BINDING OR NOT WITH_JAVA_BINDING OR NOT WITH_TLS OR NOT WITH_GO_BINDING OR NOT WITH_RUBY_BINDING OR NOT WITH_PYTHON_BINDING OR NOT WITH_DOCUMENTATION) print_components() message(FATAL_ERROR "FORCE_ALL_COMPONENTS is set but not all dependencies could be found") endif() From bc9a0e1315c0b2a40a1f99dc6d396963c8f18492 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 10:05:56 -0700 Subject: [PATCH 217/225] first attempt to add data distribution support for range feeds --- fdbclient/DatabaseContext.h | 4 +- fdbclient/NativeAPI.actor.cpp | 44 ++++- fdbclient/StorageServerInterface.h | 47 ++++- fdbserver/TLogServer.actor.cpp | 11 +- fdbserver/storageserver.actor.cpp | 287 ++++++++++++++++++++++------- 5 files changed, 308 insertions(+), 85 deletions(-) diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index e28cff582c..e6d98cef6e 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -252,7 +252,9 @@ public: // Management API, create snapshot Future createSnapshot(StringRef uid, StringRef snapshot_command); - Future>> getRangeFeedMutations(StringRef rangeID); + Future>> getRangeFeedMutations(StringRef rangeID, + KeyRangeRef range = allKeys); + Future>> getOverlappingRangeFeeds(KeyRangeRef ranges, Version minVersion); Future popRangeFeedMutations(StringRef rangeID, Version version); // private: diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index fb292cf361..c198994f48 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -6518,7 +6518,8 @@ Future DatabaseContext::createSnapshot(StringRef uid, StringRef snapshot_c } ACTOR Future>> getRangeFeedMutationsActor(Reference db, - StringRef rangeID) { + StringRef rangeID, + KeyRangeRef range) { state Database cx(db); state Transaction tr(cx); state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); @@ -6553,8 +6554,45 @@ ACTOR Future>> getRangeFeedMutation return Standalone>(rep.mutations, rep.arena); } -Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID) { - return getRangeFeedMutationsActor(Reference::addRef(this), rangeID); +Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID, + KeyRangeRef range) { + return getRangeFeedMutationsActor(Reference::addRef(this), rangeID, range); +} + +ACTOR Future>> getOverlappingRangeFeedsActor(Reference db, + KeyRangeRef range, + Version minVersion) { + state Database cx(db); + state Transaction tr(cx); + state Span span("NAPI:GetOverlappingRangeFeeds"_loc); + state vector>> locations = + wait(getKeyRangeLocations(cx, + range, + 100, + Reverse::False, + &StorageServerInterface::rangeFeed, + TransactionInfo(TaskPriority::DefaultEndpoint, span.context))); + + if (locations.size() > 1) { + throw unsupported_operation(); + } + + state OverlappingRangeFeedsRequest req; + req.range = range; + + OverlappingRangeFeedsReply rep = wait(loadBalance(cx.getPtr(), + locations[0].second, + &StorageServerInterface::overlappingRangeFeeds, + req, + TaskPriority::DefaultPromiseEndpoint, + AtMostOnce::False, + cx->enableLocalityLoadBalance ? &cx->queueModel : nullptr)); + return rep.rangeIds; +} + +Future>> DatabaseContext::getOverlappingRangeFeeds(KeyRangeRef range, + Version minVersion) { + return getOverlappingRangeFeedsActor(Reference::addRef(this), range, minVersion); } ACTOR Future popRangeFeedMutationsActor(Reference db, StringRef rangeID, Version version) { diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 999bbb4054..9efea0e732 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -78,6 +78,7 @@ struct StorageServerInterface { RequestStream getReadHotRanges; RequestStream getRangeSplitPoints; RequestStream rangeFeed; + RequestStream overlappingRangeFeeds; RequestStream rangeFeedPop; RequestStream getKeyValuesStream; @@ -120,11 +121,13 @@ struct StorageServerInterface { RequestStream(getValue.getEndpoint().getAdjustedEndpoint(11)); getRangeSplitPoints = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(12)); - rangeFeed = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(13)); - rangeFeedPop = - RequestStream(getValue.getEndpoint().getAdjustedEndpoint(14)); getKeyValuesStream = - RequestStream(getValue.getEndpoint().getAdjustedEndpoint(15)); + RequestStream(getValue.getEndpoint().getAdjustedEndpoint(13)); + rangeFeed = RequestStream(getValue.getEndpoint().getAdjustedEndpoint(14)); + overlappingRangeFeeds = + RequestStream(getValue.getEndpoint().getAdjustedEndpoint(15)); + rangeFeedPop = + RequestStream(getValue.getEndpoint().getAdjustedEndpoint(16)); } } else { ASSERT(Ar::isDeserializing); @@ -166,9 +169,10 @@ struct StorageServerInterface { streams.push_back(watchValue.getReceiver()); streams.push_back(getReadHotRanges.getReceiver()); streams.push_back(getRangeSplitPoints.getReceiver()); - streams.push_back(rangeFeed.getReceiver()); - streams.push_back(rangeFeedPop.getReceiver()); streams.push_back(getKeyValuesStream.getReceiver(TaskPriority::LoadBalancedEndpoint)); + streams.push_back(rangeFeed.getReceiver()); + streams.push_back(overlappingRangeFeeds.getReceiver()); + streams.push_back(rangeFeedPop.getReceiver()); FlowTransport::transport().addEndpoints(streams); } }; @@ -662,7 +666,7 @@ struct RangeFeedRequest { ReplyPromise reply; RangeFeedRequest() {} - RangeFeedRequest(Key const& rangeID) : rangeID(rangeID) {} + explicit RangeFeedRequest(Key const& rangeID) : rangeID(rangeID) {} template void serialize(Ar& ar) { @@ -685,6 +689,35 @@ struct RangeFeedPopRequest { } }; +struct OverlappingRangeFeedsReply { + constexpr static FileIdentifier file_identifier = 11815134; + std::vector> rangeIds; + bool cached; + Arena arena; + + OverlappingRangeFeedsReply() : cached(false) {} + explicit OverlappingRangeFeedsReply(std::vector> const& rangeIds) + : rangeIds(rangeIds), cached(false) {} + + template + void serialize(Ar& ar) { + serializer(ar, rangeIds, arena); + } +}; +struct OverlappingRangeFeedsRequest { + constexpr static FileIdentifier file_identifier = 10726174; + KeyRange range; + ReplyPromise reply; + + OverlappingRangeFeedsRequest() {} + explicit OverlappingRangeFeedsRequest(KeyRange const& range) : range(range) {} + + template + void serialize(Ar& ar) { + serializer(ar, range, reply); + } +}; + struct GetStorageMetricsReply { constexpr static FileIdentifier file_identifier = 15491478; StorageMetrics load; diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index d8e27a78ba..2643d02e01 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -1861,10 +1861,13 @@ ACTOR Future tLogPeekMessages(TLogData* self, TLogPeekRequest req, Referen reply.end = endVersion; reply.onlySpilled = onlySpilled; - //TraceEvent("TlogPeek", self->dbgid).detail("LogId", logData->logId).detail("Tag", req.tag.toString()). - // detail("BeginVer", req.begin).detail("EndVer", reply.end). - // detail("MsgBytes", reply.messages.expectedSize()). - // detail("ForAddress", req.reply.getEndpoint().getPrimaryAddress()); + TraceEvent("TlogPeek", self->dbgid) + .detail("LogId", logData->logId) + .detail("Tag", req.tag.toString()) + .detail("BeginVer", req.begin) + .detail("EndVer", reply.end) + .detail("MsgBytes", reply.messages.expectedSize()) + .detail("ForAddress", req.reply.getEndpoint().getPrimaryAddress()); if (req.sequence.present()) { auto& trackerData = logData->peekTracker[peekId]; diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 46646d968b..b4cce58fb3 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -94,6 +94,7 @@ struct AddingShard : NonCopyable { Future fetchClient; // holds FetchKeys() actor Promise fetchComplete; Promise readWrite; + PromiseStream rangeFeedRemovals; // During the Fetching phase, it saves newer mutations whose version is greater or equal to fetchClient's // fetchVersion, while the shard is still busy catching up with fetchClient. It applies these updates after fetching @@ -130,7 +131,7 @@ struct AddingShard : NonCopyable { readWrite.send(Void()); } - void addMutation(Version version, MutationRef const& mutation); + void addMutation(Version version, bool fromFetch, MutationRef const& mutation); bool isTransferred() const { return phase == Waiting; } }; @@ -159,7 +160,7 @@ public: bool notAssigned() const { return !readWrite && !adding; } bool assigned() const { return readWrite || adding; } bool isInVersionedData() const { return readWrite || (adding && adding->isTransferred()); } - void addMutation(Version version, MutationRef const& mutation); + void addMutation(Version version, bool fromFetch, MutationRef const& mutation); bool isFetched() const { return readWrite || (adding && adding->fetchComplete.isSet()); } const char* debugDescribeState() const { @@ -306,6 +307,7 @@ static int mvccStorageBytes(MutationRef const& m) { struct FetchInjectionInfo { Arena arena; + Version transferredVersion; vector changes; }; @@ -583,6 +585,7 @@ public: KeyRangeMap>> keyRangeFeed; std::map> uidRangeFeed; Deque, Version>> rangeFeedVersions; + std::map> rangeFeedRemovals; std::set currentRangeFeeds; // newestAvailableVersion[k] @@ -882,6 +885,7 @@ public: shards.insert(newShard->keys, Reference(newShard)); } void addMutation(Version version, + bool fromFetch, MutationRef const& mutation, KeyRangeRef const& shard, UpdateEagerReadInfo* eagerReads); @@ -1506,7 +1510,21 @@ ACTOR Future watchValueSendReply(StorageServer* data, } } -ACTOR Future rangeFeedQ(StorageServer* data, RangeFeedRequest req) { +ACTOR Future overlappingRangeFeedsQ(StorageServer* data, OverlappingRangeFeedsRequest req) { + wait(delay(0)); + auto ranges = data->keyRangeFeed.intersectingRanges(req.range); + std::set> rangeIds; + for (auto r : ranges) { + for (auto& it : r.value()) { + rangeIds.insert(std::make_pair(it->id, it->range)); + } + } + OverlappingRangeFeedsReply reply(std::vector>(rangeIds.begin(), rangeIds.end())); + req.reply.send(reply); + return Void(); +} + +ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFeedRequest req) { state RangeFeedReply reply; wait(delay(0)); auto& feedInfo = data->uidRangeFeed[req.rangeID]; @@ -1537,11 +1555,12 @@ ACTOR Future rangeFeedQ(StorageServer* data, RangeFeedRequest req) { } } } + return reply; +} - TraceEvent("RangeFeedQuery", data->thisServerID) - .detail("RangeID", req.rangeID.printable()) - .detail("Mutations", reply.mutations.size()); - req.reply.send(reply); +ACTOR Future rangeFeedQ(StorageServer* data, RangeFeedRequest req) { + RangeFeedReply rep = wait(getRangeFeedMutations(data, req)); + req.reply.send(rep); return Void(); } @@ -2622,7 +2641,8 @@ void applyMutation(StorageServer* self, MutationRef const& m, Arena& arena, StorageServer::VersionedData& data, - Version version) { + Version version, + bool fromFetch) { // m is expected to be in arena already // Clear split keys are added to arena StorageMetrics metrics; @@ -2656,12 +2676,14 @@ void applyMutation(StorageServer* self, data.insert(m.param1, ValueOrClearToRef::value(m.param2)); self->watches.trigger(m.param1); - for (auto& it : self->keyRangeFeed[m.param1]) { - if (it->mutations.empty() || it->mutations.back().version != version) { - it->mutations.push_back(MutationsAndVersionRef(version)); + if (!fromFetch) { + for (auto& it : self->keyRangeFeed[m.param1]) { + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), m); + self->currentRangeFeeds.insert(it->id); } - it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), m); - self->currentRangeFeeds.insert(it->id); } } else if (m.type == MutationRef::ClearRange) { data.erase(m.param1, m.param2); @@ -2670,14 +2692,16 @@ void applyMutation(StorageServer* self, data.insert(m.param1, ValueOrClearToRef::clearTo(m.param2)); self->watches.triggerRange(m.param1, m.param2); - auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); - for (auto& r : ranges) { - for (auto& it : r.value()) { - if (it->mutations.empty() || it->mutations.back().version != version) { - it->mutations.push_back(MutationsAndVersionRef(version)); + if (!fromFetch) { + auto ranges = self->keyRangeFeed.intersectingRanges(KeyRangeRef(m.param1, m.param2)); + for (auto& r : ranges) { + for (auto& it : r.value()) { + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), m); + self->currentRangeFeeds.insert(it->id); } - it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), m); - self->currentRangeFeeds.insert(it->id); } } } @@ -2760,34 +2784,34 @@ void coalesceShards(StorageServer* data, KeyRangeRef keys) { } template -void addMutation(T& target, Version version, MutationRef const& mutation) { - target.addMutation(version, mutation); +void addMutation(T& target, Version version, bool fromFetch, MutationRef const& mutation) { + target.addMutation(version, fromFetch, mutation); } template -void addMutation(Reference& target, Version version, MutationRef const& mutation) { - addMutation(*target, version, mutation); +void addMutation(Reference& target, Version version, bool fromFetch, MutationRef const& mutation) { + addMutation(*target, version, fromFetch, mutation); } template void splitMutations(StorageServer* data, KeyRangeMap& map, VerUpdateRef const& update) { for (int i = 0; i < update.mutations.size(); i++) { - splitMutation(data, map, update.mutations[i], update.version); + splitMutation(data, map, update.mutations[i], update.version, update.version); } } template -void splitMutation(StorageServer* data, KeyRangeMap& map, MutationRef const& m, Version ver) { +void splitMutation(StorageServer* data, KeyRangeMap& map, MutationRef const& m, Version ver, bool fromFetch) { if (isSingleKeyMutation((MutationRef::Type)m.type)) { if (!SHORT_CIRCUT_ACTUAL_STORAGE || !normalKeys.contains(m.param1)) - addMutation(map.rangeContaining(m.param1)->value(), ver, m); + addMutation(map.rangeContaining(m.param1)->value(), ver, fromFetch, m); } else if (m.type == MutationRef::ClearRange) { KeyRangeRef mKeys(m.param1, m.param2); if (!SHORT_CIRCUT_ACTUAL_STORAGE || !normalKeys.contains(mKeys)) { auto r = map.intersectingRanges(mKeys); for (auto i = r.begin(); i != r.end(); ++i) { KeyRangeRef k = mKeys & i->range(); - addMutation(i->value(), ver, MutationRef((MutationRef::Type)m.type, k.begin, k.end)); + addMutation(i->value(), ver, fromFetch, MutationRef((MutationRef::Type)m.type, k.begin, k.end)); } } } else @@ -2890,12 +2914,129 @@ ACTOR Future tryGetRange(PromiseStream results, Transaction* } } +#define PERSIST_PREFIX "\xff\xff" + +// Immutable +static const KeyValueRef persistFormat(LiteralStringRef(PERSIST_PREFIX "Format"), + LiteralStringRef("FoundationDB/StorageServer/1/4")); +static const KeyRangeRef persistFormatReadableRange(LiteralStringRef("FoundationDB/StorageServer/1/2"), + LiteralStringRef("FoundationDB/StorageServer/1/5")); +static const KeyRef persistID = LiteralStringRef(PERSIST_PREFIX "ID"); +static const KeyRef persistTssPairID = LiteralStringRef(PERSIST_PREFIX "tssPairID"); +static const KeyRef persistTssQuarantine = LiteralStringRef(PERSIST_PREFIX "tssQ"); + +// (Potentially) change with the durable version or when fetchKeys completes +static const KeyRef persistVersion = LiteralStringRef(PERSIST_PREFIX "Version"); +static const KeyRangeRef persistShardAssignedKeys = + KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "ShardAssigned/"), LiteralStringRef(PERSIST_PREFIX "ShardAssigned0")); +static const KeyRangeRef persistShardAvailableKeys = + KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "ShardAvailable/"), LiteralStringRef(PERSIST_PREFIX "ShardAvailable0")); +static const KeyRangeRef persistByteSampleKeys = + KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "BS/"), LiteralStringRef(PERSIST_PREFIX "BS0")); +static const KeyRangeRef persistByteSampleSampleKeys = + KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "BS/" PERSIST_PREFIX "BS/"), + LiteralStringRef(PERSIST_PREFIX "BS/" PERSIST_PREFIX "BS0")); +static const KeyRef persistLogProtocol = LiteralStringRef(PERSIST_PREFIX "LogProtocol"); +static const KeyRef persistPrimaryLocality = LiteralStringRef(PERSIST_PREFIX "PrimaryLocality"); +static const KeyRangeRef persistRangeFeedKeys = + KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "RF/"), LiteralStringRef(PERSIST_PREFIX "RF0")); +// data keys are unmangled (but never start with PERSIST_PREFIX because they are always in allKeys) + +ACTOR Future fetchRangeFeed(StorageServer* data, Key rangeId, KeyRange range) { + + TraceEvent("FetchRangeFeed", data->thisServerID) + .detail("RangeID", rangeId.printable()) + .detail("Range", range.toString()); + Reference rangeFeedInfo(new RangeFeedInfo()); + rangeFeedInfo->range = range; + rangeFeedInfo->id = rangeId; + data->uidRangeFeed[rangeId] = rangeFeedInfo; + auto rs = data->keyRangeFeed.modify(range); + for (auto r = rs.begin(); r != rs.end(); ++r) { + r->value().push_back(rangeFeedInfo); + } + data->keyRangeFeed.coalesce(range.contents()); + auto& mLV = data->addVersionToMutationLog(data->data().getLatestVersion()); + data->addMutationToMutationLog(mLV, + MutationRef(MutationRef::SetValue, + persistRangeFeedKeys.begin.toString() + rangeId.toString(), + rangeFeedValue(range))); + + state Standalone> mutations = + wait(data->cx->getRangeFeedMutations(rangeId, range)); + state RangeFeedRequest req; + req.rangeID = rangeId; + state RangeFeedReply rep = wait(getRangeFeedMutations(data, req)); + state int mLoc = 0; + state int rLoc = 0; + while (mLoc < mutations.size() && rLoc < rep.mutations.size()) { + if (mutations[mLoc].version < rep.mutations[rLoc].version) { + // write mutation to disk + mLoc++; + } else if (mutations[mLoc].version == rep.mutations[rLoc].version) { + // merge mutations and write to disk + mLoc++; + rLoc++; + } else { + rLoc++; + } + } + while (mLoc < mutations.size()) { + // write mutation to disk + mLoc++; + } +} + +ACTOR Future dispatchRangeFeeds(StorageServer* data, UID fetchKeysID, KeyRange keys, Version fetchVersion) { + // find overlapping range feeds + state std::map> feedFetches; + state PromiseStream removals; + data->rangeFeedRemovals[fetchKeysID] = removals; + try { + state std::vector> feeds = + wait(data->cx->getOverlappingRangeFeeds(keys, fetchVersion)); + for (auto& feed : feeds) { + feedFetches[feed.first] = fetchRangeFeed(data, feed.first, feed.second); + } + + loop { + Future nextFeed = Never(); + if (!removals.getFuture().isReady()) { + bool done = true; + while (!feedFetches.empty()) { + if (feedFetches.begin()->second.isReady()) { + feedFetches.erase(feedFetches.begin()); + } else { + nextFeed = feedFetches.begin()->second; + done = false; + } + } + if (done) { + data->rangeFeedRemovals.erase(fetchKeysID); + return Void(); + } + } + choose { + when(Key remove = waitNext(removals.getFuture())) { feedFetches.erase(remove); } + when(wait(nextFeed)) {} + } + } + + } catch (Error& e) { + if (!data->shuttingDown) { + data->rangeFeedRemovals.erase(fetchKeysID); + } + throw; + } +} + ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { state const UID fetchKeysID = deterministicRandom()->randomUniqueID(); state TraceInterval interval("FetchKeys"); state KeyRange keys = shard->keys; state Future warningLogger = logFetchKeysWarning(shard); state const double startTime = now(); + state Version fetchVersion = invalidVersion; state FetchKeysMetricReporter metricReporter(fetchKeysID, startTime, keys, @@ -2957,7 +3098,6 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { // Get the history state int debug_getRangeRetries = 0; state int debug_nextRetryToLog = 1; - state bool isTooOld = false; // FIXME: The client cache does not notice when servers are added to a team. To read from a local storage server // we must refresh the cache manually. @@ -2965,7 +3105,7 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { loop { state Transaction tr(data->cx); - state Version fetchVersion = data->version.get(); + fetchVersion = data->version.get(); TraceEvent(SevDebug, "FetchKeysUnblocked", data->thisServerID) .detail("FKID", interval.pairID) @@ -3107,8 +3247,10 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { // being recovered. Instead we wait for the updateStorage loop to commit something (and consequently also what // we have written) + state Future fetchDurable = data->durableVersion.whenAtLeast(data->storageVersion() + 1); + holdingFKPL.release(); - wait(data->durableVersion.whenAtLeast(data->storageVersion() + 1)); + wait(fetchDurable); TraceEvent(SevDebug, "FKAfterFinalCommit", data->thisServerID) .detail("FKID", interval.pairID) @@ -3150,8 +3292,9 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { // Eager reads will be done for them by update(), and the mutations will come back through // AddingShard::addMutations and be applied to versionedMap and mutationLog as normal. The lie about their // version is acceptable because this shard will never be read at versions < transferredVersion + + batch->transferredVersion = shard->transferredVersion; for (auto i = shard->updates.begin(); i != shard->updates.end(); ++i) { - i->version = shard->transferredVersion; batch->arena.dependsOn(i->arena()); } @@ -3232,7 +3375,8 @@ AddingShard::AddingShard(StorageServer* server, KeyRangeRef const& keys) fetchClient = fetchKeys(server, this); } -void AddingShard::addMutation(Version version, MutationRef const& mutation) { +void AddingShard::addMutation(Version version, bool fromFetch, MutationRef const& mutation) { + ASSERT(!fromFetch); if (mutation.type == mutation.ClearRange) { ASSERT(keys.begin <= mutation.param1 && mutation.param2 <= keys.end); } else if (isSingleKeyMutation((MutationRef::Type)mutation.type)) { @@ -3255,19 +3399,39 @@ void AddingShard::addMutation(Version version, MutationRef const& mutation) { } // Add the mutation to the version. updates.back().mutations.push_back_deep(updates.back().arena(), mutation); + if (mutation.type == MutationRef::SetValue) { + for (auto& it : server->keyRangeFeed[mutation.param1]) { + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), mutation); + server->currentRangeFeeds.insert(it->id); + } + } else if (mutation.type == MutationRef::ClearRange) { + auto ranges = server->keyRangeFeed.intersectingRanges(KeyRangeRef(mutation.param1, mutation.param2)); + for (auto& r : ranges) { + for (auto& it : r.value()) { + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), mutation); + server->currentRangeFeeds.insert(it->id); + } + } + } } else if (phase == Waiting) { - server->addMutation(version, mutation, keys, server->updateEagerReads); + server->addMutation(version, fromFetch, mutation, keys, server->updateEagerReads); } else ASSERT(false); } -void ShardInfo::addMutation(Version version, MutationRef const& mutation) { +void ShardInfo::addMutation(Version version, bool fromFetch, MutationRef const& mutation) { ASSERT((void*)this); ASSERT(keys.contains(mutation.param1)); if (adding) - adding->addMutation(version, mutation); + adding->addMutation(version, fromFetch, mutation); else if (readWrite) - readWrite->addMutation(version, mutation, this->keys, readWrite->updateEagerReads); + readWrite->addMutation(version, fromFetch, mutation, this->keys, readWrite->updateEagerReads); else if (mutation.type != MutationRef::ClearRange) { TraceEvent(SevError, "DeliveredToNotAssigned") .detail("Version", version) @@ -3418,6 +3582,7 @@ void rollback(StorageServer* data, Version rollbackVersion, Version nextVersion) } void StorageServer::addMutation(Version version, + bool fromFetch, MutationRef const& mutation, KeyRangeRef const& shard, UpdateEagerReadInfo* eagerReads) { @@ -3432,7 +3597,7 @@ void StorageServer::addMutation(Version version, .detail("UID", thisServerID) .detail("ShardBegin", shard.begin) .detail("ShardEnd", shard.end); - applyMutation(this, expanded, mLog.arena(), mutableData(), version); + applyMutation(this, expanded, mLog.arena(), mutableData(), version, fromFetch); // printf("\nSSUpdate: Printing versioned tree after applying mutation\n"); // mutableData().printTree(version); } @@ -3447,34 +3612,6 @@ struct OrderByVersion { } }; -#define PERSIST_PREFIX "\xff\xff" - -// Immutable -static const KeyValueRef persistFormat(LiteralStringRef(PERSIST_PREFIX "Format"), - LiteralStringRef("FoundationDB/StorageServer/1/4")); -static const KeyRangeRef persistFormatReadableRange(LiteralStringRef("FoundationDB/StorageServer/1/2"), - LiteralStringRef("FoundationDB/StorageServer/1/5")); -static const KeyRef persistID = LiteralStringRef(PERSIST_PREFIX "ID"); -static const KeyRef persistTssPairID = LiteralStringRef(PERSIST_PREFIX "tssPairID"); -static const KeyRef persistTssQuarantine = LiteralStringRef(PERSIST_PREFIX "tssQ"); - -// (Potentially) change with the durable version or when fetchKeys completes -static const KeyRef persistVersion = LiteralStringRef(PERSIST_PREFIX "Version"); -static const KeyRangeRef persistShardAssignedKeys = - KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "ShardAssigned/"), LiteralStringRef(PERSIST_PREFIX "ShardAssigned0")); -static const KeyRangeRef persistShardAvailableKeys = - KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "ShardAvailable/"), LiteralStringRef(PERSIST_PREFIX "ShardAvailable0")); -static const KeyRangeRef persistByteSampleKeys = - KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "BS/"), LiteralStringRef(PERSIST_PREFIX "BS0")); -static const KeyRangeRef persistByteSampleSampleKeys = - KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "BS/" PERSIST_PREFIX "BS/"), - LiteralStringRef(PERSIST_PREFIX "BS/" PERSIST_PREFIX "BS0")); -static const KeyRef persistLogProtocol = LiteralStringRef(PERSIST_PREFIX "LogProtocol"); -static const KeyRef persistPrimaryLocality = LiteralStringRef(PERSIST_PREFIX "PrimaryLocality"); -static const KeyRangeRef persistRangeFeedKeys = - KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "RF/"), LiteralStringRef(PERSIST_PREFIX "RF0")); -// data keys are unmangled (but never start with PERSIST_PREFIX because they are always in allKeys) - class StorageUpdater { public: StorageUpdater() @@ -3484,7 +3621,7 @@ public: : fromVersion(fromVersion), currentVersion(fromVersion), restoredVersion(restoredVersion), processedStartKey(false), processedCacheStartKey(false) {} - void applyMutation(StorageServer* data, MutationRef const& m, Version ver) { + void applyMutation(StorageServer* data, MutationRef const& m, Version ver, bool fromFetch) { //TraceEvent("SSNewVersion", data->thisServerID).detail("VerWas", data->mutableData().latestVersion).detail("ChVer", ver); if (currentVersion != ver) { @@ -3505,7 +3642,7 @@ public: // DEBUG_MUTATION("SSUpdateMutation", changes[c].version, *m); //} - splitMutation(data, data->shards, m, ver); + splitMutation(data, data->shards, m, ver, fromFetch); } if (data->otherError.getFuture().isReady()) @@ -3873,7 +4010,7 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { state int mutationNum = 0; state VerUpdateRef* pUpdate = &fii.changes[changeNum]; for (; mutationNum < pUpdate->mutations.size(); mutationNum++) { - updater.applyMutation(data, pUpdate->mutations[mutationNum], pUpdate->version); + updater.applyMutation(data, pUpdate->mutations[mutationNum], fii.transferredVersion, true); mutationBytes += pUpdate->mutations[mutationNum].totalSize(); // data->counters.mutationBytes or data->counters.mutations should not be updated because they should // have counted when the mutations arrive from cursor initially. @@ -3950,7 +4087,7 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { //TraceEvent("SSPeekMutation", data->thisServerID).detail("Mutation", msg.toString()).detail("Version", cloneCursor2->version().toString()); } - updater.applyMutation(data, msg, ver); + updater.applyMutation(data, msg, ver, false); mutationBytes += msg.totalSize(); data->counters.mutationBytes += msg.totalSize(); ++data->counters.mutations; @@ -5084,6 +5221,15 @@ ACTOR Future serveRangeFeedRequests(StorageServer* self, FutureStream serveOverlappingRangeFeedsRequests( + StorageServer* self, + FutureStream overlappingRangeFeeds) { + loop { + OverlappingRangeFeedsRequest req = waitNext(overlappingRangeFeeds); + self->actors.add(self->readGuard(req, overlappingRangeFeedsQ)); + } +} + ACTOR Future serveRangeFeedPopRequests(StorageServer* self, FutureStream rangeFeedPops) { loop { RangeFeedPopRequest req = waitNext(rangeFeedPops); @@ -5155,6 +5301,7 @@ ACTOR Future storageServerCore(StorageServer* self, StorageServerInterface self->actors.add(serveGetKeyRequests(self, ssi.getKey.getFuture())); self->actors.add(serveWatchValueRequests(self, ssi.watchValue.getFuture())); self->actors.add(serveRangeFeedRequests(self, ssi.rangeFeed.getFuture())); + self->actors.add(serveOverlappingRangeFeedsRequests(self, ssi.overlappingRangeFeeds.getFuture())); self->actors.add(serveRangeFeedPopRequests(self, ssi.rangeFeedPop.getFuture())); self->actors.add(traceRole(Role::STORAGE_SERVER, ssi.id())); self->actors.add(reportStorageServerState(self)); From 27f87471ab3049f470c5d07d77cab3a7c90a5652 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 12:48:38 -0700 Subject: [PATCH 218/225] fixed compile errors --- fdbclient/StorageServerInterface.cpp | 25 ++++++++++++++++++++++++- fdbserver/storageserver.actor.cpp | 16 ++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/fdbclient/StorageServerInterface.cpp b/fdbclient/StorageServerInterface.cpp index b52ca0a8cd..417fe03f36 100644 --- a/fdbclient/StorageServerInterface.cpp +++ b/fdbclient/StorageServerInterface.cpp @@ -296,7 +296,7 @@ void TSS_traceMismatch(TraceEvent& event, ASSERT(false); } -// split range +// range feed template <> bool TSS_doCompare(const RangeFeedReply& src, const RangeFeedReply& tss) { ASSERT(false); @@ -317,6 +317,26 @@ void TSS_traceMismatch(TraceEvent& event, ASSERT(false); } +template <> +bool TSS_doCompare(const OverlappingRangeFeedsReply& src, const OverlappingRangeFeedsReply& tss) { + ASSERT(false); + return true; +} + +template <> +const char* TSS_mismatchTraceName(const OverlappingRangeFeedsRequest& req) { + ASSERT(false); + return ""; +} + +template <> +void TSS_traceMismatch(TraceEvent& event, + const OverlappingRangeFeedsRequest& req, + const OverlappingRangeFeedsReply& src, + const OverlappingRangeFeedsReply& tss) { + ASSERT(false); +} + // only record metrics for data reads template <> @@ -358,6 +378,9 @@ void TSSMetrics::recordLatency(const GetKeyValuesStreamRequest& req, double ssLa template <> void TSSMetrics::recordLatency(const RangeFeedRequest& req, double ssLatency, double tssLatency) {} +template <> +void TSSMetrics::recordLatency(const OverlappingRangeFeedsRequest& req, double ssLatency, double tssLatency) {} + // ------------------- TEST_CASE("/StorageServerInterface/TSSCompare/TestComparison") { diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index b4cce58fb3..a832adc43c 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -307,7 +307,6 @@ static int mvccStorageBytes(MutationRef const& m) { struct FetchInjectionInfo { Arena arena; - Version transferredVersion; vector changes; }; @@ -1513,12 +1512,16 @@ ACTOR Future watchValueSendReply(StorageServer* data, ACTOR Future overlappingRangeFeedsQ(StorageServer* data, OverlappingRangeFeedsRequest req) { wait(delay(0)); auto ranges = data->keyRangeFeed.intersectingRanges(req.range); - std::set> rangeIds; + std::map rangeIds; for (auto r : ranges) { for (auto& it : r.value()) { - rangeIds.insert(std::make_pair(it->id, it->range)); + rangeIds[it->id] = it->range; } } + std::vector> result; + for (auto& it : rangeIds) { + result.push_back(std::make_pair(it.first, it.second)); + } OverlappingRangeFeedsReply reply(std::vector>(rangeIds.begin(), rangeIds.end())); req.reply.send(reply); return Void(); @@ -2985,6 +2988,7 @@ ACTOR Future fetchRangeFeed(StorageServer* data, Key rangeId, KeyRange ran // write mutation to disk mLoc++; } + return Void(); } ACTOR Future dispatchRangeFeeds(StorageServer* data, UID fetchKeysID, KeyRange keys, Version fetchVersion) { @@ -3293,8 +3297,8 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { // AddingShard::addMutations and be applied to versionedMap and mutationLog as normal. The lie about their // version is acceptable because this shard will never be read at versions < transferredVersion - batch->transferredVersion = shard->transferredVersion; for (auto i = shard->updates.begin(); i != shard->updates.end(); ++i) { + i->version = shard->transferredVersion; batch->arena.dependsOn(i->arena()); } @@ -4010,7 +4014,7 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { state int mutationNum = 0; state VerUpdateRef* pUpdate = &fii.changes[changeNum]; for (; mutationNum < pUpdate->mutations.size(); mutationNum++) { - updater.applyMutation(data, pUpdate->mutations[mutationNum], fii.transferredVersion, true); + updater.applyMutation(data, pUpdate->mutations[mutationNum], pUpdate->version, true); mutationBytes += pUpdate->mutations[mutationNum].totalSize(); // data->counters.mutationBytes or data->counters.mutations should not be updated because they should // have counted when the mutations arrive from cursor initially. @@ -4262,7 +4266,7 @@ ACTOR Future updateStorage(StorageServer* data) { } std::set modifiedRangeFeeds; - while (data->rangeFeedVersions.front().second < newOldestVersion) { + while (!data->rangeFeedVersions.empty() && data->rangeFeedVersions.front().second < newOldestVersion) { modifiedRangeFeeds.insert(data->rangeFeedVersions.front().first.begin(), data->rangeFeedVersions.front().first.end()); data->rangeFeedVersions.pop_front(); From b03649d627fbb07ff1d4d15d6c247c3324c45627 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 12:55:57 -0700 Subject: [PATCH 219/225] fixed assertion error --- fdbserver/storageserver.actor.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index a832adc43c..a101b0052e 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -3380,7 +3380,6 @@ AddingShard::AddingShard(StorageServer* server, KeyRangeRef const& keys) } void AddingShard::addMutation(Version version, bool fromFetch, MutationRef const& mutation) { - ASSERT(!fromFetch); if (mutation.type == mutation.ClearRange) { ASSERT(keys.begin <= mutation.param1 && mutation.param2 <= keys.end); } else if (isSingleKeyMutation((MutationRef::Type)mutation.type)) { @@ -3403,24 +3402,26 @@ void AddingShard::addMutation(Version version, bool fromFetch, MutationRef const } // Add the mutation to the version. updates.back().mutations.push_back_deep(updates.back().arena(), mutation); - if (mutation.type == MutationRef::SetValue) { - for (auto& it : server->keyRangeFeed[mutation.param1]) { - if (it->mutations.empty() || it->mutations.back().version != version) { - it->mutations.push_back(MutationsAndVersionRef(version)); - } - it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), mutation); - server->currentRangeFeeds.insert(it->id); - } - } else if (mutation.type == MutationRef::ClearRange) { - auto ranges = server->keyRangeFeed.intersectingRanges(KeyRangeRef(mutation.param1, mutation.param2)); - for (auto& r : ranges) { - for (auto& it : r.value()) { + if (!fromFetch) { + if (mutation.type == MutationRef::SetValue) { + for (auto& it : server->keyRangeFeed[mutation.param1]) { if (it->mutations.empty() || it->mutations.back().version != version) { it->mutations.push_back(MutationsAndVersionRef(version)); } it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), mutation); server->currentRangeFeeds.insert(it->id); } + } else if (mutation.type == MutationRef::ClearRange) { + auto ranges = server->keyRangeFeed.intersectingRanges(KeyRangeRef(mutation.param1, mutation.param2)); + for (auto& r : ranges) { + for (auto& it : r.value()) { + if (it->mutations.empty() || it->mutations.back().version != version) { + it->mutations.push_back(MutationsAndVersionRef(version)); + } + it->mutations.back().mutations.push_back_deep(it->mutations.back().arena(), mutation); + server->currentRangeFeeds.insert(it->id); + } + } } } } else if (phase == Waiting) { From 3b9cb1a85a60c4384155a9b8385f78ff383d9c54 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Mon, 9 Aug 2021 21:13:59 +0000 Subject: [PATCH 220/225] Re-enable exclude command ctest --- bindings/python/tests/fdbcli_tests.py | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index 14224a6ca8..17a94e16b1 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -332,9 +332,10 @@ def transaction(logger): output7 = run_fdbcli_command('get', 'key') assert output7 == "`key': not found" -def get_fdb_process_addresses(): +def get_fdb_process_addresses(logger): # get all processes' network addresses output = run_fdbcli_command('kill') + logger.debug(output) # except the first line, each line is one process addresses = output.split('\n')[1:] assert len(addresses) == process_number @@ -354,7 +355,7 @@ def coordinators(logger): assert coordinator_list[0]['address'] == coordinators # verify the cluster description assert get_value_from_status_json(True, 'cluster', 'connection_string').startswith('{}:'.format(cluster_description)) - addresses = get_fdb_process_addresses() + addresses = get_fdb_process_addresses(logger) # set all 5 processes as coordinators and update the cluster description new_cluster_description = 'a_simple_description' run_fdbcli_command('coordinators', *addresses, 'description={}'.format(new_cluster_description)) @@ -369,7 +370,7 @@ def coordinators(logger): @enable_logging() def exclude(logger): # get all processes' network addresses - addresses = get_fdb_process_addresses() + addresses = get_fdb_process_addresses(logger) logger.debug("Cluster processes: {}".format(' '.join(addresses))) # There should be no excluded process for now no_excluded_process_output = 'There are currently no servers or localities excluded from the database.' @@ -377,16 +378,28 @@ def exclude(logger): assert no_excluded_process_output in output1 # randomly pick one and exclude the process excluded_address = random.choice(addresses) + # If we see "not enough space" error, use FORCE option to proceed + # this should be a safe operation as we do not need any storage space for the test + force = False # sometimes we need to retry the exclude while True: logger.debug("Excluding process: {}".format(excluded_address)) - error_message = run_fdbcli_command_and_get_error('exclude', excluded_address) + if force: + error_message = run_fdbcli_command_and_get_error('exclude', 'FORCE', excluded_address) + else: + error_message = run_fdbcli_command_and_get_error('exclude', excluded_address) if error_message == 'WARNING: {} is a coordinator!'.format(excluded_address): # exclude coordinator will print the warning, verify the randomly selected process is the coordinator coordinator_list = get_value_from_status_json(True, 'client', 'coordinators', 'coordinators') assert len(coordinator_list) == 1 assert coordinator_list[0]['address'] == excluded_address break + elif 'ERROR: This exclude may cause the total free space in the cluster to drop below 10%.' in error_message: + # exclude the process may cause the free space not enough + # use FORCE option to ignore it and proceed + assert not force + force = True + logger.debug("Use FORCE option to exclude the process") elif not error_message: break else: @@ -450,10 +463,7 @@ if __name__ == '__main__': throttle() else: assert process_number > 1, "Process number should be positive" - # the kill command which used to list processes seems to not work as expected sometime - # which makes the test flaky. - # We need to figure out the reason and then re-enable these tests - #coordinators() - #exclude() + coordinators() + exclude() From f1eedf49108f058a0a6eb70917ff5bd6e37d639f Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 17:15:51 -0700 Subject: [PATCH 221/225] fixed serialization of rangefeed durable keys --- fdbclient/SystemData.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 1a0fbc662b..bd81802ebd 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -1050,19 +1050,19 @@ const KeyRangeRef rangeFeedDurableKeys(LiteralStringRef("\xff\xff/rf/"), Literal const KeyRef rangeFeedDurablePrefix = rangeFeedDurableKeys.begin; const Value rangeFeedDurableKey(Key const& feed, Version const& version) { - BinaryWriter wr(Unversioned()); + BinaryWriter wr(AssumeVersion(ProtocolVersion::withRangeFeed())); wr.serializeBytes(rangeFeedDurablePrefix); wr << feed; - wr << version; + wr << littleEndian64(version); return wr.toValue(); } std::pair decodeRangeFeedDurableKey(ValueRef const& key) { Key feed; Version version; - BinaryReader reader(key.removePrefix(rangeFeedDurablePrefix), Unversioned()); + BinaryReader reader(key.removePrefix(rangeFeedDurablePrefix), AssumeVersion(ProtocolVersion::withRangeFeed())); reader >> feed; reader >> version; - return std::make_pair(feed, version); + return std::make_pair(feed, littleEndian64(version)); } const Value rangeFeedDurableValue(Standalone> const& mutations) { BinaryWriter wr(IncludeVersion(ProtocolVersion::withRangeFeed())); From 52fcf3f5653bbd6eff9ed9ea3eedf929dd8861da Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 17:16:53 -0700 Subject: [PATCH 222/225] fixed a few bugs --- fdbcli/fdbcli.actor.cpp | 1 + fdbserver/storageserver.actor.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 4c57fbc3f8..608324cd98 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3606,6 +3606,7 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { wait(db->popRangeFeedMutations(tokens[2], v)); } } + continue; } if (tokencmp(tokens[0], "tssq")) { if (tokens.size() == 2) { diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index a101b0052e..3bf85cfd93 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -1549,7 +1549,7 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee Version version; std::tie(id, version) = decodeRangeFeedDurableKey(kv.key); auto mutations = decodeRangeFeedDurableValue(kv.value); - reply.mutations.push_back(reply.arena, MutationsAndVersionRef(mutations, version)); + reply.mutations.push_back_deep(reply.arena, MutationsAndVersionRef(mutations, version)); lastVersion = version; } for (auto& it : mutationsDeque) { @@ -4284,6 +4284,7 @@ ACTOR Future updateStorage(StorageServer* data) { info->mutations.pop_front(); } wait(yield(TaskPriority::UpdateStorage)); + curFeed++; } // Set the new durable version as part of the outstanding change set, before commit @@ -5239,7 +5240,7 @@ ACTOR Future serveRangeFeedPopRequests(StorageServer* self, FutureStreamuidRangeFeed[req.rangeID]; - while (feed->mutations.front().version < req.version) { + while (!feed->mutations.empty() && feed->mutations.front().version < req.version) { self->uidRangeFeed[req.rangeID]->mutations.pop_front(); } if (feed->durableVersion != invalidVersion) { From 42ae870c843d72ea65bb4c703d52d40e7dfd87ba Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 20:39:28 -0700 Subject: [PATCH 223/225] added support for querying specific range feed versions --- fdbcli/fdbcli.actor.cpp | 24 ++++++++- fdbclient/DatabaseContext.h | 7 ++- fdbclient/NativeAPI.actor.cpp | 12 +++-- fdbclient/StorageServerInterface.h | 4 +- fdbserver/storageserver.actor.cpp | 78 +++++++++++++++++++++++------- 5 files changed, 99 insertions(+), 26 deletions(-) diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index 608324cd98..3265126bd4 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -3580,12 +3580,32 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { } } } else if (tokencmp(tokens[1], "get")) { - if (tokens.size() != 3) { + if (tokens.size() < 3 || tokens.size() > 5) { printUsage(tokens[0]); is_error = true; continue; } - Standalone> res = wait(db->getRangeFeedMutations(tokens[2])); + Version begin = 0; + Version end = std::numeric_limits::max(); + if (tokens.size() > 3) { + int n = 0; + if (sscanf(tokens[3].toString().c_str(), "%ld%n", &begin, &n) != 1 || + n != tokens[3].size()) { + printUsage(tokens[0]); + is_error = true; + continue; + } + } + if (tokens.size() > 4) { + int n = 0; + if (sscanf(tokens[4].toString().c_str(), "%ld%n", &end, &n) != 1 || n != tokens[4].size()) { + printUsage(tokens[0]); + is_error = true; + continue; + } + } + Standalone> res = + wait(db->getRangeFeedMutations(tokens[2], begin, end)); for (auto& it : res) { for (auto& it2 : it.mutations) { printf("%lld %s\n", it.version, it2.toString().c_str()); diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index e6d98cef6e..8a7fe4021f 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -252,8 +252,11 @@ public: // Management API, create snapshot Future createSnapshot(StringRef uid, StringRef snapshot_command); - Future>> getRangeFeedMutations(StringRef rangeID, - KeyRangeRef range = allKeys); + Future>> getRangeFeedMutations( + StringRef rangeID, + Version begin = 0, + Version end = std::numeric_limits::max(), + KeyRange range = allKeys); Future>> getOverlappingRangeFeeds(KeyRangeRef ranges, Version minVersion); Future popRangeFeedMutations(StringRef rangeID, Version version); diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index c198994f48..09b8070cc2 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -6519,7 +6519,9 @@ Future DatabaseContext::createSnapshot(StringRef uid, StringRef snapshot_c ACTOR Future>> getRangeFeedMutationsActor(Reference db, StringRef rangeID, - KeyRangeRef range) { + Version begin, + Version end, + KeyRange range) { state Database cx(db); state Transaction tr(cx); state Key rangeIDKey = rangeID.withPrefix(rangeFeedPrefix); @@ -6543,6 +6545,8 @@ ACTOR Future>> getRangeFeedMutation state RangeFeedRequest req; req.rangeID = rangeID; + req.begin = begin; + req.end = end; RangeFeedReply rep = wait(loadBalance(cx.getPtr(), locations[0].second, @@ -6555,8 +6559,10 @@ ACTOR Future>> getRangeFeedMutation } Future>> DatabaseContext::getRangeFeedMutations(StringRef rangeID, - KeyRangeRef range) { - return getRangeFeedMutationsActor(Reference::addRef(this), rangeID, range); + Version begin, + Version end, + KeyRange range) { + return getRangeFeedMutationsActor(Reference::addRef(this), rangeID, begin, end, range); } ACTOR Future>> getOverlappingRangeFeedsActor(Reference db, diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 9efea0e732..7661398a58 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -663,6 +663,8 @@ struct RangeFeedReply { struct RangeFeedRequest { constexpr static FileIdentifier file_identifier = 10726174; Key rangeID; + Version begin = 0; + Version end = 0; ReplyPromise reply; RangeFeedRequest() {} @@ -670,7 +672,7 @@ struct RangeFeedRequest { template void serialize(Ar& ar) { - serializer(ar, rangeID, reply); + serializer(ar, rangeID, begin, end, reply); } }; diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 3bf85cfd93..b6827d00d8 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -313,6 +313,7 @@ struct FetchInjectionInfo { struct RangeFeedInfo : ReferenceCounted { std::deque> mutations; Version durableVersion = invalidVersion; + Version emptyVersion = 0; KeyRange range; Key id; }; @@ -1531,7 +1532,8 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee state RangeFeedReply reply; wait(delay(0)); auto& feedInfo = data->uidRangeFeed[req.rangeID]; - if (feedInfo->durableVersion == invalidVersion) { + if (req.end <= feedInfo->emptyVersion + 1) { + } else if (feedInfo->durableVersion == invalidVersion || req.begin > feedInfo->durableVersion) { for (auto& it : data->uidRangeFeed[req.rangeID]->mutations) { reply.mutations.push_back(reply.arena, it); } @@ -1539,10 +1541,7 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee state std::deque> mutationsDeque = data->uidRangeFeed[req.rangeID]->mutations; RangeResult res = wait(data->storage.readRange( - KeyRangeRef(rangeFeedDurableKey(req.rangeID, 0), rangeFeedDurableKey(req.rangeID, data->version.get())))); - if (res.empty()) { - data->uidRangeFeed[req.rangeID]->durableVersion = invalidVersion; - } + KeyRangeRef(rangeFeedDurableKey(req.rangeID, req.begin), rangeFeedDurableKey(req.rangeID, req.end)))); Version lastVersion = invalidVersion; for (auto& kv : res) { Key id; @@ -1553,10 +1552,35 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee lastVersion = version; } for (auto& it : mutationsDeque) { + if (it.version >= req.end) { + break; + } if (it.version > lastVersion) { reply.mutations.push_back(reply.arena, it); } } + if (res.empty()) { + auto& feedInfo = data->uidRangeFeed[req.rangeID]; + if (req.end > feedInfo->durableVersion) { + if (req.begin == 0) { + feedInfo->durableVersion = req.end > data->storageVersion() ? invalidVersion : req.end; + } else { + RangeResult emp = wait(data->storage.readRange( + KeyRangeRef(rangeFeedDurableKey(req.rangeID, 0), rangeFeedDurableKey(req.rangeID, req.end)), + -1)); + + auto& feedInfo = data->uidRangeFeed[req.rangeID]; + if (emp.empty()) { + feedInfo->durableVersion = req.end > data->storageVersion() ? invalidVersion : req.end; + } else { + Key id; + Version version; + std::tie(id, version) = decodeRangeFeedDurableKey(emp[0].key); + feedInfo->durableVersion = version; + } + } + } + } } return reply; } @@ -2945,7 +2969,7 @@ static const KeyRangeRef persistRangeFeedKeys = KeyRangeRef(LiteralStringRef(PERSIST_PREFIX "RF/"), LiteralStringRef(PERSIST_PREFIX "RF0")); // data keys are unmangled (but never start with PERSIST_PREFIX because they are always in allKeys) -ACTOR Future fetchRangeFeed(StorageServer* data, Key rangeId, KeyRange range) { +ACTOR Future fetchRangeFeed(StorageServer* data, Key rangeId, KeyRange range, Version fetchVersion) { TraceEvent("FetchRangeFeed", data->thisServerID) .detail("RangeID", rangeId.printable()) @@ -2966,9 +2990,11 @@ ACTOR Future fetchRangeFeed(StorageServer* data, Key rangeId, KeyRange ran rangeFeedValue(range))); state Standalone> mutations = - wait(data->cx->getRangeFeedMutations(rangeId, range)); + wait(data->cx->getRangeFeedMutations(rangeId, 0, fetchVersion, range)); state RangeFeedRequest req; req.rangeID = rangeId; + req.begin = 0; + req.end = fetchVersion; state RangeFeedReply rep = wait(getRangeFeedMutations(data, req)); state int mLoc = 0; state int rLoc = 0; @@ -3000,7 +3026,7 @@ ACTOR Future dispatchRangeFeeds(StorageServer* data, UID fetchKeysID, KeyR state std::vector> feeds = wait(data->cx->getOverlappingRangeFeeds(keys, fetchVersion)); for (auto& feed : feeds) { - feedFetches[feed.first] = fetchRangeFeed(data, feed.first, feed.second); + feedFetches[feed.first] = fetchRangeFeed(data, feed.first, feed.second, fetchVersion); } loop { @@ -3752,6 +3778,7 @@ private: Reference rangeFeedInfo(new RangeFeedInfo()); rangeFeedInfo->range = rangeFeedRange; rangeFeedInfo->id = rangeFeedId; + rangeFeedInfo->emptyVersion = currentVersion - 1; data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; auto rs = data->keyRangeFeed.modify(rangeFeedRange); for (auto r = rs.begin(); r != rs.end(); ++r) { @@ -4277,11 +4304,13 @@ ACTOR Future updateStorage(StorageServer* data) { state int curFeed = 0; while (curFeed < updatedRangeFeeds.size()) { auto info = data->uidRangeFeed[updatedRangeFeeds[curFeed]]; - while (info->mutations.front().version < newOldestVersion) { + for (auto& it : info->mutations) { + if (it.version >= newOldestVersion) { + break; + } data->storage.writeKeyValue(KeyValueRef(rangeFeedDurableKey(info->id, info->mutations.front().version), rangeFeedDurableValue(info->mutations.front().mutations))); info->durableVersion = info->mutations.front().version; - info->mutations.pop_front(); } wait(yield(TaskPriority::UpdateStorage)); curFeed++; @@ -4320,6 +4349,16 @@ ACTOR Future updateStorage(StorageServer* data) { throw please_reboot(); } + curFeed = 0; + while (curFeed < updatedRangeFeeds.size()) { + auto info = data->uidRangeFeed[updatedRangeFeeds[curFeed]]; + while (info->mutations.front().version < newOldestVersion) { + info->mutations.pop_front(); + } + wait(yield(TaskPriority::UpdateStorage)); + curFeed++; + } + durableInProgress.send(Void()); wait(delay(0, TaskPriority::UpdateStorage)); // Setting durableInProgess could cause the storage server to shut // down, so delay to check for cancellation @@ -5240,14 +5279,17 @@ ACTOR Future serveRangeFeedPopRequests(StorageServer* self, FutureStreamuidRangeFeed[req.rangeID]; - while (!feed->mutations.empty() && feed->mutations.front().version < req.version) { - self->uidRangeFeed[req.rangeID]->mutations.pop_front(); - } - if (feed->durableVersion != invalidVersion) { - self->storage.clearRange( - KeyRangeRef(rangeFeedDurableKey(feed->id, 0), rangeFeedDurableKey(feed->id, req.version))); - if (req.version > feed->durableVersion) { - feed->durableVersion = invalidVersion; + if (req.version - 1 > feed->emptyVersion) { + feed->emptyVersion = req.version - 1; + while (!feed->mutations.empty() && feed->mutations.front().version < req.version) { + self->uidRangeFeed[req.rangeID]->mutations.pop_front(); + } + if (feed->durableVersion != invalidVersion) { + self->storage.clearRange( + KeyRangeRef(rangeFeedDurableKey(feed->id, 0), rangeFeedDurableKey(feed->id, req.version))); + if (req.version > feed->durableVersion) { + feed->durableVersion = invalidVersion; + } } } TraceEvent("RangeFeedPopQuery", self->thisServerID) From 208a5790ad486df04f897ac13deb75f516d5df63 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 21:58:44 -0700 Subject: [PATCH 224/225] fixed usage of durable version --- fdbserver/TLogServer.actor.cpp | 14 +++++++------- fdbserver/storageserver.actor.cpp | 31 +++++++++++++++++++------------ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index 3cf9d55546..a0f8bc58b0 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -1860,13 +1860,13 @@ ACTOR Future tLogPeekMessages(TLogData* self, TLogPeekRequest req, Referen reply.end = endVersion; reply.onlySpilled = onlySpilled; - TraceEvent("TlogPeek", self->dbgid) - .detail("LogId", logData->logId) - .detail("Tag", req.tag.toString()) - .detail("BeginVer", req.begin) - .detail("EndVer", reply.end) - .detail("MsgBytes", reply.messages.expectedSize()) - .detail("ForAddress", req.reply.getEndpoint().getPrimaryAddress()); + // TraceEvent("TlogPeek", self->dbgid) + // .detail("LogId", logData->logId) + // .detail("Tag", req.tag.toString()) + // .detail("BeginVer", req.begin) + // .detail("EndVer", reply.end) + // .detail("MsgBytes", reply.messages.expectedSize()) + // .detail("ForAddress", req.reply.getEndpoint().getPrimaryAddress()); if (req.sequence.present()) { auto& trackerData = logData->peekTracker[peekId]; diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index c1500b6e3e..c58816de59 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -312,6 +312,7 @@ struct FetchInjectionInfo { struct RangeFeedInfo : ReferenceCounted { std::deque> mutations; + Version storageVersion = invalidVersion; Version durableVersion = invalidVersion; Version emptyVersion = 0; KeyRange range; @@ -1540,6 +1541,7 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee } else { state std::deque> mutationsDeque = data->uidRangeFeed[req.rangeID]->mutations; + state Version startingDurableVersion = feedInfo->durableVersion; RangeResult res = wait(data->storage.readRange( KeyRangeRef(rangeFeedDurableKey(req.rangeID, req.begin), rangeFeedDurableKey(req.rangeID, req.end)))); Version lastVersion = invalidVersion; @@ -1559,9 +1561,9 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee reply.mutations.push_back(reply.arena, it); } } - if (res.empty()) { + if (reply.mutations.empty()) { auto& feedInfo = data->uidRangeFeed[req.rangeID]; - if (req.end > feedInfo->durableVersion) { + if (startingDurableVersion == feedInfo->storageVersion && req.end > startingDurableVersion) { if (req.begin == 0) { feedInfo->durableVersion = req.end > data->storageVersion() ? invalidVersion : req.end; } else { @@ -1570,13 +1572,15 @@ ACTOR Future getRangeFeedMutations(StorageServer* data, RangeFee -1)); auto& feedInfo = data->uidRangeFeed[req.rangeID]; - if (emp.empty()) { - feedInfo->durableVersion = req.end > data->storageVersion() ? invalidVersion : req.end; - } else { - Key id; - Version version; - std::tie(id, version) = decodeRangeFeedDurableKey(emp[0].key); - feedInfo->durableVersion = version; + if (startingDurableVersion == feedInfo->storageVersion) { + if (emp.empty()) { + feedInfo->durableVersion = req.end > data->storageVersion() ? invalidVersion : req.end; + } else { + Key id; + Version version; + std::tie(id, version) = decodeRangeFeedDurableKey(emp[0].key); + feedInfo->durableVersion = version; + } } } } @@ -4310,7 +4314,7 @@ ACTOR Future updateStorage(StorageServer* data) { } data->storage.writeKeyValue(KeyValueRef(rangeFeedDurableKey(info->id, info->mutations.front().version), rangeFeedDurableValue(info->mutations.front().mutations))); - info->durableVersion = info->mutations.front().version; + info->storageVersion = info->mutations.front().version; } wait(yield(TaskPriority::UpdateStorage)); curFeed++; @@ -4355,6 +4359,7 @@ ACTOR Future updateStorage(StorageServer* data) { while (info->mutations.front().version < newOldestVersion) { info->mutations.pop_front(); } + info->durableVersion = info->mutations.front().version; wait(yield(TaskPriority::UpdateStorage)); curFeed++; } @@ -4744,6 +4749,7 @@ ACTOR Future restoreDurableState(StorageServer* data, IKeyValueStore* stor rangeFeedInfo->range = rangeFeedRange; rangeFeedInfo->id = rangeFeedId; rangeFeedInfo->durableVersion = version; + rangeFeedInfo->storageVersion = version; data->uidRangeFeed[rangeFeedId] = rangeFeedInfo; auto rs = data->keyRangeFeed.modify(rangeFeedRange); for (auto r = rs.begin(); r != rs.end(); ++r) { @@ -5284,10 +5290,11 @@ ACTOR Future serveRangeFeedPopRequests(StorageServer* self, FutureStreammutations.empty() && feed->mutations.front().version < req.version) { self->uidRangeFeed[req.rangeID]->mutations.pop_front(); } - if (feed->durableVersion != invalidVersion) { + if (feed->storageVersion != invalidVersion) { self->storage.clearRange( KeyRangeRef(rangeFeedDurableKey(feed->id, 0), rangeFeedDurableKey(feed->id, req.version))); - if (req.version > feed->durableVersion) { + if (req.version > feed->storageVersion) { + feed->storageVersion = invalidVersion; feed->durableVersion = invalidVersion; } } From a1b0053b572faf7f477003b76aa684e89140a63f Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 9 Aug 2021 22:06:53 -0700 Subject: [PATCH 225/225] do not return send a reply to a pop request until the clear has been made durable --- fdbserver/storageserver.actor.cpp | 48 ++++++++++++++++++------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index c58816de59..c357ca9162 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -1511,6 +1511,30 @@ ACTOR Future watchValueSendReply(StorageServer* data, } } +ACTOR Future rangeFeedPopQ(StorageServer* self, RangeFeedPopRequest req) { + auto& feed = self->uidRangeFeed[req.rangeID]; + if (req.version - 1 > feed->emptyVersion) { + feed->emptyVersion = req.version - 1; + while (!feed->mutations.empty() && feed->mutations.front().version < req.version) { + self->uidRangeFeed[req.rangeID]->mutations.pop_front(); + } + if (feed->storageVersion != invalidVersion) { + self->storage.clearRange( + KeyRangeRef(rangeFeedDurableKey(feed->id, 0), rangeFeedDurableKey(feed->id, req.version))); + if (req.version > feed->storageVersion) { + feed->storageVersion = invalidVersion; + feed->durableVersion = invalidVersion; + } + wait(self->durableVersion.whenAtLeast(self->storageVersion() + 1)); + } + } + TraceEvent("RangeFeedPopQuery", self->thisServerID) + .detail("RangeID", req.rangeID.printable()) + .detail("Version", req.version); + req.reply.send(Void()); + return Void(); +} + ACTOR Future overlappingRangeFeedsQ(StorageServer* data, OverlappingRangeFeedsRequest req) { wait(delay(0)); auto ranges = data->keyRangeFeed.intersectingRanges(req.range); @@ -4359,7 +4383,9 @@ ACTOR Future updateStorage(StorageServer* data) { while (info->mutations.front().version < newOldestVersion) { info->mutations.pop_front(); } - info->durableVersion = info->mutations.front().version; + if (info->storageVersion != invalidVersion) { + info->durableVersion = info->mutations.front().version; + } wait(yield(TaskPriority::UpdateStorage)); curFeed++; } @@ -5284,25 +5310,7 @@ ACTOR Future serveOverlappingRangeFeedsRequests( ACTOR Future serveRangeFeedPopRequests(StorageServer* self, FutureStream rangeFeedPops) { loop { RangeFeedPopRequest req = waitNext(rangeFeedPops); - auto& feed = self->uidRangeFeed[req.rangeID]; - if (req.version - 1 > feed->emptyVersion) { - feed->emptyVersion = req.version - 1; - while (!feed->mutations.empty() && feed->mutations.front().version < req.version) { - self->uidRangeFeed[req.rangeID]->mutations.pop_front(); - } - if (feed->storageVersion != invalidVersion) { - self->storage.clearRange( - KeyRangeRef(rangeFeedDurableKey(feed->id, 0), rangeFeedDurableKey(feed->id, req.version))); - if (req.version > feed->storageVersion) { - feed->storageVersion = invalidVersion; - feed->durableVersion = invalidVersion; - } - } - } - TraceEvent("RangeFeedPopQuery", self->thisServerID) - .detail("RangeID", req.rangeID.printable()) - .detail("Version", req.version); - req.reply.send(Void()); + self->actors.add(self->readGuard(req, rangeFeedPopQ)); } }