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 1voOic-002sQS-0G for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Feb 2026 16:30: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 1voOia-004s48-0C for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Feb 2026 16:30:03 +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 1voOiZ-004s40-1t for pgsql-hackers@lists.postgresql.org; Fri, 06 Feb 2026 16:30:03 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1voOiW-00000000rqN-3y7l for pgsql-hackers@lists.postgresql.org; Fri, 06 Feb 2026 16:30:02 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-482f2599980so27678975e9.0 for ; Fri, 06 Feb 2026 08:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1770395399; x=1771000199; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to; bh=GRwUft+Lih7SMiLU1OITVql9UHpNMe/uS/Bc31w4p8E=; b=RDYhn2owv7zv+X5aqGywpe1PZ12nnUvVotH3JP1UiIgxcsBJYwJ7eonAmVg10LBSY4 34DxPKgDac46lwQJyuI13gdXSQQPiXIAHw81yb5GL+qkxSMtpv3YcPvMHzwsm8Mtcs8Q HI1q96nIaFseS01G3uT8Nmdbw9wD9tnPX6fRsmAUddTyBFa31W//AiA8/UfafMZ3SwxD g/+59o7dXH8m4oMW2Kkelsb4LqCiTTocgLVktfGGPXaRu9G4ZeUsn/i2+kwvYGnEbL0p PQXRbF5P8gBXWPbk4iOUaPHmPcNaH8PKDX+asjsvmkw2YGh6mKseuWQBNBiAACmimXoV xYAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770395399; x=1771000199; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GRwUft+Lih7SMiLU1OITVql9UHpNMe/uS/Bc31w4p8E=; b=tLeapCsgbXPSejyjq1Kt3lTaXTqhMITXcVhxh9kkFe2KiiMQu1AX8nupnDGOX1q3F9 1x18PSHoeCFUIAvnLKIWHWXq36FVYlq4NuArEAm1+tI8DZY6GCf9t0lzChXekoNgp/2Y f7ma0mR5PdvuvT1ITy2s6UbDeNKsCpz0+Ps+mHQMRgY6Al11ayPr7uuxQ1XwzKqkduv9 aKg+41ZojDWtC/rEdbJSsqTEdAp//LmCjEm27WGhgtCb5EFxs7+IxqsbUOqQUO69n/YU j/1E49cjcQ0gq6jSCoIj6CO/i730jDu9XH3sQqMQFMp2anMe9ae5Lwms/af8+tINPTeU Qceg== X-Forwarded-Encrypted: i=1; AJvYcCWJHlKpNw3V7l33piS5Sxemxt6ULPH595T8z74OtZnZtEvudBJ9b0y4g9XRDflZDX5XdcnRgcKHQrF3zOrK@lists.postgresql.org X-Gm-Message-State: AOJu0Yy1WDBJD4q8ax14Otr/J0FuMUv+dZw5NPFph8SlvdGn/Qy3/TSB 2nXFhxPgCnsHC4HnuOUlKbWNttAThNF9/mO8mQc/gQLvKxgP4VdDSJ4A9DbXkaX44VM= X-Gm-Gg: AZuq6aLxE1hW1w4TsVAzlgw0+W9oIDPkn9ckp0mVfDzT8ynsim4f8gY/6Wx32h3POU+ cq3NAZ04BJZQLJq3iv1Bb7DBDdLg6xvPXjCBTBs9r4QjIw/2q4dwtpe1WMYoTQyXFwWxSDm8MEM p8gSBfLRjWX12DTbQ1qN8lbr2PPtQgbAEh6c3CTuzlH1NFoE5UWU/W9yDsUcRn+6RCSNPmLm0R1 3I3d0Rsrl00Lh4o8gudbY5VVFruFT0Hq9D/u59x7Ou2gTJYPri2kA+cfiG/xrj4u1GX4FhG92ss 1Dn17LCX4ofqcZftTcwfw7fDaq9bk/r5ABcLs0croPIg2zJxlCKbnvtvmKh1h3XgIVwi0381W3n xnacX2DHGs+cNX4HfQuvvNGYM/cg140md6Cv2kTXYSMqZhnZqcK9rZMsl44sIcNdM3qRi/F0BRe zLVh5wxmPxpQAV7eO+p5x8lo1w X-Received: by 2002:a05:600c:83c5:b0:482:ef72:5781 with SMTP id 5b1f17b1804b1-4832022593dmr44556235e9.25.1770395399183; Fri, 06 Feb 2026 08:29:59 -0800 (PST) Received: from localhost (109-81-168-246.rct.o2.cz. [109.81.168.246]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-436297462a8sm6784778f8f.30.2026.02.06.08.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 08:29:58 -0800 (PST) From: Antonin Houska To: Mihail Nikalayeu cc: Alvaro Herrera , Pg Hackers , Robert Treat Subject: Re: Adding REPACK [concurrently] In-reply-to: References: <202512151349.vlq3mpfniyk3@alvherre.pgsql> <11247.1767609087@localhost> <11558.1767609632@localhost> <141054.1767891540@localhost> <137668.1768235610@localhost> <74802.1769071060@localhost> <3901.1769412880@localhost> <88003.1769511456@localhost> <57210.1769801636@localhost> <8029.1770024929@localhost> Comments: In-reply-to Mihail Nikalayeu message dated "Mon, 02 Feb 2026 11:04:45 +0100." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27596.1770395398.1@localhost> Content-Transfer-Encoding: quoted-printable Date: Fri, 06 Feb 2026 17:29:58 +0100 Message-ID: <27597.1770395398@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mihail Nikalayeu wrote: > > I think it *is* related. My earlier patch version, which used the > > PROC_IN_VACUUM flag improperly [1] was also causing visibility issues.= Please > > let me know if you manage to reproduce the issue with v32. > = > Will try. Just to highlight - first error happened on v31 *without* PROC= _IN_REPACK. I spent some time running the test with your branch (based on v32 as you t= old me off-list), but couldn't reproduce the problem. The related code is in heap_inplace_lock(): /* no known way this can happen */ ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg_internal("attempted to overwrite invisible tuple"))); The only path REPACK (CONCURRENTLY) uses in-place update seems to be: cluster.c:build_new_indexes() -> index_create_copy() -> index_create() -> index_build() -> index_update_stats() -> systable_inplace_update_begin() However I've got no idea how this can be related to REPACK. Since the new index is not visible to other transactions until REPACK is done, VACUUM sh= ould be the only process able to change the tuple before heap_inplace_lock(). Indeed, the server log seems to indicate relationship= to VACUUM: 2026-02-01 16:44:58.878 UTC autovacuum worker[22589] LOG: automatic vacuu= m of table "postgres.pg_catalog.pg_class": index scans: 1 ... 2026-02-01 16:44:58.884 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: COMMIT; 2026-02-01 16:44:58.884 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: SELECT pg_try_advisory_lock(42)::integer AS gotlock = 2026-02-01 16:44:58.884 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: SELECT pg_advisory_lock(43); 2026-02-01 16:44:58.884 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: BEGIN; 2026-02-01 16:44:58.884 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: INSERT INTO tbl(j) VALUES (nextval('last_j')) RETURNIN= G j = 2026-02-01 16:44:58.885 UTC client backend[12727] 008_repack_concurrently.= pl LOG: statement: SELECT COUNT(*) AS count FROM tbl WHERE j <=3D 14148 = 2026-02-01 16:44:58.885 UTC client backend[12734] 008_repack_concurrently.= pl LOG: statement: SELECT COUNT(*) AS count FROM tbl WHERE j <=3D 14145 = 2026-02-01 16:44:58.885 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: COMMIT; 2026-02-01 16:44:58.885 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: SELECT pg_advisory_unlock(43); 2026-02-01 16:44:58.887 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: BEGIN --TRANSACTION ISOLATION LEVEL REPEATABLE READ ; 2026-02-01 16:44:58.887 UTC client backend[12737] 008_repack_concurrently.= pl LOG: statement: SELECT 1; 2026-02-01 16:44:58.891 UTC REPACK decoding worker[22621] FATAL: terminat= ing background worker "REPACK decoding worker" due to administrator comman= d 2026-02-01 16:44:58.896 UTC client backend[12740] 008_repack_concurrently.= pl LOG: statement: SELECT COUNT(*) AS count FROM tbl WHERE j <=3D 14146 = 2026-02-01 16:44:58.896 UTC client backend[12722] 008_repack_concurrently.= pl ERROR: attempted to overwrite invisible tuple 2026-02-01 16:44:58.896 UTC client backend[12722] 008_repack_concurrently.= pl STATEMENT: REPACK (CONCURRENTLY) tbl USING INDEX tbl_pkey; However, VACUUM should not touch the tuple because the scan in systable_inplace_update_begin() should leave the containing buffer pinned.= I wonder if you managed to hit another existing bug. -- = Antonin Houska Web: https://www.cybertec-postgresql.com