Bug #121904 Failed duplicate register_variable() resets the value of the existing component variable

Submitted: 24 Nov 9:21
Reporter: Tomas Ulin Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Components / Services Severity:S3 (Non-critical)
Version:9.7.4, trunk (26.10.0) OS:Any
Assigned to: CPU Architecture:Any

[24 Nov 9:21] Tomas Ulin
Description:
component_test_session_var_service registers test_component.int_session_var
twice. The second registration fails as a duplicate, as it should. But
before it fails, it writes the variable's default into the global value of
the variable that the first registration owns.

So after a reinstall, a persisted value is replaced by the
default: @@global.test_component.int_session_var is 8, the default, while
performance_schema.persisted_variables still shows 7. long_session_var,
which is registered once, keeps its persisted value 50.

How to repeat:
MTR test in suite service_sys_var_registration, with
duplicate_register_value-master.opt containing:

$SESSION_VAR_SERVICE_OPT

duplicate_register_value.test:

--source ../include/have_component_test_session_var_service.inc

call mtr.add_suppression("duplicate variable name");
call mtr.add_suppression("MY-000080");
call mtr.add_suppression("MY-000081");

INSTALL COMPONENT "file://component_test_session_var_service";
SET PERSIST test_component.int_session_var = 7;
SET PERSIST test_component.long_session_var = 50;
UNINSTALL COMPONENT "file://component_test_session_var_service";
INSTALL COMPONENT "file://component_test_session_var_service";

# Expected: 7 and 50, the persisted values
SELECT @@global.test_component.int_session_var, @@global.test_component.long_session_var;
SELECT VARIABLE_NAME, VARIABLE_VALUE FROM performance_schema.persisted_variables
  WHERE VARIABLE_NAME LIKE 'test_component.%' ORDER BY VARIABLE_NAME;

UNINSTALL COMPONENT "file://component_test_session_var_service";
RESET PERSIST test_component.int_session_var;
RESET PERSIST test_component.long_session_var;
let $MYSQLD_DATADIR= `select @@datadir`;
--remove_file $MYSQLD_DATADIR/test_component_session_var_service.log

Result on 9.7.4 and trunk:

SELECT @@global.test_component.int_session_var, @@global.test_component.long_session_var;
@@global.test_component.int_session_var @@global.test_component.long_session_var
8       50
SELECT VARIABLE_NAME, VARIABLE_VALUE FROM performance_schema.persisted_variables
WHERE VARIABLE_NAME LIKE 'test_component.%' ORDER BY VARIABLE_NAME;
VARIABLE_NAME   VARIABLE_VALUE
test_component.int_session_var  7
test_component.long_session_var 50

Expected: 7 for int_session_var.
[24 Nov 9:23] Tomas Ulin
test

Attachment: duplicate_register_value.test (application/octet-stream, text), 1.02 KiB.

[24 Nov 9:23] Tomas Ulin
opt

Attachment: duplicate_register_value-master.opt (application/octet-stream, text), 25 bytes.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.