State of a given scan.
Scans are restartable, and done in multiple calls. Overall, the code scans separately:
- the RW trx list
- the MySQL trx list For each list, the scan is done by ranges of trx_immutable_id(trx) values. Saving the current scan state allows to resume where the previous scan ended. The typical usage is: state.prepare_scan(); for (trx : trx list for state.get_pass() ){ if(state.trx_in_range(trx)){ process trx } } It's callers responsibility to handle that the two lists aren't disjoint. The range of trx_immutable_id(..) values to be included in scan is decided by prepare_scan(..) so that it contains SCAN_RANGE transactions from current list.
void Innodb_trx_scan_state::prepare_scan |
( |
| ) |
|
|
inline |
Prepare the scan: Sets the m_scan_pass used by get_pass() to determine which list caller should iterate, and [m_start_trx_id_range, m_end_trx_id_range) range used by trx_in_range(trx), which the caller should use to check if trx is in range.
The range will contain at most SCAN_RANGE elements. Caller must hold trx_sys->mutex. When there are no more TRX for this pass, advances to the next pass.