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 1wz0fO-003kzF-19 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Aug 2026 23:34:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wz0fM-00AP7U-0B for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Aug 2026 23:34:52 +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 1wz0fL-00AP7L-2B for pgsql-hackers@lists.postgresql.org; Tue, 25 Aug 2026 23:34:51 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wz0fJ-00000002Q2m-1zJA for pgsql-hackers@postgresql.org; Tue, 25 Aug 2026 23:34:50 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-384930ca5e2so577445a91.3 for ; Tue, 25 Aug 2026 16:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787700888; x=1788305688; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=btaZUboe7pviM47bghc8za72jcy8mBpfT8zcD33IqK0=; b=PQjqCZ2xhBwPgdgvHP3Iuq2iLvfqP8btgF+ne3ujx9LAYxbgxwsOflbEfb/w9uwmH0 /UPbioEdPJv5qtgDjyS8lSSbcqNYPSXW35E3R0ROFd7dQaIWj4EJGgnqmUC7btqj4HWP KI1p1lH1la3nJnjU9pStQzQpVcBE5H4njg1qM61OIUxpQMKm/bPRPL2sbRhjdCRtGAL+ w6+Zrn08/a5e2dEQdAFxxMUHyitgPfeTZZTeYsMWASNPCP0jwbxpC0DyvsXykVJyqhg6 gooOs76XoWeH7UKSBouCNN6f06m8TN0CgTQSave41e2catVmbkOcSC/MDz5NoOy8kAhE qpQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787700888; x=1788305688; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=btaZUboe7pviM47bghc8za72jcy8mBpfT8zcD33IqK0=; b=WqdrCFLPz3t159v/Jy1s+wXSGfk+Ds1+n/E15TJX5MCnjnlEuMKDFdFXCKiZF60MkL yAUV2JRSHmnC22Eg8CaJnh6kayddjcgPXlAqZpmcwDlFBrgOq+lvaAyC5lWGrtKhNj2I LpCfbiOUpP4jvZYNu0taULxs4BdD2cOPM7CdK5jZcg7bjpxD+3gG/QFj81xJN2Ch03jx zp5/5dyIcxj44zrw9Xgvnn2ZZaBJd0qtLvUHnmhoBh3f+oZ6xGma/bnvSVB3MvGKqdJV uBL18sKmm8tZWowk8gFGREpD5f9jImwTNSH5jyzv3OWsZH0huPO3Ra6nlnrQpOCfaCw6 /dRw== X-Gm-Message-State: AFuF++lR2zrl1komd5hpKqibANoy67E9ddpHglkfR5gxNcHddl7/TWcI GhNH4mQ5uhvQVBrZGmltNBz80AdUoww7k2MOc15hrdioSakYewpdXKlG X-Gm-Gg: AR+sD131zhuUCwhAE2yt7qK6DOxn9xpcKbXvFFqTLjKPYrso7atgTPzMqlAIk8FHsl/ yrHE5XoSgVcyjRSHtW17Y85r73/6bxR+iC7yDAR6rS5uXlAX6zZ8GWzcGOIiaEEy5Gm+B71oafT n5RHq15fo1cWfayROg69xF3ZbViDAhXJlORBrYfZcvWYolX5bvIOVy2pYRtT6+TwQDU8/sSqxSg aN1oT3HdR8JODSS1klrY9q1VHYPfZbCbdwGp1nVnGvr/BeFd6WXvS9fSkQmFiZus5P5WvReImGE KWw0fCBZnIKYB1JJ8pKvdYjgMRVg/nw1Z78VrJs1qkwi7TuPMSL2xvCpqxrmvrJc270bXyTA+6Z uRGOIPDKF189LPozB2IQFDknMJpz6vw5YDwg7rkDx22uhIftwEP3+J6bKH+2JtCPth74OphWc3D aD3ty13UZVT4bjW8cRDf0CQBCZVCuEog/rl5QmoM08IV+D/9TjATYc9B9wERceNOaOTuRhWy5Hr /soJw== X-Received: by 2002:a17:90b:1a90:b0:396:6344:3b62 with SMTP id 98e67ed59e1d1-3966d71a0e4mr4333490a91.12.1787700888527; Tue, 25 Aug 2026 16:34:48 -0700 (PDT) Received: from smtpclient.apple ([128.14.188.156]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283d886256sm2699354eec.16.2026.08.25.16.34.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Aug 2026 16:34:48 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: Allow aggressive VACUUM to freeze without a cleanup lock From: Yuhang Qiu In-Reply-To: Date: Wed, 26 Aug 2026 07:34:34 +0800 Cc: PostgreSQL-development , pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <16EBC719-6DFC-4384-B4B9-F50349C9CCB9@gmail.com> References: To: Jingtang Zhang , Peter Geoghegan , Melanie Plageman X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Melanie, Peter, Jingtang, > So it's reasonable to surmise that freezing could be done with only an > exclusive lock on top of the current VACUUM code (though not a shared > lock, which seems really dangerous). And that page defragmentation is > the only thing that necessitates a cleanup lock/makes this idea = difficult. Agreed. Freezing itself only needs an exclusive lock, a cleanup lock is = needed for page defragmentation. I also agree with Melanie that the patch = should explain this if it is not already documented elsewhere. I reviewed the patch and found a few issues. First, the buffer lock is released and reacquired between `lazy_scan_noprune()` and `lazy_scan_freeze()`. The page may be changed = or already frozen during this window, so this assertion is not always = valid: ```C Assert(state.pagefrz.freeze_required); ``` Second, the code may call heap_prepare_freeze_tuple() and then discard = the freeze plans after finding an old DEAD tuple. This function may create a = new MultiXactId, write WAL, and advance the MultiXact state. These side = effects remain even if the plans are discarded. There is also a small naming issue. lazy_scan_noprune and = lazy_scan_freeze are quite confusing now. I think lazy_scan_noprune is not correct at this = moment. The patch adds FreezeState, HeapPageFreezeParams, and HeapPageFreezeResult, but they overlap with PruneState, PruneFreezeParams, and PruneFreezeResult. These abstractions add = complexity without much reuse. Pages containing old XIDs or MultiXactIds in DEAD tuples still need a = cleanup lock. I think this is a reasonable limitation for this patch. Best Regards, Yuhang Qiu