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.94.2) (envelope-from ) id 1siDWA-000a5Z-GT for pgsql-general@arkaria.postgresql.org; Sun, 25 Aug 2024 13:42:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1siDW6-00FJsD-Ob for pgsql-general@arkaria.postgresql.org; Sun, 25 Aug 2024 13:42:51 +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.94.2) (envelope-from ) id 1siDW6-00FJs1-BH for pgsql-general@lists.postgresql.org; Sun, 25 Aug 2024 13:42:50 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1siDW3-001MsR-D4 for pgsql-general@lists.postgresql.org; Sun, 25 Aug 2024 13:42:48 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42ab99fb45dso38739775e9.1 for ; Sun, 25 Aug 2024 06:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724593365; x=1725198165; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=tfFTvH8I646nU+leXUV5VHyOFTfkprGUICjpFQC0l+A=; b=d0xqUzbobKOp2v4PVHxbpsjQ52c1HytoYugvxfiCgpms/q8OUz8yqOXS2PVqsCqBgu swVUIDoZKaN2HpHJ3aEgTh+FJDKdBurJ5++DZeMkK2nKxaJnBwbRhhTNiINZKOU0qiMZ C9MqyIMBMfkjrjisq8o5B6i3ik0952kAOJ7TfKohUrZaOlf7GDI09cpFN0teJZagI4/V wmkkynEfbKJrNo6pOek5M9M9O2UQfXm5lf4aj3jZG4fHVRrOQ9LQUDXoqSVGIL6ngB28 WNlxg4M0KRbhZ2lgIIDrVmJzhfKBC0TBl+zCafdJpRxK12GSOn8Kl54WF2hFu3c6axZ6 tsbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724593365; x=1725198165; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tfFTvH8I646nU+leXUV5VHyOFTfkprGUICjpFQC0l+A=; b=X7diJAbUuj2aP7b4xX0L3VKR7SyRV0aVVOOdtnumo2LsC9ZfeGgfH4F1V+Kwv3cwXy EdzBHSm1PYSTHwrprBFi/+1hvN/pdfKN9gSfzAp/ml4m4zbxLdBeA40SdlZyYEommHzx Y2rskSRYerEV13QlmCdYMQIQyTQ5S59+q27+i38Int68U0e8lotUdeFoM+vW1B2QIcsU BAj/IJwmHDYl/EiG0vh4vaip95nuEaMB67wFit9gDXTonTbsQJwE8ACF6tOmkgF9Hec2 l0uyGSNet9Hh6ZBNBc4R8MjtvWDD2RIG5FwD7j/uDPWRByqVw+22pYTa7aZ58KZSufs8 kuhw== X-Gm-Message-State: AOJu0YxyNAjOAud4qqsGi6AbYSwbvgp8RzHBDZYLC+XuepahPqP4jAvd RCZTMkwKEytGyGhqknMnPH1sXOEzIWcpSI0qqHJ+/oyYk+kxcpqMn66cnoxg4QRBY7RrJIBnrLj +2zkeBRqfHlXHszJwB74jEBlVwdXC9bai X-Google-Smtp-Source: AGHT+IGIJbQ0gNwcZaEqBh4N8HNXLi1zYVDR+Vu+7IVI2GtZxfmre+H3p9AHFXv8A3x1GrMWwG0du13HXBRJyfYWTXQ= X-Received: by 2002:a05:600c:a08:b0:429:c674:d9de with SMTP id 5b1f17b1804b1-42acd540cc6mr57758155e9.2.1724593365071; Sun, 25 Aug 2024 06:42:45 -0700 (PDT) MIME-Version: 1.0 From: Marcelo Zabani Date: Sun, 25 Aug 2024 10:42:33 -0300 Message-ID: Subject: ERROR: could not open relation with OID XXXX To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000e8408d0620822eaf" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e8408d0620822eaf Content-Type: text/plain; charset="UTF-8" Hi all, I can reproduce the error in the subject from time to time when querying catalog tables while DDL is happening concurrently. Here's a bash script that reproduces it (not always, you might have to run it many times until you see ERROR: could not open relation with OID XXXX): #!/usr/bin/env bash psql -c "create table test(x serial primary key); select oid, relname from pg_class where relname='test'" # The next two queries will run concurrently psql -c "select oid, relname, pg_sleep(3), pg_get_indexdef(oid) from pg_class join pg_index on indexrelid=pg_class.oid WHERE relname='test_pkey';" 2>&1 1>/tmp/pgbug.log & sleep 1 psql -c "drop table test" cat /tmp/pgbug.log wait I am confused as to how this is possible. I assume if the row with the test_pkey index exists in the pg_index catalog table, that the snapshot of the catalog tables contains the test table itself and is generally consistent, so querying the catalog should not run into such errors. I've seen this happen in Production without pg_sleep in the mix, too. I added pg_sleep to the example above only because it makes the error easier to reproduce. Is there something I can do to avoid this? Is my understanding of how the catalog tables work wrong? Thanks, Marcelo. --000000000000e8408d0620822eaf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all,

I can reproduce the = error in the subject from time to time when querying catalog tables while D= DL is happening concurrently. Here's a bash script that reproduces it (= not always, you might have to run it many times until you see ERROR: =C2=A0= could not open relation with OID XXXX):

#!/usr= /bin/env bash
psql -c "create table test(x serial primary key); sel= ect oid, relname from pg_class where relname=3D'test'"
# Th= e next two queries will run concurrently
psql -c "select oid, relna= me, pg_sleep(3), pg_get_indexdef(oid) from pg_class join pg_index on indexr= elid=3Dpg_class.oid WHERE relname=3D'test_pkey';" 2>&1 = 1>/tmp/pgbug.log &
sleep 1
psql -c "drop table test"=
cat /tmp/pgbug.log
wait

I am confused as to= how this is possible. I assume if the row with the test_pkey index exists = in the pg_index catalog table, that the snapshot of the catalog tables cont= ains the test table itself and is generally consistent, so querying the cat= alog should not run into such errors.

I've see= n this happen in Production without pg_sleep in the mix, too. I added pg_sl= eep to the example above only because it makes the error easier to reproduc= e.

Is there something I can do to avoid this? Is m= y understanding of how the catalog tables work wrong?

Thanks,
Marcelo.
--000000000000e8408d0620822eaf--