From 288d4e83f1dab9fc9744eed7129e4f77d82be7ad Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Fri, 31 Jul 2026 10:34:40 -0500 Subject: [PATCH] Fix autovacuum's database sorting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When db_comparator() was updated to use pg_cmp_s32(), the arguments were listed in the wrong order. This caused autovacuum to sort the databases by their scores in ascending order instead of descending order. To fix, swap the arguments to pg_cmp_s32(). Oversight in commit 3b42bdb471. Reported-by: Хамидуллин Рустам Author: Хамидуллин Рустам Discussion: https://postgr.es/m/5c5a7984-b149-b505-7ad9-2a7766c65b55%40postgrespro.ru Backpatch-through: 17 --- src/backend/postmaster/autovacuum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 93beed26fc6..e55d25b38d9 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -1054,8 +1054,8 @@ rebuild_database_list(Oid newdb) static int db_comparator(const void *a, const void *b) { - return pg_cmp_s32(((const avl_dbase *) a)->adl_score, - ((const avl_dbase *) b)->adl_score); + return pg_cmp_s32(((const avl_dbase *) b)->adl_score, + ((const avl_dbase *) a)->adl_score); } /*