MySQL 9.1.0
Source Code Documentation
ibuf0ibuf.cc File Reference

Insert buffer. More...

#include <sys/types.h>
#include "btr0sea.h"
#include "ha_prototypes.h"
#include "ibuf0ibuf.h"
#include "sync0sync.h"
#include <debug_sync.h>
#include "my_dbug.h"
#include "btr0btr.h"
#include "btr0cur.h"
#include "btr0pcur.h"
#include "buf0buf.h"
#include "buf0rea.h"
#include "dict0boot.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "fsp0sysspace.h"
#include "fut0lst.h"
#include "lock0lock.h"
#include "log0buf.h"
#include "log0chkp.h"
#include "log0recv.h"
#include "que0que.h"
#include "rem0cmp.h"
#include "rem0rec.h"
#include "row0upd.h"
#include "srv0start.h"
#include "trx0sys.h"

Variables

bool srv_ibuf_disable_background_merge
 
constexpr size_t IBUF_BITS_PER_PAGE = 4
 Number of bits describing a single page. More...
 
constexpr uint32_t IBUF_BITMAP = PAGE_DATA
 The start address for an insert buffer bitmap page bitmap. More...
 
ulong innodb_change_buffering = IBUF_USE_ALL
 Operations that can currently be buffered. More...
 
uint ibuf_debug
 Flag to control insert buffer debugging. More...
 
ibuf_tibuf = nullptr
 The insert buffer control structure. More...
 
constexpr uint32_t IBUF_REC_FIELD_SPACE = 0
 in the pre-4.1 format, the page number. More...
 
constexpr uint32_t IBUF_REC_FIELD_MARKER = 1
 starting with 4.1, a marker consisting of 1 byte that is 0 More...
 
constexpr uint32_t IBUF_REC_FIELD_PAGE = 2
 starting with 4.1, the page number More...
 
constexpr uint32_t IBUF_REC_FIELD_METADATA = 3
 the metadata field More...
 
constexpr uint32_t IBUF_REC_FIELD_USER = 4
 first user field More...
 
Offsets to the per-page bits in the insert buffer bitmap
constexpr uint32_t IBUF_BITMAP_FREE = 0
 Bits indicating the amount of free space. More...
 
constexpr uint32_t IBUF_BITMAP_BUFFERED = 2
 true if there are buffered changes for the page More...
 
constexpr uint32_t IBUF_BITMAP_IBUF = 3
 true if page is a part of the ibuf tree, excluding the root page, or is in the free list of the ibuf More...
 

Format of the IBUF_REC_FIELD_METADATA of an insert buffer record

The fourth column in the MySQL 5.5 format contains an operation type, counter, and some flags.

constexpr uint32_t IBUF_REC_INFO_SIZE = 4
 Combined size of info fields at the beginning of the fourth field. More...
 
constexpr uint32_t IBUF_REC_OFFSET_COUNTER = 0
 Operation counter. More...
 
constexpr uint32_t IBUF_REC_OFFSET_TYPE = 2
 Type of operation. More...
 
constexpr uint32_t IBUF_REC_OFFSET_FLAGS = 3
 Additional flags. More...
 
constexpr uint32_t IBUF_REC_COMPACT = 0x1
 Set in IBUF_REC_OFFSET_FLAGS if the user index is in COMPACT format or later. More...
 
static ib_mutex_t ibuf_pessimistic_insert_mutex
 The mutex used to block pessimistic inserts to ibuf trees. More...
 
static ib_mutex_t ibuf_mutex
 The mutex protecting the insert buffer structs. More...
 
static ib_mutex_t ibuf_bitmap_mutex
 The mutex protecting the insert buffer bitmaps. More...
 
const ulint IBUF_MERGE_AREA = 8
 The area in pages from which contract looks for page numbers for merge. More...
 
const ulint IBUF_MERGE_THRESHOLD = 4
 Inside the merge area, pages which have at most 1 per this number less buffered entries compared to maximum volume that can buffered for a single page are merged along with the page whose buffer became full. More...
 
const ulint IBUF_MAX_N_PAGES_MERGED = IBUF_MERGE_AREA
 In ibuf_contract at most this number of pages is read to memory in one batch, in order to merge the entries for them in the insert buffer. More...
 
const ulint IBUF_CONTRACT_ON_INSERT_NON_SYNC = 0
 If the combined size of the ibuf trees exceeds ibuf->max_size by this many pages, we start to contract it in connection to inserts there, using non-synchronous contract. More...
 
const ulint IBUF_CONTRACT_ON_INSERT_SYNC = 5
 If the combined size of the ibuf trees exceeds ibuf->max_size by this many pages, we start to contract it in connection to inserts there, using synchronous contract. More...
 
const ulint IBUF_CONTRACT_DO_NOT_INSERT = 10
 If the combined size of the ibuf trees exceeds ibuf->max_size by this many pages, we start to contract it synchronous contract, but do not insert. More...
 
static void ibuf_enter (mtr_t *mtr)
 Sets the flag in the current mini-transaction record indicating we're inside an insert buffer routine. More...
 
static void ibuf_exit (mtr_t *mtr)
 Sets the flag in the current mini-transaction record indicating we're exiting an insert buffer routine. More...
 
static void ibuf_btr_pcur_commit_specify_mtr (btr_pcur_t *pcur, mtr_t *mtr)
 Commits an insert buffer mini-transaction and sets the persistent cursor latch mode to BTR_NO_LATCHES, that is, detaches the cursor. More...
 
static page_tibuf_header_page_get (mtr_t *mtr)
 Gets the ibuf header page and x-latches it. More...
 
static page_tibuf_tree_root_get (mtr_t *mtr)
 Gets the root page and sx-latches it. More...
 
void ibuf_close (void)
 Closes insert buffer and frees the data structures. More...
 
static void ibuf_size_update (const page_t *root)
 Updates the size information of the ibuf, assuming the segment size has not changed. More...
 
void ibuf_init_at_db_start (void)
 Creates the insert buffer data structure at a database startup and initializes the data structures for the insert buffer. More...
 
void ibuf_max_size_update (ulint new_val)
 Updates the max_size value for ibuf. More...
 
void ibuf_bitmap_page_init (buf_block_t *block, mtr_t *mtr)
 Initializes an ibuf bitmap page. More...
 
const byteibuf_parse_bitmap_init (const byte *ptr, const byte *end_ptr, buf_block_t *block, mtr_t *mtr)
 Parses a redo log record of an ibuf bitmap page init. More...
 
static ulint ibuf_bitmap_page_get_bits_low (const page_t *page, const page_id_t &page_id, const page_size_t &page_size, ulint latch_type, mtr_t *mtr, ulint bit)
 Gets the desired bits for a given page from a bitmap page. More...
 
ulint ibuf_bitmap_page_get_bits (const page_t *page, const page_id_t &page_id, const page_size_t &page_size, ulint bit, mtr_t *mtr)
 Gets the desired bits for a given page from a bitmap page. More...
 
