MySQL 8.0.40
Source Code Documentation
Xcom_member_state Class Reference

Class that conveys the state to be exchanged between members, which is not provided by XCom. More...

#include <gcs_xcom_state_exchange.h>

Public Member Functions

 Xcom_member_state (const Gcs_xcom_view_identifier &view_id, synode_no configuration_id, Gcs_protocol_version version, const Gcs_xcom_synode_set &snapshot, const uchar *data, uint64_t data_size)
 Xcom_member_state constructor. More...
 
 Xcom_member_state (Gcs_protocol_version version, const uchar *data, uint64_t data_size)
 Xcom_member_state constructor. More...
 
 ~Xcom_member_state ()
 Member state destructor. More...
 
bool encode_header (uchar *buffer, uint64_t *buffer_len) const
 Encodes the Member State's header to be sent through the newtwork. More...
 
bool decode_header (const uchar *buffer, uint64_t buffer_len)
 Decodes the Member State's header that was sent through the network. More...
 
bool encode_snapshot (uchar *buffer, uint64_t *buffer_len) const
 Encodes the Member State's snapshot to be sent through the network. More...
 
bool decode_snapshot (const uchar *buffer, uint64_t buffer_len)
 Decodes the Member State's snapshot that was sent through the network. More...
 
bool decode (const uchar *data, uint64_t data_size)
 Decodes Member State that was sent through the network. More...
 
uint64_t get_encode_payload_size () const
 
uint64_t get_encode_snapshot_size () const
 
Gcs_xcom_view_identifierget_view_id ()
 
synode_no get_configuration_id () const
 
const ucharget_data () const
 
uint64_t get_data_size () const
 
const Gcs_xcom_synode_setget_snapshot () const
 

Static Public Member Functions

static constexpr uint64_t get_encode_header_size ()
 

Private Member Functions

 Xcom_member_state (Xcom_member_state const &)=delete
 
Xcom_member_stateoperator= (Xcom_member_state const &)=delete
 

Static Private Member Functions

static constexpr uint64_t get_encode_snapshot_elem_size ()
 

Private Attributes

Gcs_xcom_view_identifierm_view_id
 
synode_no m_configuration_id
 
ucharm_data
 
uint64_t m_data_size
 
Gcs_xcom_synode_set m_snapshot
 Recovery information which is currently a list of the XCom synods of the fragments that are in buffers when a node is joining. More...
 
Gcs_protocol_version m_version
 GCS communication version number in use. More...
 

Static Private Attributes

static constexpr auto WIRE_XCOM_VARIABLE_VIEW_ID_SIZE = 8
 
static constexpr auto WIRE_XCOM_VIEW_ID_SIZE = 4
 
static constexpr auto WIRE_XCOM_GROUP_ID_SIZE = 4
 
static constexpr auto WIRE_XCOM_MSG_ID_SIZE = 8
 
static constexpr auto WIRE_XCOM_NODE_ID_SIZE = 4
 
static constexpr auto WIRE_XCOM_SNAPSHOT_NR_ELEMS_SIZE = 8
 

Detailed Description

Class that conveys the state to be exchanged between members, which is not provided by XCom.

In the original GCS protocol (version 1), this message had the following wire format:

+--------+---------------------+
| Header | Upper-layer payload |
+--------+---------------------+

Where the header has the following format:

+---------+------------+
| View ID | XCom synod |
+---------+------------+

With the introduction of the fragmentation stage into the message pipeline, it is possible that an original message is fragmented into several fragments, and each fragment is delivered by XCom individually.

This means that when a node joins, it is possible for the transmission of a fragmented message to be ongoing, i.e. the existing group members have already received some, but not all, of the fragments. In this situation, the last fragment will arrive after the new node has joined the group. Since the original message is only delivered when all its fragments are received, this means that the original message will need to be delivered by the new node as well. But the problem is that new node does not have the fragments that were received before the new node joined.

We solve this problem by augmenting the state exchange message with information about the ongoing transmission of fragmented messages. In particular, for every fragmented message whose transmission is ongoing, a node will attach the XCom synods of the fragments it has already received. The new node can use this information to fetch the fragments from XCom.

As such, in GCS protocol version 2, this message has the following wire format:

+--------+---------------------+----------------+
| Header | Upper-layer payload | Recovery info. |
+--------+---------------------+----------------+

Where the recovery information has the following format:

+---------------+-...-+----------------+------------+
| XCom synod #1 |     | XCom synode #n | Nr. synods |
+---------------+-...-+----------------+------------+

Older GCS instances that only support protocol version 1 will deserialize the recovery information as part of the upper-layer payload. However, this works as long as the upper layer consumes only the portion it is expecting (upper-layer payload), even though it is fed its expected payload with the recovery information appended.

Constructor & Destructor Documentation

◆ Xcom_member_state() [1/3]

Xcom_member_state::Xcom_member_state ( const Gcs_xcom_view_identifier view_id,
synode_no  configuration_id,
Gcs_protocol_version  version,
const Gcs_xcom_synode_set snapshot,
const uchar data,
uint64_t  data_size 
)
explicit

Xcom_member_state constructor.

Parameters
[in]view_idthe view identifier from the node
[in]configuration_idConfiguration identifier in use when the state exchange message was created
[in]versionProtocol version used to represent the state
[in]snapshotSnapshot information currently in use
[in]datathe generic data to be exchanged
[in]data_sizedata's size

◆ Xcom_member_state() [2/3]

Xcom_member_state::Xcom_member_state ( Gcs_protocol_version  version,
const uchar data,
uint64_t  data_size 
)
explicit

Xcom_member_state constructor.

Parameters
[in]versionProtocol version used to represent the state
[in]datathe generic data to be exchanged
[in]data_sizedata's size

◆ ~Xcom_member_state()

Xcom_member_state::~Xcom_member_state ( )

Member state destructor.

◆ Xcom_member_state() [3/3]

Xcom_member_state::Xcom_member_state ( Xcom_member_state const &  )
privatedelete

Member Function Documentation

◆ decode()

bool Xcom_member_state::decode ( const uchar data,
uint64_t  data_size 
)

Decodes Member State that was sent through the network.

Parameters
[out]datawhere the data was stored.
[out]data_sizepointer to the variable that holds the data's size.
Returns
True if for any reason the data could not be exchanged. Otherwise, false.

◆ decode_header()

bool Xcom_member_state::decode_header ( const uchar buffer,
uint64_t  buffer_len 
)

Decodes the Member State's header that was sent through the network.

Parameters
[out]bufferWhere the header was stored.
[in,out]buffer_lenPointer to the variable that holds the header's size and has the buffer's len as input.
Returns
true if nothing went wrong. Otherwise, false.

◆ decode_snapshot()

bool Xcom_member_state::decode_snapshot ( const uchar buffer,
uint64_t  buffer_len 
)

Decodes the Member State's snapshot that was sent through the network.

Parameters
[out]bufferWhere the snapshot was stored.
[in,out]buffer_lenIt holds the snapshot's size.
Returns
true if nothing went wrong. Otherwise, false.

◆ encode_header()

bool Xcom_member_state::encode_header ( uchar buffer,
uint64_t *  buffer_len 
) const

Encodes the Member State's header to be sent through the newtwork.

Parameters
[out]bufferwhere the header will be stored.
[in,out]buffer_lenpointer to the variable that will hold the header's size and has the buffer's len as input.
Returns
True if there is no space to store the header. Otherwise, false.

◆ encode_snapshot()

bool Xcom_member_state::encode_snapshot ( uchar buffer,
uint64_t *  buffer_len 
) const

Encodes the Member State's snapshot to be sent through the network.

Parameters
[out]bufferwhere the snapshot will be stored.
[in,out]buffer_lenpointer to the variable that will hold the snapshot's size and has the buffer's len as input.
Returns
True if there is no space to store the snapshot. Otherwise, false.

◆ get_configuration_id()

synode_no Xcom_member_state::get_configuration_id ( ) const
inline
Returns
the configuration identifier

◆ get_data()

const uchar * Xcom_member_state::get_data ( ) const
inline
Returns
the generic exchangeable data

◆ get_data_size()

uint64_t Xcom_member_state::get_data_size ( ) const
inline
Returns
the size of the generic exchangeable data

◆ get_encode_header_size()

static constexpr uint64_t Xcom_member_state::get_encode_header_size ( )
inlinestaticconstexpr
Returns
the size of the encoded header when put on the wire.

◆ get_encode_payload_size()

uint64_t Xcom_member_state::get_encode_payload_size ( ) const
Returns
the size of the encoded payload when put on the wire.

◆ get_encode_snapshot_elem_size()

static constexpr uint64_t Xcom_member_state::get_encode_snapshot_elem_size ( )
inlinestaticconstexprprivate

◆ get_encode_snapshot_size()

uint64_t Xcom_member_state::get_encode_snapshot_size ( ) const
Returns
the size of the encoded snapshot when put on the wire.

◆ get_snapshot()

const Gcs_xcom_synode_set & Xcom_member_state::get_snapshot ( ) const
inline

◆ get_view_id()

Gcs_xcom_view_identifier * Xcom_member_state::get_view_id ( )
inline
Returns
the view identifier

◆ operator=()

Xcom_member_state & Xcom_member_state::operator= ( Xcom_member_state const &  )
privatedelete

Member Data Documentation

◆ m_configuration_id

synode_no Xcom_member_state::m_configuration_id
private

◆ m_data

uchar* Xcom_member_state::m_data
private

◆ m_data_size

uint64_t Xcom_member_state::m_data_size
private

◆ m_snapshot

Gcs_xcom_synode_set Xcom_member_state::m_snapshot
private

Recovery information which is currently a list of the XCom synods of the fragments that are in buffers when a node is joining.

This is currently used only to transfer information on slice packets that need to be fetched by the joining node before it may become ready to serve requests.

◆ m_version

Gcs_protocol_version Xcom_member_state::m_version
private

GCS communication version number in use.

◆ m_view_id

Gcs_xcom_view_identifier* Xcom_member_state::m_view_id
private

◆ WIRE_XCOM_GROUP_ID_SIZE

constexpr auto Xcom_member_state::WIRE_XCOM_GROUP_ID_SIZE = 4
staticconstexprprivate

◆ WIRE_XCOM_MSG_ID_SIZE

constexpr auto Xcom_member_state::WIRE_XCOM_MSG_ID_SIZE = 8
staticconstexprprivate

◆ WIRE_XCOM_NODE_ID_SIZE

constexpr auto Xcom_member_state::WIRE_XCOM_NODE_ID_SIZE = 4
staticconstexprprivate

◆ WIRE_XCOM_SNAPSHOT_NR_ELEMS_SIZE

constexpr auto Xcom_member_state::WIRE_XCOM_SNAPSHOT_NR_ELEMS_SIZE = 8
staticconstexprprivate

◆ WIRE_XCOM_VARIABLE_VIEW_ID_SIZE

constexpr auto Xcom_member_state::WIRE_XCOM_VARIABLE_VIEW_ID_SIZE = 8
staticconstexprprivate

◆ WIRE_XCOM_VIEW_ID_SIZE

constexpr auto Xcom_member_state::WIRE_XCOM_VIEW_ID_SIZE = 4
staticconstexprprivate

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