标签
PostgreSQL , 10.0 , GIN vacuum , 锁范围降低
背景
如果你发现你的CPU没怎么用,但是压力就是上不去,很大可能是锁等待造成的(perf可以观察),锁在数据库优化中是一个比较永恒的话题。
以往在vacuum GIN索引clean posting tree时,需要锁整个posting tree,10.0改进了这块的锁,现在只锁一个subtree。
在较大的GIN KEY被更新后,清除posting tree时,锁冲突更小了。
Reduce page locking in GIN vacuum
GIN vacuum during cleaning posting tree can lock this whole tree for a long
time with by holding LockBufferForCleanup() on root. Patch changes it with
two ways: first, cleanup lock will be taken only if there is an empty page
(which should be deleted) and, second, it tries to lock only subtree, not the
whole posting tree.
Author: Andrey Borodin with minor editorization by me
Reviewed-by: Jeff Davis, me
https://commitfest.postgresql.org/13/896/
这个patch的讨论,详见邮件组,本文末尾URL。
PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。
参考
时间: 2024-10-25 01:56:50