MySQL 26.7.0
Source Code Documentation
ib::redo Namespace Reference

Classes

struct  Const_buffers
 
class  Handler
 
class  Handler_interface
 This Redo Log Handler interface provides an abstraction over the redo log persistence and publishing of the redo log records. More...
 
class  Mtr_view
 This class represents a list of parsed redo records that form an mtr. More...
 
struct  Page_handle
 The handle that represents the page where redo log records are applied. More...
 
class  Page_handle_wrapper
 A convenience wrapper over the Page_handle (where redo log records are applied). More...
 
class  Parse_error
 Parse error description. More...
 
struct  Record_handle
 The handle that represents a log record. More...
 
class  Record_view
 This class represents a parsed redo record. More...
 
class  Redo_applier
 This class allows to parse and apply redo records. More...
 
class  Sys_var_handler
 This class implements the handling of redo log related system variables. More...
 

Typedefs

using Lsn = uint64_t
 
using Buffer = std::span< uint8_t >
 
using Const_buffer = std::span< const uint8_t >
 
using Record_list = std::vector< Record_view >
 
template<typename T >
using Parse_result = ut::Expected< T, Parse_error >
 

Enumerations

enum class  Status {
  SUCCESS = 0 , STREAM_END , LOG_ALREADY_EXISTS , NO_LOG ,
  COULD_NOT_CREATE , COULD_NOT_OPEN , ALREADY_TRUNCATED , WRONG_START_LSN ,
  WRONG_STATE , READ_ERROR , WRITE_ERROR , NOT_WRITTEN_YET ,
  FLUSH_ERROR , METADATA_IS_MISSING , WRITE_METADATA_ERROR , INCONSISTENT ,
  COULD_NOT_RESIZE , TORN_STREAM_END
}
 Additional error constants may be added to the list here, keeping in mind the following guidelines about our approach to error handling: More...
 
enum  Metadata_key : uint16_t { HEADER = 0 , CHECKPOINT }
 The type of metadata that could be handled by the handler. More...
 

Functions

void must_succeed (Status res, const ut::Location &loc)
 
void must_persist_all (const ut::Location &loc, Handler_interface::Durability desired_guarantee=Handler_interface::Durability::FULLY_PERSISTED)
 
static sn_t log_concurrency_margin (const size_t max_threads, const size_t reserved_bytes_per_thread, lsn_t log_capacity, bool &is_safe)
 Computes concurrency margin to be used within log_free_check calls, for a given redo log capacity (soft_logical_capacity). More...
 
Allocation and deallocation of log_sys
void set_handler (Handler_interface *handler)
 Sets the concrete Redo Log Handler to be used. More...
 

Variables

Handler_interfacehandler {}
 

Typedef Documentation

◆ Buffer

using ib::redo::Buffer = typedef std::span<uint8_t>

◆ Const_buffer

using ib::redo::Const_buffer = typedef std::span<const uint8_t>

◆ Lsn

using ib::redo::Lsn = typedef uint64_t

◆ Parse_result

template<typename T >
using ib::redo::Parse_result = typedef ut::Expected<T, Parse_error>

◆ Record_list

using ib::redo::Record_list = typedef std::vector<Record_view>

Enumeration Type Documentation

◆ Metadata_key

enum ib::redo::Metadata_key : uint16_t

The type of metadata that could be handled by the handler.

Enumerator
HEADER 
CHECKPOINT 

◆ Status

enum class ib::redo::Status
strong

Additional error constants may be added to the list here, keeping in mind the following guidelines about our approach to error handling:

  1. If there's an error which looks like a violation of a contract between the caller and the Redo Log Handler explained in this documentation - for example: passing end_lsn smaller than start_lsn to read(..start_lsn,end_lsn,..) - then it should result in a crash (assertion failure) rather than an error, as such bugs should be handled at implementation stage, not at runtime.
  2. Errors should be used for situations which reasonably could not be expected and prevented by the caller, but are rather caused by particular situation at runtime: for example trying to write beyond current capacity may be an effect of not being aware that somebody has changed the capacity.
  3. We acknowledge the gray area between these two. When in doubt, by default return an error. Use assertions for things we are sure are bugs in code.
  4. We should keep the number of Error constants not too large and not too small. We should ask ourselves if the caller can really perform two distinct actions in response to two different errors - if the caller doesn't really care then it seems better to not introduce the distinction.
  5. For human-readable logging, the Redo Log Handler might internally distinguish various narrow conditions and report them in different ways. But the Error codes here are meant for the caller, not the human operator. So, always ask yourself if the code which uses the API really understands the concept the error is about and can react to it. While the user may care that a given cloud bucket is unreachable, as opposed to having wrong authentication token, what the code really cares about is that it was a READ_ERROR.
  6. If there is a violation of some code invariant (like it was detected that an in-memory data structure pointer is null) it should be an assertion failure and crash, as opposed to trying to communicate it to the caller.
  7. In future we might want to distinguish between transient errors (for which the caller might want to attempt retrying) and permanent errors. For now we implicitly assume that all are transient, as otherwise there would be no point in reporting them - caller would need to crash/stop anyway. This will evolve as we understand better each and every case.
  8. There's just one SUCCESS value and it is 0. So, for example if a function may succeed in several ways, these should be conveyed by additional output argument, so that the error handling pattern is always the same: non-zero value means a problem.
  9. Same error constant may be used by multiple functions if the name seems to fit. (If we ever revisit this, then perhaps we should also have one enum per function).
Enumerator
SUCCESS 
STREAM_END 
LOG_ALREADY_EXISTS 
NO_LOG 
COULD_NOT_CREATE 
COULD_NOT_OPEN 
ALREADY_TRUNCATED 
WRONG_START_LSN 
WRONG_STATE 
READ_ERROR 
WRITE_ERROR 
NOT_WRITTEN_YET 
FLUSH_ERROR 
METADATA_IS_MISSING 
WRITE_METADATA_ERROR 
INCONSISTENT 
COULD_NOT_RESIZE 
TORN_STREAM_END 

Function Documentation

◆ log_concurrency_margin()

static sn_t ib::redo::log_concurrency_margin ( const size_t  max_threads,
const size_t  reserved_bytes_per_thread,
lsn_t  log_capacity,
bool &  is_safe 
)
static

Computes concurrency margin to be used within log_free_check calls, for a given redo log capacity (soft_logical_capacity).

Parameters
[in,out]max_threadsThe maximum number of concurrently existing threads which use redo-logged mtrs (call write_mtr).
[in]reserved_bytes_per_threadThe maximum number of bytes a thread can pass to write_mtr, before calling wait_for_space() again.
[in]log_capacityredo log capacity (soft)
[out]is_safetrue iff the computed margin wasn't truncated because of too small log_capacity
Returns
the computed margin

◆ must_persist_all()

void ib::redo::must_persist_all ( const ut::Location loc,
Handler_interface::Durability  desired_guarantee = Handler_interface::Durability::FULLY_PERSISTED 
)
inline

◆ must_succeed()

void ib::redo::must_succeed ( Status  res,
const ut::Location loc 
)
inline

◆ set_handler()

void ib::redo::set_handler ( Handler_interface handler)

Sets the concrete Redo Log Handler to be used.

Parameters
[in]handlerA Redo Log Handler Object

Variable Documentation

◆ handler

ib::redo::Handler_interface * ib::redo::handler {}
extern