MySQL 8.0.39
Source Code Documentation
Logical_clock Class Reference

Logical timestamp generator for logical timestamping binlog transactions. More...

#include <rpl_trx_tracking.h>

Public Member Functions

 Logical_clock ()
 
 Logical_clock (const Logical_clock &other)
 
int64 step ()
 Steps the absolute value of the clock (state) to return an updated value. More...
 
int64 set_if_greater (int64 new_val)
 To try setting the clock forward. More...
 
int64 get_timestamp ()
 Atomically fetch the current state. More...
 
int64 get_offset ()
 
void update_offset (int64 new_offset)
 
 ~Logical_clock ()=default
 

Private Attributes

std::atomic< int64state
 
int64 offset
 

Detailed Description

Logical timestamp generator for logical timestamping binlog transactions.

A transaction is associated with two sequence numbers see Transaction_ctx::last_committed and Transaction_ctx::sequence_number. The class provides necessary interfaces including that of generating a next consecutive value for the latter.

Constructor & Destructor Documentation

◆ Logical_clock() [1/2]

Logical_clock::Logical_clock ( )

◆ Logical_clock() [2/2]

Logical_clock::Logical_clock ( const Logical_clock other)
inline

◆ ~Logical_clock()

Logical_clock::~Logical_clock ( )
default

Member Function Documentation

◆ get_offset()

int64 Logical_clock::get_offset ( )
inline

◆ get_timestamp()

int64 Logical_clock::get_timestamp ( )
inline

Atomically fetch the current state.

Returns
not subtracted "absolute" value.

◆ set_if_greater()

int64 Logical_clock::set_if_greater ( int64  new_val)
inline

To try setting the clock forward.

The clock does not change when the new value is in the past which is reflected by the new value and by offset. In other words the function main effects is described as state= max(state, new_value). Offset that exceeds the new value indicates the binary log rotation to render such new value useless.

Parameters
new_vala new value (offset included)
Returns
a (new) value of state member regardless whether it's changed or not.

◆ step()

int64 Logical_clock::step ( )
inline

Steps the absolute value of the clock (state) to return an updated value.

The caller must be sure to call the method in no concurrent execution context so either offset and state can't change.

Returns
incremented "absolute" value

◆ update_offset()

void Logical_clock::update_offset ( int64  new_offset)
inline

Member Data Documentation

◆ offset

int64 Logical_clock::offset
private

◆ state

std::atomic<int64> Logical_clock::state
private

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