static void ibuf_bitmap_page_set_bits (page_t *page, const page_id_t &page_id, const page_size_t &page_size, ulint bit, ulint val, mtr_t *mtr)
 Sets the desired bit for a given page in a bitmap page. More...
 
static const page_id_t ibuf_bitmap_page_no_calc (const page_id_t &page_id, const page_size_t &page_size)
 Calculates the bitmap page number for a given page number. More...
 
static page_tibuf_bitmap_get_map_page (const page_id_t &page_id, const page_size_t &page_size, ut::Location location, mtr_t *mtr)
 Gets the ibuf bitmap page where the bits describing a given file page are stored. More...
 
static void ibuf_set_free_bits_low (const buf_block_t *block, ulint val, mtr_t *mtr)
 Sets the free bits of the page in the ibuf bitmap. More...
 
void ibuf_set_free_bits_func (buf_block_t *block, ulint val)
 Sets the free bit of the page in the ibuf bitmap. More...
 
void ibuf_reset_free_bits (buf_block_t *block)
 Resets the free bits of the page in the ibuf bitmap. More...
 
void ibuf_update_free_bits_low (const buf_block_t *block, ulint max_ins_size, mtr_t *mtr)
 Updates the free bits for an uncompressed page to reflect the present state. More...
 
void ibuf_update_free_bits_zip (buf_block_t *block, mtr_t *mtr)
 Updates the free bits for a compressed page to reflect the present state. More...
 
void ibuf_update_free_bits_for_two_pages_low (buf_block_t *block1, buf_block_t *block2, mtr_t *mtr)
 Updates the free bits for the two pages to reflect the present state. More...
 
static bool ibuf_fixed_addr_page (const page_id_t &page_id, const page_size_t &page_size)
 Returns true if the page is one of the fixed address ibuf pages. More...
 
bool ibuf_page_low (const page_id_t &page_id, const page_size_t &page_size, bool x_latch, ut::Location location, mtr_t *mtr)
 Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. More...
 
static page_no_t ibuf_rec_get_page_no_func (mtr_t *mtr, const rec_t *rec)
 Returns the page number field of an ibuf record. More...
 
static page_no_t ibuf_rec_get_page_no (mtr_t *mtr, const rec_t *rec)
 
static space_id_t ibuf_rec_get_space_func (mtr_t *mtr, const rec_t *rec)
 Returns the space id field of an ibuf record. More...
 
static space_id_t ibuf_rec_get_space (mtr_t *mtr, const rec_t *rec)
 
static void ibuf_rec_get_info_func (mtr_t *mtr, const rec_t *rec, ibuf_op_t *op, bool *comp, ulint *info_len, ulint *counter)
 Get various information about an ibuf record in >= 4.1.x format. More...
 
void ibuf_rec_get_info (mtr_t *mtr, const rec_t *rec, ibuf_op_t *op, bool *comp, ulint *info_len, ulint *counter)
 
static ibuf_op_t ibuf_rec_get_op_type_func (mtr_t *mtr, const rec_t *rec)
 Returns the operation type field of an ibuf record. More...
 
ibuf_op_t ibuf_rec_get_op_type (mtr_t *mtr, const rec_t *rec)
 
ulint ibuf_rec_get_counter (const rec_t *rec)
 Read the first two bytes from a record's fourth field (counter field in new records; something else in older records). More...
 
bool ibuf_rec_has_multi_value (const rec_t *rec)
 Determine if there is any multi-value field data on the change buffer record. More...
 
static void ibuf_add_ops (std::atomic< ulint > *arr, const ulint *ops)
 Add accumulated operation counts to a permanent array. More...
 
static void ibuf_print_ops (const std::atomic< ulint > *ops, FILE *file)
 Print operation counts. More...
 
static dict_index_tibuf_dummy_index_create (ulint n, bool comp)
 Creates a dummy index for inserting a record to a non-clustered index. More...
 
static void ibuf_dummy_index_add_col (dict_index_t *index, const dtype_t *type, ulint len)
 Add a column to the dummy index. More...
 
static void ibuf_dummy_index_free (dict_index_t *index)
 Deallocates a dummy index for inserting a record to a non-clustered index. More...
 
static dtuple_tibuf_build_entry_from_ibuf_rec_func (mtr_t *mtr, const rec_t *ibuf_rec, mem_heap_t *heap, dict_index_t **pindex)
 Builds the entry used to. More...
 
dtuple_tibuf_build_entry_from_ibuf_rec (mtr_t *mtr, const rec_t *ibuf_rec, mem_heap_t *heap, dict_index_t **pindex)
 
static ulint ibuf_rec_get_size (const rec_t *rec, const byte *types, ulint n_fields, bool comp)
 Get the data size. More...
 
static ulint ibuf_rec_get_volume_func (mtr_t *mtr, const rec_t *ibuf_rec)
 Returns the space taken by a stored non-clustered index entry if converted to an index record. More...
 
ulint ibuf_rec_get_volume (mtr_t *mtr, const rec_t *rec)
 
static dtuple_tibuf_entry_build (ibuf_op_t op, dict_index_t *index, const dtuple_t *entry, space_id_t space_id, page_no_t page_no, ulint counter, mem_heap_t *heap)
 Builds the tuple to insert to an ibuf tree when we have an entry for a non-clustered index. More...
 
static dtuple_tibuf_search_tuple_build (space_id_t space, page_no_t page_no, mem_heap_t *heap)
 Builds a search tuple used to search buffered inserts for an index page. More...
 
static bool ibuf_data_enough_free_for_insert (void)
 Checks if there are enough pages in the free list of the ibuf tree that we dare to start a pessimistic insert to the insert buffer. More...
 
static bool ibuf_data_too_much_free (void)
 Checks if there are enough pages in the free list of the ibuf tree that we should remove them and free to the file space management. More...
 
static bool ibuf_add_free_page (void)
 Allocates a new page from the ibuf file segment and adds it to the free list. More...
 
static void ibuf_remove_free_page (void)
 Removes a page from the free list and frees it to the fsp system. More...
 
void ibuf_free_excess_pages (void)
 Frees excess pages from the ibuf free list. More...
 
static ulint ibuf_get_merge_page_nos_func (bool contract, const rec_t *rec, mtr_t *mtr, space_id_t *space_ids, page_no_t *page_nos, ulint *n_stored)
 Reads page numbers from a leaf in an ibuf tree. More...
 
static const rec_tibuf_get_user_rec (btr_pcur_t *pcur, mtr_t *mtr)
 Get the matching records for space id. More...
 
ulint ibuf_get_merge_page_nos (bool contract, const rec_t *rec, mtr_t *mtr, space_id_t *ids, page_no_t *pages, ulint *n_stored)
 
static ulint ibuf_get_merge_pages (btr_pcur_t *pcur, space_id_t space, ulint limit, page_no_t *pages, space_id_t *spaces, ulint *n_pages, mtr_t *mtr)
 Reads page numbers for a space id from an ibuf tree. More...
 
