diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-11-15 12:31:55 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-11-15 12:31:55 +0000 |
commit | 2af589636d76af4ad3d26eaf199ddc4ce8cf011e (patch) | |
tree | ed3b59977eb7181bd756a42c909e32d7fe207fca /storage/src/tests/distributor/distributortest.cpp | |
parent | bf057fb22f9c917d616031a0cd32597b315bb803 (diff) |
Use fast updates when replica metadata is out of sync but document itself is in sync
When a bucket has replicas with mismatching metadata (i.e. they are out of sync),
the distributor will initiate a write-repair for updates to avoid divergence of
replica content. This is done by first sending a Get to all diverging replica
sets, picking the highest timestamp and applying the update locally. The updated
document is then sent out as a Put. This can be very expensive if document Put
operations are disproportionally more expensive than partial updates, and also
makes the distributor thread part of a contended critical path.
This commit lets `TwoPhaseUpdateOperation` restart an update as a "fast path"
update (partial updates sent directly to the nodes) if the initial read phase
returns the same timestamp for the document across all replicas.
It also removes an old (but now presumed unsafe) optimization where Get
operations are only sent to replicas marked "trusted" even if others are
out of sync with it. Since trustedness is a transient state that does not
persist across restarts or bucket handoffs, it's not robust enough to be
used for such purposes. Gets will now be sent to all out of sync replica
groups regardless of trusted status.
Diffstat (limited to 'storage/src/tests/distributor/distributortest.cpp')
-rw-r--r-- | storage/src/tests/distributor/distributortest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index e6c617a32e4..94d33e50047 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.cpp @@ -174,6 +174,12 @@ struct DistributorTest : Test, DistributorTestUtil { configureDistributor(builder); } + void configure_update_fast_path_restart_enabled(bool enabled) { + ConfigBuilder builder; + builder.restartWithFastUpdatePathIfAllGetTimestampsAreConsistent = enabled; + configureDistributor(builder); + } + void configureMaxClusterClockSkew(int seconds); void sendDownClusterStateCommand(); void replyToSingleRequestBucketInfoCommandWith1Bucket(); @@ -1001,6 +1007,17 @@ TEST_F(DistributorTest, stale_reads_config_is_propagated_to_external_operation_h EXPECT_FALSE(getExternalOperationHandler().concurrent_gets_enabled()); } +TEST_F(DistributorTest, fast_path_on_consistent_gets_config_is_propagated_to_internal_config) { + createLinks(true); + setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); + + configure_update_fast_path_restart_enabled(true); + EXPECT_TRUE(getConfig().update_fast_path_restart_enabled()); + + configure_update_fast_path_restart_enabled(false); + EXPECT_FALSE(getConfig().update_fast_path_restart_enabled()); +} + TEST_F(DistributorTest, concurrent_reads_not_enabled_if_btree_db_is_not_enabled) { createLinks(false); setupDistributor(Redundancy(1), NodeCount(1), "distributor:1 storage:1"); |