My opinion remains that the feature (now as of commit 22347482) can be pushed into the main branch and released with 11.7.1.
I didn't do full re-testing of the feature, but the variable still works, I don't see any essential changes comparing to the status of my comment added in the scope of 11.5 preview testing, except that the notes from it have been addressed since then.
For the fragility of the test, I see one place where it is clearly non-deterministic, the last sleep-based query ("this-should-not-be-logged" one):
SET log_slow_query_time=0.5;
|
SET log_slow_rate_limit=999;
|
SET log_slow_always_query_time=1.5;
|
SET log_slow_min_examined_row_limit= 100;
|
|
--source include/log_slow_start.inc
|
SELECT sleep(2) as 'this-should-be-logged';
|
SELECT sleep(1) as 'this-should-not-be-logged'
|
So, if the server is slow and the query actually takes longer than 1.5 seconds, it will be logged.
Without re-writing the test completely (and I don't know how it can be done deterministically without debug which we probably don't want to use unless necessary), I think the probability of the failure could be essentially reduced by changing the sleep times and variable values a little bit, e.g. like so:
SET log_slow_query_time=0.5;
|
SET log_slow_rate_limit=999;
|
SET log_slow_always_query_time=1.9;
|
SET log_slow_min_examined_row_limit= 100;
|
|
--source include/log_slow_start.inc
|
SELECT sleep(2) as 'this-should-be-logged';
|
SELECT sleep(0.6) as 'this-should-not-be-logged'
|
that is, increase log_slow_always_query_time and decrease the second sleep.
There should be no danger in having the sleep time close to the limit as long as it is exceeding the limit – I don't think sleep ever takes less than the parameter value.
We can however wait to see it fail. I ran the test (the current version in the branch) several hundred times in shm, on disk, with embedded, with ps protocol, with the heavy disk/cpu usage in parallel, and didn't get a failure so far, so it doesn't seem that the probability is extremely high.
Commit message:
MDEV-33144Implement the Percona variable slow_query_log_always_write_timeThis task is inspired by the Percona implementation of
slow_query_log_always_write_time.
This task implements the variable log_slow_always_query_time (name matching
other MariaDB variables using the slow query log). The default value for
the variable is 0, which makes MariaDB compatible with older installations.
For queries with execution time longer than log_slow_always_query_time
the variables log_slow_rate_limit and log_slow_min_examined_row_limit
will not ignored and the query will be written to the slow query log
if there is no other limitations (like log_slow_filter etc).
Other things: