From 709df795c0233c79f7041d5c0073d7e3d9d4629d Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Wed, 28 Apr 2021 16:22:34 -0700 Subject: [PATCH] Added a new option to bypass unreadable protection in read your writes for calls to get --- fdbclient/RYWIterator.cpp | 4 ++-- fdbclient/RYWIterator.h | 5 ++++- fdbclient/ReadYourWrites.actor.cpp | 8 ++++++++ fdbclient/ReadYourWrites.h | 1 + fdbclient/SnapshotCache.h | 1 + fdbclient/vexillographer/fdb.options | 5 +++++ fdbserver/workloads/Unreadable.actor.cpp | 15 ++++++++++++++- 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/fdbclient/RYWIterator.cpp b/fdbclient/RYWIterator.cpp index fd3eec35c7..6756b1f482 100644 --- a/fdbclient/RYWIterator.cpp +++ b/fdbclient/RYWIterator.cpp @@ -42,7 +42,7 @@ const RYWIterator::SEGMENT_TYPE RYWIterator::typeMap[12] = { }; RYWIterator::SEGMENT_TYPE RYWIterator::type() const { - if (is_unreadable()) + if (is_unreadable() && !bypassUnreadable) throw accessed_unreadable(); return typeMap[writes.type() * 3 + cache.type()]; @@ -72,7 +72,7 @@ ExtStringRef RYWIterator::endKey() { } const KeyValueRef* RYWIterator::kv(Arena& arena) { - if (is_unreadable()) + if (is_unreadable() && !bypassUnreadable) throw accessed_unreadable(); if (writes.is_unmodified_range()) { diff --git a/fdbclient/RYWIterator.h b/fdbclient/RYWIterator.h index e28b11c033..ba49bad9e3 100644 --- a/fdbclient/RYWIterator.h +++ b/fdbclient/RYWIterator.h @@ -28,7 +28,7 @@ class RYWIterator { public: RYWIterator(SnapshotCache* snapshotCache, WriteMap* writeMap) - : cache(snapshotCache), writes(writeMap), begin_key_cmp(0), end_key_cmp(0) {} + : cache(snapshotCache), writes(writeMap), begin_key_cmp(0), end_key_cmp(0), bypassUnreadable(false) {} enum SEGMENT_TYPE { UNKNOWN_RANGE, EMPTY_RANGE, KV }; static const SEGMENT_TYPE typeMap[12]; @@ -59,6 +59,8 @@ public: void skipContiguousBack(KeyRef key); + void bypassUnreadableProtection() { bypassUnreadable = true; } + WriteMap::iterator& extractWriteMapIterator(); // Really this should return an iterator by value, but for performance it's convenient to actually grab the internal // one. Consider copying the return value if performance isn't critical. If you modify the returned iterator, it @@ -72,6 +74,7 @@ private: SnapshotCache::iterator cache; WriteMap::iterator writes; KeyValueRef temp; + bool bypassUnreadable; void updateCmp(); }; diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index a6e047b979..717499112c 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -84,6 +84,9 @@ public: static Future> read(ReadYourWritesTransaction* ryw, GetValueReq read, Iter* it) { // This overload is required to provide postcondition: it->extractWriteMapIterator().segmentContains(read.key) + if (ryw->options.bypassUnreadable) { + it->bypassUnreadableProtection(); + } it->skip(read.key); state bool dependent = it->is_dependent(); if (it->is_kv()) { @@ -2237,6 +2240,11 @@ void ReadYourWritesTransaction::setOptionImpl(FDBTransactionOptions::Option opti validateOptionValue(value, false); options.specialKeySpaceChangeConfiguration = true; break; + case FDBTransactionOptions::BYPASS_UNREADABLE: + validateOptionValue(value, false); + TraceEvent("ReadVersionStampValueOptionSet"); + options.bypassUnreadable = true; + break; default: break; } diff --git a/fdbclient/ReadYourWrites.h b/fdbclient/ReadYourWrites.h index f8e8e390bd..d2f043987e 100644 --- a/fdbclient/ReadYourWrites.h +++ b/fdbclient/ReadYourWrites.h @@ -42,6 +42,7 @@ struct ReadYourWritesTransactionOptions { double timeoutInSeconds; int maxRetries; int snapshotRywEnabled; + bool bypassUnreadable : 1; ReadYourWritesTransactionOptions() {} explicit ReadYourWritesTransactionOptions(Transaction const& tr); diff --git a/fdbclient/SnapshotCache.h b/fdbclient/SnapshotCache.h index df389eb4ab..eabd289aee 100644 --- a/fdbclient/SnapshotCache.h +++ b/fdbclient/SnapshotCache.h @@ -203,6 +203,7 @@ public: bool is_empty_range() const { return type() == EMPTY_RANGE; } bool is_dependent() const { return false; } bool is_unreadable() const { return false; } + void bypassUnreadableProtection() {} ExtStringRef beginKey() const { if (offset == 0) { diff --git a/fdbclient/vexillographer/fdb.options b/fdbclient/vexillographer/fdb.options index c6a4a9749c..9e09062234 100644 --- a/fdbclient/vexillographer/fdb.options +++ b/fdbclient/vexillographer/fdb.options @@ -192,6 +192,9 @@ description is not currently required but encouraged. description="Enable tracing for all transactions. This is the default." />