static ulint ibuf_merge_pages (ulint *n_pages, bool sync)
 Contracts insert buffer trees by reading pages to the buffer pool. More...
 
ulint ibuf_merge_space (space_id_t space)
 Contracts insert buffer trees by reading pages referring to space_id to the buffer pool. More...
 
static ulint ibuf_merge (ulint *n_pages, bool sync)
 Contract the change buffer by reading pages to the buffer pool. More...
 
static ulint ibuf_contract (bool sync)
 Contract the change buffer by reading pages to the buffer pool. More...
 
ulint ibuf_merge_in_background (bool full)
 Contract the change buffer by reading pages to the buffer pool. More...
 
static void ibuf_contract_after_insert (ulint entry_size)
 Contract insert buffer trees after insert if they are too big. More...
 
static bool ibuf_get_volume_buffered_hash (const rec_t *rec, const byte *types, const byte *data, ulint comp, ulint *hash, ulint size)
 Determine if an insert buffer record has been encountered already. More...
 
static ulint ibuf_get_volume_buffered_count_func (mtr_t *mtr, const rec_t *rec, ulint *hash, ulint size, lint *n_recs)
 Update the estimate of the number of records on a page, and get the space taken by merging the buffered record to the index page. More...
 
static ulint ibuf_get_volume_buffered_count (mtr_t *mtr, const rec_t *rec, ulint *hash, ulint size, lint *n_recs)
 
static ulint ibuf_get_volume_buffered (const btr_pcur_t *pcur, space_id_t space_id, page_no_t page_no, lint *n_recs, mtr_t *mtr)
 Gets an upper limit for the combined size of entries buffered in the insert buffer for a given page. More...
 
void ibuf_update_max_tablespace_id (void)
 Reads the biggest tablespace id from the high end of the insert buffer tree and updates the counter in fil_system. More...
 
static ulint ibuf_get_entry_counter_low_func (mtr_t *mtr, const rec_t *rec, space_id_t space, page_no_t page_no)
 Helper function for ibuf_get_entry_counter_func. More...
 
static ulint ibuf_get_entry_counter_func (space_id_t space, page_no_t page_no, const rec_t *rec, mtr_t *mtr, bool only_leaf)
 Calculate the counter field for an entry based on the current last record in ibuf for (space, page_no). More...
 
ulint ibuf_get_entry_counter (space_id_t space, page_no_t page_no, const rec_t *rec, mtr_t *mtr, bool exact_leaf)
 
static dberr_t ibuf_insert_low (ulint mode, ibuf_op_t op, bool no_counter, const dtuple_t *entry, ulint entry_size, dict_index_t *index, const page_id_t &page_id, const page_size_t &page_size, que_thr_t *thr)
 Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible. More...
 
bool ibuf_insert (ibuf_op_t op, const dtuple_t *entry, dict_index_t *index, const page_id_t &page_id, const page_size_t &page_size, que_thr_t *thr)
 Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible. More...
 
static rec_tibuf_insert_to_index_page_low (const dtuple_t *entry, buf_block_t *block, dict_index_t *index, ulint **offsets, mem_heap_t *heap, mtr_t *mtr, page_cur_t *page_cur)
 During merge, inserts to an index page a secondary index entry extracted from the insert buffer. More...
 
static void ibuf_insert_to_index_page (const dtuple_t *entry, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
 
static void ibuf_set_del_mark (const dtuple_t *entry, buf_block_t *block, const dict_index_t *index, mtr_t *mtr)
 During merge, sets the delete mark on a record for a secondary index entry. More...
 
static void ibuf_delete (const dtuple_t *entry, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
 During merge, delete a record for a secondary index entry. More...
 
static bool ibuf_restore_pos (space_id_t space_id, page_no_t page_no, const dtuple_t *search_tuple, ulint mode, btr_pcur_t *pcur, mtr_t *mtr)
 Restores insert buffer tree cursor position. More...
 
static bool ibuf_delete_rec (space_id_t space, page_no_t page_no, btr_pcur_t *pcur, const dtuple_t *search_tuple, mtr_t *mtr)
 Deletes from ibuf the record on which pcur is positioned. More...
 
void ibuf_merge_or_delete_for_page (buf_block_t *block, const page_id_t &page_id, const page_size_t *page_size, bool update_ibuf_bitmap)
 When an index page is read from a disk to the buffer pool, this function applies any buffered operations to the page and deletes the entries from the insert buffer. More...
 
void ibuf_delete_for_discarded_space (space_id_t space)
 Deletes all entries in the insert buffer for a given space id. More...
 
bool ibuf_is_empty (void)
 Looks if the insert buffer is empty. More...
 
void ibuf_print (FILE *file)
 Prints info of ibuf. More...
 
dberr_t ibuf_check_bitmap_on_import (const trx_t *trx, space_id_t space_id)
 Checks the insert buffer bitmaps on IMPORT TABLESPACE. More...
 
void ibuf_set_bitmap_for_bulk_load (buf_block_t *block, bool reset)
 Updates free bits and buffered bits for bulk loaded page. More...
 

Detailed Description

Insert buffer.

Created 7/19/1997 Heikki Tuuri

Function Documentation

◆ ibuf_add_free_page()

static bool ibuf_add_free_page ( void  )
static

Allocates a new page from the ibuf file segment and adds it to the free list.

Returns
true on success, false if no space left

◆ ibuf_add_ops()

static void ibuf_add_ops ( std::atomic< ulint > *  arr,
const ulint ops 
)
static

Add accumulated operation counts to a permanent array.

Both arrays must be of size IBUF_OP_COUNT.

Parameters
arrin/out: array to modify
opsin: operation counts

◆ ibuf_bitmap_get_map_page()

static page_t * ibuf_bitmap_get_map_page ( const page_id_t page_id,
const page_size_t page_size,
ut::Location  location,
mtr_t mtr 
)
static

Gets the ibuf bitmap page where the bits describing a given file page are stored.

Parameters
[in]page_idPage id of the file page
[in]page_sizePage size of the file page
[in]locationLocation where called
[in,out]mtrMini-transaction
Returns
bitmap page where the file page is mapped, that is, the bitmap page containing the descriptor bits for the file page; the bitmap page is x-latched

◆ ibuf_bitmap_page_get_bits()

ulint ibuf_bitmap_page_get_bits ( const page_t page,
const page_id_t page_id,
const page_size_t page_size,
ulint  bit,
mtr_t mtr 
)
inline

Gets the desired bits for a given page from a bitmap page.

Parameters
[in]pageBitmap page
[in]page_idPage id whose bits to get
[in]page_sizePage id whose bits to get
[in]bitIBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ...
[in,out]mtrMini-transaction holding an x-latch on the bitmap page
Returns
value of bits

◆ ibuf_bitmap_page_get_bits_low()

static ulint ibuf_bitmap_page_get_bits_low ( const page_t page,
const page_id_t page_id,
const page_size_t page_size,
ulint  latch_type,
mtr_t mtr,
ulint  bit 
)
inlinestatic

Gets the desired bits for a given page from a bitmap page.

Parameters
[in]pageBitmap page
[in]page_idPage id whose bits to get
[in]page_sizePage size
[in]latch_typeMTR_MEMO_PAGE_X_FIX, MTR_MEMO_BUF_FIX, ...
[in,out]mtrMini-transaction holding latch_type on the bitmap page
[in]bitIBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ...
Returns
value of bits

◆ ibuf_bitmap_page_init()

void ibuf_bitmap_page_init ( buf_block_t block,
mtr_t mtr 
)

Initializes an ibuf bitmap page.

Parameters
blockin: bitmap page
mtrin: mtr

◆ ibuf_bitmap_page_no_calc()

static const page_id_t ibuf_bitmap_page_no_calc ( const page_id_t page_id,
const page_size_t page_size 
)
inlinestatic

Calculates the bitmap page number for a given page number.

Parameters
[in]page_idpage id
[in]page_sizepage size
Returns
the bitmap page id where the file page is mapped

◆ ibuf_bitmap_page_set_bits()

static void ibuf_bitmap_page_set_bits ( page_t page,
const page_id_t page_id,
const page_size_t page_size,
ulint  bit,
ulint  val,
mtr_t mtr 
)
static

Sets the desired bit for a given page in a bitmap page.

Parameters
[in,out]pagebitmap page
[in]page_idpage id whose bits to set
[in]page_sizepage size
[in]bitIBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ...
[in]valvalue to set
[in,out]mtrmtr containing an x-latch to the bitmap page

◆ ibuf_btr_pcur_commit_specify_mtr()

static void ibuf_btr_pcur_commit_specify_mtr ( btr_pcur_t pcur,
mtr_t mtr 
)
inlinestatic

Commits an insert buffer mini-transaction and sets the persistent cursor latch mode to BTR_NO_LATCHES, that is, detaches the cursor.

Parameters
pcurin/out: persistent cursor
mtrin/out: mini-transaction

◆ ibuf_build_entry_from_ibuf_rec()

dtuple_t * ibuf_build_entry_from_ibuf_rec ( mtr_t mtr,
const rec_t ibuf_rec,
mem_heap_t heap,
dict_index_t **  pindex 
)
inline

◆ ibuf_build_entry_from_ibuf_rec_func()

static dtuple_t * ibuf_build_entry_from_ibuf_rec_func ( mtr_t mtr,
const rec_t ibuf_rec,
mem_heap_t heap,
dict_index_t **  pindex 
)
static

Builds the entry used to.

1) IBUF_OP_INSERT: insert into a non-clustered index

2) IBUF_OP_DELETE_MARK: find the record whose delete-mark flag we need to activate

