Remove ISingleThreadTransaction::getMutableDeferredError
This commit is contained in:
parent
331dd2e377
commit
28f923c087
|
@ -27,6 +27,10 @@
|
|||
#include "flow/FastRef.h"
|
||||
|
||||
class ISingleThreadTransaction : public ReferenceCounted<ISingleThreadTransaction> {
|
||||
protected:
|
||||
ISingleThreadTransaction() = default;
|
||||
ISingleThreadTransaction(Error const& deferredError) : deferredError(deferredError) {}
|
||||
|
||||
public:
|
||||
virtual ~ISingleThreadTransaction() = default;
|
||||
|
||||
|
@ -78,5 +82,5 @@ public:
|
|||
virtual void preinitializeOnForeignThread() = 0;
|
||||
|
||||
// Used by ThreadSafeTransaction for exceptions thrown in void methods
|
||||
virtual Error& getMutableDeferredError() = 0;
|
||||
Error deferredError;
|
||||
};
|
||||
|
|
|
@ -1282,8 +1282,8 @@ public:
|
|||
};
|
||||
|
||||
ReadYourWritesTransaction::ReadYourWritesTransaction(Database const& cx)
|
||||
: cache(&arena), writes(&arena), tr(cx), retries(0), approximateSize(0), creationTime(now()), commitStarted(false),
|
||||
options(tr), deferredError(cx->deferredError), versionStampFuture(tr.getVersionstamp()),
|
||||
: ISingleThreadTransaction(cx->deferredError), cache(&arena), writes(&arena), tr(cx), retries(0), approximateSize(0),
|
||||
creationTime(now()), commitStarted(false), options(tr), versionStampFuture(tr.getVersionstamp()),
|
||||
specialKeySpaceWriteMap(std::make_pair(false, Optional<Value>()), specialKeys.end) {
|
||||
std::copy(
|
||||
cx.getTransactionDefaults().begin(), cx.getTransactionDefaults().end(), std::back_inserter(persistentOptions));
|
||||
|
@ -2276,11 +2276,10 @@ void ReadYourWritesTransaction::operator=(ReadYourWritesTransaction&& r) noexcep
|
|||
}
|
||||
|
||||
ReadYourWritesTransaction::ReadYourWritesTransaction(ReadYourWritesTransaction&& r) noexcept
|
||||
: cache(std::move(r.cache)), writes(std::move(r.writes)), arena(std::move(r.arena)), reading(std::move(r.reading)),
|
||||
retries(r.retries), approximateSize(r.approximateSize), creationTime(r.creationTime),
|
||||
deferredError(std::move(r.deferredError)), timeoutActor(std::move(r.timeoutActor)),
|
||||
resetPromise(std::move(r.resetPromise)), commitStarted(r.commitStarted), options(r.options),
|
||||
transactionDebugInfo(r.transactionDebugInfo) {
|
||||
: ISingleThreadTransaction(std::move(r.deferredError)), cache(std::move(r.cache)), writes(std::move(r.writes)),
|
||||
arena(std::move(r.arena)), reading(std::move(r.reading)), retries(r.retries), approximateSize(r.approximateSize),
|
||||
creationTime(r.creationTime), timeoutActor(std::move(r.timeoutActor)), resetPromise(std::move(r.resetPromise)),
|
||||
commitStarted(r.commitStarted), options(r.options), transactionDebugInfo(r.transactionDebugInfo) {
|
||||
cache.arena = &arena;
|
||||
writes.arena = &arena;
|
||||
tr = std::move(r.tr);
|
||||
|
|
|
@ -144,16 +144,12 @@ public:
|
|||
// Throws before the lifetime of this transaction ends
|
||||
Future<Void> resetFuture() { return resetPromise.getFuture(); }
|
||||
|
||||
Error deferredError;
|
||||
|
||||
void checkDeferredError() override {
|
||||
tr.checkDeferredError();
|
||||
if (deferredError.code() != invalid_error_code)
|
||||
throw deferredError;
|
||||
}
|
||||
|
||||
Error& getMutableDeferredError() override { return deferredError; }
|
||||
|
||||
void getWriteConflicts(KeyRangeMap<bool>* result) override;
|
||||
|
||||
void preinitializeOnForeignThread() override;
|
||||
|
|
|
@ -30,7 +30,6 @@ class SimpleConfigTransactionImpl {
|
|||
Future<Version> version;
|
||||
ConfigTransactionInterface cti;
|
||||
int numRetries{ 0 };
|
||||
Error deferredError{ success() };
|
||||
bool committed{ false };
|
||||
|
||||
ACTOR static Future<Version> getReadVersion(SimpleConfigTransactionImpl* self) {
|
||||
|
@ -130,8 +129,6 @@ public:
|
|||
reset();
|
||||
}
|
||||
|
||||
Error& getMutableDeferredError() { return deferredError; }
|
||||
|
||||
}; // SimpleConfigTransactionImpl
|
||||
|
||||
Future<Version> SimpleConfigTransaction::getReadVersion() {
|
||||
|
@ -220,10 +217,6 @@ void SimpleConfigTransaction::getWriteConflicts(KeyRangeMap<bool>* result) {}
|
|||
|
||||
void SimpleConfigTransaction::preinitializeOnForeignThread() {}
|
||||
|
||||
Error& SimpleConfigTransaction::getMutableDeferredError() {
|
||||
return impl->getMutableDeferredError();
|
||||
}
|
||||
|
||||
SimpleConfigTransaction::SimpleConfigTransaction(ClusterConnectionString const& ccs)
|
||||
: impl(std::make_unique<SimpleConfigTransactionImpl>(ccs)) {}
|
||||
|
||||
|
|
|
@ -82,7 +82,4 @@ public:
|
|||
void getWriteConflicts(KeyRangeMap<bool>* result) override;
|
||||
void preinitializeOnForeignThread() override;
|
||||
void fullReset();
|
||||
|
||||
// Used by ThreadSafeTransaction for exceptions thrown in void methods
|
||||
Error& getMutableDeferredError() override;
|
||||
};
|
||||
|
|
|
@ -155,7 +155,7 @@ void ThreadSafeTransaction::cancel() {
|
|||
}
|
||||
|
||||
void ThreadSafeTransaction::setVersion(Version v) {
|
||||
onMainThreadVoid([tr = this->tr, v]() { tr->setVersion(v); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, v]() { tr->setVersion(v); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
ThreadFuture<Version> ThreadSafeTransaction::getReadVersion() {
|
||||
|
@ -244,32 +244,31 @@ ThreadFuture<Standalone<VectorRef<const char*>>> ThreadSafeTransaction::getAddre
|
|||
void ThreadSafeTransaction::addReadConflictRange(const KeyRangeRef& keys) {
|
||||
KeyRange r = keys;
|
||||
|
||||
onMainThreadVoid([tr = this->tr, r]() { tr->addReadConflictRange(r); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, r]() { tr->addReadConflictRange(r); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
void ThreadSafeTransaction::makeSelfConflicting() {
|
||||
onMainThreadVoid([tr = this->tr]() { tr->makeSelfConflicting(); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr]() { tr->makeSelfConflicting(); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
void ThreadSafeTransaction::atomicOp(const KeyRef& key, const ValueRef& value, uint32_t operationType) {
|
||||
Key k = key;
|
||||
Value v = value;
|
||||
|
||||
onMainThreadVoid([tr = this->tr, k, v, operationType]() { tr->atomicOp(k, v, operationType); },
|
||||
&tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, k, v, operationType]() { tr->atomicOp(k, v, operationType); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
void ThreadSafeTransaction::set(const KeyRef& key, const ValueRef& value) {
|
||||
Key k = key;
|
||||
Value v = value;
|
||||
|
||||
onMainThreadVoid([tr = this->tr, k, v]() { tr->set(k, v); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, k, v]() { tr->set(k, v); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
void ThreadSafeTransaction::clear(const KeyRangeRef& range) {
|
||||
KeyRange r = range;
|
||||
|
||||
onMainThreadVoid([tr = this->tr, r]() { tr->clear(r); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, r]() { tr->clear(r); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
void ThreadSafeTransaction::clear(const KeyRef& begin, const KeyRef& end) {
|
||||
|
@ -283,13 +282,13 @@ void ThreadSafeTransaction::clear(const KeyRef& begin, const KeyRef& end) {
|
|||
|
||||
tr->clear(KeyRangeRef(b, e));
|
||||
},
|
||||
&tr->getMutableDeferredError());
|
||||
&tr->deferredError);
|
||||
}
|
||||
|
||||
void ThreadSafeTransaction::clear(const KeyRef& key) {
|
||||
Key k = key;
|
||||
|
||||
onMainThreadVoid([tr = this->tr, k]() { tr->clear(k); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, k]() { tr->clear(k); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
ThreadFuture<Void> ThreadSafeTransaction::watch(const KeyRef& key) {
|
||||
|
@ -304,7 +303,7 @@ ThreadFuture<Void> ThreadSafeTransaction::watch(const KeyRef& key) {
|
|||
void ThreadSafeTransaction::addWriteConflictRange(const KeyRangeRef& keys) {
|
||||
KeyRange r = keys;
|
||||
|
||||
onMainThreadVoid([tr = this->tr, r]() { tr->addWriteConflictRange(r); }, &tr->getMutableDeferredError());
|
||||
onMainThreadVoid([tr = this->tr, r]() { tr->addWriteConflictRange(r); }, &tr->deferredError);
|
||||
}
|
||||
|
||||
ThreadFuture<Void> ThreadSafeTransaction::commit() {
|
||||
|
@ -337,7 +336,7 @@ void ThreadSafeTransaction::setOption(FDBTransactionOptions::Option option, Opti
|
|||
|
||||
// ThreadSafeTransaction is not allowed to do anything with options except pass them through to RYW.
|
||||
onMainThreadVoid([tr = this->tr, option, passValue]() { tr->setOption(option, passValue.contents()); },
|
||||
&tr->getMutableDeferredError());
|
||||
&tr->deferredError);
|
||||
}
|
||||
|
||||
ThreadFuture<Void> ThreadSafeTransaction::checkDeferredError() {
|
||||
|
@ -345,7 +344,7 @@ ThreadFuture<Void> ThreadSafeTransaction::checkDeferredError() {
|
|||
try {
|
||||
tr->checkDeferredError();
|
||||
} catch (Error& e) {
|
||||
tr->getMutableDeferredError() = Error();
|
||||
tr->deferredError = Error();
|
||||
return Future<Void>(e);
|
||||
}
|
||||
return Future<Void>(Void());
|
||||
|
|
Loading…
Reference in New Issue