// Return false if the tuple's table (tile group) is dropped. // In such case, this recycled tuple can not be added to the recycled_list. // Since no one will use it any more, keeping track of it is useless. // Note that, if we drop a single tile group without dropping the whole table, // such assumption is problematic. bool GCManager::ResetTuple(const TupleMetadata &tuple_metadata) { auto &manager = catalog::Manager::GetInstance(); auto tile_group = manager.GetTileGroup(tuple_metadata.tile_group_id); // During the resetting, a table may deconstruct because of the DROP TABLE request if (tile_group == nullptr) { LOG_TRACE("Garbage tuple(%u, %u) in table %u no longer exists", tuple_metadata.tile_group_id, tuple_metadata.tuple_slot_id, tuple_metadata.table_id); return false; } // From now on, the tile group shared pointer is held by us // It's safe to set headers from now on. auto tile_group_header = tile_group->GetHeader(); // Reset the header tile_group_header->SetTransactionId(tuple_metadata.tuple_slot_id, INVALID_TXN_ID); tile_group_header->SetBeginCommitId(tuple_metadata.tuple_slot_id, MAX_CID); tile_group_header->SetEndCommitId(tuple_metadata.tuple_slot_id, MAX_CID); tile_group_header->SetPrevItemPointer(tuple_metadata.tuple_slot_id, INVALID_ITEMPOINTER); tile_group_header->SetNextItemPointer(tuple_metadata.tuple_slot_id, INVALID_ITEMPOINTER); PL_MEMSET( tile_group_header->GetReservedFieldRef(tuple_metadata.tuple_slot_id), 0, storage::TileGroupHeader::GetReservedSize()); LOG_TRACE("Garbage tuple(%u, %u) in table %u is reset", tuple_metadata.tile_group_id, tuple_metadata.tuple_slot_id, tuple_metadata.table_id); return true; }
bool TransactionLevelGCManager::ResetTuple(const ItemPointer &location) { auto &manager = catalog::Manager::GetInstance(); auto tile_group = manager.GetTileGroup(location.block).get(); auto tile_group_header = tile_group->GetHeader(); // Reset the header tile_group_header->SetTransactionId(location.offset, INVALID_TXN_ID); tile_group_header->SetBeginCommitId(location.offset, MAX_CID); tile_group_header->SetEndCommitId(location.offset, MAX_CID); tile_group_header->SetPrevItemPointer(location.offset, INVALID_ITEMPOINTER); tile_group_header->SetNextItemPointer(location.offset, INVALID_ITEMPOINTER); PL_MEMSET( tile_group_header->GetReservedFieldRef(location.offset), 0, storage::TileGroupHeader::GetReservedSize()); // Reclaim the varlen pool CheckAndReclaimVarlenColumns(tile_group, location.offset); LOG_TRACE("Garbage tuple(%u, %u) is reset", location.block, location.offset); return true; }