3) IBUF_OP_DELETE: find the record we need to delete

when we have the corresponding record in an ibuf index.

NOTE that as we copy pointers to fields in ibuf_rec, the caller must hold a latch to the ibuf_rec page as long as the entry is used!

Parameters
[in]mtrmini-transaction owning rec
[in]ibuf_recrecord in an insert buffer
[in]heapheap where built
[out]pindexown: dummy index that describes the entry
Returns
own: entry to insert to a non-clustered index

◆ ibuf_check_bitmap_on_import()

dberr_t ibuf_check_bitmap_on_import ( const trx_t trx,
space_id_t  space_id 
)

Checks the insert buffer bitmaps on IMPORT TABLESPACE.

Returns
DB_SUCCESS or error code
Parameters
trxin: transaction
space_idin: tablespace identifier

◆ ibuf_close()

void ibuf_close ( void  )

Closes insert buffer and frees the data structures.

◆ ibuf_contract()

static ulint ibuf_contract ( bool  sync)
static

Contract the change buffer by reading pages to the buffer pool.

Parameters
[in]syncwhether the caller waits for the issued reads to complete
Returns
a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty

◆ ibuf_contract_after_insert()

static void ibuf_contract_after_insert ( ulint  entry_size)
inlinestatic

Contract insert buffer trees after insert if they are too big.

Parameters
entry_sizein: size of a record which was inserted into an ibuf tree

◆ ibuf_data_enough_free_for_insert()

static bool ibuf_data_enough_free_for_insert ( void  )
inlinestatic

Checks if there are enough pages in the free list of the ibuf tree that we dare to start a pessimistic insert to the insert buffer.

Returns
true if enough free pages in list

◆ ibuf_data_too_much_free()

static bool ibuf_data_too_much_free ( void  )
inlinestatic

Checks if there are enough pages in the free list of the ibuf tree that we should remove them and free to the file space management.

Returns
true if enough free pages in list

◆ ibuf_delete()

static void ibuf_delete ( const dtuple_t entry,
buf_block_t block,
dict_index_t index,
mtr_t mtr 
)
static

During merge, delete a record for a secondary index entry.

Parameters
entryin: entry
blockin/out: block
indexin: record descriptor
mtrin/out: mtr; must be committed before latching any further pages

◆ ibuf_delete_for_discarded_space()

void ibuf_delete_for_discarded_space ( space_id_t  space)

Deletes all entries in the insert buffer for a given space id.

This is used in DISCARD TABLESPACE and IMPORT TABLESPACE. NOTE: this does not update the page free bitmaps in the space. The space will become CORRUPT when you call this function!

Parameters
spacein: space id

◆ ibuf_delete_rec()

static bool ibuf_delete_rec ( space_id_t  space,
page_no_t  page_no,
btr_pcur_t pcur,
const dtuple_t search_tuple,
mtr_t mtr 
)
static

Deletes from ibuf the record on which pcur is positioned.

If we have to resort to a pessimistic delete, this function commits mtr and closes the cursor.

Returns
true if mtr was committed and pcur closed in this operation
Parameters
spacein: space id
page_noin: index page number that the record should belong to
pcurin: pcur positioned on the record to delete, having latch mode BTR_MODIFY_LEAF
search_tuplein: search tuple for entries of page_no
mtrin: mtr

◆ ibuf_dummy_index_add_col()

static void ibuf_dummy_index_add_col ( dict_index_t index,
const dtype_t type,
ulint  len 
)
static

Add a column to the dummy index.

Parameters
indexin: dummy index
typein: the data type of the column
lenin: length of the column

◆ ibuf_dummy_index_create()

static dict_index_t * ibuf_dummy_index_create ( ulint  n,
bool  comp 
)
static

Creates a dummy index for inserting a record to a non-clustered index.

Returns
dummy index
Parameters
nin: number of fields
compin: true=use compact record format

◆ ibuf_dummy_index_free()

static void ibuf_dummy_index_free ( dict_index_t index)
static

Deallocates a dummy index for inserting a record to a non-clustered index.

Parameters
indexin, own: dummy index

◆ ibuf_enter()

static void ibuf_enter ( mtr_t mtr)
inlinestatic

Sets the flag in the current mini-transaction record indicating we're inside an insert buffer routine.

Parameters
mtrin/out: mini-transaction

◆ ibuf_entry_build()

static dtuple_t * ibuf_entry_build ( ibuf_op_t  op,
dict_index_t index,
const dtuple_t entry,
space_id_t  space_id,
page_no_t  page_no,
ulint  counter,
mem_heap_t heap 
)
static

Builds the tuple to insert to an ibuf tree when we have an entry for a non-clustered index.

NOTE that the original entry must be kept because we copy pointers to its fields.

Returns
own: entry to insert into an ibuf index tree
Parameters
opin: operation type
indexin: non-clustered index
entryin: entry for a non-clustered index
space_idin: space id
page_noin: index page number where entry should be inserted
counterin: counter value; ULINT_UNDEFINED=not used
heapin: heap into which to build

◆ ibuf_exit()

static void ibuf_exit ( mtr_t mtr)
inlinestatic

Sets the flag in the current mini-transaction record indicating we're exiting an insert buffer routine.

Parameters
mtrin/out: mini-transaction

◆ ibuf_fixed_addr_page()

static bool ibuf_fixed_addr_page ( const page_id_t page_id,
const page_size_t page_size 
)
inlinestatic

Returns true if the page is one of the fixed address ibuf pages.

Parameters
[in]page_idpage id
[in]page_sizepage size
Returns
true if a fixed address ibuf i/o page

◆ ibuf_free_excess_pages()

void ibuf_free_excess_pages ( void  )

Frees excess pages from the ibuf free list.

This function is called when an OS thread calls fsp services to allocate a new file segment, or a new page to a file segment, and the thread did not own the fsp latch before this call.

◆ ibuf_get_entry_counter()

ulint ibuf_get_entry_counter ( space_id_t  space,
page_no_t  page_no,
const rec_t rec,
mtr_t mtr,
bool  exact_leaf 
)
inline

◆ ibuf_get_entry_counter_func()

static ulint ibuf_get_entry_counter_func ( space_id_t  space,
page_no_t  page_no,
const rec_t rec,
mtr_t mtr,
bool  only_leaf 
)
static

Calculate the counter field for an entry based on the current last record in ibuf for (space, page_no).

Returns
the counter field, or ULINT_UNDEFINED if we should abort this insertion to ibuf
Parameters
[in]spacespace id of entry
[in]page_nopage number of entry
[in]recthe record preceding the insertion point
mtrmini-transaction
[in]only_leaftrue if this is the only leaf page that can contain entries for (space,page_no), that is, there was no exact match for (space,page_no) in the node pointer

◆ ibuf_get_entry_counter_low_func()

static ulint ibuf_get_entry_counter_low_func ( mtr_t mtr,
const rec_t rec,
space_id_t  space,
page_no_t  page_no 
)
static

Helper function for ibuf_get_entry_counter_func.

Checks if rec is for (space, page_no), and if so, reads counter value from it and returns that + 1.

Parameters
[in]mtrmini-transaction of rec
[in]recinsert buffer record
[in]spacespace id
[in]page_nopage number
Return values
ULINT_UNDEFINEDif the record does not contain any counter
0if the record is not for (space, page_no)
1+ previous counter value, otherwise

◆ ibuf_get_merge_page_nos()

ulint ibuf_get_merge_page_nos ( bool  contract,
const rec_t rec,
mtr_t mtr,
space_id_t ids,
page_no_t pages,
ulint n_stored 
)
inline

◆ ibuf_get_merge_page_nos_func()

static ulint ibuf_get_merge_page_nos_func ( bool  contract,
const rec_t rec,
mtr_t mtr,
space_id_t space_ids,
page_no_t page_nos,
ulint n_stored 
)
static

Reads page numbers from a leaf in an ibuf tree.

Parameters
[in]contracttrue if this function is called to contract the tree, false if this is called when a single page becomes full and we look if it pays to read also nearby pages
[in]recinsert buffer record
[in]mtrmini-transaction holding rec
[in,out]space_idsspace id's of the pages
[in,out]page_nosbuffer for at least IBUF_MAX_N_PAGES_MERGED many page numbers; the page numbers are in an ascending order
[out]n_storednumber of page numbers stored to page_nos in this function
Returns
a lower limit for the combined volume of records which will be merged

◆ ibuf_get_merge_pages()

static ulint ibuf_get_merge_pages ( btr_pcur_t pcur,
space_id_t  space,
ulint  limit,
page_no_t pages,
space_id_t spaces,
ulint n_pages,
mtr_t mtr 
)
static

Reads page numbers for a space id from an ibuf tree.

Returns
a lower limit for the combined volume of records which will be merged
Parameters
pcurin/out: cursor
spacein: space for which to merge
limitin: max page numbers to read
pagesout: pages read
spacesout: spaces read
n_pagesout: number of pages read
mtrin: mini-transaction

◆ ibuf_get_user_rec()

static const rec_t * ibuf_get_user_rec ( btr_pcur_t pcur,
mtr_t mtr 
)
static

Get the matching records for space id.

Returns
current rec or NULL
Parameters
pcurin: the current cursor
mtrin: mini-transaction

◆ ibuf_get_volume_buffered()

static ulint ibuf_get_volume_buffered ( const btr_pcur_t pcur,
space_id_t  space_id,
page_no_t  page_no,
lint n_recs,
mtr_t mtr 
)
static

Gets an upper limit for the combined size of entries buffered in the insert buffer for a given page.

Returns
upper limit for the volume of buffered inserts for the index page, in bytes; UNIV_PAGE_SIZE, if the entries for the index page span several pages in the insert buffer
Parameters
pcurin: pcur positioned at a place in an insert buffer tree where we would insert an entry for the index page whose number is page_no, latch mode has to be BTR_MODIFY_PREV or BTR_MODIFY_TREE
space_idin: space id
page_noin: page number of an index page
n_recsin/out: minimum number of records on the page after the buffered changes have been applied, or NULL to disable the counting
mtrin: mini-transaction of pcur

◆ ibuf_get_volume_buffered_count()

static ulint ibuf_get_volume_buffered_count ( mtr_t mtr,
const rec_t rec,
ulint hash,
ulint  size,
lint n_recs 
)
inlinestatic

◆ ibuf_get_volume_buffered_count_func()

static ulint ibuf_get_volume_buffered_count_func ( mtr_t mtr,
const rec_t rec,
ulint hash,
ulint  size,
lint n_recs 
)
static

Update the estimate of the number of records on a page, and get the space taken by merging the buffered record to the index page.

Parameters
[in]mtrmini-transaction owning rec
[in]recinsert buffer record
[in,out]hashhash array
[in]sizenumber of elements in hash array
[in,out]n_recsestimated number of records on the page that rec points to
Returns
size of index record in bytes + an upper limit of the space taken in the page directory

