Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TransactionDBImpl #2689

Closed

Conversation

maysamyabandeh
Copy link
Contributor

This opens space for the new implementations of TransactionDBImpl such as WritePreparedTxnDBImpl that has a different policy of how to write to DB.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -122,5 +123,39 @@ class TransactionDBImpl : public TransactionDB {
std::unordered_map<TransactionName, Transaction*> transactions_;
};

class WriteCommittedTxnDBImpl : public PessimisticTxnDB {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why do we say WriteCommittedTxnDBImpl instead of WriteCommittedTxnDB
I guess we should not if there is not a WriteCommittedTxnDB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I will drop "Impl"

@@ -122,5 +123,39 @@ class TransactionDBImpl : public TransactionDB {
std::unordered_map<TransactionName, Transaction*> transactions_;
};

class WriteCommittedTxnDBImpl : public PessimisticTxnDB {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think these two classes need some comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -21,8 +21,8 @@

namespace rocksdb {

TransactionDBImpl::TransactionDBImpl(DB* db,
const TransactionDBOptions& txn_db_options)
PessimisticTxnDB::PessimisticTxnDB(DB* db,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename the files if we rename the classes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Transaction* old_txn) override;
};

class WritePreparedTxnDBImpl : public PessimisticTxnDB {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -27,7 +27,7 @@ struct LockMap;
struct LockMapStripe;

class Slice;
class TransactionDBImpl;
class PessimisticTxnDB;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the decision to use PessimisticTxn was already taken in a different PR, but I would suggest to be consistent with the existing name which is OptimisticTransaction

so I would suggest using PessimisticTransaction and PessimisticTransactionDB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transaction makes the name child classes too long. I can change PessimisticTransaction to PessimisticTxn though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though I like the longer name more :D I am fine with both names as long as we are consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah it became difficult. OptimisticTransactionDB is in the include so we cannot rename it.
How about renaming PessimisticTxn to PessimisticTransaction but keep the short Txn for its children?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I applied the last suggestion.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@yiwu-arbug yiwu-arbug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will leave to @IslamAbdelRahman to approve.

@@ -115,7 +115,7 @@ TransactionLockMgr::TransactionLockMgr(
mutex_factory_(mutex_factory) {
assert(txn_db);
txn_db_impl_ =
static_cast_with_check<TransactionDBImpl, TransactionDB>(txn_db);
static_cast_with_check<PessimisticTxnDB, TransactionDB>(txn_db);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess multiple of places have PessimisticTxnDB instead of PessimisticTransactionDB
I think we will hit a compilation error

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants