MySQL 8.4.2
Source Code Documentation
trx0sys.ic File Reference

Transaction system. More...

#include "data0type.h"
#include "srv0srv.h"
#include "trx0trx.h"
#include "mtr0log.h"
#include "my_dbug.h"

Typedefs

typedef byte trx_sysf_rseg_t
 

Functions

void trx_sys_write_max_trx_id (void)
 Writes the value of max_trx_id to the file based trx system header. More...
 
static bool trx_sys_hdr_page (const page_id_t &page_id)
 Checks if a page address is the trx sys header page. More...
 
static trx_sysf_ttrx_sysf_get (mtr_t *mtr)
 Gets a pointer to the transaction system header and x-latches its page. More...
 
static space_id_t trx_sysf_rseg_get_space (trx_sysf_t *sys_header, ulint slot, mtr_t *mtr)
 Gets the space of the nth rollback segment slot in the trx system file copy. More...
 
static page_no_t trx_sysf_rseg_get_page_no (trx_sysf_t *sys_header, ulint slot, mtr_t *mtr)
 Gets the page number of the nth rollback segment slot in the trx system header. More...
 
static void trx_sysf_rseg_set_space (trx_sysf_t *sys_header, ulint slot, space_id_t space, mtr_t *mtr)
 Sets the space id of the nth rollback segment slot in the trx system file copy. More...
 
static void trx_sysf_rseg_set_page_no (trx_sysf_t *sys_header, ulint slot, page_no_t page_no, mtr_t *mtr)
 Sets the page number of the nth rollback segment slot in the trx system header. More...
 
static void trx_write_trx_id (byte *ptr, trx_id_t id)
 Writes a trx id to an index page. More...
 
static trx_id_t trx_read_trx_id (const byte *ptr)
 Reads a trx id from an index page. More...
 
static trx_ttrx_rw_is_active (trx_id_t trx_id, bool do_ref_count)
 
trx_id_t trx_sys_get_trx_id_write_margin ()
 
trx_id_t trx_sys_allocate_trx_id_or_no ()
 Allocates a new transaction id or transaction number. More...
 
trx_id_t trx_sys_allocate_trx_id ()
 Allocates a new transaction id (for trx->id). More...
 
trx_id_t trx_sys_allocate_trx_no ()
 Allocates a new transaction number (for trx->no). More...
 
static trx_id_t trx_get_serialisation_min_trx_no (void)
 Reads trx->no up to which all transactions have been serialised. More...
 
trx_id_t trx_sys_get_next_trx_id_or_no ()
 Retrieves a next value that will be allocated if trx_sys_allocate_trx_id() or trx_sys_allocate_trx_id_trx_no() was called. More...
 
static bool trx_sys_need_rollback ()
 Determine if there are incomplete transactions in the system. More...
 
static void trx_sys_rw_trx_add (trx_t *trx)
 

Variables

constexpr uint32_t TRX_SYS_RSEG_SPACE = 0
 space where the segment header is placed; starting with MySQL/InnoDB 5.1.7, this is UNIV_UNDEFINED if the slot is unused More...
 
constexpr uint32_t TRX_SYS_RSEG_PAGE_NO = 4
 page number where the segment header is placed; this is FIL_NULL if the slot is unused More...
 
constexpr uint32_t TRX_SYS_RSEG_SLOT_SIZE = 8
 

Detailed Description

Transaction system.

Created 3/26/1996 Heikki Tuuri

Typedef Documentation

◆ trx_sysf_rseg_t

Function Documentation

◆ trx_get_serialisation_min_trx_no()

static trx_id_t trx_get_serialisation_min_trx_no ( void  )
inlinestatic

Reads trx->no up to which all transactions have been serialised.

Returns
minimum value which is still possibly not serialised

◆ trx_read_trx_id()

static trx_id_t trx_read_trx_id ( const byte ptr)
inlinestatic

Reads a trx id from an index page.

In case that the id size changes in some future version, this function should be used instead of mach_read_...

Returns
id
Parameters
ptrin: pointer to memory from where to read

◆ trx_rw_is_active()

static trx_t * trx_rw_is_active ( trx_id_t  trx_id,
bool  do_ref_count 
)
inlinestatic

◆ trx_sys_allocate_trx_id()

trx_id_t trx_sys_allocate_trx_id ( )
inline

Allocates a new transaction id (for trx->id).

Before calling, the trx_sys_mutex must be acquired.

Returns
new, allocated trx id

◆ trx_sys_allocate_trx_id_or_no()