◆ ibuf_get_volume_buffered_hash()

static bool ibuf_get_volume_buffered_hash ( const rec_t rec,
const byte types,
const byte data,
ulint  comp,
ulint hash,
ulint  size 
)
static

Determine if an insert buffer record has been encountered already.

Returns
true if a new record, false if possible duplicate
Parameters
recin: ibuf record in post-4.1 format
typesin: fields
datain: start of user record data
compin: 0=ROW_FORMAT=REDUNDANT, nonzero=ROW_FORMAT=COMPACT
hashin/out: hash array
sizein: number of elements in hash array

◆ ibuf_header_page_get()

static page_t * ibuf_header_page_get ( mtr_t mtr)
static

Gets the ibuf header page and x-latches it.

Returns
insert buffer header page
Parameters
mtrin/out: mini-transaction

◆ ibuf_init_at_db_start()

void ibuf_init_at_db_start ( void  )

Creates the insert buffer data structure at a database startup and initializes the data structures for the insert buffer.

Creates the insert buffer data structure at a database startup.

◆ ibuf_insert()

bool ibuf_insert ( ibuf_op_t  op,
const dtuple_t entry,
dict_index_t index,
const page_id_t page_id,
const page_size_t page_size,
que_thr_t thr 
)

Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible.

Does not do it if the index is clustered or unique.

Parameters
[in]opoperation type
[in]entryindex entry to insert
[in,out]indexindex where to insert
[in]page_idpage id where to insert
[in]page_sizepage size
[in,out]thrquery thread
Returns
true if success

◆ ibuf_insert_low()

static dberr_t ibuf_insert_low ( ulint  mode,
ibuf_op_t  op,
bool  no_counter,
const dtuple_t entry,
ulint  entry_size,
dict_index_t index,
const page_id_t page_id,
const page_size_t page_size,
que_thr_t thr 
)
static

Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible.

Parameters
[in]modeBTR_MODIFY_PREV or BTR_MODIFY_TREE
[in]opoperation type
[in]no_countertrue=use 5.0.3 format; false=allow delete buffering
[in]entryindex entry to insert
[in]entry_sizerec_get_converted_size(index, entry)
[in,out]indexindex where to insert; must not be unique or clustered
[in]page_idpage id where to insert
[in]page_sizepage size
[in,out]thrquery thread
Returns
DB_SUCCESS, DB_STRONG_FAIL or other error

◆ ibuf_insert_to_index_page()

static void ibuf_insert_to_index_page ( const dtuple_t entry,
buf_block_t block,
dict_index_t index,
mtr_t mtr 
)
static
Parameters
entryin: buffered entry to insert
blockin/out: index page where the buffered entry should be placed
indexin: record descriptor
mtrin: mtr

◆ ibuf_insert_to_index_page_low()

static rec_t * ibuf_insert_to_index_page_low ( const dtuple_t entry,
buf_block_t block,
dict_index_t index,
ulint **  offsets,
mem_heap_t heap,
mtr_t mtr,
page_cur_t page_cur 
)
static

During merge, inserts to an index page a secondary index entry extracted from the insert buffer.

Returns
newly inserted record
Parameters
entryin: buffered entry to insert
blockin/out: index page where the buffered entry should be placed
indexin: record descriptor
offsetsout: offsets on *rec
heapin/out: memory heap
mtrin/out: mtr
page_curin/out: cursor positioned on the record after which to insert the buffered entry

◆ ibuf_is_empty()

bool ibuf_is_empty ( void  )

Looks if the insert buffer is empty.

Returns
true if empty

◆ ibuf_max_size_update()

void ibuf_max_size_update ( ulint  new_val)

Updates the max_size value for ibuf.

in: new value in terms of percentage of the buffer pool size

Parameters
new_valin: new value in terms of percentage of the buffer pool size

◆ ibuf_merge()

static ulint ibuf_merge ( ulint n_pages,
bool  sync 
)
static

Contract the change buffer by reading pages to the buffer pool.

Parameters
[out]n_pagesnumber of pages merged
[in]syncwhether the caller waits for the issued reads to complete
Returns
a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty

◆ ibuf_merge_in_background()

ulint ibuf_merge_in_background ( bool  full)

Contract the change buffer by reading pages to the buffer pool.

Parameters
[in]fullIf true, do a full contraction based on PCT_IO(100). If false, the size of contract batch is determined based on the current size of the change buffer.
Returns
a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty

◆ ibuf_merge_or_delete_for_page()

void ibuf_merge_or_delete_for_page ( buf_block_t block,
const page_id_t page_id,
const page_size_t page_size,
bool  update_ibuf_bitmap 
)

When an index page is read from a disk to the buffer pool, this function applies any buffered operations to the page and deletes the entries from the insert buffer.

If the page is not read, but created in the buffer pool, this function deletes its buffered entries from the insert buffer; there can exist entries for such a page if the page belonged to an index which subsequently was dropped.

Parameters
[in,out]blockif page has been read from disk, pointer to the page x-latched, else NULL
[in]page_idpage id of the index page
[in]update_ibuf_bitmapnormally this is set to true, but if we have deleted or are deleting the tablespace, then we naturally do not want to update a non-existent bitmap page
[in]page_sizepage size

◆ ibuf_merge_pages()

static ulint ibuf_merge_pages ( ulint n_pages,
bool  sync 
)
static

Contracts insert buffer trees by reading pages to the buffer pool.

Returns
a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty
Parameters
n_pagesout: number of pages to which merged
syncin: true if the caller wants to wait for the issued read with the highest tablespace address to complete

◆ ibuf_merge_space()

ulint ibuf_merge_space ( space_id_t  space)

Contracts insert buffer trees by reading pages referring to space_id to the buffer pool.

Returns
number of pages merged.
Parameters
spacein: tablespace id to merge

◆ ibuf_page_low()

bool ibuf_page_low ( const page_id_t page_id,
const page_size_t page_size,
bool  x_latch,
ut::Location  location,
mtr_t mtr 
)

Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.

Must not be called when recv_no_ibuf_operations==true.

Parameters
[in]page_idpage id
[in]page_sizepage size
[in]x_latchfalse if relaxed check (avoid latching the bitmap page)
[in]locationLocation where called
[in,out]mtrmtr which will contain an x-latch to the bitmap page if the page is not one of the fixed address ibuf pages, or NULL, in which case a new transaction is created.
Returns
true if level 2 or level 3 page

◆ ibuf_parse_bitmap_init()

const byte * ibuf_parse_bitmap_init ( const byte ptr,
const byte end_ptr,
buf_block_t block,
mtr_t mtr 
)

Parses a redo log record of an ibuf bitmap page init.

Parameters
[in]ptrBuffer.
[in]end_ptrBuffer end.
[in]blockBlock or nullptr.
[in]mtrMTR or nullptr.
Returns
end of log record or NULL

◆ ibuf_print()

void ibuf_print ( FILE *  file)

Prints info of ibuf.

