#include <tc_log.h>
◆ PAGE_STATE
Enumerator |
---|
PS_POOL | |
PS_ERROR | |
PS_DIRTY | |
◆ TC_LOG_MMAP()
TC_LOG_MMAP::TC_LOG_MMAP |
( |
| ) |
|
|
inline |
◆ close()
void TC_LOG_MMAP::close |
( |
| ) |
|
|
overridevirtual |
Close the transaction coordinator log and free any resources.
Called during server shutdown.
Implements TC_LOG.
◆ commit()
Commit the transaction.
- Note
- When the TC_LOG interface was changed, this function was added and uses the functions that were there with the old interface to implement the logic.
Implements TC_LOG.
◆ do_msync_and_fsync()
virtual int TC_LOG_MMAP::do_msync_and_fsync |
( |
int |
fd_arg, |
|
|
void * |
addr, |
|
|
size_t |
len, |
|
|
int |
flags |
|
) |
| |
|
inlineprotectedvirtual |
◆ get_active_from_pool()
there is no active page, let's got one from the pool.
Two strategies here:
- take the first from the pool
- if there're waiters - take the one with the most free space.
- Returns
- Pointer to qualifying page or NULL if no page in the pool can be made active.
◆ log_xid()
ulong TC_LOG_MMAP::log_xid |
( |
my_xid |
xid | ) |
|
|
private |
Record that transaction XID is committed on the persistent storage.
This function is called in the middle of two-phase commit: First all resources prepare the transaction, then tc_log->log() is called, then all resources commit the transaction, then tc_log->unlog() is called.
All access to active page is serialized but it's not a problem, as we're assuming that fsync() will be a main bottleneck. That is, parallelizing writes to log pages we'll decrease number of threads waiting for a page, but then all these threads will be waiting for a fsync() anyway
If tc_log == MYSQL_BIN_LOG then tc_log writes transaction to binlog and records XID in a special Xid_log_event. If tc_log = TC_LOG_MMAP then xid is written in a special memory-mapped log.
- Returns
- "cookie", a number that will be passed as an argument to unlog() call. tc_log can define it any way it wants, and use for whatever purposes. TC_LOG_MMAP sets it to the position in memory where xid was logged to.
- Return values
-
◆ open()
int TC_LOG_MMAP::open |
( |
const char * |
opt_name | ) |
|
|
overridevirtual |
Initialize and open the coordinator log.
Do recovery if necessary. Called during server startup.
- Parameters
-
- Return values
-
Implements TC_LOG.
◆ overflow()
void TC_LOG_MMAP::overflow |
( |
| ) |
|
|
private |
◆ prepare()
int TC_LOG_MMAP::prepare |
( |
THD * |
thd, |
|
|
bool |
all |
|
) |
| |
|
overridevirtual |
Log a prepare record of the transaction to the storage engines.
- Parameters
-
thd | Session to log transaction record for. |
all | true if an explicit commit or an implicit commit for a statement, false if an internal commit of the statement. |
- Returns
- Error code on failure, zero on success.
Implements TC_LOG.
◆ recover()
int TC_LOG_MMAP::recover |
( |
| ) |
|
◆ rollback()
int TC_LOG_MMAP::rollback |
( |
THD * |
thd, |
|
|
bool |
all |
|
) |
| |
|
overridevirtual |
Log a rollback record of the transaction to the transaction coordinator log.
When the function returns, the transaction have been aborted in the transaction coordinator log.
- Parameters
-
thd | Session to log transaction record for. |
all | true if an explicit commit or an implicit commit for a statement, false if an internal commit of the statement. |
- Returns
- Error code on failure, zero on success.
Implements TC_LOG.
◆ size()
uint TC_LOG_MMAP::size |
( |
| ) |
const |
Get the total amount of potentially usable slots for XIDs in TC log.
◆ store_xid_in_empty_slot()
ulong TC_LOG_MMAP::store_xid_in_empty_slot |
( |
my_xid |
xid, |
|
|
PAGE * |
p, |
|
|
uchar * |
data_arg |
|
) |
| |
|
inlineprivate |
Find empty slot in the page and write xid value there.
- Parameters
-
xid | value of xid to store in the page |
p | pointer to the page where to store xid |
data_arg | pointer to the top of the mapped to memory file to calculate offset value (cookie) |
- Returns
- offset value from the top of the page where the xid was stored.
◆ sync()
bool TC_LOG_MMAP::sync |
( |
| ) |
|
|
private |
Write the page data being synchronized to the disk.
- Return values
-
◆ unlog()
void TC_LOG_MMAP::unlog |
( |
ulong |
cookie, |
|
|
my_xid |
xid |
|
) |
| |
|
private |
erase xid from the page, update page free space counters/pointers.
cookie points directly to the memory where xid was logged.
◆ wait_sync_completion()
bool TC_LOG_MMAP::wait_sync_completion |
( |
PAGE * |
p | ) |
|
|
inlineprivate |
Wait for until page data will be written to the disk.
- Parameters
-
p | pointer to the PAGE to store to the disk |
- Return values
-
◆ TCLogMMapTest
friend class TCLogMMapTest |
|
friend |
◆ active
PAGE * TC_LOG_MMAP::active |
|
private |
◆ COND_active
Signalled when active PAGE is moved to syncing state, thus member "active" becomes 0.
◆ COND_pool
Signalled when one more page becomes available in the pool which we might select as active.
◆ data
◆ fd
◆ file_length
◆ inited
◆ LOCK_tc
◆ logname
◆ npages
◆ pages
◆ pool
◆ pool_last_ptr
PAGE ** TC_LOG_MMAP::pool_last_ptr |
|
private |
◆ syncing
PAGE * TC_LOG_MMAP::syncing |
|
private |
The documentation for this class was generated from the following files: