src/backend/gc/gc_manager.cpp
// GC for vacuum and cooperative schemes
GC for vacuum and cooperative schemes
GC for vacuum and cooperative schemes
void GCManager::PerformGC() {
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  auto max_cid = txn_manager.GetMaxCommittedCid();
  if (is_running_ == false) {
    LOG_INFO("returning");
    return;
  }
  for (size_t i = 0; i < max_tuples_per_gc; ++i) {
    TupleMetadata tuple_metadata;
    if (possibly_free_list_.TryPop(tuple_metadata) == false) {
      break;
    }
    if (max_cid == MAX_CID || tuple_metadata.tuple_end_cid <= max_cid) {
      RefurbishTuple(tuple_metadata);
    } else {
      possibly_free_list_.TryPush(tuple_metadata);
    }
  }  
}
void GCManager :: PerformGC ( ) { auto & txn_manager = concurrency :: TransactionManagerFactory :: GetInstance ( ) ; auto max_cid = txn_manager . GetMaxCommittedCid ( ) ; if ( is_running_ == false ) { LOG_INFO ( " " ) ; return ; } for ( size_t i = 0 ; i < max_tuples_per_gc ; ++ i ) { TupleMetadata tuple_metadata ; if ( possibly_free_list_ . TryPop ( tuple_metadata ) == false ) { break ; } if ( max_cid == MAX_CID || tuple_metadata . tuple_end_cid <= max_cid ) { RefurbishTuple ( tuple_metadata ) ; } else { possibly_free_list_ . TryPush ( tuple_metadata ) ; } } }
GC for vacuum and cooperative schemes
GC for vacuum and cooperative schemes
// Check if we can move anything from the possibly free list to the free list. // if GC is not running, return without doing anything // every time we garbage collect at most max_tuples_per_gc tuples. // if there's no more tuples in the queue, then break. // if there are no transactions running or if this tuple is not visible to // any of the running transactions // if a tuple can't be refurbished, add it back to the list. // end for