in: file where to print

Parameters
filein: file where to print

◆ ibuf_print_ops()

static void ibuf_print_ops ( const std::atomic< ulint > *  ops,
FILE *  file 
)
static

Print operation counts.

The array must be of size IBUF_OP_COUNT.

Parameters
opsin: operation counts
filein: file where to print

◆ ibuf_rec_get_counter()

ulint ibuf_rec_get_counter ( const rec_t rec)

Read the first two bytes from a record's fourth field (counter field in new records; something else in older records).

in: ibuf record

Returns
"counter" field, or ULINT_UNDEFINED if for some reason it can't be read
Parameters
recin: ibuf record

◆ ibuf_rec_get_info()

void ibuf_rec_get_info ( mtr_t mtr,
const rec_t rec,
ibuf_op_t op,
bool *  comp,
ulint info_len,
ulint counter 
)
inline

◆ ibuf_rec_get_info_func()

static void ibuf_rec_get_info_func ( mtr_t mtr,
const rec_t rec,
ibuf_op_t op,
bool *  comp,
ulint info_len,
ulint counter 
)
static

Get various information about an ibuf record in >= 4.1.x format.

Parameters
[in]mtrMini-transaction owning rec, or nullptr if this is called from ibuf_rec_has_multi_value(). Because it's from page_validate() which doesn't have mtr at hand
[in]recIbuf record
[in,out]opOperation type, or NULL
[in,out]compCompact flag, or NULL
[in,out]info_lenLength of info fields at the start of the fourth field, or NULL
[in]counterCounter value, or NULL

◆ ibuf_rec_get_op_type()

ibuf_op_t ibuf_rec_get_op_type ( mtr_t mtr,
const rec_t rec 
)
inline

◆ ibuf_rec_get_op_type_func()

static ibuf_op_t ibuf_rec_get_op_type_func ( mtr_t mtr,
const rec_t rec 
)
static

Returns the operation type field of an ibuf record.

Parameters
[in]mtrmini-transaction owning rec
[in]recibuf record
Returns
operation type

◆ ibuf_rec_get_page_no()

static page_no_t ibuf_rec_get_page_no ( mtr_t mtr,
const rec_t rec 
)
inlinestatic

◆ ibuf_rec_get_page_no_func()

static page_no_t ibuf_rec_get_page_no_func ( mtr_t mtr,
const rec_t rec 
)
static

Returns the page number field of an ibuf record.

Parameters
[in]mtrmini-transaction owning rec
[in]recibuf record
Returns
page number

◆ ibuf_rec_get_size()

static ulint ibuf_rec_get_size ( const rec_t rec,
const byte types,
ulint  n_fields,
bool  comp 
)
inlinestatic

Get the data size.

Returns
size of fields
Parameters
recin: ibuf record
typesin: fields
n_fieldsin: number of fields
compin: 0=ROW_FORMAT=REDUNDANT, nonzero=ROW_FORMAT=COMPACT

◆ ibuf_rec_get_space()

static space_id_t ibuf_rec_get_space ( mtr_t mtr,
const rec_t rec 
)
inlinestatic

◆ ibuf_rec_get_space_func()

static space_id_t ibuf_rec_get_space_func ( mtr_t mtr,
const rec_t rec 
)
static

Returns the space id field of an ibuf record.

For < 4.1.x format records returns 0.

Parameters
[in]mtrmini-transaction owning rec
[in]recibuf record
Returns
space id

◆ ibuf_rec_get_volume()

ulint ibuf_rec_get_volume ( mtr_t mtr,
const rec_t rec 
)
inline

◆ ibuf_rec_get_volume_func()

static ulint ibuf_rec_get_volume_func ( mtr_t mtr,
const rec_t ibuf_rec 
)
static

Returns the space taken by a stored non-clustered index entry if converted to an index record.

Parameters
[in]mtrmini-transaction owning rec
[in]ibuf_recibuf record
Returns
size of index record in bytes + an upper limit of the space taken in the page directory

◆ ibuf_rec_has_multi_value()

bool ibuf_rec_has_multi_value ( const rec_t rec)

Determine if there is any multi-value field data on the change buffer record.

Parameters
[in]recibuf record
Returns
true if there is any multi-value field in the record

◆ ibuf_remove_free_page()

static void ibuf_remove_free_page ( void  )
static

Removes a page from the free list and frees it to the fsp system.

◆ ibuf_reset_free_bits()

void ibuf_reset_free_bits ( buf_block_t block)

Resets the free bits of the page in the ibuf bitmap.

This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to decrement or reset the bits in the bitmap in a mini-transaction that is committed before the mini-transaction that affects the free space.

Parameters
blockin: index page; free bits are set to 0 if the index is a non-clustered non-unique, and page level is 0

◆ ibuf_restore_pos()

static bool ibuf_restore_pos ( space_id_t  space_id,
page_no_t  page_no,
const dtuple_t search_tuple,
ulint  mode,
btr_pcur_t pcur,
mtr_t mtr 
)
static

Restores insert buffer tree cursor position.

Parameters
[in]space_idTablespace id
[in]page_noindex page number where the record should belong
[in]search_tuplesearch tuple for entries of page_no
[in]modeBTR_MODIFY_LEAF or BTR_MODIFY_TREE
[in,out]pcurpersistent cursor whose position is to be restored
[in,out]mtrmini-transaction
Returns
true if the position was restored; false if not

◆ ibuf_search_tuple_build()

static dtuple_t * ibuf_search_tuple_build ( space_id_t  space,
page_no_t  page_no,
mem_heap_t heap 
)
static

Builds a search tuple used to search buffered inserts for an index page.

This is for >= 4.1.x format records.

Returns
own: search tuple
Parameters
spacein: space id
page_noin: index page number
heapin: heap into which to build

◆ ibuf_set_bitmap_for_bulk_load()

void ibuf_set_bitmap_for_bulk_load ( buf_block_t block,
bool  reset 
)

Updates free bits and buffered bits for bulk loaded page.

Parameters
[in]blockindex page
[in]resetflag if reset free val

◆ ibuf_set_del_mark()

static void ibuf_set_del_mark ( const dtuple_t entry,
buf_block_t block,
const dict_index_t index,
mtr_t mtr 
)
static

During merge, sets the delete mark on a record for a secondary index entry.

Parameters
entryin: entry
blockin/out: block
indexin: record descriptor
mtrin: mtr

◆ ibuf_set_free_bits_func()

void ibuf_set_free_bits_func ( buf_block_t block,
ulint  val 
)

Sets the free bit of the page in the ibuf bitmap.

This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept.

Parameters
blockin: index page of a non-clustered index; free bit is reset if page level is 0
valin: value to set: < 4

◆ ibuf_set_free_bits_low()

static void ibuf_set_free_bits_low ( const buf_block_t block,
ulint  val,
mtr_t mtr 
)
inlinestatic

Sets the free bits of the page in the ibuf bitmap.