trx_id_t trx_sys_allocate_trx_id_or_no ( )
inline

Allocates a new transaction id or transaction number.

Returns
new, allocated trx id or trx no

◆ trx_sys_allocate_trx_no()

trx_id_t trx_sys_allocate_trx_no ( )
inline

Allocates a new transaction number (for trx->no).

Before calling, the trx_sys_serialisation_mutex must be acquired.

Returns
new, allocated trx no

◆ trx_sys_get_next_trx_id_or_no()

trx_id_t trx_sys_get_next_trx_id_or_no ( )
inline

Retrieves a next value that will be allocated if trx_sys_allocate_trx_id() or trx_sys_allocate_trx_id_trx_no() was called.

Returns
the next trx->id or trx->no that will be allocated

◆ trx_sys_get_trx_id_write_margin()

trx_id_t trx_sys_get_trx_id_write_margin ( )
inline

◆ trx_sys_hdr_page()

static bool trx_sys_hdr_page ( const page_id_t page_id)
inlinestatic

Checks if a page address is the trx sys header page.

Parameters
[in]page_idpage id
Returns
true if trx sys header page

◆ trx_sys_need_rollback()

static bool trx_sys_need_rollback ( )
inlinestatic

Determine if there are incomplete transactions in the system.

Returns
whether incomplete transactions need rollback

◆ trx_sys_rw_trx_add()

static void trx_sys_rw_trx_add ( trx_t trx)
inlinestatic

◆ trx_sys_write_max_trx_id()

void trx_sys_write_max_trx_id ( void  )

Writes the value of max_trx_id to the file based trx system header.

◆ trx_sysf_get()

static trx_sysf_t * trx_sysf_get ( mtr_t mtr)
inlinestatic

Gets a pointer to the transaction system header and x-latches its page.

Returns
pointer to system header, page x-latched.
Parameters
mtrin: mtr

◆ trx_sysf_rseg_get_page_no()

static page_no_t trx_sysf_rseg_get_page_no ( trx_sysf_t sys_header,
ulint  slot,
mtr_t mtr 
)
inlinestatic

Gets the page number of the nth rollback segment slot in the trx system header.

Returns
page number, FIL_NULL if slot unused
Parameters
sys_headerin: trx system header
slotin: slot index == rseg id
mtrin: mtr

◆ trx_sysf_rseg_get_space()

static space_id_t trx_sysf_rseg_get_space ( trx_sysf_t sys_header,
ulint  slot,
mtr_t mtr 
)
inlinestatic

Gets the space of the nth rollback segment slot in the trx system file copy.

Returns
space id
Parameters
sys_headerin: trx sys header
slotin: slot index == rseg id
mtrin: mtr

◆ trx_sysf_rseg_set_page_no()

static void trx_sysf_rseg_set_page_no ( trx_sysf_t sys_header,
ulint  slot,
page_no_t  page_no,
mtr_t mtr 
)
inlinestatic

Sets the page number of the nth rollback segment slot in the trx system header.

Parameters
sys_headerin: trx sys header
slotin: slot index == rseg id
page_noin: page number, FIL_NULL if the slot is reset to unused
mtrin: mtr

◆ trx_sysf_rseg_set_space()

static void trx_sysf_rseg_set_space ( trx_sysf_t sys_header,
ulint  slot,
space_id_t  space,
mtr_t mtr 
)
inlinestatic

Sets the space id of the nth rollback segment slot in the trx system file copy.

Parameters
sys_headerin: trx sys file copy
slotin: slot index == rseg id
spacein: space id
mtrin: mtr

◆ trx_write_trx_id()

static void trx_write_trx_id ( byte ptr,
trx_id_t  id 
)
inlinestatic

Writes a trx id to an index page.

In case that the id size changes in some future version, this function should be used instead of mach_write_...

Parameters
ptrin: pointer to memory where written
idin: id

Variable Documentation

◆ TRX_SYS_RSEG_PAGE_NO

constexpr uint32_t TRX_SYS_RSEG_PAGE_NO = 4
constexpr

page number where the segment header is placed; this is FIL_NULL if the slot is unused

◆ TRX_SYS_RSEG_SLOT_SIZE

constexpr uint32_t TRX_SYS_RSEG_SLOT_SIZE = 8
constexpr

◆ TRX_SYS_RSEG_SPACE

constexpr uint32_t TRX_SYS_RSEG_SPACE = 0
constexpr

space where the segment header is placed; starting with MySQL/InnoDB 5.1.7, this is UNIV_UNDEFINED if the slot is unused