MySQL 8.4.2
Source Code Documentation
|
InnoDB concurrency manager. More...
#include <mysql/service_thd_wait.h>
#include <stddef.h>
#include <sys/types.h>
#include "dict0dict.h"
#include "ha_prototypes.h"
#include "row0mysql.h"
#include "srv0srv.h"
#include "trx0trx.h"
Classes | |
struct | srv_conc_t |
Variables tracking the active and waiting threads. More... | |
Functions | |
static void | srv_enter_innodb_with_tickets (trx_t *trx) |
Note that a user thread is entering InnoDB. More... | |
static dberr_t | srv_conc_enter_innodb_with_atomics (trx_t *trx) |
Handle the scheduling of a user thread that wants to enter InnoDB. More... | |
static void | srv_conc_exit_innodb_with_atomics (trx_t *trx) |
Note that a user thread is leaving InnoDB code. More... | |
dberr_t | srv_conc_enter_innodb (row_prebuilt_t *prebuilt) |
Puts an OS thread to wait if there are too many concurrent threads (>= srv_thread_concurrency) inside InnoDB. More... | |
void | srv_conc_force_enter_innodb (trx_t *trx) |
This lets a thread enter InnoDB regardless of the number of threads inside InnoDB. More... | |
void | srv_conc_force_exit_innodb (trx_t *trx) |
This must be called when a thread exits InnoDB in a lock wait or at the end of an SQL statement. More... | |
int32_t | srv_conc_get_waiting_threads (void) |
Get the count of threads waiting inside InnoDB. More... | |
int32_t | srv_conc_get_active_threads (void) |
Get the count of threads active inside InnoDB. More... | |
Variables | |
ulong | srv_n_free_tickets_to_enter = 500 |
Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket. More... | |
ulong | srv_adaptive_max_sleep_delay = 150000 |
Maximum sleep delay (in micro-seconds), value of 0 disables it. More... | |
ulong | srv_thread_sleep_delay = 10000 |
Sleep delay for threads waiting to enter InnoDB. More... | |
ulong | srv_thread_concurrency = 0 |
The following controls how many threads we let inside InnoDB concurrently: threads waiting for locks are not counted into the number because otherwise we could get a deadlock. More... | |
static srv_conc_t | srv_conc |
InnoDB concurrency manager.
Created 2011/04/18 Sunny Bains
dberr_t srv_conc_enter_innodb | ( | row_prebuilt_t * | prebuilt | ) |
Puts an OS thread to wait if there are too many concurrent threads (>= srv_thread_concurrency) inside InnoDB.
The threads wait in a FIFO queue.
[in,out] | prebuilt | row prebuilt handler |
Handle the scheduling of a user thread that wants to enter InnoDB.
Setting srv_adaptive_max_sleep_delay > 0 switches the adaptive sleep calibration to ON. When set, we want to wait in the queue for as little time as possible. However, very short waits will result in a lot of context switches and that is also not desirable. When threads need to sleep multiple times we increment srv_thread_sleep_delay by one. When we see threads getting a slot without waiting and there are no other threads waiting in the queue, we try and reduce the wait as much as we can. Currently we reduce it by half each time. If the thread only had to wait for one turn before it was able to enter InnoDB we decrement it by one. This is to try and keep the sleep time stable around the "optimum" sleep time.
trx | in/out: transaction that wants to enter InnoDB |
|
static |
Note that a user thread is leaving InnoDB code.
trx | in/out: transaction |
void srv_conc_force_enter_innodb | ( | trx_t * | trx | ) |
This lets a thread enter InnoDB regardless of the number of threads inside InnoDB.
This must be called when a thread ends a lock wait.
trx | in: transaction object associated with the thread |
void srv_conc_force_exit_innodb | ( | trx_t * | trx | ) |
This must be called when a thread exits InnoDB in a lock wait or at the end of an SQL statement.
in: transaction object associated with the thread
trx | in: transaction object associated with the thread |
int32_t srv_conc_get_active_threads | ( | void | ) |
Get the count of threads active inside InnoDB.
int32_t srv_conc_get_waiting_threads | ( | void | ) |
Get the count of threads waiting inside InnoDB.
|
static |
Note that a user thread is entering InnoDB.
trx | in/out: transaction that wants to enter InnoDB |
ulong srv_adaptive_max_sleep_delay = 150000 |
Maximum sleep delay (in micro-seconds), value of 0 disables it.
|
static |
ulong srv_n_free_tickets_to_enter = 500 |
Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket.
ulong srv_thread_concurrency = 0 |
The following controls how many threads we let inside InnoDB concurrently: threads waiting for locks are not counted into the number because otherwise we could get a deadlock.
Value of 0 will disable the concurrency check.
ulong srv_thread_sleep_delay = 10000 |
Sleep delay for threads waiting to enter InnoDB.
In micro-seconds.