Skip to content

Commit

Permalink
MDEV-30120 Update the wsrep_provider_options read_only value in the s…
Browse files Browse the repository at this point in the history
…ystem_variables table.

When wsrep-provider-options plugin is initialized we need to update
wsrep-provider-options variable as READ_ONLY.
  • Loading branch information
Jan Lindström authored and vuvova committed Feb 14, 2023
1 parent 79d0194 commit 4849b73
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion mysql-test/suite/wsrep/t/wsrep_provider_plugin.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
SET GLOBAL wsrep_provider_repl_max_ws_size=1;
SHOW VARIABLES LIKE 'wsrep_provider_repl_max_ws_size';

--error ER_ERROR_DURING_COMMIT
--error ER_UNKNOWN_ERROR
INSERT INTO t1 VALUES (1);

SET GLOBAL wsrep_provider_repl_max_ws_size=DEFAULT;
Expand All @@ -31,3 +31,8 @@ DROP TABLE t1;

CALL mtr.add_suppression("transaction size limit");
CALL mtr.add_suppression("rbr write fail");

#
# MDEV-30120 :Update the wsrep_provider_options read_only value in the system_variables table.
#
SELECT VARIABLE_NAME,READ_ONLY FROM information_schema.system_variables where VARIABLE_NAME like '%wsrep_provider_options%';
3 changes: 2 additions & 1 deletion sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ IF(WITH_WSREP AND NOT EMBEDDED_LIBRARY)
wsrep_schema.cc
wsrep_plugin.cc
service_wsrep.cc
)
)
MYSQL_ADD_PLUGIN(wsrep_provider ${WSREP_SOURCES} DEFAULT NOT_EMBEDDED LINK_LIBRARIES wsrep-lib wsrep_api_v26)
MYSQL_ADD_PLUGIN(wsrep ${WSREP_SOURCES} MANDATORY NOT_EMBEDDED LINK_LIBRARIES wsrep-lib wsrep_api_v26)
IF(VISIBILITY_HIDDEN_FLAG AND TARGET wsrep)
# wsrep_info plugin needs some wsrep symbols from inside mysqld
Expand Down
2 changes: 2 additions & 0 deletions sql/set_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class sys_var: protected Value_source // for double_from_string_with_check
return system_charset_info;
}
bool is_readonly() const { return flags & READONLY; }
void update_flags(int new_flags) { flags = new_flags; }
int get_flags() const { return flags; }
/**
the following is only true for keycache variables,
that support the syntax @@keycache_name.variable_name
Expand Down
14 changes: 14 additions & 0 deletions sql/wsrep_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
in favor of single options which are initialized from provider.
*/

#include "sql_plugin.h"
#include "sql_priv.h"
#include "sql_class.h"
#include "set_var.h"

#include "my_global.h"
#include "mysqld_error.h"
#include <mysql/plugin.h>
Expand Down Expand Up @@ -272,12 +277,21 @@ static int wsrep_provider_plugin_init(void *p)
{
WSREP_DEBUG("wsrep_provider_plugin_init()");
provider_plugin_enabled= true;

// When plugin-wsrep-provider is enabled we set
// wsrep_provider_options parameter as READ_ONLY
sys_var *my_var= find_sys_var(current_thd, "wsrep_provider_options");
int flags= my_var->get_flags();
my_var->update_flags(flags |= (int)sys_var::READONLY);
return 0;
}

static int wsrep_provider_plugin_deinit(void *p)
{
WSREP_DEBUG("wsrep_provider_plugin_deinit()");
sys_var *my_var= find_sys_var(current_thd, "wsrep_provider_options");
int flags= my_var->get_flags();
my_var->update_flags(flags &= (int)~sys_var::READONLY);
return 0;
}

Expand Down

0 comments on commit 4849b73

Please sign in to comment.