Zero  0.1.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
log_core Class Reference

#include <log_core.h>

Classes

struct  epoch
 

Public Types

enum  { SEGMENT_SIZE = 16384 * log_storage::BLOCK_SIZE }
 

Public Member Functions

 log_core (const sm_options &)
 
virtual ~log_core ()
 
rc_t init ()
 
rc_t insert (logrec_t &r, lsn_t *l=nullptr)
 
rc_t flush (const lsn_t &lsn, bool block=true, bool signal=true, bool *ret_flushed=nullptr)
 
rc_t flush_all (bool block=true)
 
rc_t compensate (const lsn_t &orig_lsn, const lsn_t &undo_lsn)
 
rc_t fetch (lsn_t &lsn, void *buf, lsn_t *nxt, const bool forward)
 
bool fetch_direct (lsn_t lsn, logrec_t *&lr, lsn_t &prev_lsn)
 
void shutdown ()
 
rc_t truncate ()
 
lsn_t curr_lsn () const
 
lsn_t durable_lsn () const
 
void start_flush_daemon ()
 
long segsize () const
 
void flush_daemon ()
 Log-flush daemon driver. More...
 
lsn_t flush_daemon_work (lsn_t old_mark)
 Flush unflushed-portion of log buffer. More...
 
rc_t load_fetch_buffers ()
 
void discard_fetch_buffers (partition_number_t recycled=std::numeric_limits< partition_number_t >::max())
 
string make_log_name (uint32_t p)
 
log_storageget_storage ()
 
PoorMansOldestLsnTrackerget_oldest_lsn_tracker ()
 
lsn_t get_oldest_active_lsn ()
 
unsigned get_page_img_compression ()
 

Static Public Member Functions

static lsn_t first_lsn (uint32_t pnum)
 

Static Public Attributes

static const std::string IMPL_NAME
 

Protected Types

enum  { invalid_fhdl = -1 }
 

Protected Member Functions

long start_byte () const
 
long end_byte () const
 
bool _should_group_commit (unsigned long write_size)
 

Protected Attributes

char * _buf
 
vector< char * > _fetch_buffers
 
uint32_t _fetch_buf_first
 
uint32_t _fetch_buf_last
 
lsn_t _fetch_buf_begin
 
lsn_t _fetch_buf_end
 
shared_ptr< fetch_buffer_loader_t_fetch_buf_loader
 
ticker_thread_t_ticker
 
lsn_t _curr_lsn
 
lsn_t _durable_lsn
 
log_storage_storage
 
PoorMansOldestLsnTracker_oldest_lsn_tracker
 
long _start
 
long _end
 
long _segsize
 
lsn_t _flush_lsn
 
tatas_lock _flush_lock
 
tatas_lock _comp_lock
 
mcs_lock _insert_lock
 
pthread_mutex_t _wait_flush_lock
 
pthread_cond_t _wait_cond
 
pthread_cond_t _flush_cond
 
bool _waiting_for_flush
 
flush_daemon_thread_t_flush_daemon
 
lintel::Atomic< bool > _shutting_down
 
lintel::Atomic< bool > _flush_daemon_running
 
ConsolidationArray_carray
 
size_t _group_commit_size
 
stopwatch_t _group_commit_timer
 Timer object to keep track of group commit timeout. More...
 
long _group_commit_timeout
 
unsigned _page_img_compression
 
bool directIO
 
epoch _buf_epoch
 
epoch _cur_epoch
 
epoch _old_epoch
 
void _acquire_buffer_space (CArraySlot *info, long size)
 
lsn_t _copy_to_buffer (logrec_t &rec, long pos, long size, CArraySlot *info)
 
bool _update_epochs (CArraySlot *info)
 
rc_t _join_carray (CArraySlot *&info, long &pos, int32_t size)
 
rc_t _leave_carray (CArraySlot *info, int32_t size)
 
void _copy_raw (CArraySlot *info, long &pos, const char *data, size_t size)
 

Member Enumeration Documentation

§ anonymous enum

anonymous enum
Enumerator
SEGMENT_SIZE 

§ anonymous enum

anonymous enum
protected
Enumerator
invalid_fhdl 

Constructor & Destructor Documentation

§ log_core()

log_core::log_core ( const sm_options options)

§ ~log_core()

log_core::~log_core ( )
virtual

Member Function Documentation

§ _should_group_commit()

bool log_core::_should_group_commit ( unsigned long  write_size)
protected

Returns true iff the given log write size, under the current group commit policy, qualifies for a log flush. If false, flush daemon will not flush its buffer but wait for the next invocation.

§ compensate()

rc_t log_core::compensate ( const lsn_t orig_lsn,
const lsn_t undo_lsn 
)

§ curr_lsn()

lsn_t log_core::curr_lsn ( ) const
inline

§ discard_fetch_buffers()

void log_core::discard_fetch_buffers ( partition_number_t  recycled = std::numeric_limits<partition_number_t>::max())

§ durable_lsn()

lsn_t log_core::durable_lsn ( ) const
inline

§ end_byte()

long log_core::end_byte ( ) const
inlineprotected

§ fetch()

rc_t log_core::fetch ( lsn_t lsn,
void *  buf,
lsn_t nxt,
const bool  forward 
)

§ fetch_direct()

bool log_core::fetch_direct ( lsn_t  lsn,
logrec_t *&  lr,
lsn_t prev_lsn 
)

§ first_lsn()

