minor changes to optimize innodb_kill_idle_transaction
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.1 |
Won't Fix
|
Undecided
|
Unassigned | |||
5.5 |
Won't Fix
|
Wishlist
|
Laurynas Biveinis | |||
5.6 |
Fix Released
|
Wishlist
|
Laurynas Biveinis | |||
5.7 |
Fix Released
|
Wishlist
|
Laurynas Biveinis |
Bug Description
If innodb_
1. while scanning the trx list, pick out the oldest idle time ( that not need to be killed), called last_max_idle;
2.During next loop, if ++last_max_idle < last_max_idle, then we don't need to scan the trx list.
A simple patch (Not tested fully)
Index: srv/srv0srv.cc
=======
--- srv/srv0srv.cc (revision 7085)
+++ srv/srv0srv.cc (working copy)
@@ -2068,6 +2068,7 @@
/* the semaphore that is being waited for */
const void* sema = NULL;
const void* old_sema = NULL;
+ long long last_max_idle = 0;
@@ -2140,10 +2141,13 @@
old_sema = sema;
}
- if (srv_kill_
+ if (srv_kill_
+ && ((++last_max_idle) >= srv_kill_
+ && trx_sys) {
trx_t* trx;
time_t now;
rescan_idle:
+ last_max_idle = 0;
now = time(NULL);
trx = UT_LIST_
@@ -2158,12 +2162,16 @@
- } else if (difftime(now, trx->idle_start)
- > srv_kill_
- /* kill the session */
- mutex_exit(
- innobase_
- goto rescan_idle;
+ } else {
+ longlong diff = difftime(now, trx->idle_start);
+ if (diff > srv_kill_
+ /* kill the session */
+ mutex_exit(
+ innobase_
+ goto rescan_idle;
+
+ } else
+ last_max_idle = ut_max(
}
trx = UT_LIST_
description: | updated |
tags: | added: performance |
tags: | added: kill-idle-trx |
Thank you for the patch contributed. It makes sense to consider this idea for all Percona Server versions.