This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept.

Parameters
blockin: index page; free bits are set if the index is non-clustered and page level is 0
valin: value to set: < 4
mtrin/out: mtr

◆ ibuf_size_update()

static void ibuf_size_update ( const page_t root)
static

Updates the size information of the ibuf, assuming the segment size has not changed.

Parameters
rootin: ibuf tree root

◆ ibuf_tree_root_get()

static page_t * ibuf_tree_root_get ( mtr_t mtr)
static

Gets the root page and sx-latches it.

Returns
insert buffer tree root page
Parameters
mtrin: mtr

◆ ibuf_update_free_bits_for_two_pages_low()

void ibuf_update_free_bits_for_two_pages_low ( buf_block_t block1,
buf_block_t block2,
mtr_t mtr 
)

Updates the free bits for the two pages to reflect the present state.

Does this in the mtr given, which means that the latching order rules virtually prevent any further operations until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the pages.

Parameters
block1in: index page
block2in: index page
mtrin: mtr

◆ ibuf_update_free_bits_low()

void ibuf_update_free_bits_low ( const buf_block_t block,
ulint  max_ins_size,
mtr_t mtr 
)

Updates the free bits for an uncompressed page to reflect the present state.

Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS thread until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the page.

Parameters
blockin: index page
max_ins_sizein: value of maximum insert size with reorganize before the latest operation performed to the page
mtrin/out: mtr

◆ ibuf_update_free_bits_zip()

void ibuf_update_free_bits_zip ( buf_block_t block,
mtr_t mtr 
)

Updates the free bits for a compressed page to reflect the present state.

Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS thread until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the page.

Parameters
blockin/out: index page
mtrin/out: mtr

◆ ibuf_update_max_tablespace_id()

void ibuf_update_max_tablespace_id ( void  )

Reads the biggest tablespace id from the high end of the insert buffer tree and updates the counter in fil_system.

Variable Documentation

◆ ibuf

ibuf_t* ibuf = nullptr

The insert buffer control structure.

◆ IBUF_BITMAP

constexpr uint32_t IBUF_BITMAP = PAGE_DATA
constexpr

The start address for an insert buffer bitmap page bitmap.

◆ IBUF_BITMAP_BUFFERED

constexpr uint32_t IBUF_BITMAP_BUFFERED = 2
constexpr

true if there are buffered changes for the page

◆ IBUF_BITMAP_FREE

constexpr uint32_t IBUF_BITMAP_FREE = 0
constexpr

Bits indicating the amount of free space.

◆ IBUF_BITMAP_IBUF

constexpr uint32_t IBUF_BITMAP_IBUF = 3
constexpr

true if page is a part of the ibuf tree, excluding the root page, or is in the free list of the ibuf

◆ ibuf_bitmap_mutex

ib_mutex_t ibuf_bitmap_mutex
static

The mutex protecting the insert buffer bitmaps.

◆ IBUF_BITS_PER_PAGE

constexpr size_t IBUF_BITS_PER_PAGE = 4
constexpr

Number of bits describing a single page.

◆ IBUF_CONTRACT_DO_NOT_INSERT

const ulint IBUF_CONTRACT_DO_NOT_INSERT = 10

If the combined size of the ibuf trees exceeds ibuf->max_size by this many pages, we start to contract it synchronous contract, but do not insert.

◆ IBUF_CONTRACT_ON_INSERT_NON_SYNC

const ulint IBUF_CONTRACT_ON_INSERT_NON_SYNC = 0

If the combined size of the ibuf trees exceeds ibuf->max_size by this many pages, we start to contract it in connection to inserts there, using non-synchronous contract.

◆ IBUF_CONTRACT_ON_INSERT_SYNC

const ulint IBUF_CONTRACT_ON_INSERT_SYNC = 5

If the combined size of the ibuf trees exceeds ibuf->max_size by this many pages, we start to contract it in connection to inserts there, using synchronous contract.

◆ ibuf_debug

uint ibuf_debug

Flag to control insert buffer debugging.

◆ IBUF_MAX_N_PAGES_MERGED

const ulint IBUF_MAX_N_PAGES_MERGED = IBUF_MERGE_AREA

In ibuf_contract at most this number of pages is read to memory in one batch, in order to merge the entries for them in the insert buffer.

◆ IBUF_MERGE_AREA

const ulint IBUF_MERGE_AREA = 8

The area in pages from which contract looks for page numbers for merge.

◆ IBUF_MERGE_THRESHOLD

const ulint IBUF_MERGE_THRESHOLD = 4

Inside the merge area, pages which have at most 1 per this number less buffered entries compared to maximum volume that can buffered for a single page are merged along with the page whose buffer became full.

◆ ibuf_mutex

ib_mutex_t ibuf_mutex
static

The mutex protecting the insert buffer structs.

◆ ibuf_pessimistic_insert_mutex

ib_mutex_t ibuf_pessimistic_insert_mutex
static

The mutex used to block pessimistic inserts to ibuf trees.

◆ IBUF_REC_COMPACT

constexpr uint32_t IBUF_REC_COMPACT = 0x1
constexpr

Set in IBUF_REC_OFFSET_FLAGS if the user index is in COMPACT format or later.

◆ IBUF_REC_FIELD_MARKER

constexpr uint32_t IBUF_REC_FIELD_MARKER = 1
constexpr

starting with 4.1, a marker consisting of 1 byte that is 0

◆ IBUF_REC_FIELD_METADATA

constexpr uint32_t IBUF_REC_FIELD_METADATA = 3
constexpr

the metadata field

◆ IBUF_REC_FIELD_PAGE

constexpr uint32_t IBUF_REC_FIELD_PAGE = 2
constexpr

starting with 4.1, the page number

◆ IBUF_REC_FIELD_SPACE

constexpr uint32_t IBUF_REC_FIELD_SPACE = 0
constexpr

in the pre-4.1 format, the page number.

later, the space_id

◆ IBUF_REC_FIELD_USER

constexpr uint32_t IBUF_REC_FIELD_USER = 4
constexpr

first user field

◆ IBUF_REC_INFO_SIZE

constexpr uint32_t IBUF_REC_INFO_SIZE = 4
constexpr

Combined size of info fields at the beginning of the fourth field.

◆ IBUF_REC_OFFSET_COUNTER

constexpr uint32_t IBUF_REC_OFFSET_COUNTER = 0
constexpr

Operation counter.

◆ IBUF_REC_OFFSET_FLAGS

constexpr uint32_t IBUF_REC_OFFSET_FLAGS = 3
constexpr

Additional flags.

◆ IBUF_REC_OFFSET_TYPE

constexpr uint32_t IBUF_REC_OFFSET_TYPE = 2
constexpr

Type of operation.

◆ innodb_change_buffering

ulong innodb_change_buffering = IBUF_USE_ALL

Operations that can currently be buffered.

◆ srv_ibuf_disable_background_merge

bool srv_ibuf_disable_background_merge