Skip to content
/ server Public

Commit cb31d75

Browse files
committed
MDEV-38604 Assertion `thd->utime_after_query >= thd->utime_after_lock' failed in query_response_time_audit_notify on 2nd execution of SP with query cache
even when PS is served from a query cache, thd->utime_after_query must be updated. also, backport the assert from 11.8
1 parent cd02709 commit cb31d75

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# MDEV-38604 Assertion `thd->utime_after_query >= thd->utime_after_lock' failed in query_response_time_audit_notify on 2nd execution of SP with query cache
3+
#
4+
set global query_response_time_stats=on;
5+
set global query_cache_type=on;
6+
set query_cache_type=on;
7+
create table t (a int);
8+
create procedure sp() execute immediate 'select * from t';
9+
call sp;
10+
a
11+
call sp;
12+
a
13+
drop table t;
14+
drop procedure sp;
15+
set global query_cache_type= default;
16+
set global query_response_time_stats=default;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--echo #
2+
--echo # MDEV-38604 Assertion `thd->utime_after_query >= thd->utime_after_lock' failed in query_response_time_audit_notify on 2nd execution of SP with query cache
3+
--echo #
4+
set global query_response_time_stats=on;
5+
set global query_cache_type=on;
6+
set query_cache_type=on;
7+
8+
create table t (a int);
9+
create procedure sp() execute immediate 'select * from t';
10+
call sp;
11+
call sp;
12+
drop table t;
13+
drop procedure sp;
14+
15+
set global query_cache_type= default;
16+
set global query_response_time_stats=default;

plugin/query_response_time/plugin.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ static void query_response_time_audit_notify(MYSQL_THD thd,
122122
THDVAR(thd, exec_time_debug) : 0);
123123
else
124124
#endif
125-
query_response_time_collect(thd->utime_after_query - thd->utime_after_lock);
125+
{
126+
DBUG_ASSERT(thd->utime_after_query >= thd->utime_after_lock);
127+
query_response_time_collect(thd->utime_after_query - thd->utime_after_lock);
128+
}
126129
}
127130
}
128131

sql/sql_prepare.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5284,7 +5284,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
52845284
(char *) thd->security_ctx->host_or_ip, 1);
52855285
error= mysql_execute_command(thd, true);
52865286
MYSQL_QUERY_EXEC_DONE(error);
5287-
thd->update_server_status();
52885287
}
52895288
else
52905289
{
@@ -5293,6 +5292,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
52935292
thd->update_stats();
52945293
qc_executed= TRUE;
52955294
}
5295+
thd->update_server_status();
52965296
}
52975297

52985298
/*

0 commit comments

Comments
 (0)