开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
2 Star 0 Fork 0

万里数据库/GreatSQL-Cluster

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
标签 (1)
master
greatsql-cluster-8.4.4-4
GreatSQL-Cluster-8.4.4-4
master
分支 (2)
标签 (1)
master
greatsql-cluster-8.4.4-4
GreatSQL-Cluster-8.4.4-4
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
标签 (1)
master
greatsql-cluster-8.4.4-4
GreatSQL-Cluster-8.4.4-4
GreatSQL-Cluster
/
plugin
/
x
/
src
/
module_mysqlx.cc
GreatSQL-Cluster
/
plugin
/
x
/
src
/
module_mysqlx.cc
module_mysqlx.cc 9.17 KB
一键复制 编辑 原始数据 按行查看 历史
GreatSQL 提交于 2025年11月15日 22:14 +08:00 . first commit for GreatSQL Cluster 8.4.4-4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0,
* as published by the Free Software Foundation.
*
* This program is designed to work with certain software (including
* but not limited to OpenSSL) that is licensed under separate terms,
* as designated in a particular file or component or in included license
* documentation. The authors of MySQL hereby grant you an additional
* permission to link the program and your derivative works with the
* separately licensed software that they have either included with
* the program or referenced in the documentation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License, version 2.0, for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "plugin/x/src/module_mysqlx.h"
#include <memory>
#include <string>
#include <utility>
#include "my_dbug.h" // NOLINT(build/include_subdir)
#include <mysql/psi/mysql_metric.h>
#include "plugin/x/src/helper/multithread/xsync_point.h"
#include "plugin/x/src/module_cache.h"
#include "plugin/x/src/mysql_variables.h"
#include "plugin/x/src/server/builder/server_builder.h"
#include "plugin/x/src/services/mysqlx_group_member_status_listener.h"
#include "plugin/x/src/services/mysqlx_group_membership_listener.h"
#include "plugin/x/src/services/mysqlx_maintenance.h"
#include "plugin/x/src/services/registrator.h"
#include "plugin/x/src/sha256_password_cache.h"
#include "plugin/x/src/udf/mysqlx_error.h"
#include "plugin/x/src/udf/mysqlx_generate_document_id.h"
#include "plugin/x/src/udf/mysqlx_get_prepared_statement_id.h"
#include "plugin/x/src/udf/registry.h"
#include "plugin/x/src/variables/status_variables.h"
#include "plugin/x/src/variables/system_variables.h"
#include "plugin/x/src/variables/xpl_global_status_variables.h"
#include "plugin/x/src/xpl_log.h"
#include "plugin/x/src/xpl_performance_schema.h"
#include "scope_guard.h" // NOLINT(build/include_subdir)
namespace modules {
namespace details {
std::shared_ptr<xpl::iface::Client> get_client_by_thd(THD *thd) {
auto server = Module_mysqlx::get_instance_server();
if (!server.container()) return {};
return server->get_client(thd);
}
} // namespace details
xpl::RWLock Module_mysqlx::m_instance_rwl{KEY_rwlock_x_xpl_server_instance};
xpl::Services *Module_mysqlx::m_services = nullptr;
xpl::Notice_input_queue *Module_mysqlx::m_input_queue = nullptr;
xpl::udf::Registry *Module_mysqlx::m_udf_register = nullptr;
xpl::iface::Server *Module_mysqlx::m_server = nullptr;
xpl::iface::SHA256_password_cache *Module_mysqlx::m_sha256_password_cache =
nullptr;
void Module_mysqlx::require_services() {
Module_mysqlx::m_services = new xpl::Services();
if (!Module_mysqlx::m_services->is_valid())
throw std::runtime_error("One of \"mysqlx_server\" services was not found");
}
void Module_mysqlx::unrequire_services() {
delete Module_mysqlx::m_services;
Module_mysqlx::m_services = nullptr;
}
void Module_mysqlx::provide_services() {
xpl::Service_registrator r;
r.register_service(SERVICE(mysql_server, mysqlx_maintenance));
r.register_service(SERVICE(mysqlx, group_membership_listener));
r.register_service(SERVICE(mysqlx, group_member_status_listener));
}
void Module_mysqlx::unprovide_services() {
const char *service_names[] = {
SERVICE_ID(mysql_server, mysqlx_maintenance),
SERVICE_ID(mysqlx, group_membership_listener),
SERVICE_ID(mysqlx, group_member_status_listener)};
xpl::Service_registrator r;
for (const auto name : service_names) {
try {
r.unregister_service(name);
} catch (const std::exception &e) {
log_error(ER_XPLUGIN_FAILED_TO_STOP_SERVICES, e.what());
}
}
}
void Module_mysqlx::provide_udfs() {
m_udf_register = new xpl::udf::Registry();
m_udf_register->insert({
UDF(mysqlx_error),
UDF(mysqlx_generate_document_id),
UDF(mysqlx_get_prepared_statement_id),
});
}
void Module_mysqlx::unregister_udfs() {
if (m_udf_register) m_udf_register->drop();
delete m_udf_register;
m_udf_register = nullptr;
}
static bool x_ssl_reload_cb(void *) {
auto server = Module_mysqlx::get_instance_server();
server->reload_ssl_context();
return true;
}
int Module_mysqlx::initialize(MYSQL_PLUGIN plugin_handle) {
xpl::plugin_handle = plugin_handle;
try {
DBUG_EXECUTE_IF("xplugin_shutdown_unixsocket", {
XSYNC_POINT_ENABLE({"xacceptor_stop_wait", "xacceptor_pre_loop_wait",
"xacceptor_post_loop_wait"});
});
xpl::init_performance_schema();
provide_udfs();
require_services();
provide_services();
if (mysqld::get_initialize()) {
return 0;
}
xpl::Server_builder builder(plugin_handle);
auto update_plugin_vars = builder.get_result_reconfigure_server_callback();
auto sys_var_service = m_services->m_system_variable_register.get();
xpl::Global_status_variables::initialize();
xpl::Plugin_system_variables::initialize(
sys_var_service, update_plugin_vars, details::get_client_by_thd);
auto acceptor_task = builder.get_result_acceptor_task();
if (!acceptor_task) return 1;
xpl::RWLock_writelock guard_lock(&m_instance_rwl);
auto guard_of_server_start = create_scope_guard([]() {
if (m_server) m_server->start_failed();
});
m_sha256_password_cache =
ngs::allocate_object<xpl::SHA256_password_cache>();
m_input_queue = ngs::allocate_object<xpl::Notice_input_queue>();
m_server = builder.get_result_server_instance(
{acceptor_task, m_input_queue->create_broker_task()});
// Cache cleaning plugin started before the X plugin so cache was not
// enabled yet
//
// The `plugin` should be constructed in a way that `module_cache` is
// initialized before `module_mysqlx`. Thus is almost all cases
// `if` below should be evaluated as true.
//
// The problematic case is when module_cache was disabled by the user.
// In this case we should execute delayed startup.
if (Module_cache::m_is_sha256_password_cache_enabled) {
m_sha256_password_cache->enable();
}
if (!m_server->prepare()) {
// This is startup error, still we would like to keep
// X Plugin loaded.
return 0;
}
// Module_cache is not loaded, this means that it won't
// be able start the server. We must do "delayed start".
if (!Module_cache::m_is_sha256_password_cache_enabled) {
m_server->delayed_start_tasks();
}
mysql_meter_register(xpl::Plugin_status_variables::m_xpl_meter,
xpl::Plugin_status_variables::get_meter_count());
guard_of_server_start.release();
} catch (const std::exception &e) {
log_error(ER_XPLUGIN_STARTUP_FAILED, e.what());
return 1;
}
if (!register_ssl_reload_callback(&x_ssl_reload_cb)) {
log_warning(ER_XPLUGIN_SSL_RELOAD_REGISTER_FAILED);
}
return 0;
}
int Module_mysqlx::deinitialize(MYSQL_PLUGIN) {
// this flag will trigger the on_verify_server_state() timer to trigger an
// acceptor thread exit
deregister_ssl_reload_callback(&x_ssl_reload_cb);
if (m_server) m_server->stop();
xpl::Plugin_system_variables::cleanup();
{
xpl::RWLock_writelock slock(&m_instance_rwl);
ngs::free_object(m_server);
m_server = nullptr;
ngs::free_object(m_input_queue);
m_input_queue = nullptr;
ngs::free_object(m_sha256_password_cache);
m_sha256_password_cache = nullptr;
}
unrequire_services();
unprovide_services();
unregister_udfs();
mysql_meter_unregister(xpl::Plugin_status_variables::m_xpl_meter,
xpl::Plugin_status_variables::get_meter_count());
xpl::plugin_handle = nullptr;
return 0;
}
bool Module_mysqlx::reset() {
auto server = get_instance_server();
if (!server.container()) return false;
if (!server->reset()) return false;
const int64 worker_thread_count =
xpl::Global_status_variables::instance().m_worker_thread_count.load();
xpl::Global_status_variables::initialize(worker_thread_count);
return true;
}
struct SYS_VAR **Module_mysqlx::get_plugin_variables() {
return xpl::Plugin_system_variables::m_plugin_system_variables;
}
struct SHOW_VAR *Module_mysqlx::get_status_variables() {
return xpl::Plugin_status_variables::m_plugin_status_variables;
}
Module_mysqlx::Server_with_lock Module_mysqlx::get_instance_server() {
return Server_with_lock(m_server, &m_instance_rwl);
}
Module_mysqlx::Services_with_lock Module_mysqlx::get_instance_services() {
return Services_with_lock(m_services, &m_instance_rwl);
}
Module_mysqlx::Notice_queue_with_lock
Module_mysqlx::get_instance_notice_queue() {
return Notice_queue_with_lock(m_input_queue, &m_instance_rwl);
}
Module_mysqlx::Sha245_cache_with_lock
Module_mysqlx::get_instance_sha256_password_cache() {
return Sha245_cache_with_lock(m_sha256_password_cache, &m_instance_rwl);
}
} // namespace modules
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

GreatSQL Cluster是GreatSQL社区开源的分布式关系型数据库,具备卓越的水平扩展能力、金融级的数据一致性、秒级故障自动无损容灾能力以及完整SQL语法支持等重要特性。
取消

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/GreatSQL/GreatSQL-Cluster.git
git@gitee.com:GreatSQL/GreatSQL-Cluster.git
GreatSQL
GreatSQL-Cluster
GreatSQL-Cluster
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /