src/backend/logging/checkpoint/simple_checkpoint.cpp
// Only called when checkpoint has actual contents
Only called when checkpoint has actual contents
Only called when checkpoint has actual contents
void SimpleCheckpoint::Persist() {
  assert(checkpoint_file_);
  assert(records_.size() > 2);
  assert(checkpoint_file_fd_ != INVALID_FILE_DESCRIPTOR);
  LOG_INFO("Persisting %lu checkpoint entries", records_.size());
  for (auto record : records_) {
    assert(record);
    assert(record->GetMessageLength() > 0);
    fwrite(record->GetMessage(), sizeof(char), record->GetMessageLength(),
           checkpoint_file_);
  }
  int ret = fflush(checkpoint_file_);
  if (ret != 0) {
    LOG_ERROR("Error occured in fflush(%d)", ret);
  }
  ret = fsync(checkpoint_file_fd_);
  if (ret != 0) {
    LOG_ERROR("Error occured in fsync(%d)", ret);
  }
}
void SimpleCheckpoint :: Persist ( ) { assert ( checkpoint_file_ ) ; assert ( records_ . size ( ) > 2 ) ; assert ( checkpoint_file_fd_ != INVALID_FILE_DESCRIPTOR ) ; LOG_INFO ( " " , records_ . size ( ) ) ; for ( auto record : records_ ) { assert ( record ) ; assert ( record -> GetMessageLength ( ) > 0 ) ; fwrite ( record -> GetMessage ( ) , sizeof ( char ) , record -> GetMessageLength ( ) , checkpoint_file_ ) ; } int ret = fflush ( checkpoint_file_ ) ; if ( ret != 0 ) { LOG_ERROR ( " " , ret ) ; } ret = fsync ( checkpoint_file_fd_ ) ; if ( ret != 0 ) { LOG_ERROR ( " " , ret ) ; } }
Only called when checkpoint has actual contents
Only called when checkpoint has actual contents
// First, write all the record in the queue // Then, flush // Finally, sync