From d69fda1d2ec866f9d27b84596794e59e0ce3d7be Mon Sep 17 00:00:00 2001
From: Andrew Noyes <andrew.noyes@snowflake.com>
Date: Wed, 23 Jun 2021 14:33:41 -0700
Subject: [PATCH] Remove preinitializeOnForeignThread

---
 fdbclient/ISingleThreadTransaction.cpp | 4 +++-
 fdbclient/NativeAPI.actor.h            | 4 +---
 fdbclient/ReadYourWrites.actor.cpp     | 4 ----
 fdbclient/ReadYourWrites.h             | 2 --
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/fdbclient/ISingleThreadTransaction.cpp b/fdbclient/ISingleThreadTransaction.cpp
index 4a0b686540..a36f92fe9a 100644
--- a/fdbclient/ISingleThreadTransaction.cpp
+++ b/fdbclient/ISingleThreadTransaction.cpp
@@ -27,7 +27,6 @@
 ISingleThreadTransaction* ISingleThreadTransaction::allocateOnForeignThread(Type type) {
 	if (type == Type::RYW) {
 		auto tr = new ReadYourWritesTransaction;
-		tr->preinitializeOnForeignThread();
 		return tr;
 	} else if (type == Type::SIMPLE_CONFIG) {
 		auto tr = new SimpleConfigTransaction;
@@ -43,12 +42,15 @@ ISingleThreadTransaction* ISingleThreadTransaction::allocateOnForeignThread(Type
 void ISingleThreadTransaction::create(ISingleThreadTransaction* tr, Type type, Database db) {
 	switch (type) {
 	case Type::RYW:
+		dynamic_cast<ReadYourWritesTransaction*>(tr)->~ReadYourWritesTransaction();
 		new (tr) ReadYourWritesTransaction(db);
 		break;
 	case Type::SIMPLE_CONFIG:
+		dynamic_cast<SimpleConfigTransaction*>(tr)->~SimpleConfigTransaction();
 		new (tr) SimpleConfigTransaction(db);
 		break;
 	case Type::PAXOS_CONFIG:
+		dynamic_cast<PaxosConfigTransaction*>(tr)->~PaxosConfigTransaction();
 		new (tr) PaxosConfigTransaction(db);
 		break;
 	default:
diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h
index 043bcaf4f2..b0f589e97a 100644
--- a/fdbclient/NativeAPI.actor.h
+++ b/fdbclient/NativeAPI.actor.h
@@ -241,8 +241,6 @@ public:
 	explicit Transaction(Database const& cx);
 	~Transaction();
 
-	void preinitializeOnForeignThread() { committedVersion = invalidVersion; }
-
 	void setVersion(Version v);
 	Future<Version> getReadVersion() { return getReadVersion(0); }
 	Future<Version> getRawReadVersion();
@@ -418,7 +416,7 @@ private:
 	Database cx;
 
 	double backoff;
-	Version committedVersion;
+	Version committedVersion{ invalidVersion };
 	CommitTransactionRequest tr;
 	Future<Version> readVersion;
 	Promise<Optional<Value>> metadataVersion;
diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp
index 4db07f527b..8b0ef80754 100644
--- a/fdbclient/ReadYourWrites.actor.cpp
+++ b/fdbclient/ReadYourWrites.actor.cpp
@@ -1729,10 +1729,6 @@ void ReadYourWritesTransaction::getWriteConflicts(KeyRangeMap<bool>* result) {
 	}
 }
 
-void ReadYourWritesTransaction::preinitializeOnForeignThread() {
-	tr.preinitializeOnForeignThread();
-}
-
 void ReadYourWritesTransaction::setTransactionID(uint64_t id) {
 	tr.setTransactionID(id);
 }
diff --git a/fdbclient/ReadYourWrites.h b/fdbclient/ReadYourWrites.h
index 65bb972da9..4f4827792d 100644
--- a/fdbclient/ReadYourWrites.h
+++ b/fdbclient/ReadYourWrites.h
@@ -153,8 +153,6 @@ public:
 
 	void getWriteConflicts(KeyRangeMap<bool>* result) override;
 
-	void preinitializeOnForeignThread();
-
 	Database getDatabase() const { return tr.getDatabase(); }
 
 	const TransactionInfo& getTransactionInfo() const { return tr.info; }