为何MySQL未像Percona Server那样实现kill idle transaction功能?
kill idle transaction Feature Like Percona Server? Great question! Let's break down what we know about Percona's implementation and the context around why MySQL core hasn't adopted this feature yet:
First, Percona Server does offer a mechanism to kill idle transactions. Its initial implementation operated at the underlying InnoDB transaction list level—periodically scanning the transaction list and terminating sessions that had been idle for an extended period.
Later, a developer named Peng Lixun proposed a refined approach (tied to bug 907719) that reimplements this feature using socket read timeouts instead. This new design brings several key improvements over the original:
- Cleaner, more stable code: It resolves crash bugs present in the initial implementation (bug 1166744, bug 1179136)
- Engine-agnostic support: Unlike the first version which only worked with InnoDB, this updated approach supports all MySQL storage engines
From a user perspective, the revised implementation introduces a new server variable kill_idle_transaction, while marking the old innodb_kill_idle_transaction as a deprecated alias (set to be removed in version 8.0).
As for why MySQL core hasn't added this feature: Official MySQL tends to prioritize broad stability, cross-environment compatibility, and conservative design over niche, user-requested enhancements. Automatically terminating idle transactions carries inherent risks—like unexpected interruptions to long-running but temporarily idle sessions, or potential consistency issues across diverse engine architectures. Percona, as a specialized branch focused on performance and practical user pain points, can move faster to ship and iterate on features like this that solve specific real-world problems for their user base.
内容的提问来源于stack exchange,提问作者褚华兴

