diff options
author | Julius Goryavsky <julius.goryavsky@mariadb.com> | 2022-04-28 15:06:16 +0200 |
---|---|---|
committer | Julius Goryavsky <julius.goryavsky@mariadb.com> | 2022-05-09 07:55:41 +0200 |
commit | e571174e80a7f3e4b4753c54c2ae0803fe7c96ef (patch) | |
tree | 3832a6da46df54b3f7d1abe4204b7c2937acf477 | |
parent | 0902cfaec8cf15c042b1c2159db8ffc97e9bce95 (diff) | |
download | mariadb-git-e571174e80a7f3e4b4753c54c2ae0803fe7c96ef.tar.gz |
MDEV-28291: Hashicorp: Cache variables claim to be dynamic but changes are ignored
This commit fixes an issue with no visible update in caching
option values after changing them dynamically while the server
is running. This issue was related to forgotten copy operations
of new values into dynamic variables. At the same time, internal
variables (responsible for caching) were always updated correctly.
The commit includes a test that checks that the update is now
reflected in the values of dynamic variables.
4 files changed, 50 insertions, 2 deletions
diff --git a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc index 321b9d74d14..f58a2fca9bd 100644 --- a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc +++ b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc @@ -356,7 +356,9 @@ static void cache_timeout_update (MYSQL_THD thd, void *var_ptr, const void *save) { - cache_max_time = ms_to_ticks(* (long *) var_ptr); + long timeout = * (long *) save; + * (long *) var_ptr = timeout; + cache_max_time = ms_to_ticks(timeout); } static MYSQL_SYSVAR_LONG(cache_timeout, cache_timeout, @@ -370,7 +372,9 @@ static void void *var_ptr, const void *save) { - cache_max_ver_time = ms_to_ticks(* (long *) var_ptr); + long timeout = * (long *) save; + * (long *) var_ptr = timeout; + cache_max_ver_time = ms_to_ticks(timeout); } static MYSQL_SYSVAR_LONG(cache_version_timeout, cache_version_timeout, diff --git a/plugin/hashicorp_key_management/mysql-test/vault/r/hashicorp_cache_timeout_update.result b/plugin/hashicorp_key_management/mysql-test/vault/r/hashicorp_cache_timeout_update.result new file mode 100644 index 00000000000..a26b813a3e7 --- /dev/null +++ b/plugin/hashicorp_key_management/mysql-test/vault/r/hashicorp_cache_timeout_update.result @@ -0,0 +1,19 @@ +SELECT +@@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT, +@@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT; +@@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT +0 180000 +SET GLOBAL +HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT= 1, +HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT= 1; +SELECT +@@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT, +@@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT; +@@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT +1 1 +SET GLOBAL HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT=0, HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT=180000; +SELECT +@@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT, +@@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT; +@@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT +0 180000 diff --git a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_cache_timeout_update.opt b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_cache_timeout_update.opt new file mode 100644 index 00000000000..cdc590b33ed --- /dev/null +++ b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_cache_timeout_update.opt @@ -0,0 +1,2 @@ +--loose-hashicorp-key-management-cache-timeout=180000 +--loose-hashicorp-key-management-cache-version-timeout=0 diff --git a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_cache_timeout_update.test b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_cache_timeout_update.test new file mode 100644 index 00000000000..61c23d44548 --- /dev/null +++ b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_cache_timeout_update.test @@ -0,0 +1,23 @@ +# MDEV-28291: Cache variables claim to be dynamic but changes are ignored + +--source hashicorp_plugin.inc +--source hashicorp_init.inc + +--let $ct=`SELECT @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT` +--let $vt=`SELECT @@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT` + +SELECT + @@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT, + @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT; +SET GLOBAL + HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT= 1, + HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT= 1; +SELECT + @@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT, + @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT; +--eval SET GLOBAL HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT=$vt, HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT=$ct +SELECT + @@HASHICORP_KEY_MANAGEMENT_CACHE_VERSION_TIMEOUT, + @@HASHICORP_KEY_MANAGEMENT_CACHE_TIMEOUT; + +--source hashicorp_deinit.inc |