MySQL  8.0.18
Source Code Documentation
Gtid_mode_copy Class Reference

An optimized way of checking GTID_MODE without acquiring locks every time. More...

#include <rpl_gtid.h>

Inheritance diagram for Gtid_mode_copy:
Binlog_sender Master_info

Public Member Functions

enum_gtid_mode get_gtid_mode_from_copy (enum_gtid_mode_lock have_lock)
 Return the current server GTID_MODE without acquiring locks if possible. More...
 

Private Attributes

ulong m_gtid_mode_counter = 0
 The copy of the atomic counter of the last time we copied the GTID_MODE. More...
 
enum_gtid_mode m_gtid_mode = DEFAULT_GTID_MODE
 Local copy of the GTID_MODE. More...
 

Detailed Description

An optimized way of checking GTID_MODE without acquiring locks every time.

GTID_MODE is a global variable that should not be changed often, but the access to it is protected by any of the four locks described at enum_gtid_mode_lock.

Every time a channel receiver thread connects to a master, and every time a Gtid_log_event or an Anonymous_gtid_log_event is queued by a receiver thread, there must be checked if the current GTID_MODE is compatible with the operation.

There are some places where the verification is performed while already holding one of the above mentioned locks, but there are other places that rely on no lock and will rely on the global_sid_lock, blocking any other GTID operation relying on the global_sid_map.

In order to avoid acquiring lock to check a variable that is not changed often, there is a global (atomic) counter of how many times the GTID_MODE was changed since the server startup.

This class holds a copy of the last GTID_MODE to be returned without the need of acquiring locks if the local GTID mode counter has the same value as the global atomic counter.

Member Function Documentation

◆ get_gtid_mode_from_copy()

enum_gtid_mode Gtid_mode_copy::get_gtid_mode_from_copy ( enum_gtid_mode_lock  have_lock)
inline

Return the current server GTID_MODE without acquiring locks if possible.

Parameters
have_lockThe lock type held by the caller.

Member Data Documentation

◆ m_gtid_mode

enum_gtid_mode Gtid_mode_copy::m_gtid_mode = DEFAULT_GTID_MODE
private

Local copy of the GTID_MODE.

◆ m_gtid_mode_counter

ulong Gtid_mode_copy::m_gtid_mode_counter = 0
private

The copy of the atomic counter of the last time we copied the GTID_MODE.


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