static lsn_t log_core::first_lsn ( uint32_t  pnum)
inlinestatic

§ flush()

rc_t log_core::flush ( const lsn_t lsn,
bool  block = true,
bool  signal = true,
bool *  ret_flushed = nullptr 
)

§ flush_all()

rc_t log_core::flush_all ( bool  block = true)
inline

§ flush_daemon()

void log_core::flush_daemon ( )

Log-flush daemon driver.

This method handles the wait/block of the daemon thread, and when awake, calls its main-work method, flush_daemon_work.

§ flush_daemon_work()

lsn_t log_core::flush_daemon_work ( lsn_t  old_mark)

Flush unflushed-portion of log buffer.

Parameters
[in]old_markDurable lsn from last flush. Flush records later than this.

This is the guts of the log daemon.

Flush the log buffer of any log records later than old_mark. The argument indicates what is already durable and these log records must not be duplicated on the disk.

Called by the log flush daemon. Protection from duplicate flushing is handled by the fact that we have only one log flush daemon.

Returns
Latest durable lsn resulting from this flush

§ get_oldest_active_lsn()

lsn_t log_core::get_oldest_active_lsn ( )

§ get_oldest_lsn_tracker()

PoorMansOldestLsnTracker* log_core::get_oldest_lsn_tracker ( )
inline

§ get_page_img_compression()

unsigned log_core::get_page_img_compression ( )
inline

§ get_storage()

log_storage* log_core::get_storage ( )
inline

§ init()

rc_t log_core::init ( )

§ insert()

rc_t log_core::insert ( logrec_t r,
lsn_t l = nullptr 
)

§ load_fetch_buffers()

rc_t log_core::load_fetch_buffers ( )

§ make_log_name()

string log_core::make_log_name ( uint32_t  p)
inline

§ segsize()

long log_core::segsize ( ) const
inline

§ shutdown()

void log_core::shutdown ( )

§ start_byte()

long log_core::start_byte ( ) const
inlineprotected

§ start_flush_daemon()

void log_core::start_flush_daemon ( )

§ truncate()

rc_t log_core::truncate ( )

Finish current log partition and start writing to a new one.

Member Data Documentation

§ _buf

char* log_core::_buf
protected

§ _comp_lock

tatas_lock log_core::_comp_lock
protected

§ _curr_lsn

lsn_t log_core::_curr_lsn
protected

§ _durable_lsn

lsn_t log_core::_durable_lsn
protected

§ _end

long log_core::_end
protected

§ _fetch_buf_begin

lsn_t log_core::_fetch_buf_begin
protected

§ _fetch_buf_end

lsn_t log_core::_fetch_buf_end
protected

§ _fetch_buf_first

uint32_t log_core::_fetch_buf_first
protected

§ _fetch_buf_last

uint32_t log_core::_fetch_buf_last
protected

§ _fetch_buf_loader

shared_ptr<fetch_buffer_loader_t> log_core::_fetch_buf_loader
protected

§ _fetch_buffers

vector<char*> log_core::_fetch_buffers
protected

Buffers for fetch operation – used during log analysis and single-page redo. One buffer is used for each partition. The number of partitions is specified by sm_log_fetch_buf_partitions

§ _flush_cond

pthread_cond_t log_core::_flush_cond
protected

§ _flush_daemon

flush_daemon_thread_t* log_core::_flush_daemon
protected

§ _flush_daemon_running

lintel::Atomic<bool> log_core::_flush_daemon_running
protected

§ _flush_lsn

lsn_t log_core::_flush_lsn
protected

§ _group_commit_size

size_t log_core::_group_commit_size
protected

Group commit: only flush log if the given amount of unflushed bytes is available in the log buffer. This makes sure that all log writes are of at least this size, unless the group commit timeout expires (see below).

§ _group_commit_timeout

long log_core::_group_commit_timeout
protected

Group commit timeout in miliseconds. The flush daemon will wait until the size above is reached before flushing. However, if it waits this long, it will flush whatever is in the log buffer, regardless of the write size.

§ _group_commit_timer

stopwatch_t log_core::_group_commit_timer
protected

Timer object to keep track of group commit timeout.

§ _insert_lock

mcs_lock log_core::_insert_lock
protected

Lock to protect threads acquiring their log buffer.

§ _oldest_lsn_tracker

PoorMansOldestLsnTracker* log_core::_oldest_lsn_tracker
protected

§ _page_img_compression

unsigned log_core::_page_img_compression
protected

Enables page-image compression in the log. For every N bytes of log generated for a page, a page_img_format log record is generated rather than a log record describing that individual update. This makes recovery of that page more efficient by pruning the chain of log records that must be applied during redo. If set to zero, page-image compression is turned off.

§ _segsize

long log_core::_segsize
protected

§ _shutting_down

lintel::Atomic<bool> log_core::_shutting_down
protected
Todo:
both of the below should become std::atomic_flag's at some time

§ _start

long log_core::_start
protected

§ _storage

log_storage* log_core::_storage
protected

§ _ticker

ticker_thread_t* log_core::_ticker
protected

§ _wait_cond

pthread_cond_t log_core::_wait_cond
protected

§ _wait_flush_lock

pthread_mutex_t log_core::_wait_flush_lock
protected

§ _waiting_for_flush

bool log_core::_waiting_for_flush
protected

§ directIO

bool log_core::directIO
protected

§ IMPL_NAME

const std::string log_core::IMPL_NAME
static

The documentation for this class was generated from the following files: