Skip to content

Commit

Permalink
MDEV-33031 Assertion failure upon reading from performance schema wit…
Browse files Browse the repository at this point in the history
…h binlog enabled

same assertion with spider. spider status variables
didn't expect to be queried from a different thread
without LOCK_thd_data.

And they didn't expect to be queried under LOCK_thd_data either
(because spider_get_trx() calls thd_set_ha_data()).
  • Loading branch information
vuvova committed Jan 9, 2024
1 parent b3065af commit 23e107d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
11 changes: 11 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/perfschema.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# MDEV-33031 Assertion failure upon reading from performance schema with binlog enabled
#
connect foo,localhost,root;
select variable_name, variable_value from performance_schema.status_by_thread
where variable_name like '%spider_direct_aggregate%';
variable_name variable_value
Spider_direct_aggregate 0
Spider_direct_aggregate 0
disconnect foo;
connection default;
1 change: 1 addition & 0 deletions storage/spider/mysql-test/spider/bugfix/t/perfschema.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--performance-schema
15 changes: 15 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/perfschema.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
disable_query_log;
source ../../include/init_spider.inc;
enable_query_log;

--echo #
--echo # MDEV-33031 Assertion failure upon reading from performance schema with binlog enabled
--echo #
connect foo,localhost,root;
select variable_name, variable_value from performance_schema.status_by_thread
where variable_name like '%spider_direct_aggregate%';
disconnect foo;
connection default;

disable_query_log;
source ../../include/deinit_spider.inc;
14 changes: 9 additions & 5 deletions storage/spider/spd_param.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,20 @@ extern volatile ulonglong spider_mon_table_cache_version_req;
MYSQL_SYSVAR_NAME(param_name).def_val; \
}

extern handlerton *spider_hton_ptr;
static int spider_trx_status_var(THD *thd, SHOW_VAR *var, char *buff,
ulonglong SPIDER_TRX::*counter)
{
int error_num = 0;
SPIDER_TRX *trx;
DBUG_ENTER("spider_direct_update");
var->type = SHOW_LONGLONG;
if ((trx = spider_get_trx(thd, TRUE, &error_num)))
var->value = (char *) &(trx->*counter);
DBUG_RETURN(error_num);
var->value= buff;
if (thd != current_thd)
mysql_mutex_lock(&thd->LOCK_thd_data);
SPIDER_TRX *trx = (SPIDER_TRX*)thd_get_ha_data(thd, spider_hton_ptr);
*(ulonglong*)buff= trx ? trx->*counter : 0;
if (thd != current_thd)
mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(0);
}


Expand Down

0 comments on commit 23e107d

Please sign in to comment.