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 1w7AWj-0051hH-09 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 11:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7AWh-002iH1-1G for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 11:11:23 +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 1w7AWh-002iGs-0P for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 11:11:23 +0000 Received: from mail-dl1-x1229.google.com ([2607:f8b0:4864:20::1229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7AWf-00000001n5O-3rFJ for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 11:11:22 +0000 Received: by mail-dl1-x1229.google.com with SMTP id a92af1059eb24-12a80c36350so4607094c88.1 for ; Mon, 30 Mar 2026 04:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774869081; cv=none; d=google.com; s=arc-20240605; b=FUPELG54kLT1uqRJETWhAvE9nrWJH46dAAqbRQFGVYacchDjD1AGUxP/NsnQYqg/d5 CblOiFXLojjbeF1yK5Ecp47N3IOGsc3//qrLQ94+aofuAF6mWcKzBAKn477JixW+vVsf 1LCs3mcsSLWSrETCh6nYEKn+3UA1QKaEveIGdiufTqszO+ZZpFDyesUK0etqnUusaBq9 ohgRj3vgGJHwQQ5u2fsEwPw1gJIZUM9k7/dHaSbHkAA8CQByKrwL5AxwLOdQE1qq10iF UO3lI7ZsQ1kl2ERRGzhJsCMbmdLk6Fu2B2VsYCiZtIiLdA2WrFTkaIYRO1Kgs6ASZ/8d xPTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OXzCtDi2AzqGxnF2bsIs9mQvOYNwMWkrMmhDmRTMwi8=; fh=PDhzRmLFhJQgKl2kpY6iqaoiggk+rKjB8rXL7ERgOws=; b=AuZ/sx7ZCXRZe8TUztMo5m49XUjQh1O3YkOgr/eY2fzak2MBEzjeWjO4Ug8tL3eUBR /4x7/vAunPyv70Cw9F5uw9jov7eh0sz5kQsOVmjhN2WF9n5k0cXlwQvaJEQ0TzHLdamk saAVsv0SUgVc7mjc9LUQ0bPqOrRNRXKgKYy9Eo0/CoGZNWYZRpnXZe9GLqInPj9sqOWy B4XF6UnxJo0yB+5WLxJWJhlNzkZcMC3yDIbAXwfR950lYXmEbDWg4jountgLMMZfA/7B 1x0KegHT2nL/H/U+R0Tt2HJ3e0k8zZEc/bCt7DBnrK7XeZTjDv4hoDpmBkpYK9cyE4vT qeLA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774869081; x=1775473881; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OXzCtDi2AzqGxnF2bsIs9mQvOYNwMWkrMmhDmRTMwi8=; b=W/yFH2wpe2lSsOI5qP2GjMZgwMrgnMxrM1WZA6Kft9U87S4cIf/oejbBYbGWdmvmWf JmxkwixTRH1RZ41ps16O+ML7io+uRLv+J4dC7/s4ykqzF2fZLwSWwq7+0MpPBSH2ZzUU CWCAUuBaU2QUkHgOxUvWkJ4TDyBwDIz9rsLAI3BG/gmZhX+zmniVEiJjMWNQDzmy6zX+ uvdYFNV+OF7nCK/Fa8nAZzC/hrmnStJ0xHko2W/s5vqw68Zp4GxxuGXluOPKINt+4GTA a+1jveVIK84fp9Lu1KqlyntNQxnYnznllPRj3ENUV3jpMHab+o1MSY9zOEq4ptNw2YjL g3uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774869081; x=1775473881; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OXzCtDi2AzqGxnF2bsIs9mQvOYNwMWkrMmhDmRTMwi8=; b=UhrzHkUypzm/pmMqIZYDpv+fyk093OuGO5QPOAsg9rJgBJKfcDueqeJYN5lV8ZnVqC 3aNpjYDiNx8or5m3ukw1Ik/ch/eXnM8s7/PCE7TwiHsjGpCtGxfVtmBAaUOP9eCxeq5y ixqQCucWV4OEOE1XyU9GVBQOeRMZDPCZi/LXeDUt9p7D5mQD25Q49VvjbECo2VTZeRG+ aLw+dkEypIqr11NdBJK0RlywEKR6nQk7el39mzXlTjNelCS/hcD8r9wyKuXjjybMC++W /RvH7KtJTTJwm5/8BF5sl0co3/45yygXIFEGWZ87dilZQzH0PjHPwy9ej5GUj28Rohos bHsw== X-Gm-Message-State: AOJu0YwQChxFSjqkzGMNGCCC7utl5LapL6yt03wpeph4eXuzsgyedCUt /jMeL6eyYhOkpn2q8sK7I59Pts9b91qhU1dqRpbZWZbXf4UK0RrbgErTC2S1zMKxIN4WBx4Se2B 9CmafTs/skajcNO6jVab8B39AQtFbAMA= X-Gm-Gg: ATEYQzzID68Org/Ka31A14/AjVtnhzIGKF6Cz2ArD3h6ac/sTTGIs8f3lYJmrjrgFSQ lXsUJ/FjKxreg6n/psO6m7qc0mwrxXh56DQpaBHh+kl25DcxoKRw9OyN6eKtZjsko4KmHSAg4M2 robLI21LstzCO+BoSLWDbPcM134rq59gyXhXtOQwsI0r/3DoBysg3qPJXDHd5iPSYOw2+PJ9q/A llIyXnZwd3ktOhSpuA47G57i/JYKN8Oz9dzqC+6hBh7RD4kG8j2tU0jRSqchhqwZ2A7eI0qVLPT Vhb/nmi2Tn6saZ9H/INqXDseNGuzQdX2fZr6Xdcc+A== X-Received: by 2002:a05:7022:92a:b0:128:d4db:4478 with SMTP id a92af1059eb24-12ab28e9aa5mr6636155c88.24.1774869080719; Mon, 30 Mar 2026 04:11:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ashutosh Sharma Date: Mon, 30 Mar 2026 16:41:08 +0530 X-Gm-Features: AQROBzA2qZGU41oG4sUHiMCUo-8PbgJciyRG3Sw5JVDD0J2wAuh5jjtfAFKi0R4 Message-ID: Subject: Re: Make pg_prewarm, autoprewarm yield for waiting DDL To: SATYANARAYANA NARLAPURAM Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Satya, On Thu, Mar 26, 2026 at 3:02=E2=80=AFAM SATYANARAYANA NARLAPURAM wrote: > > Both pg_prewarm() and the autoprewarm background worker hold AccessShareL= ock on the target relation for the entire duration of prewarming. On large = tables this can take a long time, which means > that any DDL that needs a stronger lock (TRUNCATE, DROP TABLE, ALTER TABL= E, etc.) is blocked for the full duration. > This indeed seems like a valid concern. > VACUUM already solves this same problem during heap truncation: it period= ically calls LockHasWaitersRelation() and backs off when a conflicting wait= er is detected (see lazy_truncate_heap()). > Yes, in the current design, waiter-aware backoff logic is present in some code paths (like VACUUM) that acquire the strongest lock (AccessExclusiveLock), but is largely absent from paths that hold weaker locks. While AccessShareLock conflicts with only one lock mode (AccessExclusiveLock), a long-held AccessShareLock, as in the pg_prewarm case you mentioned, can still cause meaningful delays for DDL or maintenance operations that require AccessExclusiveLock. So despite its narrow conflict set, the practical impact can be quite significant in some cases. On that basis, extending waiter-aware behavior to places like pg_prewarm (or similar long-running lock holders) seems reasonable, though it would be worth seeing how others think about it. -- With Regards, Ashutosh Sharma.