mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
MDEV-31746 Problems with tx_isolation after MDEV-21921
With session tracking on the tx_isolation of importance to connector frameworks, its important that tracking of tx_isolation does get informed if a user `set session transaction_isolation=X` as the alias for tx_isolation. Rather than just implement this for one variable alias, it is implemented for all aliases. To assist with this the key hash of session_tracker is now made up of the offset, not the sys_var pointer. The impacts of aliases are: - If track one variable, its alias changes, you get a tracking change on the variable you are monitoring. - If you track two aliased variables of each other, changing a variable will have a tracking events for only one of them. Aliases of Sys_var_bit are not implemented, because we don't have them, so would've been no way to verify that the new code works. Post-Review edits by Sergei Golubchik <serg@mariadb.com>
This commit is contained in:
parent
00d09aae6f
commit
fa2faf41e7
4 changed files with 205 additions and 10 deletions
|
@ -91,3 +91,138 @@ SET GLOBAL event_scheduler=default;
|
|||
# MDEV-16470 - Session user variables tracker
|
||||
#
|
||||
# End of 10.5 tests
|
||||
#
|
||||
# MDEV-31746 Problems with tx_isolation after MDEV-21921
|
||||
#
|
||||
# tracking info on
|
||||
SET session_track_system_variables='max_insert_delayed_threads';
|
||||
SET max_delayed_threads=0;
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- max_insert_delayed_threads
|
||||
-- 0
|
||||
|
||||
SET @@max_delayed_threads=0;
|
||||
SET SESSION max_delayed_threads=0;
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- max_insert_delayed_threads
|
||||
-- 0
|
||||
|
||||
SET session_track_system_variables='max_delayed_threads';
|
||||
SET max_insert_delayed_threads=@@global.max_delayed_threads;
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- max_delayed_threads
|
||||
-- 20
|
||||
|
||||
SET session_track_system_variables='tx_isolation';
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-COMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-UNCOMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- REPEATABLE-READ
|
||||
|
||||
Track 2, get 2
|
||||
SET session_track_system_variables='tx_isolation,transaction_isolation';
|
||||
select @@session_track_system_variables;
|
||||
@@session_track_system_variables
|
||||
tx_isolation
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-COMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-UNCOMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- REPEATABLE-READ
|
||||
|
||||
SET session_track_system_variables='transaction_isolation';
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- transaction_isolation
|
||||
-- READ-COMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- transaction_isolation
|
||||
-- READ-UNCOMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- transaction_isolation
|
||||
-- REPEATABLE-READ
|
||||
|
||||
SET session_track_system_variables='tx_isolation,transaction_isolation,tx_isolation';
|
||||
SELECT @@session_track_system_variables;
|
||||
@@session_track_system_variables
|
||||
tx_isolation
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-COMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-UNCOMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- REPEATABLE-READ
|
||||
|
||||
accumulate as we encounter duplicates
|
||||
SET session_track_system_variables='*';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- session_track_system_variables
|
||||
-- *
|
||||
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-COMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- READ-UNCOMMITTED
|
||||
|
||||
Warnings:
|
||||
Warning 1287 '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- tx_isolation
|
||||
-- REPEATABLE-READ
|
||||
|
||||
# End of 11.1 tests
|
||||
|
|
|
@ -123,3 +123,59 @@ SET GLOBAL event_scheduler=default;
|
|||
#SET @inserted_value=REPEAT(1,16777180); # Only crashes when >=16777180 (max = 16777216)
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31746 Problems with tx_isolation after MDEV-21921
|
||||
--echo #
|
||||
|
||||
--echo # tracking info on
|
||||
|
||||
--enable_session_track_info
|
||||
|
||||
SET session_track_system_variables='max_insert_delayed_threads';
|
||||
SET max_delayed_threads=0;
|
||||
SET @@max_delayed_threads=0;
|
||||
SET SESSION max_delayed_threads=0;
|
||||
|
||||
SET session_track_system_variables='max_delayed_threads';
|
||||
SET max_insert_delayed_threads=@@global.max_delayed_threads;
|
||||
|
||||
SET session_track_system_variables='tx_isolation';
|
||||
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
|
||||
--echo Track 2, get 2
|
||||
SET session_track_system_variables='tx_isolation,transaction_isolation';
|
||||
select @@session_track_system_variables;
|
||||
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
|
||||
SET session_track_system_variables='transaction_isolation';
|
||||
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
|
||||
SET session_track_system_variables='tx_isolation,transaction_isolation,tx_isolation';
|
||||
|
||||
SELECT @@session_track_system_variables;
|
||||
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
|
||||
--echo accumulate as we encounter duplicates
|
||||
SET session_track_system_variables='*';
|
||||
|
||||
SET @@session.tx_isolation='READ-COMMITTED';
|
||||
SET SESSION tx_isolation='READ-UNCOMMITTED';
|
||||
SET SESSION transaction_isolation='REPEATABLE-READ';
|
||||
# TEST GAP, there are no aliases of Sys_var_bit variables, implemented but
|
||||
# no tests yet.
|
||||
--disable_session_track_info
|
||||
|
||||
--echo # End of 11.1 tests
|
||||
|
|
|
@ -60,6 +60,16 @@ void Session_sysvars_tracker::vars_list::copy(vars_list* from, THD *thd)
|
|||
from->init();
|
||||
}
|
||||
|
||||
Session_sysvars_tracker::
|
||||
sysvar_node_st *Session_sysvars_tracker::vars_list::search(const sys_var *svar)
|
||||
{
|
||||
return reinterpret_cast<sysvar_node_st*>(
|
||||
my_hash_search(&m_registered_sysvars,
|
||||
reinterpret_cast<const uchar*>(&svar->offset),
|
||||
sizeof(svar->offset)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Inserts the variable to be tracked into m_registered_sysvars hash.
|
||||
|
||||
|
@ -559,8 +569,9 @@ uchar *Session_sysvars_tracker::sysvars_get_key(const char *entry,
|
|||
size_t *length,
|
||||
my_bool not_used __attribute__((unused)))
|
||||
{
|
||||
*length= sizeof(sys_var *);
|
||||
return (uchar *) &(((sysvar_node_st *) entry)->m_svar);
|
||||
auto key=&(((sysvar_node_st *) entry)->m_svar->offset);
|
||||
*length= sizeof(*key);
|
||||
return (uchar *) key;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -154,14 +154,7 @@ class Session_sysvars_tracker: public State_tracker
|
|||
my_hash_free(&m_registered_sysvars);
|
||||
}
|
||||
|
||||
sysvar_node_st *search(const sys_var *svar)
|
||||
{
|
||||
return reinterpret_cast<sysvar_node_st*>(
|
||||
my_hash_search(&m_registered_sysvars,
|
||||
reinterpret_cast<const uchar*>(&svar),
|
||||
sizeof(sys_var*)));
|
||||
}
|
||||
|
||||
sysvar_node_st *search(const sys_var *svar);
|
||||
sysvar_node_st *at(ulong i)
|
||||
{
|
||||
DBUG_ASSERT(i < m_registered_sysvars.records);
|
||||
|
|
Loading…
Add table
Reference in a new issue