1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-13727 top-level query timestamp reset at stored func/trigger internal statements

Being executed under slow_log is ON the test revealed a "side-effect"
in MDEV-8305 implementation which inadvertently made the trigger or
stored function statements to reset the top-level query's
THD::start_time et al. (Details of the test failure analysis are footnoted).
Unlike the SP case the SF and Trigger's internal statement should not
do that.

Fixed with revising the MDEV-8305 decision to backup/reset/restore
the session timestamp inside sp_instr_stmt::execute(). The timestamp
actually remains reset in the SP case by its caller per statement basis by ever
existing logics.

Timestamps related tests are extended to cover the trigger and stored function case.

Note, commit 3395ab7324 is reverted as its struct QUERY_START_TIME_INFO
declaration is not in use anymore after this patch.

Footnote:
--------
Specifically to the failing test, a query on the master was logged
okay with a timestamp of the query's top-level statement but its post
update trigger managed to compute one more (later) timestamp which got
inserted into another table. The latter table master-vs-slave
no fractional part timestamp discrepancy became evident
thanks to different execution time of the trigger combined with the
fact of the logged with micro-second fractional part master timestamp
was truncated on the slave. On master when the fractional part was
close to 1 the trigger execution added up its own latency to overflow
to next second value. That's how the master timestamp surprisingly
turned out to bigger than the slave's one.
This commit is contained in:
Andrei Elkin
2018-05-22 20:19:13 +03:00
parent 83ec8c88c6
commit 3bbc30c73b
4 changed files with 89 additions and 36 deletions

View File

@ -2139,26 +2139,6 @@ struct wait_for_commit
void reinit();
};
/*
Structure to store the start time for a query
*/
struct QUERY_START_TIME_INFO
{
my_time_t start_time;
ulong start_time_sec_part;
ulonglong start_utime, utime_after_lock;
void backup_query_start_time(QUERY_START_TIME_INFO *backup)
{
*backup= *this;
}
void restore_query_start_time(QUERY_START_TIME_INFO *backup)
{
*this= *backup;
}
};
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
/**
@ -2177,8 +2157,7 @@ class THD :public Statement,
*/
public Item_change_list,
public MDL_context_owner,
public Open_tables_state,
public QUERY_START_TIME_INFO
public Open_tables_state
{
private:
inline bool is_stmt_prepare() const
@ -2403,10 +2382,12 @@ public:
uint32 file_id; // for LOAD DATA INFILE
/* remote (peer) port */
uint16 peer_port;
my_time_t start_time; // start_time and its sec_part
ulong start_time_sec_part; // are almost always used separately
my_hrtime_t user_time;
// track down slow pthread_create
ulonglong prior_thr_create_utime, thr_create_utime;
ulonglong utime_after_query;
ulonglong start_utime, utime_after_lock, utime_after_query;
// Process indicator
struct {