foundationdb/fdbclient/StorageServerInterface.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

645 lines
27 KiB
C++
Raw Normal View History

2021-03-06 03:28:15 +08:00
/*
* StorageServerInterface.cpp
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2013-2026 Apple Inc. and the FoundationDB project authors
2021-03-06 03:28:15 +08:00
*
* 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.
*/
// TODO this should really be renamed "TSSComparison.cpp"
Misc small changes and FIXME comment additions from reading fdbrpc code (#12395) Small changes accumulated while reading through a bunch of files in fdbrpc (mostly). Throughout: add FIXME comments where it would be useful to have a comment explaining something or suggesting a change of some kind. Several places: rename a variable to get a better name A few places: delete code that has been commented out for > 5 years A few places: delete useless or apparently out of date, incorrect comments One place: delete a function that has no callers One place: reorder methods, listing them in the order which users are to call them (i.e. the natural order for explanation) One or more places: delete unneeded FIXME comments network.h: put the function comments before the functions they describe * put function comments before the function they describe * add fixme comment * setLocalAddress had an obviously broken function comment. Then I noticed nobody was calling it. So delete it * QueueModel.h: list methods and comments in order that methods are to be called by users; remove a many years old commented out block of code * fdbrpc.h: FIXMEs to request explanations of Public and Private * Add a variety of FIXME comments to FlowTransport.cpp to be revisited later * add FIXMEs for comment additions; remove useless or outdated comments; rename a variable for clarity; other very cosmetic updates * add FIXMEs for suggested comments; rename a variable; delete one or more useless comments * simplify some FIXME comments * add one space to address CODE FORMAT CLEAN CI check * Updates based on code review comments * fix comment
2025-09-27 02:43:19 +08:00
// FIXME: actually it should be renamed "ReplyComparison" because TSS vs SS
// is just one use case. This code is agnostic to the specific use cases.
// Fundamentally it is just about comparing replies. Where they came from is incidental.
2021-03-06 03:28:15 +08:00
#include "fdbclient/StorageServerInterface.h"
Delete blob granule feature (#12435) This is the first experimental feature to be deleted in the list published at PR #12400. There is more code here than I anticipated. It is about 40,000 lines total, of which about three quarters are in dedicated files which I am deleting, and about one quarter is in shared files. That means about 10k lines in shared files, which is the stuff we tend to notice day to day (that plus the test failures on heretofore not-yet-disabled test cases, which I am now deleting). I ran 3 million simulations, mostly against 692df86 or very similar code (differing by one TraceEvent). This was prior to syncing with upstream/main, which had no conflicts and from which I don't expect problems. The number of failures in these runs was about 8. We looked at them and believe there is a high likelihood that these are existing issues not related to the changes in this PR. More details on these failures can be found in docs linked from here: https://quip-apple.com/MN7gAyXLjgyn * change Long Term status for unowned features for "scheduled for deletion" where applicable * Relax wording about scheduled for deletion features * Delete blob granule feature. WIP. Does not compile. * more incremental hacking to remove / comment out blob granule related code * more hacking to remove blob granule related code, e.g. blob manager and blob migrator roles * delete more blob granule stuff * more hacking * more hacking * more hacking * More changes to remove blob granule related code. IT COMPILES NOW * dont try to run AuthzSecurity tests as we have deleted that workload as part of this effort * delete more stuff that matches, abbreviates, or smells like blob granule related * EncryptKeyProxy: dont do blobMetadata stuff, because that is not used and support is being removed * delete more references to blob granule stuff * SimulationConfig::setEncryptionAtRestMode: always use DISABLED; also disable EncryptKeyProxyTest.toml * format code * manual update to bindings/java/src/tests.cmake to remove a deleted file * fix compile errors. I guess by default I dont build Java bindings * remove unneeded blob granule functions rather than #if..#endif them out * remove more code in #if..#endif * remove more code in #if 0..#endif * revert changes to fdb_c.h in preparation for marking removed API calls as removed * rework C API declarations to in preparation for marking blob granule APIs as removed * deprecate removed glob granule related API functions as of version 740 (and add a comment to request a justification of this convention) * make progress on broken ctests. E.g. 1) python does not need to do blob granule stuff. 2) authz tests seemingly not needed * remove blob granule stuff from Java and Python APIs and fix test runner stuff so that ctests pass * reformat comments to fix compile error. FIXME: why is this error not happening on the default compile commands we use * hacks all the way down to try to fix the Mac build * add pointed comment about the perceived pointlessness of the API deprecation scheme embodied in this source file * really serious about the C++ style comments, arent we * remove commented-out code from prior iterative efforts * put back undeleted code in original order * delete commented-out code * update feature-status.md to say blob granule is mostly deleted * upgrade `mostly deleted` to `has been deleted`
2025-10-14 07:18:56 +08:00
2022-06-28 07:05:55 +08:00
#include "crc32/crc32c.h" // for crc32c_append, to checksum values in tss trace events
2021-03-06 03:28:15 +08:00
// Includes template specializations for all tss operations on storage server types.
// New StorageServerInterface reply types must be added here or it won't compile.
void StorageServerInterface::initEndpointsFromGetValue() {
getKey = PublicRequestStream<struct GetKeyRequest>(getValue.getEndpoint().getAdjustedEndpoint(1));
getKeyValues = PublicRequestStream<struct GetKeyValuesRequest>(getValue.getEndpoint().getAdjustedEndpoint(2));
getShardState = RequestStream<struct GetShardStateRequest>(getValue.getEndpoint().getAdjustedEndpoint(3));
waitMetrics = PublicRequestStream<struct WaitMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(4));
splitMetrics = RequestStream<struct SplitMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(5));
getStorageMetrics = RequestStream<struct GetStorageMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(6));
waitFailure = RequestStream<ReplyPromise<Void>>(getValue.getEndpoint().getAdjustedEndpoint(7));
getQueuingMetrics =
RequestStream<struct StorageQueuingMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(8));
getKeyValueStoreType =
RequestStream<ReplyPromise<KeyValueStoreType>>(getValue.getEndpoint().getAdjustedEndpoint(9));
watchValue = PublicRequestStream<struct WatchValueRequest>(getValue.getEndpoint().getAdjustedEndpoint(10));
getReadHotRanges = RequestStream<struct ReadHotSubRangeRequest>(getValue.getEndpoint().getAdjustedEndpoint(11));
getRangeSplitPoints = RequestStream<struct SplitRangeRequest>(getValue.getEndpoint().getAdjustedEndpoint(12));
getKeyValuesStream =
PublicRequestStream<struct GetKeyValuesStreamRequest>(getValue.getEndpoint().getAdjustedEndpoint(13));
getMappedKeyValues =
PublicRequestStream<struct GetMappedKeyValuesRequest>(getValue.getEndpoint().getAdjustedEndpoint(14));
changeFeedStream = RequestStream<struct ChangeFeedStreamRequest>(getValue.getEndpoint().getAdjustedEndpoint(15));
overlappingChangeFeeds =
RequestStream<struct OverlappingChangeFeedsRequest>(getValue.getEndpoint().getAdjustedEndpoint(16));
changeFeedPop = RequestStream<struct ChangeFeedPopRequest>(getValue.getEndpoint().getAdjustedEndpoint(17));
changeFeedVersionUpdate =
RequestStream<struct ChangeFeedVersionUpdateRequest>(getValue.getEndpoint().getAdjustedEndpoint(18));
checkpoint = RequestStream<struct GetCheckpointRequest>(getValue.getEndpoint().getAdjustedEndpoint(19));
fetchCheckpoint = RequestStream<struct FetchCheckpointRequest>(getValue.getEndpoint().getAdjustedEndpoint(20));
fetchCheckpointKeyValues =
RequestStream<struct FetchCheckpointKeyValuesRequest>(getValue.getEndpoint().getAdjustedEndpoint(21));
updateCommitCostRequest =
RequestStream<struct UpdateCommitCostRequest>(getValue.getEndpoint().getAdjustedEndpoint(22));
auditStorage = RequestStream<struct AuditStorageRequest>(getValue.getEndpoint().getAdjustedEndpoint(23));
getHotShards = RequestStream<struct GetHotShardsRequest>(getValue.getEndpoint().getAdjustedEndpoint(24));
getCheckSum = RequestStream<struct GetStorageCheckSumRequest>(getValue.getEndpoint().getAdjustedEndpoint(25));
bulkdump = RequestStream<struct BulkDumpRequest>(getValue.getEndpoint().getAdjustedEndpoint(26));
}
void StorageServerInterface::initEndpoints() {
std::vector<std::pair<FlowReceiver*, TaskPriority>> streams;
streams.push_back(getValue.getReceiver(TaskPriority::LoadBalancedEndpoint));
streams.push_back(getKey.getReceiver(TaskPriority::LoadBalancedEndpoint));
streams.push_back(getKeyValues.getReceiver(TaskPriority::LoadBalancedEndpoint));
streams.push_back(getShardState.getReceiver());
streams.push_back(waitMetrics.getReceiver());
streams.push_back(splitMetrics.getReceiver());
streams.push_back(getStorageMetrics.getReceiver());
streams.push_back(waitFailure.getReceiver());
streams.push_back(getQueuingMetrics.getReceiver());
streams.push_back(getKeyValueStoreType.getReceiver());
streams.push_back(watchValue.getReceiver());
streams.push_back(getReadHotRanges.getReceiver());
streams.push_back(getRangeSplitPoints.getReceiver());
streams.push_back(getKeyValuesStream.getReceiver(TaskPriority::LoadBalancedEndpoint));
streams.push_back(getMappedKeyValues.getReceiver(TaskPriority::LoadBalancedEndpoint));
streams.push_back(changeFeedStream.getReceiver());
streams.push_back(overlappingChangeFeeds.getReceiver());
streams.push_back(changeFeedPop.getReceiver());
streams.push_back(changeFeedVersionUpdate.getReceiver());
streams.push_back(checkpoint.getReceiver());
streams.push_back(fetchCheckpoint.getReceiver());
streams.push_back(fetchCheckpointKeyValues.getReceiver());
streams.push_back(updateCommitCostRequest.getReceiver());
streams.push_back(auditStorage.getReceiver());
streams.push_back(getHotShards.getReceiver());
streams.push_back(getCheckSum.getReceiver());
streams.push_back(bulkdump.getReceiver());
FlowTransport::transport().addEndpoints(streams);
}
2021-03-06 03:28:15 +08:00
// if size + hex of checksum is shorter than value, record that instead of actual value. break-even point is 12
// characters
std::string traceChecksumValue(const ValueRef& s) {
2021-03-06 03:28:15 +08:00
return s.size() > 12 ? format("(%d)%08x", s.size(), crc32c_append(0, s.begin(), s.size())) : s.toString();
}
2021-06-12 05:20:38 +08:00
// point reads
2021-03-06 03:28:15 +08:00
template <>
2021-06-12 05:20:38 +08:00
bool TSS_doCompare(const GetValueReply& src, const GetValueReply& tss) {
return src.value.present() == tss.value.present() && (!src.value.present() || src.value.get() == tss.value.get());
}
template <>
const char* LB_mismatchTraceName(const GetValueRequest& req, const ComparisonType& type) {
return type == TSS_COMPARISON ? "TSSMismatchGetValue" : "ReplicaMismatchGetValue";
2021-06-12 05:20:38 +08:00
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const GetValueRequest& req,
const GetValueReply& src,
const GetValueReply& tss,
const ComparisonType& type) {
event.detail("Key", req.key)
2021-06-12 05:20:38 +08:00
.detail("Version", req.version)
.detail(type == TSS_COMPARISON ? "SSReply" : "SourceSSReply",
src.value.present() ? traceChecksumValue(src.value.get()) : "missing")
.detail(type == TSS_COMPARISON ? "TSSReply" : "ReplicaSSReply",
tss.value.present() ? traceChecksumValue(tss.value.get()) : "missing");
2021-03-06 03:28:15 +08:00
}
2021-06-12 05:20:38 +08:00
// key selector reads
2021-03-06 03:28:15 +08:00
template <>
2021-06-12 05:20:38 +08:00
bool TSS_doCompare(const GetKeyReply& src, const GetKeyReply& tss) {
2021-03-06 03:28:15 +08:00
// This process is a bit complicated. Since the tss and ss can return different results if neighboring shards to
// req.sel.key are currently being moved, We validate that the results are the same IF the returned key selectors
// are final. Otherwise, we only mark the request as a mismatch if the difference between the two returned key
// selectors could ONLY be because of different results from the storage engines. We can afford to only partially
// check key selectors that start in a TSS shard and end in a non-TSS shard because the other read queries and the
// consistency check will eventually catch a misbehaving storage engine.
bool matches = true;
if (src.sel.orEqual == tss.sel.orEqual && src.sel.offset == tss.sel.offset) {
// full matching case
if (src.sel.offset == 0 && src.sel.orEqual) {
// found exact key, should be identical
matches = src.sel.getKey() == tss.sel.getKey();
}
// if the query doesn't return the final key, there is an edge case where the ss and tss have different shard
// boundaries, so they pass different shard boundary keys back for the same offset
} else if (src.sel.getKey() == tss.sel.getKey()) {
// There is one case with a positive offset where the shard boundary the incomplete query stopped at is the next
// key in the shard that the complete query returned. This is not possible with a negative offset because the
// shard boundary is exclusive backwards
if (src.sel.offset == 0 && src.sel.orEqual && tss.sel.offset == 1 && !tss.sel.orEqual) {
// case where ss was complete and tss was incomplete
} else if (tss.sel.offset == 0 && tss.sel.orEqual && src.sel.offset == 1 && !src.sel.orEqual) {
// case where tss was complete and ss was incomplete
} else {
matches = false;
}
} else {
// ss/tss returned different keys, and different offsets and/or orEqual
// here we just validate that ordering of the keys matches the ordering of the offsets
bool tssKeyLarger = src.sel.getKey() < tss.sel.getKey();
// the only case offsets are equal and orEqual aren't equal is the case with a negative offset,
// where one response has <=0 with the actual result and the other has <0 with the shard upper boundary.
// So whichever one has the actual result should have the lower key.
bool tssOffsetLarger = (src.sel.offset == tss.sel.offset) ? tss.sel.orEqual : src.sel.offset < tss.sel.offset;
matches = tssKeyLarger != tssOffsetLarger;
}
return matches;
}
template <>
const char* LB_mismatchTraceName(const GetKeyRequest& req, const ComparisonType& type) {
return type == TSS_COMPARISON ? "TSSMismatchGetKey" : "ReplicaMismatchGetKey";
2021-06-12 05:20:38 +08:00
}
2021-03-06 03:28:15 +08:00
2021-06-12 05:20:38 +08:00
template <>
void TSS_traceMismatch(TraceEvent& event,
const GetKeyRequest& req,
const GetKeyReply& src,
const GetKeyReply& tss,
const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
event
.detail("KeySelector",
format("%s%s:%d", req.sel.orEqual ? "=" : "", req.sel.getKey().printable().c_str(), req.sel.offset))
.detail("Version", req.version)
.detail(type == TSS_COMPARISON ? "SSReply" : "SourceSSReply",
2021-06-12 05:20:38 +08:00
format("%s%s:%d", src.sel.orEqual ? "=" : "", src.sel.getKey().printable().c_str(), src.sel.offset))
.detail(type == TSS_COMPARISON ? "TSSReply" : "ReplicaSSReply",
2021-06-12 05:20:38 +08:00
format("%s%s:%d", tss.sel.orEqual ? "=" : "", tss.sel.getKey().printable().c_str(), tss.sel.offset));
}
2021-03-06 03:28:15 +08:00
2021-06-12 05:20:38 +08:00
// range reads
template <>
bool TSS_doCompare(const GetKeyValuesReply& src, const GetKeyValuesReply& tss) {
return src.more == tss.more && src.data == tss.data;
}
template <>
const char* LB_mismatchTraceName(const GetKeyValuesRequest& req, const ComparisonType& type) {
return type == TSS_COMPARISON ? "TSSMismatchGetKeyValues" : "ReplicaMismatchGetKeyValues";
2021-06-12 05:20:38 +08:00
}
2021-03-06 03:28:15 +08:00
static void traceKeyValuesSummary(TraceEvent& event,
const KeySelectorRef& begin,
const KeySelectorRef& end,
Version version,
int limit,
int limitBytes,
size_t ssSize,
bool ssMore,
size_t tssSize,
bool tssMore,
const ComparisonType& type) {
std::string ssSummaryString = format("(%d)%s", ssSize, ssMore ? "+" : "");
std::string tssSummaryString = format("(%d)%s", tssSize, tssMore ? "+" : "");
event.detail("Begin", format("%s%s:%d", begin.orEqual ? "=" : "", begin.getKey().printable().c_str(), begin.offset))
.detail("End", format("%s%s:%d", end.orEqual ? "=" : "", end.getKey().printable().c_str(), end.offset))
.detail("Version", version)
.detail("Limit", limit)
.detail("LimitBytes", limitBytes)
.detail((type == TSS_COMPARISON ? "SSReplySummary" : "SourceSSReplySummary"), ssSummaryString)
.detail((type == TSS_COMPARISON ? "TSSReplySummary" : "ReplicaSSReplySummary"), tssSummaryString);
}
// convert a StringRef to Hex string
static std::string hexStringRef(const StringRef& s) {
std::string result;
result.reserve(static_cast<size_t>(s.size()) * 2);
for (int i = 0; i < s.size(); i++) {
result.append(format("%02x", s[i]));
}
return result;
}
static void traceKeyValuesDiff(TraceEvent& event,
const KeySelectorRef& begin,
const KeySelectorRef& end,
Version version,
int limit,
int limitBytes,
const VectorRef<KeyValueRef>& ssKV,
bool ssMore,
const VectorRef<KeyValueRef>& tssKV,
bool tssMore,
const ComparisonType& type) {
traceKeyValuesSummary(
Delete multitenant and metacluster features (#12583) These features have been previously marked for deletion per PR #12400. This change necessarily affects a lot of files. In general I found it preferable to cut along the FDB <-> tenant boundary, rather than try to cut tenant into multiple pieces, stitch the Frankenstein tenant implementation back together with FDB, and generally remove the limbs one by one. So it is a single big deletion. Note that some tenant-related metadata has been written in a non-flag-controlled manner by prior releases and probably must be ignored indefinitely. Fortunately this is isolated to include/fdbclient/ClientLogEvents.h. (Details: deleting an Optional from a serialized struct results in deserialization of garbage in upgrade tests. The serialized nullopt to indicate "no Tenant" is formally part of FDB persistent metadata even in FDB clusters that never would have enabled the tenant feature.) During the course of testing these changes, many interesting bugs were encountered. I won't discuss details of them here. Causes range from flat out damage (by me) to production code in the course of removing tenant related bits (mainly in NativeAPI.actor.cpp and CommitProxy.actor.cpp), damage to various workload files (particularly FuzzApiCorrectness.actor.cpp, which is very sensitive to changes), and many toml files needing updated test flags/options. More testing details: https://quip-apple.com/Zr6VAycxoli9 20251209-012852-gglass-8ff850b772d868f2 compressed=True data_size=35311687 duration=21671404 ended=500000 fail_fast=1000 max_runs=500000 pass=500000 priority=100 remaining=0 runtime=2:31:30 sanity=False started=500000 stopped=20251209-040022 submitted=20251209-012852 timeout=5400 username=gglass * remove some unneeded tests, and remove mentions of deleted tests from tests/CmakeLists.txt * Initiate removal of metacluster. NOTE: this seems to also want removal of tenant. Consider removing them together. * work on removing metacluster * delete files with `Tenant` in the name, having reviewed them to ensure that they basically contain what the name implies * fdb_c.h: remove prototypes for C API methods which have been deleted (blob granule) or which are so long deprecated that they are outside any reasonable/documented support window * Surgical removal of tenant references from files in bindings/ top level directory. Compilation not yet attempted. * Surgical removal of tenant related stuff from fdbcli/ top level directory. Compilation not yet attempted. * Misc tenant code removal, and other stuff which I think may not be needed. Compilation still not attempted. * Remove more tenant or tenant-adjacent or blob-granule-adjacent stuff. Or at least stuff that looks adjacent to that stuff. Not compiled or tested. * Start removing Tenant stuff from fdbclient/. Far from complete. Compilation not attempted. * Remove tenant references from many source files. There are still about 7 principal fdbclient/ and fdbserver/ files with a lot of tenant logic left to delete. Also, all of fdbserver/workloads needs to be looked at. Still have not attempted compilation. * Remove tenant entanglement from watch functionality * Remove tenant stuff from fdbserver/tester.actor.cpp * Delete metacluster workloads * Remove tenant related stuff from workloads. Also taken the liberty of removing some functionality that appears unused or untestable by Apple. * Checkpoint tenant removal from FuzzApiCorrectness.actor.cpp * NativeAPI.actor.cpp: `Tenant` has left the building. * SimulatedCluster.actor.cpp: `Tenant` has left the building * DDShardTracker.actor.cpp: Tenant evicted * storageserver.actor.cpp: `tenant` has left the building. * fdbserver/workloads/FuzzApiCorrectness.actor.cpp: remove tenant references, but some lingering cleanup needed in `loadAndRun` * FileBackupAgent.actor.cpp: tenant has left the building * CommitProxyServer.actor.cpp: remove tenant * Remove more tenant references from misc files such as bindings tests, documentation, and some fdbserver headers I left earlier * Fix missing-file errors in CMakeLists.txt files. This is the first attempt to compile this stuff. * checkpoint misc changes to fix compile errors * checkpoint more compile fixes * StorageServerInterface.h: put back more verify() calls * More misc compile fixes * whole bunch of misc fixups including some code put-backs to address compile errors * More compile fixes * More compile fixes. Still does not compile. * incremental compile fixing * ... * ... * Checkpoint a bunch of compile fixes. Not quite there but getting closer * More compile fixes. There seem to be about 10 files left, mainly CommitProxyServer.actor.cpp and storageserver.actor.cpp * IT COMPILES NOW. THIS IS STILL ALL UNTESTED. Unsurprisingly, CommitProxyServer.actor.cpp and storageserver.actor.cpp took the most tweaking. The updates in CMakeLists.txt and workloads/UnitTests.actor.cpp are basically trivial and mainly reflect the ordering of dependencies -- that stuff didn't get attempted until all of fdbserver compiled. * Put back one block relating to encryption at rest mode. Simplify some TODO(gglass) instances. * Put back some encryption related knobs * remove `enable_tenants` from local_cluster.py to maybe fix some ctests * Remove tenant related options from toml files. * feature-status.md: add a line for encryption at rest, which seems to have been added for multi-tenant; status is now in doubt * Fix a pretty bad bug introduced in tenant deletion; ensure we dont attempt to construct a std::string of negative length * workloads/FuzzApiCorrectness.actor.cpp: avoid division by zero * flow/Platform.actor.cpp: add a try/catch wrapper around side threads; emit a better addr2line type command * NativeAPI.actor.cpp: fix a bug introduced in tenant removal relating to reporting conflicting keys under conflictingKeysRange * ReportConflictingKeys.actor.cpp: separate an ANDed assert into two asserts * SpecialKeySPaceCorrectness.actor.cpp: put back some logic removed with tenant removal. This test was failing due to a bug with conflict key range reporting. Fixed separately in NativeAPI.actor.cpp. * remove QuotaCommand.actor.cpp * Force disable tenant and encryption on disk in upgrade tests * Add back file I guess I deleted? who knows * put back another file * design/feature-status.md: update the new row for encryption at rest to firm up the claim that it is experimental, unowned, and scheduled for deletion * Remove EncryptKeyProxyTest since we do not use it * new file tests/slow/BulkDumpingS3WithChaos.toml: remove tenantModes setting * Undo damage to pushToBackupMutations() from removing tenant feature. This caused inverted_range errors and failed commits in backup related simulations. * tests/restarting/from_7.4.0/Snap*-1: ensure that tenantModes = disabled * Try again on workloads/FuzzApiCorrectness.actor.cpp * simplify tenant-free (mostly) FuzzApiCorrectness workload code * try harder to remove lingering tenant-related brokenness from FuzzApiCorrectness.actor.cpp * Explicitly specify tenantModes = ['disabled'] in all the -1 restart files * Remove tenantModes from 7.1-based upgrade tests as its an unknown option. Hopefully the code doesnt actually turn on tenant stuff * do not specify tenantModes in downgrade tests * Downgrade test to_7.4.5: dont say tenantModes * more tenantModes updates * Remove a legacy allowDefaultTenant that no longer is meaningful in downgrade to 8.0 * Put back empty Optional<TenantName> turdlets into serialized log events to avoid breaking ClientTransactionProfilingCorrectness upgrade tests (even with tenantMode = disabled) * disable encryption on a few more upgrade related test cases. That feature is slated for removal anyway * Remove unneeded workload files that have been subject to #if 0 for a while. Remove commented out block in ClusterRecovery * disable encryption in more upgrade tests * Remove choice four-letter words from commentary * Format 42 files * Try to fix a doc bug failing the CI build * More doc compilation error fixes * Delete more tenant junk from documentation * fix spelling mistake in comment * Remove deleted cross-references from documentation. This necessitated editing release 3.0.0 release notes, which is insane. * Remove more tenant stuff from bindings tests * Remove more tenant bits from design/ files * Remove more tenant related stuff * Delete more tenant references. Put back ten-ant spellings as tenant now that grep output is substantially reduced. * Put back some tenant stuff into apitester; its deletion seems to have introduced bugs. Also whine about comments some more, because, really, the comments deserve it. * Updates to workload files and one other thing based on review comments * de-actorify decodeKVPairs * format one source file * Restore transaction tagging doc * Restore throttle doc details in administration.rst * Restore fdbserver/workloads/GetEstimatedRangeSize.actor.cpp and associated toml file, minus tenant stuff * bindings/c/test/{shim related}: update comments and disable functionality that no longer works post-tenant * put the cli-throttle tag back in * bindingtester: fix python syntax errors * remove useless comment * Remove comment about useless comments, and remove the useless comments
2025-12-10 04:39:41 +08:00
event, begin, end, version, limit, limitBytes, ssKV.size(), ssMore, tssKV.size(), tssMore, type);
bool mismatchFound = false;
for (int i = 0; i < std::max(ssKV.size(), tssKV.size()); i++) {
if (i >= ssKV.size() || i >= tssKV.size() || ssKV[i] != tssKV[i]) {
event.detail("MismatchIndex", i);
if (i >= ssKV.size() || i >= tssKV.size() || ssKV[i].key != tssKV[i].key) {
event.detail("MismatchSSKey", i < ssKV.size() ? ssKV[i].key : "missing"_sr);
event.detail("MismatchSSKeyHex", i < ssKV.size() ? hexStringRef(ssKV[i].key) : "missing"_sr);
event.detail("MismatchTSSKey", i < tssKV.size() ? tssKV[i].key : "missing"_sr);
event.detail("MismatchTSSKeyHex", i < tssKV.size() ? hexStringRef(tssKV[i].key) : "missing"_sr)
.setMaxFieldLength(-1);
} else {
event.detail("MismatchKey", ssKV[i].key);
event.detail("MismatchSSValue", traceChecksumValue(ssKV[i].value));
event.detail("MismatchSSValueHex", hexStringRef(traceChecksumValue(ssKV[i].value)));
event.detail("MismatchTSSValue", traceChecksumValue(tssKV[i].value));
event.detail("MismatchTSSValueHex", hexStringRef(traceChecksumValue(tssKV[i].value)))
.setMaxFieldLength(-1);
}
mismatchFound = true;
break;
}
}
ASSERT(mismatchFound);
}
2021-06-12 05:20:38 +08:00
template <>
void TSS_traceMismatch(TraceEvent& event,
const GetKeyValuesRequest& req,
const GetKeyValuesReply& src,
const GetKeyValuesReply& tss,
const ComparisonType& type) {
traceKeyValuesDiff(event,
req.begin,
req.end,
req.version,
req.limit,
req.limitBytes,
src.data,
src.more,
tss.data,
tss.more,
type);
}
// range reads and flat map
template <>
bool TSS_doCompare(const GetMappedKeyValuesReply& src, const GetMappedKeyValuesReply& tss) {
return src.more == tss.more && src.data == tss.data;
}
template <>
const char* LB_mismatchTraceName(const GetMappedKeyValuesRequest& req, const ComparisonType& type) {
return type == TSS_COMPARISON ? "TSSMismatchGetMappedKeyValues" : "ReplicaMismatchGetMappedKeyValues";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const GetMappedKeyValuesRequest& req,
const GetMappedKeyValuesReply& src,
const GetMappedKeyValuesReply& tss,
const ComparisonType& type) {
traceKeyValuesSummary(event,
req.begin,
req.end,
req.version,
req.limit,
req.limitBytes,
src.data.size(),
src.more,
tss.data.size(),
tss.more,
type);
// FIXME: trace details for TSS mismatch of mapped data
}
// streaming range reads
template <>
bool TSS_doCompare(const GetKeyValuesStreamReply& src, const GetKeyValuesStreamReply& tss) {
return src.more == tss.more && src.data == tss.data;
}
template <>
const char* LB_mismatchTraceName(const GetKeyValuesStreamRequest& req, const ComparisonType& type) {
return type == TSS_COMPARISON ? "TSSMismatchGetKeyValuesStream" : "ReplicaMismatchGetKeyValuesStream";
}
// TODO this is all duplicated from above, simplify?
template <>
void TSS_traceMismatch(TraceEvent& event,
const GetKeyValuesStreamRequest& req,
const GetKeyValuesStreamReply& src,
const GetKeyValuesStreamReply& tss,
const ComparisonType& type) {
traceKeyValuesDiff(event,
req.begin,
req.end,
req.version,
req.limit,
req.limitBytes,
src.data,
src.more,
tss.data,
tss.more,
type);
2021-03-06 03:28:15 +08:00
}
template <>
2021-06-12 05:20:38 +08:00
bool TSS_doCompare(const WatchValueReply& src, const WatchValueReply& tss) {
// We duplicate watches just for load, no need to validate replies.
2021-03-06 03:28:15 +08:00
return true;
}
template <>
const char* LB_mismatchTraceName(const WatchValueRequest& req, const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
return "";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const WatchValueRequest& req,
const WatchValueReply& src,
const WatchValueReply& tss,
const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
}
template <>
bool TSS_doCompare(const SplitMetricsReply& src, const SplitMetricsReply& tss) {
// We duplicate split metrics just for load, no need to validate replies.
2021-03-06 03:28:15 +08:00
return true;
}
template <>
const char* LB_mismatchTraceName(const SplitMetricsRequest& req, const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
return "";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const SplitMetricsRequest& req,
const SplitMetricsReply& src,
const SplitMetricsReply& tss,
const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
}
template <>
bool TSS_doCompare(const ReadHotSubRangeReply& src, const ReadHotSubRangeReply& tss) {
// We duplicate read hot sub range metrics just for load, no need to validate replies.
2021-03-06 03:28:15 +08:00
return true;
}
template <>
const char* LB_mismatchTraceName(const ReadHotSubRangeRequest& req, const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
return "";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const ReadHotSubRangeRequest& req,
const ReadHotSubRangeReply& src,
const ReadHotSubRangeReply& tss,
const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
}
template <>
bool TSS_doCompare(const SplitRangeReply& src, const SplitRangeReply& tss) {
// We duplicate read hot sub range metrics just for load, no need to validate replies.
2021-03-06 03:28:15 +08:00
return true;
}
2021-06-12 05:20:38 +08:00
template <>
const char* LB_mismatchTraceName(const SplitRangeRequest& req, const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
return "";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const SplitRangeRequest& req,
const SplitRangeReply& src,
const SplitRangeReply& tss,
const ComparisonType& type) {
2021-06-12 05:20:38 +08:00
ASSERT(false);
}
// change feed
2021-07-29 05:02:12 +08:00
template <>
bool TSS_doCompare(const OverlappingChangeFeedsReply& src, const OverlappingChangeFeedsReply& tss) {
// We duplicate for load, no need to validate replies
2021-07-29 05:02:12 +08:00
return true;
}
template <>
const char* LB_mismatchTraceName(const OverlappingChangeFeedsRequest& req, const ComparisonType& type) {
2021-07-29 05:02:12 +08:00
ASSERT(false);
return "";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const OverlappingChangeFeedsRequest& req,
const OverlappingChangeFeedsReply& src,
const OverlappingChangeFeedsReply& tss,
const ComparisonType& type) {
2021-07-29 05:02:12 +08:00
ASSERT(false);
}
// template specializations for metrics replies that should never be called because these requests aren't duplicated
// storage metrics
2021-08-10 03:48:38 +08:00
template <>
bool TSS_doCompare(const StorageMetrics& src, const StorageMetrics& tss) {
2021-08-10 03:48:38 +08:00
ASSERT(false);
return true;
}
template <>
const char* LB_mismatchTraceName(const WaitMetricsRequest& req, const ComparisonType& type) {
2021-08-10 03:48:38 +08:00
ASSERT(false);
return "";
}
template <>
void TSS_traceMismatch(TraceEvent& event,
const WaitMetricsRequest& req,
const StorageMetrics& src,
const StorageMetrics& tss,
const ComparisonType& type) {
2021-08-10 03:48:38 +08:00
ASSERT(false);
}
2021-03-06 03:28:15 +08:00
// only record metrics for data reads
template <>
void TSSMetrics::recordLatency(const GetValueRequest& req, double ssLatency, double tssLatency) {
SSgetValueLatency.addSample(ssLatency);
TSSgetValueLatency.addSample(tssLatency);
}
template <>
void TSSMetrics::recordLatency(const GetKeyRequest& req, double ssLatency, double tssLatency) {
SSgetKeyLatency.addSample(ssLatency);
TSSgetKeyLatency.addSample(tssLatency);
}
template <>
void TSSMetrics::recordLatency(const GetKeyValuesRequest& req, double ssLatency, double tssLatency) {
SSgetKeyValuesLatency.addSample(ssLatency);
TSSgetKeyValuesLatency.addSample(tssLatency);
}
template <>
void TSSMetrics::recordLatency(const GetMappedKeyValuesRequest& req, double ssLatency, double tssLatency) {
SSgetMappedKeyValuesLatency.addSample(ssLatency);
TSSgetMappedKeyValuesLatency.addSample(tssLatency);
}
2021-03-06 03:28:15 +08:00
template <>
void TSSMetrics::recordLatency(const WatchValueRequest& req, double ssLatency, double tssLatency) {}
template <>
void TSSMetrics::recordLatency(const WaitMetricsRequest& req, double ssLatency, double tssLatency) {}
template <>
void TSSMetrics::recordLatency(const SplitMetricsRequest& req, double ssLatency, double tssLatency) {}
template <>
void TSSMetrics::recordLatency(const ReadHotSubRangeRequest& req, double ssLatency, double tssLatency) {}
template <>
void TSSMetrics::recordLatency(const SplitRangeRequest& req, double ssLatency, double tssLatency) {}
template <>
void TSSMetrics::recordLatency(const GetKeyValuesStreamRequest& req, double ssLatency, double tssLatency) {}
2021-08-10 03:48:38 +08:00
template <>
void TSSMetrics::recordLatency(const OverlappingChangeFeedsRequest& req, double ssLatency, double tssLatency) {}
2021-08-10 03:48:38 +08:00
2021-03-06 03:28:15 +08:00
// -------------------
TEST_CASE("/StorageServerInterface/TSSCompare/TestComparison") {
printf("testing tss comparisons\n");
2021-05-13 02:53:20 +08:00
// to avoid compiler issues that StringRef(char* is deprecated)
std::string s_a = "a";
std::string s_b = "b";
std::string s_c = "c";
std::string s_d = "d";
std::string s_e = "e";
2021-03-06 03:28:15 +08:00
UID tssId;
GetValueReply gvReplyMissing;
2021-05-13 02:53:20 +08:00
GetValueReply gvReplyA(Optional<Value>(StringRef(s_a)), false);
GetValueReply gvReplyB(Optional<Value>(StringRef(s_b)), false);
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(gvReplyMissing, gvReplyMissing));
ASSERT(TSS_doCompare(gvReplyA, gvReplyA));
ASSERT(TSS_doCompare(gvReplyB, gvReplyB));
2021-03-06 03:28:15 +08:00
2021-06-12 05:20:38 +08:00
ASSERT(!TSS_doCompare(gvReplyMissing, gvReplyA));
ASSERT(!TSS_doCompare(gvReplyA, gvReplyB));
2021-03-06 03:28:15 +08:00
// test GetKeyValues
2021-06-12 05:20:38 +08:00
Arena a;
2021-03-06 03:28:15 +08:00
GetKeyValuesReply gkvReplyEmpty;
GetKeyValuesReply gkvReplyOne;
KeyValueRef v;
2021-05-13 02:53:20 +08:00
v.key = StringRef(a, s_a);
v.value = StringRef(a, s_b);
2021-03-06 03:28:15 +08:00
gkvReplyOne.data.push_back_deep(gkvReplyOne.arena, v);
GetKeyValuesReply gkvReplyOneMore;
gkvReplyOneMore.data.push_back_deep(gkvReplyOneMore.arena, v);
gkvReplyOneMore.more = true;
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(gkvReplyEmpty, gkvReplyEmpty));
ASSERT(TSS_doCompare(gkvReplyOne, gkvReplyOne));
ASSERT(TSS_doCompare(gkvReplyOneMore, gkvReplyOneMore));
ASSERT(!TSS_doCompare(gkvReplyEmpty, gkvReplyOne));
ASSERT(!TSS_doCompare(gkvReplyOne, gkvReplyOneMore));
2021-03-06 03:28:15 +08:00
2021-05-13 02:53:20 +08:00
GetKeyReply gkReplyA(KeySelectorRef(StringRef(a, s_a), false, 20), false);
GetKeyReply gkReplyB(KeySelectorRef(StringRef(a, s_b), false, 10), false);
GetKeyReply gkReplyC(KeySelectorRef(StringRef(a, s_c), true, 0), false);
GetKeyReply gkReplyD(KeySelectorRef(StringRef(a, s_d), false, -10), false);
GetKeyReply gkReplyE(KeySelectorRef(StringRef(a, s_e), false, -20), false);
2021-03-06 03:28:15 +08:00
// identical cases
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(gkReplyA, gkReplyA));
ASSERT(TSS_doCompare(gkReplyB, gkReplyB));
ASSERT(TSS_doCompare(gkReplyC, gkReplyC));
ASSERT(TSS_doCompare(gkReplyD, gkReplyD));
ASSERT(TSS_doCompare(gkReplyE, gkReplyE));
2021-03-06 03:28:15 +08:00
// relative offset cases
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(gkReplyA, gkReplyB));
ASSERT(TSS_doCompare(gkReplyB, gkReplyA));
ASSERT(TSS_doCompare(gkReplyA, gkReplyC));
ASSERT(TSS_doCompare(gkReplyC, gkReplyA));
ASSERT(TSS_doCompare(gkReplyB, gkReplyC));
ASSERT(TSS_doCompare(gkReplyC, gkReplyB));
ASSERT(TSS_doCompare(gkReplyC, gkReplyD));
ASSERT(TSS_doCompare(gkReplyD, gkReplyC));
ASSERT(TSS_doCompare(gkReplyC, gkReplyE));
ASSERT(TSS_doCompare(gkReplyE, gkReplyC));
ASSERT(TSS_doCompare(gkReplyD, gkReplyE));
ASSERT(TSS_doCompare(gkReplyE, gkReplyD));
2021-03-06 03:28:15 +08:00
// test same offset/orEqual wrong key
2021-06-12 05:20:38 +08:00
ASSERT(!TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), true, 0), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), true, 0), false)));
2021-03-06 03:28:15 +08:00
// this could be from different shard boundaries, so don't say it's a mismatch
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), false, 10), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), false, 10), false)));
2021-03-06 03:28:15 +08:00
// test offsets and key difference don't match
2021-06-12 05:20:38 +08:00
ASSERT(!TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), false, 0), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), false, 10), false)));
ASSERT(!TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), false, -10), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), false, 0), false)));
2021-03-06 03:28:15 +08:00
// test key is next over in one shard, one found it and other didn't
// positive
// one that didn't find is +1
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), false, 1), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), true, 0), false)));
ASSERT(!TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), true, 0), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), false, 1), false)));
2021-03-06 03:28:15 +08:00
// negative will have zero offset but not equal set
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), true, 0), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), false, 0), false)));
ASSERT(!TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), false, 0), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_b), true, 0), false)));
2021-03-06 03:28:15 +08:00
// test shard boundary key returned by incomplete query is the same as the key found by the other (only possible in
// positive direction)
2021-06-12 05:20:38 +08:00
ASSERT(TSS_doCompare(GetKeyReply(KeySelectorRef(StringRef(a, s_a), true, 0), false),
GetKeyReply(KeySelectorRef(StringRef(a, s_a), false, 1), false)));
2021-03-06 03:28:15 +08:00
2024-02-05 05:59:37 +08:00
// explicitly test checksum function
2021-03-06 03:28:15 +08:00
std::string s12 = "ABCDEFGHIJKL";
std::string s13 = "ABCDEFGHIJKLO";
std::string checksumStart13 = "(13)";
2021-05-13 02:53:20 +08:00
ASSERT(s_a == traceChecksumValue(StringRef(s_a)));
2021-03-06 03:28:15 +08:00
ASSERT(s12 == traceChecksumValue(StringRef(s12)));
ASSERT(checksumStart13 == traceChecksumValue(StringRef(s13)).substr(0, 4));
return Void();
}