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 1wAcTG-0008vV-03 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 23:38:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAcTE-002aqA-0v for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 23:38:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAcTD-002aq2-39 for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 23:38:04 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAcTC-000000005Gg-3gWy for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 23:38:04 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5a2b5ea59a1so276427e87.1 for ; Wed, 08 Apr 2026 16:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775691480; cv=none; d=google.com; s=arc-20240605; b=D0KcJifTPIohw3dmKobBeHnIl1t7g49I5qXrmBqygwISugzGI8RIZyuQ5uufOBE4a9 wU/gmRIh2LqELR6SZJF9U51ZwtXokd5Jh+rXdMxAaKg/JT3133xNHlFetuAJWrY+FZpT TisojkySL99LAirjSh7EjoOxZ10CmaqpqM26gFWqg5sVYxFS3J8QOXfFIeTARWkFocCt NYdQeFQl+RfIFjsmzvhgvl841eZyyD1cuRJsmDQtcjBDObEccAz5+Onap5Mx2iEtlRbw Z5mFPnZpCvWeMw4RCeUSQelV2AtZ+zonhksTZiSdgPQ/w/oBWm0PIGebnu7WqPluU0bz uXHw== 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=yujyqP9860K6yZK/di3mgFhvipi7N5yir+IG022cYdg=; fh=2gQMEpUHKHO0zJvfc+GdluG8hR7C55m4R7jmvJy87Jw=; b=gcs5vpGRt4shDb9zNIHJqMgKaqB+99B39JJEGxtrxxlS/vrqCQTCVesZ9lZQ3gFB3/ HpXqLj2jhULNuhfpO2lZBCjiGSsmZbXN4K/sG5aG+5d7qXmI+BUYnDtMN4QGIMADLRPI 4ryMDoY2q2NXtoMToA2Vk0aiCi5OmrH9v3gPq9fgnUh5VYgW9ksA7QSOU/2yiRMRx7m7 eUDEakoNDzRz2Lq6ISc2wjFNPQ8E3WrfNYaBnLoagqxm1yB9DaGG8Zh1dy6X7FkzRPBD zQODaAbyGaTx833ufQXZBzGaTzM5lazPPiIwpu71Bjkqx3fyIwBvaiZ17VfMU0iTlrHj jWLw==; 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=1775691480; x=1776296280; 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=yujyqP9860K6yZK/di3mgFhvipi7N5yir+IG022cYdg=; b=hemHKk3vR5zQyXfsGL6diowgWIEOctAiSKg8/ebiF8nJrUhyU9pLiTomBbsIxqIqdu XKkEoYr2XPXWLxNxnXz2UTSVSHR95Ca8EpUZjZ0vXJYq0K2caCLYBh9Xypvjtq7w1Alr /6EgikHLkiG66i1IIoCwJf/qI+Z2SuPTSmv+5+F/BVL1TMAzsOi8kxLO1HMBoHTB5oJO RCkb6X41Qd6Oi7j1oYFV8izPzB8HYqQejRyuaIC+XdmNzmml2QFtgdmiVYUs+0PDERUx yvP971DcZUaTkEkXcGBmZOXUpGq3oPnHkFHQodhssFFPObGVD4faTBZXHu9j21AMGZ7f uXhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775691480; x=1776296280; 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=yujyqP9860K6yZK/di3mgFhvipi7N5yir+IG022cYdg=; b=qYzydcHLHO62frdtZsF7V2HQq41339T4UZp2xWqbsOaii9KVTaYKjFpRAtkf17ercO NvSD6ahjKFlArC5pbVv20eQM7mNiroW3Ogl+YltOModhy/oF2OKunJ+b01hw2gFEowdY lBn/yvF62zve/B7q0hNZyto8cfwpTqmDQpLjBs9+HVFWzmI6wi4zZvnkOz98yqf9EgoW 11ylvvPQgYiNednUPpUWDBgmrLnvZLUHYTRrLsSJUeZbolgvPBk90a4q3XvVHd8yQCCg jTe22OUBw3cqQGjpFDbJlOBFqHLLhGyQB8Z5T+BWb70QdLp8Pn0gjSG/TKWFosNgEINs 3dGA== X-Forwarded-Encrypted: i=1; AJvYcCXRYtwuR4hyzJT3M1jmc1W8J/ZULNMc+C/nNAi9Jwub1Cgs8uEa+qkKyUcAxgP7v2khPIHQQxxn7wAfTksB@lists.postgresql.org X-Gm-Message-State: AOJu0YwB2r7GuFRQuyXQn1H1j9D+m4moRe3tZis1V7yWv+hTh+zyFCHh Noz4BBX/5r5scijKWloogv58kpp+LQiws/r22xExfMQ2KLaCLiZW0nz3cCSsWuE6ST8HhvaEayI wZKOV5Pt7EzgK08GQHLn1Jwowu+OvNNQ= X-Gm-Gg: AeBDievj8Cg6WZbO0irOD+RnNLkOSeM9+CQDsZQESmy1+LxNZ2cHe04EOxqTkg3HPq9 cTEEmhbenkUrnWmuS13EbJuLAht/0/9i/NbJHdlyDM5ydsp5c9+VhaA7k/jfhTmXkiIXENFze9k x4QzR1faU0vqwMWy6ilQzA/UlxIyvT548pWN8gx/YLa8jJ1vIEg1lv8q4dx+zUwq5jAB8ErX6SC MB3En+nwpD5mEwSuJNJWeA2YFCISkXIRD0e6xgwBAM4Rm9aKeTcTnP4aehRD+DYgwFgeTH3M9uk PS2uvqp2PJw83FiH2K/H/syzICFvrX20q6YTjJW48SUPEUrq3XZ3Biyf/ekse94UqOlVY8Aafup BAwA= X-Received: by 2002:a05:6512:3c85:b0:5a1:1d29:e749 with SMTP id 2adb3069b0e04-5a33755d746mr7946497e87.12.1775691480106; Wed, 08 Apr 2026 16:38:00 -0700 (PDT) MIME-Version: 1.0 References: <202604062213.cgo352cdsgsm@alvherre.pgsql> <4n4q3preb3lgyhpzstebhux7b2aojhsw7gik4ivaznyggiezrs@lrznutssxlh2> In-Reply-To: From: Mihail Nikalayeu Date: Thu, 9 Apr 2026 01:36:00 +0200 X-Gm-Features: AQROBzCRGOlrimaDrXpNvfb0QGHfnN9ntmj2otjHkc2S1ZYk8_YA-XBG543wFFg Message-ID: Subject: Re: Adding REPACK [concurrently] To: Andres Freund Cc: Amit Kapila , Alvaro Herrera , Antonin Houska , Srinath Reddy Sadipiralla , Matthias van de Meent , Pg Hackers , Robert Treat 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 Hello, Andres! On Wed, Apr 8, 2026 at 7:22=E2=80=AFPM Andres Freund w= rote: > I don't think this is a viable path. You need to prevent any further loc= k > acquisitions on the relation to be able to swap it, not just conflicting = DDL. AFAIU, Amit's main idea is that we currently upgrade the lock instead of **releasing and re-acquiring** it because we fear DDL between those actions. DML actions are ok for us; REPACK will wait for them while getting AEL. Later changes will be applied by REPACK backend while holding AEL. One more thing we may prevent from sneaking into that hole is a VACUUM. It will not break anything, but will be huge waste of time and resources. > And you need to wait for all pre-existing locks to have been released. T= hat > doesn't really get easier by what you propose. Do you mean locks from other sessions accessing the table? Is it done automatically while waiting for AEL? > I don't think CheckTableNotInUse() would work anyway - don't we already h= old > locks by the point we call it? Yes, the DDL session already holds locks by the time CheckTableNotInUse is called - but is that really the problem? They will be released on error. > And even if that were not the case, there are > several paths to locking relations that don't ever go anywhere near > CheckTableNotInUse(). But those aren't DDL, so they shouldn't be the problem (CREATE TRIGGER might be - it seems to ignore CheckTableNotInUse, but perhaps it's fine). So, in my undeerstanding Amit's idea has two parts: "set flag and release/re-acquire" + "use CheckTableNotInUse (or some place like that) to check the flag and fail for DDL commands." Reading your arguments again, they all seem valid under the assumption that we still hold SUEL while requesting AEL. I suspect you may have just skimmed past the 'release/re-acquire' part - but more probably I missed something. Best regards, Mikhail.