2020-08-06 03:20:52 +08:00
|
|
|
/*
|
2026-03-29 03:10:10 +08:00
|
|
|
* ProxyCommitData.h
|
2020-08-06 03:20:52 +08:00
|
|
|
*
|
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
|
*
|
2026-01-23 02:49:41 +08:00
|
|
|
* Copyright 2013-2026 Apple Inc. and the FoundationDB project authors
|
2020-08-06 03:20:52 +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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "fdbclient/FDBTypes.h"
|
2024-10-24 07:25:56 +08:00
|
|
|
#include "fdbclient/RangeLock.h"
|
2020-08-06 03:20:52 +08:00
|
|
|
#include "fdbrpc/Stats.h"
|
2026-03-13 06:59:28 +08:00
|
|
|
#include "fdbserver/core/AccumulativeChecksumUtil.h"
|
2026-04-12 14:39:52 +08:00
|
|
|
#include "fdbserver/logsystem/ApplyMetadataMutation.h"
|
2026-03-13 06:59:28 +08:00
|
|
|
#include "fdbserver/core/Knobs.h"
|
2026-04-12 14:39:52 +08:00
|
|
|
#include "fdbserver/logsystem/LogSystem.h"
|
2026-05-12 01:25:57 +08:00
|
|
|
#include "fdbserver/logsystem/LogSystemConsumer.h"
|
2026-03-13 03:32:13 +08:00
|
|
|
#include "fdbserver/core/MasterInterface.h"
|
|
|
|
|
#include "fdbserver/core/ResolverInterface.h"
|
2026-04-12 12:18:56 +08:00
|
|
|
#include "../logsystem/include/fdbserver/logsystem/LogSystem.h"
|
2020-08-06 03:20:52 +08:00
|
|
|
#include "flow/IRandom.h"
|
|
|
|
|
|
2026-03-31 02:45:01 +08:00
|
|
|
struct SingleKeyMutationDescriptor {
|
2020-08-06 03:20:52 +08:00
|
|
|
Standalone<StringRef> shardBegin;
|
|
|
|
|
Standalone<StringRef> shardEnd;
|
|
|
|
|
int64_t tag1;
|
|
|
|
|
int64_t tag2;
|
|
|
|
|
int64_t tag3;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-26 04:26:53 +08:00
|
|
|
template <>
|
2026-03-31 02:45:01 +08:00
|
|
|
struct Descriptor<SingleKeyMutationDescriptor>
|
|
|
|
|
: DescribeType<SingleKeyMutationDescriptor,
|
|
|
|
|
"SingleKeyMutation",
|
|
|
|
|
DescribeField<&SingleKeyMutationDescriptor::shardBegin, "shardBegin">,
|
|
|
|
|
DescribeField<&SingleKeyMutationDescriptor::shardEnd, "shardEnd">,
|
|
|
|
|
DescribeField<&SingleKeyMutationDescriptor::tag1, "tag1">,
|
|
|
|
|
DescribeField<&SingleKeyMutationDescriptor::tag2, "tag2">,
|
|
|
|
|
DescribeField<&SingleKeyMutationDescriptor::tag3, "tag3">> {};
|
2026-03-26 04:26:53 +08:00
|
|
|
|
2026-03-17 04:49:38 +08:00
|
|
|
class LogSystemDiskQueueAdapter;
|
|
|
|
|
|
2020-08-06 03:20:52 +08:00
|
|
|
struct ProxyStats {
|
2026-06-28 17:03:44 +08:00
|
|
|
enum class CommitBatchFlushReason {
|
|
|
|
|
BYTE_LIMIT,
|
|
|
|
|
COUNT_LIMIT,
|
|
|
|
|
TIMEOUT,
|
|
|
|
|
FIRST_IN_BATCH,
|
|
|
|
|
TRANSACTION_SIZE_LIMIT,
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-06 03:20:52 +08:00
|
|
|
CounterCollection cc;
|
|
|
|
|
Counter txnCommitIn, txnCommitVersionAssigned, txnCommitResolving, txnCommitResolved, txnCommitOut,
|
|
|
|
|
txnCommitOutSuccess, txnCommitErrors;
|
|
|
|
|
Counter txnConflicts;
|
2021-02-08 06:56:34 +08:00
|
|
|
Counter txnRejectedForQueuedTooLong;
|
2020-08-06 03:20:52 +08:00
|
|
|
Counter commitBatchIn, commitBatchOut;
|
2026-06-28 17:03:44 +08:00
|
|
|
Counter commitBatchFlushByteLimit, commitBatchFlushCountLimit, commitBatchFlushTimeout,
|
2026-06-28 17:48:48 +08:00
|
|
|
commitBatchFlushFirstInBatch, commitBatchFlushTransactionSizeLimit;
|
2020-08-06 03:20:52 +08:00
|
|
|
Counter mutationBytes;
|
|
|
|
|
Counter mutations;
|
|
|
|
|
Counter conflictRanges;
|
|
|
|
|
Counter keyServerLocationIn, keyServerLocationOut, keyServerLocationErrors;
|
2020-08-21 07:00:45 +08:00
|
|
|
Counter txnExpensiveClearCostEstCount;
|
2026-06-13 04:11:23 +08:00
|
|
|
// rejectMutationsForReadLockOnRange takes the fast path (no locks held -> early return)
|
|
|
|
|
// vs the slow path (per-mutation lock check). Observable in production via ProxyMetrics
|
|
|
|
|
// to confirm the no-locks-active optimization fires when expected.
|
|
|
|
|
Counter rangeLockFastPath, rangeLockSlowPath;
|
2020-08-06 03:20:52 +08:00
|
|
|
Version lastCommitVersionAssigned;
|
|
|
|
|
|
|
|
|
|
LatencySample commitLatencySample;
|
|
|
|
|
LatencyBands commitLatencyBands;
|
|
|
|
|
|
2021-06-25 12:20:21 +08:00
|
|
|
// Ratio of tlogs receiving empty commit messages.
|
|
|
|
|
LatencySample commitBatchingEmptyMessageRatio;
|
|
|
|
|
|
2021-03-18 00:28:12 +08:00
|
|
|
LatencySample commitBatchingWindowSize;
|
|
|
|
|
|
2022-04-21 05:31:14 +08:00
|
|
|
LatencySample computeLatency;
|
|
|
|
|
|
2020-08-06 03:20:52 +08:00
|
|
|
Future<Void> logger;
|
|
|
|
|
|
2020-10-20 13:51:56 +08:00
|
|
|
int64_t maxComputeNS;
|
|
|
|
|
int64_t minComputeNS;
|
|
|
|
|
|
2021-08-06 00:17:37 +08:00
|
|
|
Reference<Histogram> commitBatchQueuingDist;
|
|
|
|
|
Reference<Histogram> getCommitVersionDist;
|
|
|
|
|
std::vector<Reference<Histogram>> resolverDist;
|
|
|
|
|
Reference<Histogram> resolutionDist;
|
|
|
|
|
Reference<Histogram> postResolutionDist;
|
|
|
|
|
Reference<Histogram> processingMutationDist;
|
|
|
|
|
Reference<Histogram> tlogLoggingDist;
|
|
|
|
|
Reference<Histogram> replyCommitDist;
|
2026-06-12 07:06:13 +08:00
|
|
|
Reference<Histogram> transactionSizeDist;
|
2021-08-06 00:17:37 +08:00
|
|
|
|
Adds more detailed mutation logging to commit proxy
The commit proxy writes a `ProxyMetrics` trace every 5 seconds. This
event contains a lot of useful information, such as the number of commit
batches that arrived and exited, the number of mutations processed, the
number of bytes those mutations made up, etc.. However, it is difficult
to tell what the workload pattern looks like within these 5 second
intervals when the metrics are being calculated.
This PR adds a new trace, `ProxyDetailedMetrics`, which logs itself
every 100ms. It currently only writes the number of mutations and the
number of mutation bytes that arrived during the 100ms time period. But
it should be easy to add more metrics in the future.
It's possible this increased logging could cause issues. Based off a
simulation run of the `WriteDuringRead` test, I got the following
results:
```
$ rg ProxyDetailedMetrics trace.json | wc -l
6877
$ rg "Roles\": \".*CP.*\"" trace.json | wc -l
11402
$ wc -l trace.json
96147 trace.json
```
So on processes running as a commit proxy, this approximately doubled
the number of lines logged. But relative to the cluster overall, it only
added about 5% overhead.
If we want to reduce this number, one possibility would be to not write
a trace if all the values being written are 0. I'm not sure if this
would help much in production, but in simulation the large majority of
the traces (99%+) consist of zero values.
2023-02-17 08:31:27 +08:00
|
|
|
// These metrics are only logged as part of `ProxyDetailedMetrics`. Since
|
|
|
|
|
// the detailed proxy metrics combine data from different sources, we can't
|
|
|
|
|
// use a `Counter` along with a `CounterCollection` here, and instead have
|
|
|
|
|
// to reimplement the basic functionality.
|
|
|
|
|
std::unordered_set<NetworkAddress> uniqueClients;
|
|
|
|
|
|
2020-10-20 13:51:56 +08:00
|
|
|
int64_t getAndResetMaxCompute() {
|
|
|
|
|
int64_t r = maxComputeNS;
|
|
|
|
|
maxComputeNS = 0;
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t getAndResetMinCompute() {
|
|
|
|
|
int64_t r = minComputeNS;
|
|
|
|
|
minComputeNS = 1e12;
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
Adds more detailed mutation logging to commit proxy
The commit proxy writes a `ProxyMetrics` trace every 5 seconds. This
event contains a lot of useful information, such as the number of commit
batches that arrived and exited, the number of mutations processed, the
number of bytes those mutations made up, etc.. However, it is difficult
to tell what the workload pattern looks like within these 5 second
intervals when the metrics are being calculated.
This PR adds a new trace, `ProxyDetailedMetrics`, which logs itself
every 100ms. It currently only writes the number of mutations and the
number of mutation bytes that arrived during the 100ms time period. But
it should be easy to add more metrics in the future.
It's possible this increased logging could cause issues. Based off a
simulation run of the `WriteDuringRead` test, I got the following
results:
```
$ rg ProxyDetailedMetrics trace.json | wc -l
6877
$ rg "Roles\": \".*CP.*\"" trace.json | wc -l
11402
$ wc -l trace.json
96147 trace.json
```
So on processes running as a commit proxy, this approximately doubled
the number of lines logged. But relative to the cluster overall, it only
added about 5% overhead.
If we want to reduce this number, one possibility would be to not write
a trace if all the values being written are 0. I'm not sure if this
would help much in production, but in simulation the large majority of
the traces (99%+) consist of zero values.
2023-02-17 08:31:27 +08:00
|
|
|
int64_t getSizeAndResetUniqueClients() {
|
|
|
|
|
int64_t r = uniqueClients.size();
|
|
|
|
|
uniqueClients.clear();
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-28 17:03:44 +08:00
|
|
|
void recordCommitBatchFlush(CommitBatchFlushReason reason) {
|
|
|
|
|
switch (reason) {
|
|
|
|
|
case CommitBatchFlushReason::BYTE_LIMIT:
|
|
|
|
|
++commitBatchFlushByteLimit;
|
|
|
|
|
break;
|
|
|
|
|
case CommitBatchFlushReason::COUNT_LIMIT:
|
|
|
|
|
++commitBatchFlushCountLimit;
|
|
|
|
|
break;
|
|
|
|
|
case CommitBatchFlushReason::TIMEOUT:
|
|
|
|
|
++commitBatchFlushTimeout;
|
|
|
|
|
break;
|
|
|
|
|
case CommitBatchFlushReason::FIRST_IN_BATCH:
|
|
|
|
|
++commitBatchFlushFirstInBatch;
|
|
|
|
|
break;
|
|
|
|
|
case CommitBatchFlushReason::TRANSACTION_SIZE_LIMIT:
|
|
|
|
|
++commitBatchFlushTransactionSizeLimit;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-06 03:20:52 +08:00
|
|
|
explicit ProxyStats(UID id,
|
2022-02-26 03:18:42 +08:00
|
|
|
NotifiedVersion* pVersion,
|
2020-08-06 03:20:52 +08:00
|
|
|
NotifiedVersion* pCommittedVersion,
|
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
|
|
|
int64_t* commitBatchesMemBytesCountPtr)
|
2021-07-23 13:48:27 +08:00
|
|
|
: cc("ProxyStats", id.toString()), txnCommitIn("TxnCommitIn", cc),
|
2021-02-08 06:56:34 +08:00
|
|
|
txnCommitVersionAssigned("TxnCommitVersionAssigned", cc), txnCommitResolving("TxnCommitResolving", cc),
|
|
|
|
|
txnCommitResolved("TxnCommitResolved", cc), txnCommitOut("TxnCommitOut", cc),
|
|
|
|
|
txnCommitOutSuccess("TxnCommitOutSuccess", cc), txnCommitErrors("TxnCommitErrors", cc),
|
2021-07-23 13:48:27 +08:00
|
|
|
txnConflicts("TxnConflicts", cc), txnRejectedForQueuedTooLong("TxnRejectedForQueuedTooLong", cc),
|
2026-06-28 17:03:44 +08:00
|
|
|
commitBatchIn("CommitBatchIn", cc), commitBatchOut("CommitBatchOut", cc),
|
|
|
|
|
commitBatchFlushByteLimit("CommitBatchFlushByteLimit", cc),
|
|
|
|
|
commitBatchFlushCountLimit("CommitBatchFlushCountLimit", cc),
|
|
|
|
|
commitBatchFlushTimeout("CommitBatchFlushTimeout", cc),
|
|
|
|
|
commitBatchFlushFirstInBatch("CommitBatchFlushFirstInBatch", cc),
|
|
|
|
|
commitBatchFlushTransactionSizeLimit("CommitBatchFlushTransactionSizeLimit", cc),
|
2026-06-28 17:48:48 +08:00
|
|
|
mutationBytes("MutationBytes", cc), mutations("Mutations", cc), conflictRanges("ConflictRanges", cc),
|
2021-02-08 06:56:34 +08:00
|
|
|
keyServerLocationIn("KeyServerLocationIn", cc), keyServerLocationOut("KeyServerLocationOut", cc),
|
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
|
|
|
keyServerLocationErrors("KeyServerLocationErrors", cc),
|
2026-06-13 04:11:23 +08:00
|
|
|
txnExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc), rangeLockFastPath("RangeLockFastPath", cc),
|
|
|
|
|
rangeLockSlowPath("RangeLockSlowPath", cc), lastCommitVersionAssigned(0),
|
2020-08-06 03:20:52 +08:00
|
|
|
commitLatencySample("CommitLatencyMetrics",
|
|
|
|
|
id,
|
|
|
|
|
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
|
2022-10-01 01:39:43 +08:00
|
|
|
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
|
2022-03-03 06:57:42 +08:00
|
|
|
commitLatencyBands("CommitLatencyBands", id, SERVER_KNOBS->STORAGE_LOGGING_DELAY),
|
2021-06-25 12:20:21 +08:00
|
|
|
commitBatchingEmptyMessageRatio("CommitBatchingEmptyMessageRatio",
|
|
|
|
|
id,
|
|
|
|
|
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
|
2022-10-01 01:39:43 +08:00
|
|
|
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
|
2021-03-18 00:28:12 +08:00
|
|
|
commitBatchingWindowSize("CommitBatchingWindowSize",
|
|
|
|
|
id,
|
|
|
|
|
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
|
2022-10-01 01:39:43 +08:00
|
|
|
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
|
2022-04-21 05:31:14 +08:00
|
|
|
computeLatency("ComputeLatency",
|
|
|
|
|
id,
|
|
|
|
|
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
|
2022-10-01 01:39:43 +08:00
|
|
|
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
|
2021-08-06 00:17:37 +08:00
|
|
|
maxComputeNS(0), minComputeNS(1e12),
|
2022-09-20 02:35:58 +08:00
|
|
|
commitBatchQueuingDist(
|
2022-11-14 12:11:05 +08:00
|
|
|
Histogram::getHistogram("CommitProxy"_sr, "CommitBatchQueuing"_sr, Histogram::Unit::milliseconds)),
|
2022-09-20 02:35:58 +08:00
|
|
|
getCommitVersionDist(
|
2022-11-14 12:11:05 +08:00
|
|
|
Histogram::getHistogram("CommitProxy"_sr, "GetCommitVersion"_sr, Histogram::Unit::milliseconds)),
|
|
|
|
|
resolutionDist(Histogram::getHistogram("CommitProxy"_sr, "Resolution"_sr, Histogram::Unit::milliseconds)),
|
2022-09-20 02:35:58 +08:00
|
|
|
postResolutionDist(
|
2022-11-14 12:11:05 +08:00
|
|
|
Histogram::getHistogram("CommitProxy"_sr, "PostResolutionQueuing"_sr, Histogram::Unit::milliseconds)),
|
2022-09-20 02:35:58 +08:00
|
|
|
processingMutationDist(
|
2022-11-14 12:11:05 +08:00
|
|
|
Histogram::getHistogram("CommitProxy"_sr, "ProcessingMutation"_sr, Histogram::Unit::milliseconds)),
|
|
|
|
|
tlogLoggingDist(Histogram::getHistogram("CommitProxy"_sr, "TlogLogging"_sr, Histogram::Unit::milliseconds)),
|
2026-06-12 07:06:13 +08:00
|
|
|
replyCommitDist(Histogram::getHistogram("CommitProxy"_sr, "ReplyCommit"_sr, Histogram::Unit::milliseconds)),
|
|
|
|
|
transactionSizeDist(Histogram::getHistogram("CommitProxy"_sr, "TransactionSize"_sr, Histogram::Unit::bytes)) {
|
2020-08-06 03:20:52 +08:00
|
|
|
specialCounter(cc, "LastAssignedCommitVersion", [this]() { return this->lastCommitVersionAssigned; });
|
2022-02-26 03:18:42 +08:00
|
|
|
specialCounter(cc, "Version", [pVersion]() { return pVersion->get(); });
|
2020-08-06 03:20:52 +08:00
|
|
|
specialCounter(cc, "CommittedVersion", [pCommittedVersion]() { return pCommittedVersion->get(); });
|
|
|
|
|
specialCounter(cc, "CommitBatchesMemBytesCount", [commitBatchesMemBytesCountPtr]() {
|
|
|
|
|
return *commitBatchesMemBytesCountPtr;
|
|
|
|
|
});
|
2020-10-20 13:51:56 +08:00
|
|
|
specialCounter(cc, "MaxCompute", [this]() { return this->getAndResetMaxCompute(); });
|
|
|
|
|
specialCounter(cc, "MinCompute", [this]() { return this->getAndResetMinCompute(); });
|
2022-10-26 01:17:15 +08:00
|
|
|
logger = cc.traceCounters("ProxyMetrics", id, SERVER_KNOBS->WORKER_LOGGING_INTERVAL, "ProxyMetrics");
|
2020-08-06 03:20:52 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-29 00:07:54 +08:00
|
|
|
struct ExpectedIdempotencyIdCountForKey {
|
|
|
|
|
Version commitVersion = invalidVersion;
|
|
|
|
|
int16_t idempotencyIdCount = 0;
|
|
|
|
|
uint8_t batchIndexHighByte = 0;
|
|
|
|
|
|
2026-07-07 17:45:16 +08:00
|
|
|
ExpectedIdempotencyIdCountForKey() = default;
|
2022-10-29 00:07:54 +08:00
|
|
|
ExpectedIdempotencyIdCountForKey(Version commitVersion, int16_t idempotencyIdCount, uint8_t batchIndexHighByte)
|
|
|
|
|
: commitVersion(commitVersion), idempotencyIdCount(idempotencyIdCount), batchIndexHighByte(batchIndexHighByte) {}
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-02 00:48:25 +08:00
|
|
|
struct RangeLock;
|
2020-08-06 03:20:52 +08:00
|
|
|
struct ProxyCommitData {
|
|
|
|
|
UID dbgid;
|
|
|
|
|
int64_t commitBatchesMemBytesCount;
|
|
|
|
|
ProxyStats stats;
|
|
|
|
|
MasterInterface master;
|
2021-09-17 08:42:34 +08:00
|
|
|
std::vector<ResolverInterface> resolvers;
|
2020-08-06 03:20:52 +08:00
|
|
|
LogSystemDiskQueueAdapter* logAdapter;
|
2026-04-12 12:18:56 +08:00
|
|
|
Reference<LogSystem> logSystem;
|
2026-05-12 01:25:57 +08:00
|
|
|
Reference<LogSystemConsumer> logSystemConsumer;
|
2020-08-06 03:20:52 +08:00
|
|
|
IKeyValueStore* txnStateStore;
|
|
|
|
|
NotifiedVersion committedVersion; // Provided that this recovery has succeeded or will succeed, this version is
|
|
|
|
|
// fully committed (durable)
|
|
|
|
|
Version minKnownCommittedVersion; // No version smaller than this one will be used as the known committed version
|
|
|
|
|
// during recovery
|
2022-02-26 03:18:42 +08:00
|
|
|
NotifiedVersion version; // The version at which txnStateStore is up to date
|
2020-08-06 03:20:52 +08:00
|
|
|
Promise<Void> validState; // Set once txnStateStore and version are valid
|
|
|
|
|
double lastVersionTime;
|
|
|
|
|
KeyRangeMap<std::set<Key>> vecBackupKeys;
|
2026-05-24 02:51:53 +08:00
|
|
|
CDCRoutingTable cdcRouting;
|
2020-08-06 03:20:52 +08:00
|
|
|
uint64_t commitVersionRequestNumber;
|
|
|
|
|
uint64_t mostRecentProcessedRequestNumber;
|
|
|
|
|
KeyRangeMap<Deque<std::pair<Version, int>>> keyResolvers;
|
2021-10-09 09:03:01 +08:00
|
|
|
// When all resolvers process system keys (for private mutations), the "keyResolvers"
|
|
|
|
|
// only tracks normalKeys. This is used for tracking versions for systemKeys.
|
|
|
|
|
Deque<Version> systemKeyVersions;
|
2021-03-18 00:36:45 +08:00
|
|
|
KeyRangeMap<ServerCacheInfo> keyInfo; // keyrange -> all storage servers in all DCs for the keyrange
|
2020-08-06 03:20:52 +08:00
|
|
|
std::map<Key, ApplyMutationsData> uid_applyMutationsData;
|
|
|
|
|
bool firstProxy;
|
|
|
|
|
double lastCoalesceTime;
|
|
|
|
|
bool locked;
|
|
|
|
|
Optional<Value> metadataVersion;
|
|
|
|
|
double commitBatchInterval;
|
2023-01-19 07:11:58 +08:00
|
|
|
bool provisional;
|
2020-08-06 03:20:52 +08:00
|
|
|
|
|
|
|
|
int64_t localCommitBatchesStarted;
|
|
|
|
|
NotifiedVersion latestLocalCommitBatchResolving;
|
|
|
|
|
NotifiedVersion latestLocalCommitBatchLogging;
|
|
|
|
|
|
2022-03-15 23:57:26 +08:00
|
|
|
PublicRequestStream<CommitTransactionRequest> commit;
|
2020-08-06 03:20:52 +08:00
|
|
|
Database cx;
|
2021-07-12 13:17:09 +08:00
|
|
|
Reference<AsyncVar<ServerDBInfo> const> db;
|
2026-03-31 02:45:01 +08:00
|
|
|
EventMetricHandle<SingleKeyMutationDescriptor> singleKeyMutationEvent;
|
2020-08-06 03:20:52 +08:00
|
|
|
std::map<UID, Reference<StorageInfo>> storageCache;
|
2021-05-29 02:15:52 +08:00
|
|
|
std::unordered_map<UID, StorageServerInterface> tssMapping;
|
2020-08-06 03:20:52 +08:00
|
|
|
std::map<Tag, Version> tag_popped;
|
|
|
|
|
Deque<std::pair<Version, Version>> txsPopVersions;
|
|
|
|
|
Version lastTxsPop;
|
|
|
|
|
bool popRemoteTxs;
|
2021-09-17 08:42:34 +08:00
|
|
|
std::vector<Standalone<StringRef>> whitelistedBinPathVec;
|
2023-11-01 00:01:34 +08:00
|
|
|
std::vector<std::pair<KeyRange, double>> hotShards;
|
2020-08-06 03:20:52 +08:00
|
|
|
|
|
|
|
|
Optional<LatencyBandConfig> latencyBandConfig;
|
|
|
|
|
double lastStartCommit;
|
|
|
|
|
double lastCommitLatency;
|
|
|
|
|
int updateCommitRequests = 0;
|
|
|
|
|
NotifiedDouble lastCommitTime;
|
|
|
|
|
|
2021-09-17 08:42:34 +08:00
|
|
|
std::vector<double> commitComputePerOperation;
|
2020-08-21 08:03:06 +08:00
|
|
|
UIDTransactionTagMap<TransactionCommitCostEstimation> ssTrTagCommitCost;
|
2020-10-20 13:51:56 +08:00
|
|
|
double lastMasterReset;
|
|
|
|
|
double lastResolverReset;
|
2022-05-07 02:19:37 +08:00
|
|
|
int localTLogCount = -1;
|
2022-02-19 13:22:31 +08:00
|
|
|
|
2022-10-29 00:07:54 +08:00
|
|
|
PromiseStream<ExpectedIdempotencyIdCountForKey> expectedIdempotencyIdCountForKey;
|
|
|
|
|
Standalone<VectorRef<MutationRef>> idempotencyClears;
|
|
|
|
|
|
2023-01-13 01:11:30 +08:00
|
|
|
AsyncVar<bool> triggerCommit;
|
|
|
|
|
|
2024-04-05 06:03:44 +08:00
|
|
|
uint16_t commitProxyIndex; // decided when the cluster controller recruits commit proxies
|
|
|
|
|
std::shared_ptr<AccumulativeChecksumBuilder> acsBuilder = nullptr;
|
|
|
|
|
LogEpoch epoch;
|
|
|
|
|
|
2025-03-12 01:19:57 +08:00
|
|
|
Version lastShardMove;
|
|
|
|
|
|
2024-10-24 07:25:56 +08:00
|
|
|
std::shared_ptr<RangeLock> rangeLock = nullptr;
|
|
|
|
|
|
2020-08-06 03:20:52 +08:00
|
|
|
// The tag related to a storage server rarely change, so we keep a vector of tags for each key range to be slightly
|
|
|
|
|
// more CPU efficient. When a tag related to a storage server does change, we empty out all of these vectors to
|
|
|
|
|
// signify they must be repopulated. We do not repopulate them immediately to avoid a slow task.
|
2021-09-17 08:42:34 +08:00
|
|
|
const std::vector<Tag>& tagsForKey(StringRef key) {
|
2020-08-06 03:20:52 +08:00
|
|
|
auto& tags = keyInfo[key].tags;
|
2026-07-07 17:45:16 +08:00
|
|
|
if (tags.empty()) {
|
2020-08-06 03:20:52 +08:00
|
|
|
auto& r = keyInfo.rangeContaining(key).value();
|
2020-08-11 08:14:55 +08:00
|
|
|
r.populateTags();
|
2020-08-06 03:20:52 +08:00
|
|
|
return r.tags;
|
|
|
|
|
}
|
|
|
|
|
return tags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateLatencyBandConfig(Optional<LatencyBandConfig> newLatencyBandConfig) {
|
|
|
|
|
if (newLatencyBandConfig.present() != latencyBandConfig.present() ||
|
|
|
|
|
(newLatencyBandConfig.present() &&
|
|
|
|
|
newLatencyBandConfig.get().commitConfig != latencyBandConfig.get().commitConfig)) {
|
|
|
|
|
TraceEvent("LatencyBandCommitUpdatingConfig").detail("Present", newLatencyBandConfig.present());
|
|
|
|
|
stats.commitLatencyBands.clearBands();
|
|
|
|
|
if (newLatencyBandConfig.present()) {
|
|
|
|
|
for (auto band : newLatencyBandConfig.get().commitConfig.bands) {
|
|
|
|
|
stats.commitLatencyBands.addThreshold(band);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
latencyBandConfig = newLatencyBandConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 14:36:54 +08:00
|
|
|
void updateSSTagCost(const UID& id, const TagSet& tagSet, MutationRef m, uint64_t cost) {
|
2020-08-21 08:03:06 +08:00
|
|
|
auto [it, _] = ssTrTagCommitCost.try_emplace(id, TransactionTagMap<TransactionCommitCostEstimation>());
|
2020-08-19 12:23:23 +08:00
|
|
|
|
2020-08-30 03:35:31 +08:00
|
|
|
for (auto& tag : tagSet) {
|
2020-08-19 12:23:23 +08:00
|
|
|
auto& costItem = it->second[tag];
|
2020-08-30 03:35:31 +08:00
|
|
|
if (m.isAtomicOp() || m.type == MutationRef::Type::SetValue || m.type == MutationRef::Type::ClearRange) {
|
|
|
|
|
costItem.opsSum++;
|
2020-08-19 12:23:23 +08:00
|
|
|
costItem.costSum += cost;
|
2020-08-11 08:14:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 00:48:25 +08:00
|
|
|
// RangeLock feature currently does not support version vector
|
|
|
|
|
// So, if the version vector is enabled, the RangeLock is automatically disabled
|
|
|
|
|
// RangeLock feature currently rely on processing private mutations in commit proxy
|
Delete encryption at rest (#12667)
Delete encryption at rest in accordance with plans circulated in PR #12400.
Development of this PR was mostly straightforward. Several issues of note:
Upgrade tests which use Redwood want to use the old "encrypt by 0xFF XOR" test-only encoding/encryption algorithm. I wanted to delete that in main and did so. Upgrade tests have been modified not to use Redwood (storage engine 3, mentioned in various storageEngineExcludeTypes test options updates). 7.1 did not define storageEngineExcludeTypes. After some discussion we have decided to delete 7.1-based upgrade tests. 7.3- and 7.4-based upgrade tests remain in place.
Cross-version compatibility (such as it is, I assume in client library startup) remains super easy to break when deleting code. Tips: (A) removing unnecessary arguments to functions is bread and butter code editing when removing code, but if you find yourself removing arguments from a serializer() invocation, you might be breaking a protocol. (B) run ctest -R upgrade early and often.
An implication of these changes is that we are going to rely on the community to make us aware of any {upgrade+Redwood}-specific bugs. In other words, we are declining to continue to go out of our way to test functionality that we have no plans to use.
On the plus side this reclaims 15,000 more lines of code that we don't have to look at or think about, including in common areas such as commit proxy, backups, and generic storage server code.
Testing:
20260129-230241-gglass-15694f5f80af6932 compressed=True data_size=34905446 duration=4335357 ended=100000 fail_fast=1000 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=6:21:47 sanity=False started=100000 stopped=20260130-052428 submitted=20260129-230241 timeout=5400 username=gglass
20260202-214159-gglass-69b90c779cf8ec68 compressed=True data_size=35007141 duration=4612639 ended=100000 fail_fast=1000 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=3:00:25 sanity=False started=100000 stopped=20260203-004224 submitted=20260202-214159 timeout=5400 username=gglass
* Checkpoint file removals and code edits for removing encryption at rest. Have not tried to compile this yet.
* Checkpoint some improvements. Still does not compile.
* Merging with upstream changes in copyright updates resurrected previously deleted files, so delete them again
* Checkpoint incremental progress towards getting this to compile
* Checkpoint more intermediate changes getting encryption at rest deleted. Still doesnt compile but getting closer.
* Changes sufficient to get things to compile with removal of encryption at rest. NOT TESTED.
* Delete encryptModes from toml files run by current fdbserver binaries; restarting tests using <= 7.4 binaries do need encryptModes to say disabled
* Avoid using MAX_ENCODING_VALUE for random purposes for which other solutions are more clear and generally better
* Stop using XOREncryption_TestOnly because that no longer works. Also I see no need to support it as it requires unneeded interfaces and test fixtures in order to actually work.
* Remove more page encryption stuff, and address some TODO(gglass) comments.
* debugging redwood failures
* Fix some misc simulation failures. Notably, disable storage engine type 3 (redwood) on upgrade tests, as it writes databases with encoding type 1 which is no longer supported
* Add a comment discussion deprecation options for fields in persistent metadata, and explain why we are merely renaming the member as deprecated and nothing anything else.
* Remove 7.1 upgrade tests. These tests enable Redwood and write databases with "0xFF XOR encryption" style encoding (encoding 1), which is removed in main.
* Improve comments
* Obligatory f3f commit. Format The Effin Source Files
* Delete more unneeded encryption stuff
* Put back about 1% of deleted code in a desperate attempt to unbreak broken protocol compatibility
* formatting
* Remove mentions of encryption at rest in backup related APIs
* Address misc review comments. Remove --encrypt-files backup option.
2026-02-05 08:02:06 +08:00
|
|
|
// So, if PROXY_USE_RESOLVER_PRIVATE_MUTATIONS is on, the RangeLock is automatically disabled.
|
2024-11-02 00:48:25 +08:00
|
|
|
bool rangeLockEnabled() {
|
|
|
|
|
return SERVER_KNOBS->ENABLE_READ_LOCK_ON_RANGE && !SERVER_KNOBS->ENABLE_VERSION_VECTOR &&
|
Delete encryption at rest (#12667)
Delete encryption at rest in accordance with plans circulated in PR #12400.
Development of this PR was mostly straightforward. Several issues of note:
Upgrade tests which use Redwood want to use the old "encrypt by 0xFF XOR" test-only encoding/encryption algorithm. I wanted to delete that in main and did so. Upgrade tests have been modified not to use Redwood (storage engine 3, mentioned in various storageEngineExcludeTypes test options updates). 7.1 did not define storageEngineExcludeTypes. After some discussion we have decided to delete 7.1-based upgrade tests. 7.3- and 7.4-based upgrade tests remain in place.
Cross-version compatibility (such as it is, I assume in client library startup) remains super easy to break when deleting code. Tips: (A) removing unnecessary arguments to functions is bread and butter code editing when removing code, but if you find yourself removing arguments from a serializer() invocation, you might be breaking a protocol. (B) run ctest -R upgrade early and often.
An implication of these changes is that we are going to rely on the community to make us aware of any {upgrade+Redwood}-specific bugs. In other words, we are declining to continue to go out of our way to test functionality that we have no plans to use.
On the plus side this reclaims 15,000 more lines of code that we don't have to look at or think about, including in common areas such as commit proxy, backups, and generic storage server code.
Testing:
20260129-230241-gglass-15694f5f80af6932 compressed=True data_size=34905446 duration=4335357 ended=100000 fail_fast=1000 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=6:21:47 sanity=False started=100000 stopped=20260130-052428 submitted=20260129-230241 timeout=5400 username=gglass
20260202-214159-gglass-69b90c779cf8ec68 compressed=True data_size=35007141 duration=4612639 ended=100000 fail_fast=1000 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=3:00:25 sanity=False started=100000 stopped=20260203-004224 submitted=20260202-214159 timeout=5400 username=gglass
* Checkpoint file removals and code edits for removing encryption at rest. Have not tried to compile this yet.
* Checkpoint some improvements. Still does not compile.
* Merging with upstream changes in copyright updates resurrected previously deleted files, so delete them again
* Checkpoint incremental progress towards getting this to compile
* Checkpoint more intermediate changes getting encryption at rest deleted. Still doesnt compile but getting closer.
* Changes sufficient to get things to compile with removal of encryption at rest. NOT TESTED.
* Delete encryptModes from toml files run by current fdbserver binaries; restarting tests using <= 7.4 binaries do need encryptModes to say disabled
* Avoid using MAX_ENCODING_VALUE for random purposes for which other solutions are more clear and generally better
* Stop using XOREncryption_TestOnly because that no longer works. Also I see no need to support it as it requires unneeded interfaces and test fixtures in order to actually work.
* Remove more page encryption stuff, and address some TODO(gglass) comments.
* debugging redwood failures
* Fix some misc simulation failures. Notably, disable storage engine type 3 (redwood) on upgrade tests, as it writes databases with encoding type 1 which is no longer supported
* Add a comment discussion deprecation options for fields in persistent metadata, and explain why we are merely renaming the member as deprecated and nothing anything else.
* Remove 7.1 upgrade tests. These tests enable Redwood and write databases with "0xFF XOR encryption" style encoding (encoding 1), which is removed in main.
* Improve comments
* Obligatory f3f commit. Format The Effin Source Files
* Delete more unneeded encryption stuff
* Put back about 1% of deleted code in a desperate attempt to unbreak broken protocol compatibility
* formatting
* Remove mentions of encryption at rest in backup related APIs
* Address misc review comments. Remove --encrypt-files backup option.
2026-02-05 08:02:06 +08:00
|
|
|
!SERVER_KNOBS->ENABLE_VERSION_VECTOR_TLOG_UNICAST;
|
2024-11-02 00:48:25 +08:00
|
|
|
}
|
|
|
|
|
|
2020-08-06 03:20:52 +08:00
|
|
|
ProxyCommitData(UID dbgid,
|
|
|
|
|
MasterInterface master,
|
|
|
|
|
Version recoveryTransactionVersion,
|
2022-03-15 23:57:26 +08:00
|
|
|
PublicRequestStream<CommitTransactionRequest> commit,
|
2021-07-12 13:17:09 +08:00
|
|
|
Reference<AsyncVar<ServerDBInfo> const> db,
|
2022-12-13 13:23:55 +08:00
|
|
|
bool firstProxy,
|
2024-03-12 00:51:31 +08:00
|
|
|
bool provisional,
|
2024-04-05 06:03:44 +08:00
|
|
|
uint16_t commitProxyIndex,
|
|
|
|
|
LogEpoch epoch)
|
2021-07-23 13:48:27 +08:00
|
|
|
: dbgid(dbgid), commitBatchesMemBytesCount(0),
|
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
|
|
|
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),
|
|
|
|
|
provisional(provisional), lastCoalesceTime(0), locked(false),
|
|
|
|
|
commitBatchInterval(SERVER_KNOBS->COMMIT_TRANSACTION_BATCH_INTERVAL_MIN), localCommitBatchesStarted(0),
|
2026-04-14 02:20:41 +08:00
|
|
|
commit(commit), cx(openDBOnServer(db, TaskPriority::DefaultEndpoint, LockAware::True)), db(db),
|
2022-09-20 02:35:58 +08:00
|
|
|
singleKeyMutationEvent("SingleKeyMutation"_sr), lastTxsPop(0), popRemoteTxs(false), lastStartCommit(0),
|
|
|
|
|
lastCommitLatency(SERVER_KNOBS->REQUIRED_MIN_RECOVERY_DURATION), lastCommitTime(0), lastMasterReset(now()),
|
2024-04-05 06:03:44 +08:00
|
|
|
lastResolverReset(now()), commitProxyIndex(commitProxyIndex),
|
|
|
|
|
acsBuilder(CLIENT_KNOBS->ENABLE_MUTATION_CHECKSUM && CLIENT_KNOBS->ENABLE_ACCUMULATIVE_CHECKSUM &&
|
Delete encryption at rest (#12667)
Delete encryption at rest in accordance with plans circulated in PR #12400.
Development of this PR was mostly straightforward. Several issues of note:
Upgrade tests which use Redwood want to use the old "encrypt by 0xFF XOR" test-only encoding/encryption algorithm. I wanted to delete that in main and did so. Upgrade tests have been modified not to use Redwood (storage engine 3, mentioned in various storageEngineExcludeTypes test options updates). 7.1 did not define storageEngineExcludeTypes. After some discussion we have decided to delete 7.1-based upgrade tests. 7.3- and 7.4-based upgrade tests remain in place.
Cross-version compatibility (such as it is, I assume in client library startup) remains super easy to break when deleting code. Tips: (A) removing unnecessary arguments to functions is bread and butter code editing when removing code, but if you find yourself removing arguments from a serializer() invocation, you might be breaking a protocol. (B) run ctest -R upgrade early and often.
An implication of these changes is that we are going to rely on the community to make us aware of any {upgrade+Redwood}-specific bugs. In other words, we are declining to continue to go out of our way to test functionality that we have no plans to use.
On the plus side this reclaims 15,000 more lines of code that we don't have to look at or think about, including in common areas such as commit proxy, backups, and generic storage server code.
Testing:
20260129-230241-gglass-15694f5f80af6932 compressed=True data_size=34905446 duration=4335357 ended=100000 fail_fast=1000 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=6:21:47 sanity=False started=100000 stopped=20260130-052428 submitted=20260129-230241 timeout=5400 username=gglass
20260202-214159-gglass-69b90c779cf8ec68 compressed=True data_size=35007141 duration=4612639 ended=100000 fail_fast=1000 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=3:00:25 sanity=False started=100000 stopped=20260203-004224 submitted=20260202-214159 timeout=5400 username=gglass
* Checkpoint file removals and code edits for removing encryption at rest. Have not tried to compile this yet.
* Checkpoint some improvements. Still does not compile.
* Merging with upstream changes in copyright updates resurrected previously deleted files, so delete them again
* Checkpoint incremental progress towards getting this to compile
* Checkpoint more intermediate changes getting encryption at rest deleted. Still doesnt compile but getting closer.
* Changes sufficient to get things to compile with removal of encryption at rest. NOT TESTED.
* Delete encryptModes from toml files run by current fdbserver binaries; restarting tests using <= 7.4 binaries do need encryptModes to say disabled
* Avoid using MAX_ENCODING_VALUE for random purposes for which other solutions are more clear and generally better
* Stop using XOREncryption_TestOnly because that no longer works. Also I see no need to support it as it requires unneeded interfaces and test fixtures in order to actually work.
* Remove more page encryption stuff, and address some TODO(gglass) comments.
* debugging redwood failures
* Fix some misc simulation failures. Notably, disable storage engine type 3 (redwood) on upgrade tests, as it writes databases with encoding type 1 which is no longer supported
* Add a comment discussion deprecation options for fields in persistent metadata, and explain why we are merely renaming the member as deprecated and nothing anything else.
* Remove 7.1 upgrade tests. These tests enable Redwood and write databases with "0xFF XOR encryption" style encoding (encoding 1), which is removed in main.
* Improve comments
* Obligatory f3f commit. Format The Effin Source Files
* Delete more unneeded encryption stuff
* Put back about 1% of deleted code in a desperate attempt to unbreak broken protocol compatibility
* formatting
* Remove mentions of encryption at rest in backup related APIs
* Address misc review comments. Remove --encrypt-files backup option.
2026-02-05 08:02:06 +08:00
|
|
|
!SERVER_KNOBS->ENABLE_VERSION_VECTOR && !SERVER_KNOBS->ENABLE_VERSION_VECTOR_TLOG_UNICAST
|
2024-04-05 06:03:44 +08:00
|
|
|
? std::make_shared<AccumulativeChecksumBuilder>(
|
|
|
|
|
getCommitProxyAccumulativeChecksumIndex(commitProxyIndex))
|
|
|
|
|
: nullptr),
|
2025-03-12 01:19:57 +08:00
|
|
|
lastShardMove(invalidVersion), epoch(epoch) {
|
2020-08-06 03:20:52 +08:00
|
|
|
commitComputePerOperation.resize(SERVER_KNOBS->PROXY_COMPUTE_BUCKETS, 0.0);
|
|
|
|
|
}
|
2026-03-29 02:44:33 +08:00
|
|
|
|
2026-03-29 03:47:29 +08:00
|
|
|
// Build the core-owned view consumed by applyMetadataMutations() without
|
|
|
|
|
// exposing the full ProxyCommitData type outside commitproxy.
|
2026-03-29 03:39:23 +08:00
|
|
|
ApplyMetadataProxyContext getApplyMetadataProxyContext();
|
2020-08-06 03:20:52 +08:00
|
|
|
};
|
2026-03-29 03:23:40 +08:00
|
|
|
struct RangeLock : ApplyMetadataRangeLock {
|
2024-11-02 00:48:25 +08:00
|
|
|
public:
|
2026-03-16 05:30:00 +08:00
|
|
|
explicit RangeLock(ProxyCommitData* const pProxyCommitData) : pProxyCommitData(pProxyCommitData) {
|
2024-11-02 00:48:25 +08:00
|
|
|
coreMap.insert(allKeys, RangeLockStateSet());
|
2026-06-13 04:11:23 +08:00
|
|
|
// anyExclusiveLockHeld_ stays false: the initial all-keys entry is empty.
|
2024-11-02 00:48:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-29 03:23:40 +08:00
|
|
|
~RangeLock() override = default;
|
|
|
|
|
|
|
|
|
|
bool pendingRequest() const override { return currentRangeLockStartKey.present(); }
|
2024-11-02 00:48:25 +08:00
|
|
|
|
2026-06-13 04:11:23 +08:00
|
|
|
// Cheap query for the commit hot path. True when at least one
|
|
|
|
|
// ExclusiveReadLock is currently held over a sub-range. When this is
|
|
|
|
|
// false, rejectMutationsForReadLockOnRange skips its per-mutation loop.
|
|
|
|
|
bool anyExclusiveLockHeld() const { return anyExclusiveLockHeld_; }
|
|
|
|
|
|
2024-11-02 00:48:25 +08:00
|
|
|
void initKeyPoint(const Key& key, const Value& value) {
|
|
|
|
|
ASSERT(pProxyCommitData != nullptr && pProxyCommitData->rangeLockEnabled());
|
|
|
|
|
if (!value.empty()) {
|
2026-06-13 04:11:23 +08:00
|
|
|
RangeLockStateSet decoded = decodeRangeLockStateSet(value);
|
|
|
|
|
coreMap.rawInsert(key, decoded);
|
|
|
|
|
if (decoded.isLockedFor(RangeLockType::ExclusiveReadLock)) {
|
|
|
|
|
// Recovery init is monotonic-up: it only adds state.
|
|
|
|
|
anyExclusiveLockHeld_ = true;
|
|
|
|
|
}
|
2024-11-02 00:48:25 +08:00
|
|
|
} else {
|
|
|
|
|
coreMap.rawInsert(key, RangeLockStateSet());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 03:23:40 +08:00
|
|
|
void setPendingRequest(const Key& startKey, const RangeLockStateSet& lockSetState) override {
|
2024-11-02 00:48:25 +08:00
|
|
|
ASSERT(pProxyCommitData != nullptr && pProxyCommitData->rangeLockEnabled());
|
|
|
|
|
ASSERT(!pendingRequest());
|
|
|
|
|
currentRangeLockStartKey = std::make_pair(startKey, lockSetState);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 03:23:40 +08:00
|
|
|
void consumePendingRequest(const Key& endKey) override {
|
2024-11-02 00:48:25 +08:00
|
|
|
ASSERT(pProxyCommitData != nullptr && pProxyCommitData->rangeLockEnabled());
|
|
|
|
|
ASSERT(pendingRequest());
|
|
|
|
|
ASSERT(endKey <= normalKeys.end);
|
|
|
|
|
ASSERT(currentRangeLockStartKey.get().first < endKey);
|
|
|
|
|
KeyRange lockRange = Standalone(KeyRangeRef(currentRangeLockStartKey.get().first, endKey));
|
|
|
|
|
RangeLockStateSet lockSetState = currentRangeLockStartKey.get().second;
|
|
|
|
|
coreMap.insert(lockRange, lockSetState);
|
|
|
|
|
coreMap.coalesce(allKeys);
|
|
|
|
|
currentRangeLockStartKey.reset();
|
2026-06-13 04:11:23 +08:00
|
|
|
// This path can transition locked -> unlocked when an empty
|
|
|
|
|
// RangeLockStateSet is inserted over a previously locked range, so we
|
|
|
|
|
// must rescan after coalesce to keep anyExclusiveLockHeld_ accurate.
|
|
|
|
|
recomputeAnyExclusiveLockHeld();
|
2024-11-02 00:48:25 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isLocked(const KeyRange& range) const {
|
|
|
|
|
ASSERT(pProxyCommitData != nullptr && pProxyCommitData->rangeLockEnabled());
|
|
|
|
|
if (range.end >= normalKeys.end) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (auto lockRange : coreMap.intersectingRanges(range)) {
|
2025-03-08 06:11:23 +08:00
|
|
|
if (lockRange.value().isValid() && lockRange.value().isLockedFor(RangeLockType::ExclusiveReadLock)) {
|
2024-11-02 00:48:25 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2026-06-13 04:11:23 +08:00
|
|
|
// Full rescan; only called on lock add/remove (rare, per-bulkload-job),
|
|
|
|
|
// not per-commit. Cost = O(coreMap entries), bounded by active lock count.
|
|
|
|
|
void recomputeAnyExclusiveLockHeld() {
|
|
|
|
|
for (auto it : coreMap.ranges()) {
|
|
|
|
|
if (it.value().isValid() && it.value().isLockedFor(RangeLockType::ExclusiveReadLock)) {
|
|
|
|
|
anyExclusiveLockHeld_ = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
anyExclusiveLockHeld_ = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 00:48:25 +08:00
|
|
|
Optional<std::pair<Key, RangeLockStateSet>> currentRangeLockStartKey;
|
|
|
|
|
KeyRangeMap<RangeLockStateSet> coreMap;
|
|
|
|
|
ProxyCommitData* const pProxyCommitData;
|
2026-06-13 04:11:23 +08:00
|
|
|
// Per-proxy cached summary of coreMap. Each proxy derives this from the
|
|
|
|
|
// same txnStateStore content, so all proxies converge to the same value.
|
|
|
|
|
bool anyExclusiveLockHeld_ = false;
|
2024-11-02 00:48:25 +08:00
|
|
|
};
|
2026-03-29 03:39:23 +08:00
|
|
|
|
|
|
|
|
inline ApplyMetadataProxyContext ProxyCommitData::getApplyMetadataProxyContext() {
|
|
|
|
|
return { .dbgid = dbgid,
|
|
|
|
|
.txnStateStore = txnStateStore,
|
|
|
|
|
.vecBackupKeys = &vecBackupKeys,
|
2026-05-24 02:51:53 +08:00
|
|
|
.cdcRouting = &cdcRouting,
|
2026-03-29 03:39:23 +08:00
|
|
|
.keyInfo = &keyInfo,
|
|
|
|
|
.uid_applyMutationsData = firstProxy ? &uid_applyMutationsData : nullptr,
|
|
|
|
|
.commit = commit,
|
|
|
|
|
.cx = cx,
|
|
|
|
|
.committedVersion = &committedVersion,
|
|
|
|
|
.storageCache = &storageCache,
|
|
|
|
|
.tag_popped = &tag_popped,
|
|
|
|
|
.tssMapping = &tssMapping,
|
|
|
|
|
.commitProxyIndex = commitProxyIndex,
|
|
|
|
|
.acsBuilder = acsBuilder,
|
|
|
|
|
.epoch = epoch,
|
2026-03-29 03:47:29 +08:00
|
|
|
// applyMetadataMutations() only borrows the interface during the
|
|
|
|
|
// synchronous call, so there is no need to propagate shared
|
|
|
|
|
// ownership through the context object.
|
|
|
|
|
.rangeLock = rangeLock.get() };
|
2026-03-29 03:39:23 +08:00
|
|
|
}
|