-
Notifications
You must be signed in to change notification settings - Fork 623
Read-Only TxnContext Interface; Read-Only (single-statement select, txn) optimizations #1402
base: master
Are you sure you want to change the base?
Changes from 7 commits
50411cb
e506f17
e0a9348
8b1531b
467834c
b2612aa
3395f6c
5711dc2
6787337
bd5ac57
9adeccb
2c7cf9e
9f8acef
c8e14f6
0fa4b3d
9b29a4c
5739f18
61fd663
ec4c796
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,10 +171,9 @@ void TimestampOrderingTransactionManager::YieldOwnership( | |
tile_group_header->SetTransactionId(tuple_id, INITIAL_TXN_ID); | ||
} | ||
|
||
bool TimestampOrderingTransactionManager::PerformRead(TransactionContext *const current_txn, | ||
const ItemPointer &read_location, | ||
storage::TileGroupHeader *tile_group_header, | ||
bool acquire_ownership) { | ||
bool TimestampOrderingTransactionManager::PerformRead( | ||
TransactionContext *const current_txn, const ItemPointer &read_location, | ||
storage::TileGroupHeader *tile_group_header, bool acquire_ownership) { | ||
ItemPointer location = read_location; | ||
|
||
////////////////////////////////////////////////////////// | ||
|
@@ -374,7 +373,8 @@ void TimestampOrderingTransactionManager::PerformInsert( | |
oid_t tuple_id = location.offset; | ||
|
||
auto storage_manager = storage::StorageManager::GetInstance(); | ||
auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
auto tile_group_header = | ||
storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
auto transaction_id = current_txn->GetTransactionId(); | ||
|
||
// check MVCC info | ||
|
@@ -420,9 +420,8 @@ void TimestampOrderingTransactionManager::PerformUpdate( | |
// version. | ||
PELOTON_ASSERT(tile_group_header->GetTransactionId(old_location.offset) == | ||
transaction_id); | ||
PELOTON_ASSERT( | ||
tile_group_header->GetPrevItemPointer(old_location.offset).IsNull() == | ||
true); | ||
PELOTON_ASSERT(tile_group_header->GetPrevItemPointer(old_location.offset) | ||
.IsNull() == true); | ||
|
||
// check whether the new version is empty. | ||
PELOTON_ASSERT(new_tile_group_header->GetTransactionId(new_location.offset) == | ||
|
@@ -529,9 +528,8 @@ void TimestampOrderingTransactionManager::PerformDelete( | |
PELOTON_ASSERT(tile_group_header->GetTransactionId(old_location.offset) == | ||
transaction_id); | ||
// we must be deleting the latest version. | ||
PELOTON_ASSERT( | ||
tile_group_header->GetPrevItemPointer(old_location.offset).IsNull() == | ||
true); | ||
PELOTON_ASSERT(tile_group_header->GetPrevItemPointer(old_location.offset) | ||
.IsNull() == true); | ||
|
||
// check whether the new version is empty. | ||
PELOTON_ASSERT(new_tile_group_header->GetTransactionId(new_location.offset) == | ||
|
@@ -588,7 +586,8 @@ void TimestampOrderingTransactionManager::PerformDelete( | |
oid_t tuple_id = location.offset; | ||
|
||
auto storage_manager = storage::StorageManager::GetInstance(); | ||
auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
auto tile_group_header = | ||
storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
|
||
PELOTON_ASSERT(tile_group_header->GetTransactionId(tuple_id) == | ||
current_txn->GetTransactionId()); | ||
|
@@ -624,6 +623,14 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( | |
//// handle other isolation levels | ||
////////////////////////////////////////////////////////// | ||
|
||
auto &rw_set = current_txn->GetReadWriteSet(); | ||
|
||
// if no modifying queries, treat as read-only | ||
if (rw_set.empty()) { | ||
EndTransaction(current_txn); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
return ResultType::SUCCESS; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the transaction just drops an object, like an index? |
||
|
||
auto storage_manager = storage::StorageManager::GetInstance(); | ||
auto &log_manager = logging::LogManager::GetInstance(); | ||
|
||
|
@@ -632,7 +639,6 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( | |
// generate transaction id. | ||
cid_t end_commit_id = current_txn->GetCommitId(); | ||
|
||
auto &rw_set = current_txn->GetReadWriteSet(); | ||
auto &rw_object_set = current_txn->GetCreateDropSet(); | ||
|
||
auto gc_set = current_txn->GetGCSetPtr(); | ||
|
@@ -660,7 +666,8 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( | |
oid_t tile_group_id = item_ptr.block; | ||
oid_t tuple_slot = item_ptr.offset; | ||
|
||
auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
auto tile_group_header = | ||
storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
|
||
if (tuple_entry.second == RWType::READ_OWN) { | ||
// A read operation has acquired ownership but hasn't done any further | ||
|
@@ -811,7 +818,8 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction( | |
ItemPointer item_ptr = tuple_entry.first; | ||
oid_t tile_group_id = item_ptr.block; | ||
oid_t tuple_slot = item_ptr.offset; | ||
auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
auto tile_group_header = | ||
storage_manager->GetTileGroup(tile_group_id)->GetHeader(); | ||
|
||
if (tuple_entry.second == RWType::READ_OWN) { | ||
// A read operation has acquired ownership but hasn't done any further | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the implementation of the is_written_ flag in #1401 could we also check the is_written_ flag here? That would tell us if the RWSet is just reads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbutrovich I've tried changing it to use is_written_ instead of empty(), but I keep breaking on multi_granularity_access_test. Did you and/or @pervazea say something about SCAN being broken earlier?
In particular, I added an IsWritten() getter and the check became if (!current_txn->IsWritten()). Haven't been able to find the bug, for now, I'm leaving it as empty().