MySQL 9.3.0
Source Code Documentation
query_retry_on_ro.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 2025, 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 ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_HELPER_QUERY_RETRY_ON_RO_H_
25#define ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_HELPER_QUERY_RETRY_ON_RO_H_
26
29#include "mrs/gtid_manager.h"
31
33
34namespace mrs {
35namespace database {
36
38 public:
41
42 public:
44 GtidManager *gtid_manager, FilterObjectGenerator &fog,
45 uint64_t wait_gtid_timeout, bool query_has_gtid_check);
46
47 void before_query() override;
49 const FilterObjectGenerator &get_fog() override;
50 bool should_retry(const uint64_t affected) const override;
51
52 protected:
53 virtual void throw_timeout() const = 0;
54 virtual void using_ro_connection() const = 0;
55 virtual void using_rw_connection() const = 0;
56 virtual void switch_ro_to_rw() const = 0;
57
58 private:
59 bool check_gtid(const std::string &gtid);
64 mutable bool is_retry_{false};
69};
70
71} // namespace database
72} // namespace mrs
73
74#endif // ROUTER_SRC_MYSQL_REST_SERVICE_SRC_MRS_DATABASE_HELPER_QUERY_RETRY_ON_RO_H_
Definition: cache_manager.h:41
Definition: mysql_cache_manager.h:87
MySqlCacheManager::CachedObject CachedObject
Definition: mysql_cache_manager.h:92
Definition: gtid_manager.h:50
Definition: filter_object_generator.h:44
Definition: query_retry_on_ro.h:37
const FilterObjectGenerator & get_fog() override
Definition: query_retry_on_ro.cc:106
virtual void throw_timeout() const =0
virtual void using_rw_connection() const =0
bool query_has_gtid_check_
Definition: query_retry_on_ro.h:68
mysqlrouter::sqlstring gtid_
Definition: query_retry_on_ro.h:66
bool should_retry(const uint64_t affected) const override
Definition: query_retry_on_ro.cc:108
GtidManager * gtid_manager_
Definition: query_retry_on_ro.h:61
mysqlrouter::MySQLSession * get_session() override
Definition: query_retry_on_ro.cc:102
virtual void using_ro_connection() const =0
bool check_gtid(const std::string &gtid)
Definition: query_retry_on_ro.cc:132
bool filter_object_has_asof_
Definition: query_retry_on_ro.h:65
uint64_t wait_gtid_timeout_
Definition: query_retry_on_ro.h:67
FilterObjectGenerator & fog_
Definition: query_retry_on_ro.h:63
QueryRetryOnRO(collector::MysqlCacheManager *cache, CachedSession &session, GtidManager *gtid_manager, FilterObjectGenerator &fog, uint64_t wait_gtid_timeout, bool query_has_gtid_check)
Definition: query_retry_on_ro.cc:45
CachedSession & session_
Definition: query_retry_on_ro.h:60
void before_query() override
Definition: query_retry_on_ro.cc:63
bool is_retry_
Definition: query_retry_on_ro.h:64
collector::MysqlCacheManager * cache_
Definition: query_retry_on_ro.h:62
virtual void switch_ro_to_rw() const =0
Definition: query_retry.h:35
Definition: mysql_session.h:157
Definition: utils_sqlstring.h:67
collector::MysqlCacheManager MysqlCacheManager
Definition: handler_db_object_table.cc:266
Definition: authorize_manager.h:48