MySQL 8.4.0
Source Code Documentation
Connection_handler_manager Class Reference

This is a singleton class that provides various connection management related functionalities, most importantly dispatching new connections to the currently active Connection_handler. More...

#include <connection_handler_manager.h>

Public Types

enum  scheduler_types { SCHEDULER_ONE_THREAD_PER_CONNECTION = 0 , SCHEDULER_NO_THREADS , SCHEDULER_TYPES_COUNT }
 thread_handling enumeration. More...
 

Public Member Functions

bool valid_connection_count ()
 Check if the current number of connections are below or equal the value given by the max_connections server system variable. More...
 
bool check_and_incr_conn_count (bool ignore_max_connection_count)
 Increment connection count if max_connections is not exceeded. More...
 
void inc_aborted_connects ()
 
ulong aborted_connects () const
 
ulong connection_errors_max_connection () const
 
void load_connection_handler (Connection_handler *conn_handler)
 Dynamically load a connection handler implemented as a plugin. More...
 
bool unload_connection_handler ()
 Unload the connection handler previously loaded by load_connection_handler(). More...
 
void process_new_connection (Channel_info *channel_info)
 Process a new incoming connection. More...
 

Static Public Member Functions

static Connection_handler_managerget_instance ()
 Singleton method to return an instance of this class. More...
 
static bool init ()
 Initialize the connection handler manager. More...
 
static void destroy_instance ()
 Destroy the singleton instance. More...
 
static void reset_max_used_connections ()
 Reset the max_used_connections counter to the number of current connections. More...
 
static void dec_connection_count ()
 Decrease the number of current connections. More...
 
static void wait_till_no_connection ()
 Waits until all connections are done with their job. More...
 
static uint get_connection_count ()
 Return number of connections in thread-safe way. More...
 

Static Public Attributes

static uint connection_count = 0
 
static ulong max_used_connections = 0
 
static ulong max_used_connections_time = 0
 
static ulong thread_handling
 
static THD_event_functionsevent_functions = nullptr
 
static THD_event_functionssaved_event_functions
 
static uint max_threads = 0
 Maximum number of threads that can be created by the current connection handler. More...
 

Private Member Functions

 Connection_handler_manager (Connection_handler *connection_handler)
 Constructor to instantiate an instance of this class. More...
 
 ~Connection_handler_manager ()
 
 Connection_handler_manager (const Connection_handler_manager &)
 
Connection_handler_manageroperator= (const Connection_handler_manager &)
 

Private Attributes

Connection_handlerm_connection_handler
 
Connection_handlerm_saved_connection_handler
 
ulong m_saved_thread_handling
 
ulong m_aborted_connects
 
ulong m_connection_errors_max_connection
 

Static Private Attributes

static Connection_handler_managerm_instance = nullptr
 
static mysql_mutex_t LOCK_connection_count
 
static mysql_cond_t COND_connection_count
 

Detailed Description

This is a singleton class that provides various connection management related functionalities, most importantly dispatching new connections to the currently active Connection_handler.

Member Enumeration Documentation

◆ scheduler_types

thread_handling enumeration.

The default of –thread-handling is the first one in the thread_handling_names array, this array has to be consistent with the order in this array, so to change default one has to change the first entry in this enum and the first entry in the thread_handling_names array.

Note
The last entry of the enumeration is also used to mark the thread handling as dynamic. In this case the name of the thread handling is fetched from the name of the plugin that implements it.
Enumerator
SCHEDULER_ONE_THREAD_PER_CONNECTION 
SCHEDULER_NO_THREADS 
SCHEDULER_TYPES_COUNT 

Constructor & Destructor Documentation

◆ Connection_handler_manager() [1/2]

Connection_handler_manager::Connection_handler_manager ( Connection_handler connection_handler)
inlineprivate

Constructor to instantiate an instance of this class.

◆ ~Connection_handler_manager()

Connection_handler_manager::~Connection_handler_manager ( )
inlineprivate

◆ Connection_handler_manager() [2/2]

Connection_handler_manager::Connection_handler_manager ( const Connection_handler_manager )
private

Member Function Documentation

◆ aborted_connects()

ulong Connection_handler_manager::aborted_connects ( ) const
inline

◆ check_and_incr_conn_count()

bool Connection_handler_manager::check_and_incr_conn_count ( bool  ignore_max_connection_count)

