MySQL 26.7.0
Source Code Documentation
session_service_bounded_queue.h
Go to the documentation of this file.
1// Copyright (c) 2026, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24#ifndef MYSQL_CSA_SESSION_SERVICE_BOUNDED_QUEUE_H
25#define MYSQL_CSA_SESSION_SERVICE_BOUNDED_QUEUE_H
26
27#include <memory>
36#include "sql/log_event.h" // Log_event
37
38namespace mysql::csa {
39
40/// @brief Service that provides a free session to executing transactions
42 public:
43 /// @brief Alias for task identifier from base class
45 /// @brief Constructor
46 /// @param psi_params Instrumentation parameters
48 /// @brief Virtual destructor
49 virtual ~Session_service_bounded_queue() override;
50
51 /// @brief Initializes the session service with a bounded queue
52 /// @param session_number The number of sessions to add to initial pool
53 /// @param channel_rli Parent RLI - channel RLI to share common applier config
54 /// @return True if initialization succeeds, false otherwise
55 bool init(std::size_t session_number, Relay_log_info *channel_rli) override;
56 /// @brief Deinitializes the session service
57 /// @return False on success, true on failure
58 bool deinit() override;
59
60 /// @brief Acquires a session for the given task ID
61 /// @param id The task ID
62 /// @return A shared pointer to the Relay_context
64 /// @brief Releases a session back to the pool
65 /// @param session Session to return to the session pool
66 /// @param id Session internal ID
67 void release_session(Relay_context_ptr session, Task_id id) override;
68
69 private:
70 /// @brief Type alias for a shared pointer to Relay_context
71 using Relay_context_entry = std::shared_ptr<Relay_context>;
72 /// @brief Type alias for the synchronized bounded queue of Relay_context_ptr
75 /// @brief The session registry queue
77
78 /// @brief The number of maintained sessions
80 /// Pointer to the channel RLI (to share data, such as applier privileges)
82 /// PSI parameters
84};
85
86} // namespace mysql::csa
87
88#endif // MYSQL_CSA_SESSION_SERVICE_BOUNDED_QUEUE_H
Definition: rpl_rli.h:208
Service that provides a free session to executing transactions.
Definition: session_service_bounded_queue.h:41
std::size_t m_session_number
The number of maintained sessions.
Definition: session_service_bounded_queue.h:79
virtual ~Session_service_bounded_queue() override
Virtual destructor.
Definition: session_service_bounded_queue.cpp:32
Session_registry m_sessions
The session registry queue.
Definition: session_service_bounded_queue.h:76
Relay_log_info * m_channel_rli
Pointer to the channel RLI (to share data, such as applier privileges)
Definition: session_service_bounded_queue.h:81
bool deinit() override
Deinitializes the session service.
Definition: session_service_bounded_queue.cpp:34
Session_service::Task_id Task_id
Alias for task identifier from base class.
Definition: session_service_bounded_queue.h:44
Session_service_bounded_queue(Session_service_psi psi_params={})
Constructor.
Definition: session_service_bounded_queue.cpp:28
Relay_context_ptr acquire_session(Task_id id) override
Acquires a session for the given task ID.
Definition: session_service_bounded_queue.cpp:56
Session_service_psi m_psi
PSI parameters.
Definition: session_service_bounded_queue.h:83
void release_session(Relay_context_ptr session, Task_id id) override
Releases a session back to the pool.
Definition: session_service_bounded_queue.cpp:63
std::shared_ptr< Relay_context > Relay_context_entry
Type alias for a shared pointer to Relay_context.
Definition: session_service_bounded_queue.h:71
bool init(std::size_t session_number, Relay_log_info *channel_rli) override
Initializes the session service with a bounded queue.
Definition: session_service_bounded_queue.cpp:40
Service that provides a free session to executing transactions.
Definition: session_service.h:44
mysql::scheduler::Task_id Task_id
Alias for task identifier.
Definition: session_service.h:47
Represents the identifier of a task ingested by the scheduler,.
Definition: task_id.h:41
Binary log event definitions.
constexpr std::size_t csa_session_default_cache_size
Definition: tune.h:34
Definition: channel.cpp:28
std::shared_ptr< Relay_context > Relay_context_ptr
Definition: relay_context.h:39
Experimental API header.
Dependency_tracker instrumentation parameters, packed into this structure to simplify construction of...
Definition: session_service_psi.h:38