pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jochen Bandhauer <jb@jbitc.de>
To: pgsql-bugs@lists.postgresql.org
Subject: on 19beta3: repack (concurrently) affects sessions with transaction isolation level repeatable read
Date: Sat, 22 Aug 2026 09:29:41 +0200
Message-ID: <5d2060d5-8145-40c6-9a2e-4ddb9f6b0fc9@jbitc.de> (raw)

Hello,

while using repack (concurrently) I found a behavior that I didn't 
expect. When running a "repack (concurrently) t;" in one session, 
another session with "transaction isolation level repeatable read" 
reports sometimes 0 for "select count(*) from t;".

PostgreSQL Version: PostgreSQL 19beta3 on x86_64-pc-linux-gnu, compiled 
by gcc (GCC) 14.3.1 20251022 (Red Hat 14.3.1-4), 64-bit
configure command: ./configure --prefix=/home/postgres/pginstall
OS: Red Hat Enterprise Linux 10.2 (Coughlan)
uname -a: Linux lin8.fritz.box 6.12.0-211.44.1.el10_2.x86_64 #1 SMP 
PREEMPT_DYNAMIC Tue Aug  4 03:10:19 EDT 2026 x86_64 GNU/Linux

Test Case:
-- create table
drop table if exists t;
create table t (
     col1 bigint primary key,
     col2 text default 'default text'
);
insert into t (col1) select g from generate_series(1, 10000) as g;

Session 1 runs from time to time: repack (concurrently) t;
Session 2 runs the following script with:  while true; do psql mydb -f 
./s2.sql; sleep 0.1; done| grep -v "^$"
Script s2.sql:

\pset tuples_only on
\o /dev/null
begin;
set transaction isolation level repeatable read;
select 1;
select pg_sleep(1);
\o
select count(*) from t;
\o /dev/null
end;

Output Session 2:
  10000
  10000
      0
  10000
  10000
      0
  10000
  10000
  10000
      0
  10000
  10000
      0
  10000

0 always when Session 1 runs: repack (concurrently) t;

Expected Output: Always 10000

Only the (concurrently) option shows this behavior. Wehen using "repack 
t;" or "repack t using index t_pkey;" the output is always 10000.

Thanks
Jochen

-- 
Mit freundlichen Grüßen

Jochen Bandhauer
+49 (0)176 29390012
www.jbitc.de

Attachments:

  [text/vcard] jb.vcf (202B, ../5d2060d5-8145-40c6-9a2e-4ddb9f6b0fc9@jbitc.de/2-jb.vcf)
  download | inline:
BEGIN:VCARD
VERSION:4.0
N:Bandhauer;Jochen;;;
FN:Jochen Bandhauer
EMAIL;PREF=1;TYPE=work:jb@jbitc.de
URL:https://www.jbitc.de
TEL;TYPE=work;VALUE=TEXT:+4917629390012
TZ:Europe/Berlin
END:VCARD

view thread (3+ messages)  latest in thread

Message-ID: <5d2060d5-8145-40c6-9a2e-4ddb9f6b0fc9@jbitc.de>
Permalink:  ../5d2060d5-8145-40c6-9a2e-4ddb9f6b0fc9@jbitc.de/
Also on:    postgresql.org/message-id/5d2060d5-8145-40c6-9a2e-4ddb9f6b0fc9@jbitc.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: jb@jbitc.de, pgsql-bugs@lists.postgresql.org
  Subject: Re: on 19beta3: repack (concurrently) affects sessions with transaction isolation level repeatable read
  In-Reply-To: <5d2060d5-8145-40c6-9a2e-4ddb9f6b0fc9@jbitc.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox