Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 6231d7f

Browse files
Fix memory leak when GC is turned off
1 parent fb4217d commit 6231d7f

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/concurrency/timestamp_ordering_transaction_manager.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,13 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
775775
gc_object_set->emplace_back(database_oid, table_oid, index_oid);
776776
}
777777

778-
// Call the GetIterator() function to explicitly lock the cuckoohash
779-
// and initilaize the iterator
780-
auto rw_set_lt = rw_set.GetConstIterator();
781-
782778
oid_t database_id = 0;
783779
if (static_cast<StatsType>(settings::SettingsManager::GetInt(settings::SettingId::stats_mode)) !=
784780
StatsType::INVALID) {
785781
if (!rw_set.IsEmpty()) {
782+
// Call the GetIterator() function to explicitly lock the cuckoohash
783+
// and initilaize the iterator
784+
auto rw_set_lt = rw_set.GetConstIterator();
786785
const auto tile_group_id = rw_set_lt.begin()->first.block;
787786
database_id = manager.GetTileGroup(tile_group_id)->GetDatabaseId();
788787
}
@@ -793,9 +792,10 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
793792
// 2. install an empty version for delete operations;
794793
// 3. install a new tuple for insert operations.
795794
// Iterate through each item pointer in the read write set
795+
796796
// TODO: This might be inefficient since we will have to get the
797797
// tile_group_header for each entry. Check if this needs to be consolidated
798-
for (const auto &tuple_entry : rw_set_lt) {
798+
for (const auto &tuple_entry : rw_set.GetConstIterator()) {
799799
ItemPointer item_ptr = tuple_entry.first;
800800
oid_t tile_group_id = item_ptr.block;
801801
oid_t tuple_slot = item_ptr.offset;
@@ -951,15 +951,13 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction(
951951
gc_object_set->emplace_back(database_oid, table_oid, index_oid);
952952
}
953953

954-
955-
// Call the GetIterator() function to explicitly lock the cuckoohash
956-
// and initilaize the iterator
957-
auto rw_set_lt = rw_set.GetConstIterator();
958-
959954
oid_t database_id = 0;
960955
if (static_cast<StatsType>(settings::SettingsManager::GetInt(settings::SettingId::stats_mode)) !=
961956
StatsType::INVALID) {
962957
if (!rw_set.IsEmpty()) {
958+
// Call the GetIterator() function to explicitly lock the cuckoohash
959+
// and initilaize the iterator
960+
auto rw_set_lt = rw_set.GetConstIterator();
963961
const auto tile_group_id = rw_set_lt.begin()->first.block;
964962
database_id = manager.GetTileGroup(tile_group_id)->GetDatabaseId();
965963
}
@@ -968,7 +966,7 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction(
968966
// Iterate through each item pointer in the read write set
969967
// TODO: This might be inefficient since we will have to get the
970968
// tile_group_header for each entry. Check if this needs to be consolidated
971-
for (const auto &tuple_entry : rw_set_lt) {
969+
for (const auto &tuple_entry : rw_set.GetConstIterator()) {
972970
ItemPointer item_ptr = tuple_entry.first;
973971
oid_t tile_group_id = item_ptr.block;
974972
oid_t tuple_slot = item_ptr.offset;

0 commit comments

Comments
 (0)