Increment connection count if max_connections is not exceeded.

Parameters
ignore_max_connection_counttrue if checking for a limit specified by the max-connections server option should be skipped
Return values
truemax_connections NOT exceeded false max_connections reached

◆ connection_errors_max_connection()

ulong Connection_handler_manager::connection_errors_max_connection ( ) const
inline
Note
This is a dirty read.

◆ dec_connection_count()

static void Connection_handler_manager::dec_connection_count ( )
inlinestatic

Decrease the number of current connections.

◆ destroy_instance()

void Connection_handler_manager::destroy_instance ( )
static

Destroy the singleton instance.

◆ get_connection_count()

static uint Connection_handler_manager::get_connection_count ( )
inlinestatic

Return number of connections in thread-safe way.

◆ get_instance()

static Connection_handler_manager * Connection_handler_manager::get_instance ( )
inlinestatic

Singleton method to return an instance of this class.

◆ inc_aborted_connects()

void Connection_handler_manager::inc_aborted_connects ( )
inline

◆ init()

bool Connection_handler_manager::init ( )
static

Initialize the connection handler manager.

Must be called before get_instance() can be used.

Returns
true if initialization failed, false otherwise.

◆ load_connection_handler()

void Connection_handler_manager::load_connection_handler ( Connection_handler conn_handler)

Dynamically load a connection handler implemented as a plugin.

The current connection handler will be saved so that it can later be restored by unload_connection_handler().

◆ operator=()

Connection_handler_manager & Connection_handler_manager::operator= ( const Connection_handler_manager )
private

◆ process_new_connection()

void Connection_handler_manager::process_new_connection ( Channel_info channel_info)

Process a new incoming connection.

Parameters
channel_infoPointer to Channel_info object containing connection channel information.

◆ reset_max_used_connections()

void Connection_handler_manager::reset_max_used_connections ( )
static

Reset the max_used_connections counter to the number of current connections.

◆ unload_connection_handler()

bool Connection_handler_manager::unload_connection_handler ( )

Unload the connection handler previously loaded by load_connection_handler().

The previous connection handler will be restored.

Returns
true if unload failed (no previous connection handler was found).

◆ valid_connection_count()

bool Connection_handler_manager::valid_connection_count ( )

Check if the current number of connections are below or equal the value given by the max_connections server system variable.

Returns
true if a new connection can be accepted, false otherwise.

◆ wait_till_no_connection()

void Connection_handler_manager::wait_till_no_connection ( )
static

Waits until all connections are done with their job.

In other words, wat till connection_count to become zero.

Member Data Documentation

◆ COND_connection_count

mysql_cond_t Connection_handler_manager::COND_connection_count
staticprivate

◆ connection_count

uint Connection_handler_manager::connection_count = 0
static

◆ event_functions

THD_event_functions * Connection_handler_manager::event_functions = nullptr
static

◆ LOCK_connection_count

mysql_mutex_t Connection_handler_manager::LOCK_connection_count
staticprivate

◆ m_aborted_connects

ulong Connection_handler_manager::m_aborted_connects
private

◆ m_connection_errors_max_connection

ulong Connection_handler_manager::m_connection_errors_max_connection
private

◆ m_connection_handler

Connection_handler* Connection_handler_manager::m_connection_handler
private

◆ m_instance

Connection_handler_manager * Connection_handler_manager::m_instance = nullptr
staticprivate

◆ m_saved_connection_handler

Connection_handler* Connection_handler_manager::m_saved_connection_handler
private

◆ m_saved_thread_handling

ulong Connection_handler_manager::m_saved_thread_handling
private

◆ max_threads

uint Connection_handler_manager::max_threads = 0
static

Maximum number of threads that can be created by the current connection handler.

Must be static as it is used by the signal handler.

◆ max_used_connections

ulong Connection_handler_manager::max_used_connections = 0
static

◆ max_used_connections_time

ulong Connection_handler_manager::max_used_connections_time = 0
static

◆ saved_event_functions

THD_event_functions * Connection_handler_manager::saved_event_functions
static
Initial value:
=
nullptr

◆ thread_handling

ulong Connection_handler_manager::thread_handling
static
Initial value:
=
@ SCHEDULER_ONE_THREAD_PER_CONNECTION
Definition: connection_handler_manager.h:111

The documentation for this class was generated from the following files: