Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wQbMG-001g3i-2Y for pgsql-hackers@arkaria.postgresql.org; Sat, 23 May 2026 01:40:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQbMD-00F6aC-0s for pgsql-hackers@arkaria.postgresql.org; Sat, 23 May 2026 01:40:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wQbMC-00F6a4-2e for pgsql-hackers@lists.postgresql.org; Sat, 23 May 2026 01:40:53 +0000 Received: from mail-australiaeastazolkn190110001.outbound.protection.outlook.com ([2a01:111:f403:d40d::1] helo=SY2PR01CU004.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wQbMB-00000000Lw6-3UZF for pgsql-hackers@lists.postgresql.org; Sat, 23 May 2026 01:40:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KUxpMuu09hxn6qvgkUvfckwGjZi5v+zuBnhUxOLtmW+eiC+3dCC6Cw8sbrFqy1zxggQA+ibdWOeDzgorSRIh9UFMR3A8K3nJB/H9YwlGtmHutuT2vk682MTrEKpcqNOkysFVq0U0bPgWHLse7QKKuBg0quJGR1b+aKUmXxRwtyjB+scZwsrScb6DKObTYddypXvUPUk1A/LGFTJQs3ETIvSpaP2htfpH7wv+kt+abJkCeTvdoH5nJbQmdv2n1p75SRP8c67vxx9oIWr2pQWOsQZ1c347FjQ4agi7NHcwja2bnTvo+1912MaY8/UA0c6kOj8sL/i6LSHUszxPmz6hkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9nRUqgmNxedT1yvrPSt/uJWf3pIjrSpYw2lkN5OvfH4=; b=cRD8HrRWg4vH2nHmemZPYKcFpV0MTQs0Ur2K2CihLya7rmaZa/laJ32lotSWhsO7D0PcOE7+c9Iz+YM5S/C+5BH6vHa2oompiN+XaAcv3Cd7ErJV79ioQt5l9pGXBO10LMsWQVsmMVSIIhY7ax48AFbXxfxgjsLnQElwIx6Xu7hkXN4FCPsR2u87lRhYpJFt30JyAOtEWZ+CwB+xJ8TdXDtsDqQT65aqGf0DyQiwJ6vCFf2pG+7bUaxDpTfiXNaRhII9hRpGStnRqsf34PQb5yUfIEIVcJUnzbsOebDE5OdHpcAoO/U6QlMS38obmNzHn/d9NT7mvis/LbG/FJSwkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9nRUqgmNxedT1yvrPSt/uJWf3pIjrSpYw2lkN5OvfH4=; b=g3BeNMyOBxFPthpNw8x4V4/zfKxUIbaru12NDUxaZ7NZVeZ5WDs/kDCq+RWz3/Ho2NtL7qcizH055sMPNtWIrPqimhMuiUnEfyvEcywUF+DhRdAO87WOEuoiOYyTrwp7ZKbpT5xty2k+dFAEpZ/8I7dSeccgsciY6RHMQ1Ey5oTciG8X+rn0aLKScaHRbheh2Fyj6lzJ1DdKe5eGfelICGremMQ+W3rNT2DBU9sUksh3E6AIyPiiMU7i/06dzrnGo+1MiP8guKPnJN2MFYuaG1XK4KE493wxrBhW35whNYdtSXzwNCCPcGVxANopbzqSRkKA+8pHKRBVUlsI7llMug== Received: from SY7PR01MB10921.ausprd01.prod.outlook.com (2603:10c6:10:334::16) by SY7PR01MB8432.ausprd01.prod.outlook.com (2603:10c6:10:1f0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Sat, 23 May 2026 01:40:45 +0000 Received: from SY7PR01MB10921.ausprd01.prod.outlook.com ([fe80::7908:e00:4ab1:d120]) by SY7PR01MB10921.ausprd01.prod.outlook.com ([fe80::7908:e00:4ab1:d120%5]) with mapi id 15.21.0048.016; Sat, 23 May 2026 01:40:45 +0000 From: Japin Li To: Shinya Kato Cc: wenhui qiu , Sami Imseih , PostgreSQL Hackers Subject: Re: Report oldest xmin source when autovacuum cannot remove tuples In-Reply-To: (Shinya Kato's message of "Fri, 22 May 2026 22:05:31 +0900") References: User-Agent: mu4e 1.14.1; emacs 30.2 Date: Sat, 23 May 2026 09:40:39 +0800 Message-ID: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TY4P286CA0079.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:36d::8) To SY7PR01MB10921.ausprd01.prod.outlook.com (2603:10c6:10:334::16) X-Microsoft-Original-Message-ID: <87v7ceewdk.fsf@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SY7PR01MB10921:EE_|SY7PR01MB8432:EE_ X-MS-Office365-Filtering-Correlation-Id: 564c0e33-a3d1-4d02-73be-08deb86c4d57 X-Microsoft-Antispam: BCL:0;ARA:14566002|8022599003|12121999013|23021999003|24121999003|6090799003|5072599009|22091999003|24021099003|15080799012|19110799012|8060799015|440099028|3412199025|18061999006|26121999007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NDVmSUtiRjNMcDNkMDZleXE0VXozSktlcjZlVTBsMXdKQ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N3NXUkQ0ZFlkTG4yT0NRdmw0MDJ5Mk9PRVFQ?= =?utf-8?B?d2xvVDNsTFYzREtpRi82dGp5Smx2Z3RIUUxnWlhWM3pIbitkZG1SYktMcHRD?= =?utf-8?B?Mkc2MHZJVXlEMEdleUlUSzRsaEVnTDBYYVA3Ry9JdWd1b2t3UEUzOENNK3gz?= =?utf-8?B?aWUwYlAxT1BWaGZWMThGa0dpaWc1blhDd1p0TTJ6N25nLzFNa0hhMTNsTDZo?= =?utf-8?B?TUZsOWxnQUtqQzlKcmZMV2FxODhBam5tZHpEYlhIc0xCRXplelhJMStKTmlB?= =?utf-8?B?dTBBZjA5N2F5RWpNZDRmQkRiUTZrTmoyMno0SUY5MHA3VjE5ak1rR3dwMWkv?= =?utf-8?B?bndEMVF0ZE9XVHl1VkxIdWFaM1o4OFduM0liKzdlR2ZJMFp1VE5EM2VZNHVO?= =?utf-8?B?L0ZGQTVBK3JjQ3FVa0lOeDY2RUJqamRkWTJiaXdJZXNLN1R3ZmF1Vkkza3pJ?= =?utf-8?B?MElPMFE5dSt2V3lrWDFMMFpENi9yQVhYZGQ0cFlUT2laMnZ5cUhNaFQyWWhD?= =?utf-8?B?OUdKNFVsZHJxOTZDZERFQmh1TktzemxPa2ZxdlQ5d0FUMXNvbVF5M2lJekNL?= =?utf-8?B?RlU2T0ZuWWNTcG9rTElkcTdSa1dsM3hERW1pc1FkVko4M0ZBQTVkNklCRW9p?= =?utf-8?B?cjRMNjk4cVhDZEtIamNWb1Qrek9tSk1DOHdCeENKNmFBRWJtWDFvaTFBSHdx?= =?utf-8?Q?AoVSv3UvJ/bt/?= X-OriginatorOrg: sct-15-20-9412-4-msonline-outlook-feddd.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 564c0e33-a3d1-4d02-73be-08deb86c4d57 X-MS-Exchange-CrossTenant-AuthSource: SY7PR01MB10921.ausprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2026 01:40:45.5577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY7PR01MB8432 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 22 May 2026 at 22:05, Shinya Kato wrote: > Thank you for your feedback! > > On Mon, Mar 16, 2026 at 8:19=E2=80=AFPM Japin Li wr= ote: >> >> On Mon, 16 Mar 2026 at 15:59, wenhui qiu wrote: >> > HI Shinya >> >> typedef enum XidHorizonBlockerType >> >> { >> >> XHB_NONE =3D 0, >> >> XHB_ACTIVE_TRANSACTION, >> >> XHB_IDLE_IN_TRANSACTION, >> >> XHB_PREPARED_TRANSACTION, >> >> XHB_XMIN_ACTIVE_TRANSACTION, >> >> XHB_XMIN_IDLE_IN_TRANSACTION, >> >> XHB_HOT_STANDBY_FEEDBACK, >> >> XHB_REPLICATION_SLOT, >> >> } >> > Thank you for your working on this ,I have another small suggestion >> > The priority ordering encoded in XidHorizonBlockerType determines whic= h blocker gets reported when multiple candidates >> > exist. In particular: >> > >> > ACTIVE_TRANSACTION >> > IDLE_IN_TRANSACTION >> > PREPARED_TRANSACTION >> > >> > Prepared transactions are currently ranked after idle-in-transaction s= essions. Operationally, prepared transactions are >> > often harder for DBAs to resolve than idle sessions, so it might be wo= rth clarifying the rationale behind this ordering >> > or reconsidering whether prepared transactions should have higher prio= rity. >> >> Agreed. Explaining the reason for this priority is very helpful. > > We always pick a blocker from the xid-match group first (it is the > transaction actually holding the horizon, while the xmin-match entries > are just held back by it). Within the xid-match group, the > active/idle/prepared order never matters: a given xid is owned by only > one backend, so when the horizon equals a proc's xid there is only one > matching entry, and it is exactly one of active, idle, or prepared. So > moving prepared ahead of idle would not change which blocker we > report. > >> >> typedef enum XidHorizonBlockerType >> >> { >> >> XHB_NONE =3D 0, >> >> XHB_ACTIVE_TRANSACTION, >> >> XHB_PREPARED_TRANSACTION, >> >> XHB_IDLE_IN_TRANSACTION, >> >> XHB_XMIN_ACTIVE_TRANSACTION, >> >> XHB_XMIN_IDLE_IN_TRANSACTION, >> >> XHB_HOT_STANDBY_FEEDBACK, >> >> XHB_REPLICATION_SLOT, >> >> } >> > Another one: >> > Currently GetXidHorizonBlocker() selects only one blocker (based on th= e enum priority) even though multiple independent >> > sources could hold back the xmin horizon simultaneously. For example, = it is possible to have both a prepared transaction >> > and a replication slot preventing the horizon from advancing. >> > Have you considered reporting all detected blockers instead of just th= e highest-priority one? Returning only a single >> > entry might hide other relevant blockers from the user. >> > >> >> I'm also curious =E2=80=94 why don't we list all the blockers? Did I mis= s anything? > > I did think about this, but I would like to keep reporting one blocker > in the VACUUM log, for two reasons. > > First, the log can get very large. In Sami's earlier example [0], a > pgbench run had many backends all sharing the same xmin while only one > idle-in-transaction backend actually owned the cutoff xid. Reporting > every blocker would print 20+ lines, almost all of them just victims > of the same root cause, which makes the log harder to read, not > easier. > > Second, the one blocker we report is the root cause (the xid owner). > Once the DBA resolves it, the next VACUUM will show the next blocker > if one remains. > > This is also why the code is split into GetXidHorizonBlockers(), which > already collects every candidate, and GetXidHorizonBlocker(), which > picks the highest-priority one for the log. The "show everything" case > is what I would like to expose later through a dynamic statistics > view, where a full list makes more sense than in a VACUUM log line. > > > I've rebased the patch. > Thanks for updating the patch. LGTM. Just one nitpick. + int pid; /* backend pid (0 for slots) */ Per the code, the prepared transaction is also associated with a PID of zer= o. --=20 Regards, Japin Li ChengDu WenWu Information Technology Co., Ltd.