pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedUnexpected behavior after OOM errors
32+ messages / 6 participants
[nested] [flat]
Commits from this thread:
2026-07-22 ccfd4b6838 Improve lookup_type_cache() handling on out-of-memory errors
2026-07-21 fc6425fbe7 Improve generate_partition_qual()'s cache handling on out-of-memory errors
2026-07-20 16ebc196d8 Improve pgstat_get_entry_ref_cached() behavior on out-of-memory errors
2026-06-20 73dab12719 Make type cache initialization more resilient on re-entry after OOM
2026-06-20 b85f9c00fb Make StandbyAcquireAccessExclusiveLock() more resilent with OOMs
2026-06-18 29fb598b9c 94641eda4c bdae2f8eaa a123cc8429 d06780d4dd Make GetSnapshotData() more resilient on out-of-memory errors
* Unexpected behavior after OOM errors
@ 2026-06-17 06:00 Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Alexander Lakhin @ 2026-06-17 06:00 UTC (permalink / raw)
To: pgsql-hackers
Hello hackers,
I'd like to share my findings related to OOM error handling. I'm not sure
how large the class of such anomalies is (and if all of these can be
detected and fixed), but please look at a few issues I have discovered so
far:
1) An issue in lookup_type_cache()
The following modification:
inline patch 1: src/backend/utils/hash/dynahash.c (+2/-1 lines) download inline-1.patch
--- a/src/backend/utils/hash/dynahash.c
+++ b/src/backend/utils/hash/dynahash.c
@@ -104,6 +104,7 @@
#include "storage/spin.h"
#include "utils/memutils.h"
+#include "common/pg_prng.h"
/*
* Constants
@@ -528,7 +529,7 @@ hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
* that this is the first allocation made with the alloc function. That's
* a little ugly, but works for now.
*/
- hashp->hctl = (HASHHDR *) hashp->alloc(sizeof(HASHHDR), hashp->alloc_arg);
+ hashp->hctl = (pg_prng_double(&pg_global_prng_state) < 0.001) ? NULL : (HASHHDR *) hashp->alloc(sizeof(HASHHDR),
hashp->alloc_arg);
if (!hashp->hctl)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
@@ -609,7 +610,7 @@ hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
{
int temp = (i == 0) ? nelem_alloc_first : nelem_alloc;
- if (!element_alloc(hashp, temp, i))
+ if ((pg_prng_double(&pg_global_prng_state) < 0.001) || !element_alloc(hashp, temp, i))
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
makes this script:
for i in {1..10000}; do
cat << 'EOS' | psql >>psql.log
SELECT 1 ORDER BY 1;
SELECT 1 ORDER BY 1;
EOS
grep "terminated by signal" server.log && break;
done
trigger an assertion failure:
2026-06-17 07:26:07.837 EEST [87325:3] [unknown] LOG: connection authorized: user=law database=regression
application_name=psql
2026-06-17 07:26:07.837 EEST [87325:4] psql LOG: statement: SELECT 1 ORDER BY 1;
2026-06-17 07:26:07.837 EEST [87325:5] psql ERROR: out of memory at character 19
2026-06-17 07:26:07.837 EEST [87325:6] psql LOG: statement: SELECT 1 ORDER BY 1;
TRAP: failed Assert("TypeCacheHash != NULL && RelIdToTypeIdCacheHash != NULL"), File: "typcache.c", Line: 441, PID: 87325
ExceptionalCondition at assert.c:51:13
lookup_type_cache at typcache.c:444:27
get_sort_group_operators at parse_oper.c:207:13
addTargetToSortList at parse_clause.c:3647:4
transformSortClause at parse_clause.c:2959:14
transformSelectStmt at analyze.c:1806:18
transformStmt at analyze.c:396:15
transformOptionalSelectInto at analyze.c:327:1
transformTopLevelStmt at analyze.c:276:11
parse_analyze_fixedparams at analyze.c:144:10
pg_analyze_and_rewrite_fixedparams at postgres.c:699:10
exec_simple_query at postgres.c:1206:20
PostgresMain at postgres.c:4860:27
BackendInitialize at backend_startup.c:142:1
postmaster_child_launch at launch_backend.c:269:3
BackendStartup at postmaster.c:3627:8
ServerLoop at postmaster.c:1731:10
PostmasterMain at postmaster.c:1415:11
main at main.c:236:2
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b)[0x7b3d5c02a28b]
postgres: law regression [local] SELECT(_start+0x25)[0x5944d79e8155]
2026-06-17 07:26:07.914 EEST [85875:6] LOG: client backend (PID 87325) was terminated by signal 6: Aborted
Without asserts enables, the server might crash.
2) An issue in GetSnapshotData()
The following modification:
inline patch 2: src/backend/storage/ipc/procarray.c (+2/-1 lines) download inline-2.patch
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -71,2 +71,3 @@
#include "utils/wait_event.h"
+#include "common/pg_prng.h"
@@ -2157,3 +2158,3 @@ GetSnapshotData(Snapshot snapshot)
Assert(snapshot->subxip == NULL);
- snapshot->subxip = (TransactionId *)
+ snapshot->subxip = (pg_prng_double(&pg_global_prng_state) < 0.01) ? NULL : (TransactionId *)
malloc(GetMaxSnapshotSubxidCount() * sizeof(TransactionId));
makes this script (max_prepared_transactions = 2 in postgresql.conf):
for i in {1..1000}; do
cat << 'EOS' | psql >>psql.log
SELECT 1;
BEGIN;
CREATE TABLE t1(a int);
SAVEPOINT sp1;
INSERT INTO t1 VALUES (1);
ROLLBACK TO sp1;
INSERT INTO t1 VALUES (2);
PREPARE TRANSACTION 'pt1';
BEGIN;
CREATE TABLE t2(a int);
ROLLBACK;
ROLLBACK PREPARED 'pt1';
EOS
grep "terminated by signal" server.log && break;
done
trigger a segmentation fault:
2026-06-17 07:37:52.619 EEST [108789:3] [unknown] LOG: connection authorized: user=law database=regression
application_name=psql
2026-06-17 07:37:52.620 EEST [108789:4] psql LOG: statement: SELECT 1;
2026-06-17 07:37:52.620 EEST [108789:5] psql ERROR: out of memory
2026-06-17 07:37:52.620 EEST [108789:6] psql LOG: statement: BEGIN;
2026-06-17 07:37:52.620 EEST [108789:7] psql LOG: statement: CREATE TABLE t1(a int);
2026-06-17 07:37:52.621 EEST [108789:8] psql LOG: statement: SAVEPOINT sp1;
2026-06-17 07:37:52.621 EEST [108789:9] psql LOG: statement: INSERT INTO t1 VALUES (1);
2026-06-17 07:37:52.621 EEST [108789:10] psql LOG: statement: ROLLBACK TO sp1;
2026-06-17 07:37:52.621 EEST [108789:11] psql LOG: statement: INSERT INTO t1 VALUES (2);
2026-06-17 07:37:52.621 EEST [108789:12] psql LOG: statement: PREPARE TRANSACTION 'pt1';
2026-06-17 07:37:52.622 EEST [108789:13] psql LOG: statement: BEGIN;
2026-06-17 07:37:52.622 EEST [108789:14] psql LOG: statement: CREATE TABLE t2(a int);
2026-06-17 07:37:52.777 EEST [108710:6] LOG: client backend (PID 108789) was terminated by signal 11: Segmentation fault
2026-06-17 07:37:52.777 EEST [108710:7] DETAIL: Failed process was running: CREATE TABLE t2(a int);
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __memcpy_avx512_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:289
(gdb) bt
#0 __memcpy_avx512_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:289
#1 0x00005e857d7dc534 in GetSnapshotData (snapshot=0x5e857df07ae0 <CurrentSnapshotData>) at procarray.c:2297
#2 0x00005e857da9e452 in GetTransactionSnapshot () at snapmgr.c:331
#3 0x00005e857d823117 in PortalRunUtility (portal=0x5e85b337f3b0, pstmt=0x5e85b32fcd58, isTopLevel=true,
setHoldSnapshot=false, dest=0x5e85b32fd118, qc=0x7ffe081d5aa0) at pquery.c:1127
#4 0x00005e857d82343b in PortalRunMulti (portal=0x5e85b337f3b0, isTopLevel=true, setHoldSnapshot=false,
dest=0x5e85b32fd118,
altdest=0x5e85b32fd118, qc=0x7ffe081d5aa0) at pquery.c:1307
#5 0x00005e857d82289a in PortalRun (portal=0x5e85b337f3b0, count=9223372036854775807, isTopLevel=true, dest=0x5e85b32fd118,
altdest=0x5e85b32fd118, qc=0x7ffe081d5aa0) at pquery.c:784
(gdb) f 1
#1 0x00005e857d7dc534 in GetSnapshotData (snapshot=0x5e857df07ae0 <CurrentSnapshotData>) at procarray.c:2297
2297 memcpy(snapshot->subxip + subcount,
(gdb) p *snapshot
$1 = {snapshot_type = SNAPSHOT_MVCC, xmin = 745, xmax = 747, xip = 0x5e85b3329030, xcnt = 0, subxip = 0x0, subxcnt = 0,
suboverflowed = false, takenDuringRecovery = false, copied = false, curcid = 3, speculativeToken = 0, vistest = 0x0,
active_count = 0, regd_count = 0, ph_node = {first_child = 0x0, next_sibling = 0x0, prev_or_parent = 0x0},
snapXactCompletionCount = 55}
3) An issue in StandbyAcquireAccessExclusiveLock()
No modification needed. Please try the attached TAP test on REL_17_STABLE.
It fails as below:
t/099_out_of_shared_memory.pl .. Bailout called. Further testing stopped: pg_ctl start failed
099_out_of_shared_memory_standby.log contains:
2026-06-17 07:53:03.237 EEST [167771] LOG: database system is ready to accept read-only connections
2026-06-17 07:53:03.240 EEST [167775] LOG: started streaming WAL from primary at 0/3000000 on timeline 1
2026-06-17 07:53:03.269 EEST [167774] FATAL: out of shared memory
2026-06-17 07:53:03.269 EEST [167774] HINT: You might need to increase "max_locks_per_transaction".
2026-06-17 07:53:03.269 EEST [167774] CONTEXT: WAL redo at 0/32218D8 for Standby/LOCK: xid 738 db 5 rel 17839
2026-06-17 07:53:03.269 EEST [167774] WARNING: you don't own a lock of type AccessExclusiveLock
2026-06-17 07:53:03.269 EEST [167774] LOG: RecoveryLockHash contains entry for lock no longer recorded by lock manager:
xid 738 database 5 relation 17839
TRAP: failed Assert("false"), File: "standby.c", Line: 1053, PID: 167774
ExceptionalCondition at assert.c:52:13
StandbyReleaseXidEntryLocks at standby.c:1056:8
StandbyReleaseAllLocks at standby.c:1116:3
ShutdownRecoveryTransactionEnvironment at standby.c:178:2
StartupProcExit at startup.c:208:1
shmem_exit at ipc.c:282:9
proc_exit_prepare at ipc.c:201:2
proc_exit at ipc.c:155:2
errfinish at elog.c:593:5
LockAcquireExtended at lock.c:1020:4
LockAcquire at lock.c:763:1
StandbyAcquireAccessExclusiveLock at standby.c:1026:10
standby_redo at standby.c:1175:35
ApplyWalRecord at xlogrecovery.c:2008:13
PerformWalRecovery at xlogrecovery.c:1835:8
StartupXLOG at xlog.c:5803:24
StartupProcessMain at startup.c:264:2
postmaster_child_launch at launch_backend.c:281:9
StartChildProcess at postmaster.c:3918:8
PostmasterMain at postmaster.c:1369:13
startup_hacks at main.c:219:1
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b)[0x71abb4e2a28b]
postgres: standby: startup recovering 000000010000000000000003(_start+0x25)[0x64d0286de095]
2026-06-17 07:53:03.279 EEST [167771] LOG: startup process (PID 167774) was terminated by signal 6: Aborted
Best regards,
Alexander
Patches and attachments: download all (3 files, .tar.gz)
099_out_of_shared_memory.pl (application/x-perl, 903B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
@ 2026-06-17 12:27 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-06-17 12:27 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: pgsql-hackers
On Wed, 17 Jun 2026 at 08:00, Alexander Lakhin <exclusion@gmail.com> wrote:
>
> Hello hackers,
>
> I'd like to share my findings related to OOM error handling. I'm not sure
> how large the class of such anomalies is (and if all of these can be
> detected and fixed), but please look at a few issues I have discovered so
> far:
>
> 1) An issue in lookup_type_cache()
>
> The following modification:
<snip>
> makes this script:
<snip>
> trigger an assertion failure:
<snip>
> Without asserts enables, the server might crash.
I believe this is caused by partial subsystem initialization. Attached
patch 0001 should address this failure without causing the server to
restart on OOM.
> 2) An issue in GetSnapshotData()
>
> The following modification:
<snip>
> makes this script (max_prepared_transactions = 2 in postgresql.conf):
<snip>
> trigger a segmentation fault:
<snip>
Again, caused by partial initialization, though in this case it's of a
SnapshotData* which is later checked again. Attached patch 0002 should
address this failure.
> 3) An issue in StandbyAcquireAccessExclusiveLock()
<snip>
I'm not sure how to solve this correctly; I think ideally the
StandbyAcquireAccessExclusiveLock() hash code would be wrapped by a
critical section, but I'm not 100% sure if that will be a sufficient
approach; and it'd definitely need some code to allow the various
hashmaps' memctxs to alloc during critical sections.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
Attachments: download all (2 files, .tar.gz)
v1-0002-Make-GetSnapshotData-more-resilient-against-OOM-e.patch (application/octet-stream, 1.2K) download
From 286a9c26b55a9201ef69463d33b6c8db397ada5f Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Tue, 16 Jun 2026 15:07:40 +0200
Subject: [PATCH v1 2/2] Make GetSnapshotData more resilient against OOM errors
---
src/backend/storage/ipc/procarray.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index f540bb6b23f..d23ce3800e4 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -2158,9 +2158,20 @@ GetSnapshotData(Snapshot snapshot)
snapshot->subxip = (TransactionId *)
malloc(GetMaxSnapshotSubxidCount() * sizeof(TransactionId));
if (snapshot->subxip == NULL)
+ {
+ /*
+ * Clean up Snapshot's state ahead of throwing the error -- it's
+ * not guaranteed that this Snapshot is not reused.
+ * Additionally, we'd possibly leak the xip allocation, so
+ * better make sure to clean this up.
+ */
+ free(snapshot->xip);
+ snapshot->xip = NULL;
+
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
+ }
}
/*
--
2.50.1 (Apple Git-155)
v1-0001-typcache-Use-new-LAZY_INIT-system.patch (application/octet-stream, 5.3K) download
From df023ee26492199e0a120416ebdcc1e3af1d4c76 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Wed, 17 Jun 2026 14:13:17 +0200
Subject: [PATCH v1 1/2] typcache: Use new LAZY_INIT system
This allows us to recover from OOMs when they happen during the
initialization of the typcache.
---
src/backend/utils/cache/typcache.c | 53 +++++++++++++++++++++---------
src/include/miscadmin.h | 39 ++++++++++++++++++++++
2 files changed, 76 insertions(+), 16 deletions(-)
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index da91a2ff1dd..997f0e1cb1c 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -73,6 +73,7 @@
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
+#include "miscadmin.h"
/* The main type cache hashtable searched by lookup_type_cache */
@@ -388,11 +389,12 @@ type_cache_syshash(const void *key, Size keysize)
TypeCacheEntry *
lookup_type_cache(Oid type_id, int flags)
{
+ LAZY_INIT_SYSTEM(typcache, 5);
TypeCacheEntry *typentry;
bool found;
int in_progress_offset;
- if (TypeCacheHash == NULL)
+ if (!LAZY_INIT_DONE(typcache))
{
/* First time through: initialize the hash table */
HASHCTL ctl;
@@ -408,34 +410,53 @@ lookup_type_cache(Oid type_id, int flags)
*/
ctl.hash = type_cache_syshash;
- TypeCacheHash = hash_create("Type information cache", 64,
- &ctl, HASH_ELEM | HASH_FUNCTION);
+ LAZY_INIT_STEP(typcache, {
+ TypeCacheHash = hash_create("Type information cache", 64,
+ &ctl, HASH_ELEM | HASH_FUNCTION);
+ });
Assert(RelIdToTypeIdCacheHash == NULL);
ctl.keysize = sizeof(Oid);
ctl.entrysize = sizeof(RelIdToTypeIdCacheEntry);
- RelIdToTypeIdCacheHash = hash_create("Map from relid to OID of cached composite type", 64,
- &ctl, HASH_ELEM | HASH_BLOBS);
- /* Also set up callbacks for SI invalidations */
- CacheRegisterRelcacheCallback(TypeCacheRelCallback, (Datum) 0);
- CacheRegisterSyscacheCallback(TYPEOID, TypeCacheTypCallback, (Datum) 0);
- CacheRegisterSyscacheCallback(CLAOID, TypeCacheOpcCallback, (Datum) 0);
- CacheRegisterSyscacheCallback(CONSTROID, TypeCacheConstrCallback, (Datum) 0);
+ LAZY_INIT_STEP(typcache, {
+ RelIdToTypeIdCacheHash = hash_create("Map from relid to OID of cached composite type", 64,
+ &ctl, HASH_ELEM | HASH_BLOBS);
+ });
+
+ /*
+ * Also set up callbacks for SI invalidations.
+ * A critical section is used, because we must not run out of slots
+ * for syscache callbacks; this backend cannot recover from that.
+ */
+ LAZY_INIT_STEP(typcache, {
+ START_CRIT_SECTION();
+ CacheRegisterRelcacheCallback(TypeCacheRelCallback, (Datum) 0);
+ CacheRegisterSyscacheCallback(TYPEOID, TypeCacheTypCallback, (Datum) 0);
+ CacheRegisterSyscacheCallback(CLAOID, TypeCacheOpcCallback, (Datum) 0);
+ CacheRegisterSyscacheCallback(CONSTROID, TypeCacheConstrCallback, (Datum) 0);
+ END_CRIT_SECTION();
+ });
/* Also make sure CacheMemoryContext exists */
- if (!CacheMemoryContext)
- CreateCacheMemoryContext();
+ LAZY_INIT_STEP(typcache, {
+ if (!CacheMemoryContext)
+ CreateCacheMemoryContext();
+ });
/*
* reserve enough in_progress_list slots for many cases
*/
allocsize = 4;
- in_progress_list =
- MemoryContextAlloc(CacheMemoryContext,
- allocsize * sizeof(*in_progress_list));
- in_progress_list_maxlen = allocsize;
+ LAZY_INIT_STEP(typcache, {
+ in_progress_list =
+ MemoryContextAlloc(CacheMemoryContext,
+ allocsize * sizeof(*in_progress_list));
+ in_progress_list_maxlen = allocsize;
+ });
+
+ Assert(LAZY_INIT_DONE(typcache));
}
Assert(TypeCacheHash != NULL && RelIdToTypeIdCacheHash != NULL);
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 7de0a115402..5c4392a3da3 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -158,6 +158,45 @@ do { \
} while(0)
+/*
+ * Helpers to allow subsystems to run lazy initialization code that can deal
+ * with temporary resource constraints, like OOMs, without significant manual
+ * coding to support errors in every call to a subcomponent.
+ *
+ * The user is expected to run one _STEP per fallible resource allocation, or
+ * wrap the code that should be executed just once per session in a critical
+ * section.
+ *
+ * Usage:
+ *
+ * LAZY_INIT_SYSTEM(name, # of _STEP invocations for this system);
+ * if (!LAZY_INIT_DONE(name))
+ * {
+ * ...locals;
+ * ...infallible code;
+ * LAZY_INIT_STEP(name, { code });
+ * ...
+ * Assert(LAZY_INIT_DONE(name));
+ * }
+ */
+
+#define LAZY_INIT_SYSTEM(sysname, nsteps) \
+ static const int LI_STEPS_TOTAL_ ## sysname = (nsteps); \
+ static int LI_STEPS_DONE_ ## sysname = 0; \
+ int LI_CURRENT_STEP_ ## sysname = 0
+
+#define LAZY_INIT_STEP(sysname, operation) \
+ do { \
+ if ((LI_STEPS_DONE_ ## sysname) == (LI_CURRENT_STEP_ ## sysname)++) \
+ { \
+ operation; \
+ (LI_STEPS_DONE_ ## sysname) += 1; \
+ } \
+ } while (false)
+
+#define LAZY_INIT_DONE(sysname) \
+ ((LI_STEPS_DONE_ ## sysname) == (LI_STEPS_TOTAL_ ## sysname))
+
/*****************************************************************************
* globals.h -- *
*****************************************************************************/
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-06-18 04:37 ` Michael Paquier <michael@paquier.xyz>
2026-06-18 06:42 ` Re: Unexpected behavior after OOM errors Heikki Linnakangas <hlinnaka@iki.fi>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 15:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
0 siblings, 3 replies; 32+ messages in thread
From: Michael Paquier @ 2026-06-18 04:37 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Wed, Jun 17, 2026 at 02:27:25PM +0200, Matthias van de Meent wrote:
> On Wed, 17 Jun 2026 at 08:00, Alexander Lakhin <exclusion@gmail.com> wrote:
>> 1) An issue in lookup_type_cache()
>
> I believe this is caused by partial subsystem initialization. Attached
> patch 0001 should address this failure without causing the server to
> restart on OOM.
Hmm. I think that this is an ordering problem. We could make the
callbacks be registered last, once we are sure that the two hash
tables and the in-progress list have been initialized. I am not sure
that this requires a new facility; it is also an advantage to keep the
initialization sequence in a one code path, without an abstraction.
RelIdToTypeIdCacheHash and RelIdToTypeIdCacheHash are in the
TopMemoryContext, static to the process, so we could just check them
for NULL-ness to make the initialization repeatable. That gives me
the attached v2. Reusing Alexander's randomness trick, that looks
stable here.
>> 2) An issue in GetSnapshotData()
>
> Again, caused by partial initialization, though in this case it's of a
> SnapshotData* which is later checked again. Attached patch 0002 should
> address this failure.
Yeah, that seems right to make repeated calls of GetSnapshotData()
able to work. LGTM.
>> 3) An issue in StandbyAcquireAccessExclusiveLock()
> <snip>
>
> I'm not sure how to solve this correctly; I think ideally the
> StandbyAcquireAccessExclusiveLock() hash code would be wrapped by a
> critical section, but I'm not 100% sure if that will be a sufficient
> approach; and it'd definitely need some code to allow the various
> hashmaps' memctxs to alloc during critical sections.
Not checked this one yet.
Thoughts about the first part?
--
Michael
Attachments:
v2-0001-typcache-Make-initialization-more-resilient-on-OO.patch (text/plain, 3.6K) download
From 8b2ecd4df82750ca98cf7e67244cb46b1e4239ed Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Thu, 18 Jun 2026 13:24:47 +0900
Subject: [PATCH v2] typcache: Make initialization more resilient on OOM
---
src/backend/utils/cache/typcache.c | 57 +++++++++++++++++-------------
1 file changed, 33 insertions(+), 24 deletions(-)
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index da91a2ff1dd8..b96554a4b32e 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -392,50 +392,59 @@ lookup_type_cache(Oid type_id, int flags)
bool found;
int in_progress_offset;
- if (TypeCacheHash == NULL)
+ if (in_progress_list == NULL)
{
/* First time through: initialize the hash table */
HASHCTL ctl;
int allocsize;
- ctl.keysize = sizeof(Oid);
- ctl.entrysize = sizeof(TypeCacheEntry);
+ if (TypeCacheHash == NULL)
+ {
+ ctl.keysize = sizeof(Oid);
+ ctl.entrysize = sizeof(TypeCacheEntry);
- /*
- * TypeCacheEntry takes hash value from the system cache. For
- * TypeCacheHash we use the same hash in order to speedup search by
- * hash value. This is used by hash_seq_init_with_hash_value().
- */
- ctl.hash = type_cache_syshash;
+ /*
+ * TypeCacheEntry takes hash value from the system cache. For
+ * TypeCacheHash we use the same hash in order to speedup search
+ * by hash value. This is used by
+ * hash_seq_init_with_hash_value().
+ */
+ ctl.hash = type_cache_syshash;
- TypeCacheHash = hash_create("Type information cache", 64,
- &ctl, HASH_ELEM | HASH_FUNCTION);
+ TypeCacheHash = hash_create("Type information cache", 64,
+ &ctl, HASH_ELEM | HASH_FUNCTION);
+ }
- Assert(RelIdToTypeIdCacheHash == NULL);
-
- ctl.keysize = sizeof(Oid);
- ctl.entrysize = sizeof(RelIdToTypeIdCacheEntry);
- RelIdToTypeIdCacheHash = hash_create("Map from relid to OID of cached composite type", 64,
- &ctl, HASH_ELEM | HASH_BLOBS);
-
- /* Also set up callbacks for SI invalidations */
- CacheRegisterRelcacheCallback(TypeCacheRelCallback, (Datum) 0);
- CacheRegisterSyscacheCallback(TYPEOID, TypeCacheTypCallback, (Datum) 0);
- CacheRegisterSyscacheCallback(CLAOID, TypeCacheOpcCallback, (Datum) 0);
- CacheRegisterSyscacheCallback(CONSTROID, TypeCacheConstrCallback, (Datum) 0);
+ if (RelIdToTypeIdCacheHash == NULL)
+ {
+ ctl.keysize = sizeof(Oid);
+ ctl.entrysize = sizeof(RelIdToTypeIdCacheEntry);
+ RelIdToTypeIdCacheHash = hash_create("Map from relid to OID of cached composite type", 64,
+ &ctl, HASH_ELEM | HASH_BLOBS);
+ }
/* Also make sure CacheMemoryContext exists */
if (!CacheMemoryContext)
CreateCacheMemoryContext();
/*
- * reserve enough in_progress_list slots for many cases
+ * Reserve enough in_progress_list slots for many cases. This is
+ * the last allocation on purpose, done after the two others.
*/
allocsize = 4;
in_progress_list =
MemoryContextAlloc(CacheMemoryContext,
allocsize * sizeof(*in_progress_list));
in_progress_list_maxlen = allocsize;
+
+ /*
+ * Set up callbacks for SI invalidations. These are done last,
+ * once all the other initializations are done.
+ */
+ CacheRegisterRelcacheCallback(TypeCacheRelCallback, (Datum) 0);
+ CacheRegisterSyscacheCallback(TYPEOID, TypeCacheTypCallback, (Datum) 0);
+ CacheRegisterSyscacheCallback(CLAOID, TypeCacheOpcCallback, (Datum) 0);
+ CacheRegisterSyscacheCallback(CONSTROID, TypeCacheConstrCallback, (Datum) 0);
}
Assert(TypeCacheHash != NULL && RelIdToTypeIdCacheHash != NULL);
--
2.54.0
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-18 06:42 ` Heikki Linnakangas <hlinnaka@iki.fi>
2 siblings, 0 replies; 32+ messages in thread
From: Heikki Linnakangas @ 2026-06-18 06:42 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On 18/06/2026 07:37, Michael Paquier wrote:
> On Wed, Jun 17, 2026 at 02:27:25PM +0200, Matthias van de Meent wrote:
>> On Wed, 17 Jun 2026 at 08:00, Alexander Lakhin <exclusion@gmail.com> wrote:
>>> 1) An issue in lookup_type_cache()
>>
>> I believe this is caused by partial subsystem initialization. Attached
>> patch 0001 should address this failure without causing the server to
>> restart on OOM.
>
> Hmm. I think that this is an ordering problem. We could make the
> callbacks be registered last, once we are sure that the two hash
> tables and the in-progress list have been initialized. I am not sure
> that this requires a new facility; it is also an advantage to keep the
> initialization sequence in a one code path, without an abstraction.
>
> RelIdToTypeIdCacheHash and RelIdToTypeIdCacheHash are in the
> TopMemoryContext, static to the process, so we could just check them
> for NULL-ness to make the initialization repeatable. That gives me
> the attached v2. Reusing Alexander's randomness trick, that looks
> stable here.
Yeah, this can be solved by ordering. It's a bit fiddly though. I don't
know about Matthias's proposal either, but it'd be nice to have a less
fiddly system for these.
One idea is to have something similar to
START_CRIT_SECTION()/END_CRIT_SECTION(), but instead of promoting the
ERROR to a PANIC, promote it to FATAL. That way, if any of these
one-time allocations fail, the backend exits. If you're so
memory-starved that you cannot even initialize the type cache, you won't
be able to do anything useful with the connection anyway.
Another idea is that instead of having these be singletons in the type
cache, initialized on first use, move it to a new TypeCacheInitialize()
function that is always called at backend startup, like
RelationCacheInitialize(). If an allocation fails at that stage, the
backend will just exit. I think that's my favorite alternative so far.
BTW, I'm surprised we create the hash tables are created in
TopMemoryContext rather than CacheMemoryContext...
- Heikki
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-18 09:27 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-06-18 09:27 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Thu, 18 Jun 2026 at 06:37, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Jun 17, 2026 at 02:27:25PM +0200, Matthias van de Meent wrote:
> > On Wed, 17 Jun 2026 at 08:00, Alexander Lakhin <exclusion@gmail.com> wrote:
> >> 1) An issue in lookup_type_cache()
> >
> > I believe this is caused by partial subsystem initialization. Attached
> > patch 0001 should address this failure without causing the server to
> > restart on OOM.
>
> Hmm. I think that this is an ordering problem. We could make the
> callbacks be registered last, once we are sure that the two hash
> tables and the in-progress list have been initialized.
I don't disagree that there's an ordering problem, but in my view the
main problem is the fallible initialization of N components, gated
behind a single condition. The question of when to register the
callbacks is just one part of many.
> I am not sure
> that this requires a new facility; it is also an advantage to keep the
> initialization sequence in a one code path, without an abstraction.
I'm not a huge fan of templating if(!global) { init_global(); } all
around. But, it works.
> RelIdToTypeIdCacheHash and RelIdToTypeIdCacheHash are in the
> TopMemoryContext, static to the process, so we could just check them
> for NULL-ness to make the initialization repeatable. That gives me
> the attached v2. Reusing Alexander's randomness trick, that looks
> stable here.
This un-fixes one of the unlikely issues that was fixed in my patch -
though unrelated to OOM:
Each of the calls to
CacheRegisterSyscacheCallback/CacheRegisterRelcacheCallback can throw
an ERROR when all slots have been used. This would leave the typcache
in an invalid state, so I think that must be wrapped in a critical
section: neither syscache nor relcache has options to release
callbacks, and we can't safely continue without the callbacks
installed, so once an error is thrown here this backend can't ever be
properly initialized. This is unlike OOMs, whose conditions for
failure may (and often do) change as workloads change in other
backends.
I think Heikki's suggestion for a FATAL critical section option would
be a good alternative. It wouldn't always be sufficient, but would fix
issues here.
> >> 2) An issue in GetSnapshotData()
> >
> > Again, caused by partial initialization, though in this case it's of a
> > SnapshotData* which is later checked again. Attached patch 0002 should
> > address this failure.
>
> Yeah, that seems right to make repeated calls of GetSnapshotData()
> able to work. LGTM.
Thanks for committing!
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-06-18 23:55 ` Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Michael Paquier @ 2026-06-18 23:55 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Thu, Jun 18, 2026 at 11:27:28AM +0200, Matthias van de Meent wrote:
> Each of the calls to
> CacheRegisterSyscacheCallback/CacheRegisterRelcacheCallback can throw
> an ERROR when all slots have been used. This would leave the typcache
> in an invalid state, so I think that must be wrapped in a critical
> section: neither syscache nor relcache has options to release
> callbacks, and we can't safely continue without the callbacks
> installed, so once an error is thrown here this backend can't ever be
> properly initialized. This is unlike OOMs, whose conditions for
> failure may (and often do) change as workloads change in other
> backends.
We don't ERROR when failing to register a syscache/relcache callback,
we FATAL if we reach one of the thresholds. Reaching these thresholds
points to me to a programming error anyway, so these should not matter
in the field. The OOM is a random pattern that can happen outside the
Postgres realm.
Just in case, I have planted a elog(FATAL) triggering randomly in the
middle of cache registration callback calls, and the typcache
inconsistency does not come in play with the shutdown sequence once
these trigger even if we have the tables set but not the callbacks.
As a whole, I tend to think that reordering the actions is a solution
good enough here.
> I think Heikki's suggestion for a FATAL critical section option would
> be a good alternative. It wouldn't always be sufficient, but would fix
> issues here.
That sounds like an interesting idea, potentially reusable for other
areas, but I'm not really convinced that we need to add this kind of
facility for the case dealt with here. To me, that's also where we
could use a TRY/CATCH block and call it a day. If others feel
differently about this matter, I'm fine to be outvoted.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-19 07:18 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-06-19 07:18 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Fri, 19 Jun 2026 at 01:55, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Thu, Jun 18, 2026 at 11:27:28AM +0200, Matthias van de Meent wrote:
> > Each of the calls to
> > CacheRegisterSyscacheCallback/CacheRegisterRelcacheCallback can throw
> > an ERROR when all slots have been used. This would leave the typcache
> > in an invalid state, so I think that must be wrapped in a critical
> > section: neither syscache nor relcache has options to release
> > callbacks, and we can't safely continue without the callbacks
> > installed, so once an error is thrown here this backend can't ever be
> > properly initialized. This is unlike OOMs, whose conditions for
> > failure may (and often do) change as workloads change in other
> > backends.
>
> We don't ERROR when failing to register a syscache/relcache callback,
> we FATAL if we reach one of the thresholds.
Ah, thanks for correcting me. I'm not sure why I had ERROR in mind,
but you're obviously correct. Your patch v2 LGTM.
> Reaching these thresholds
> points to me to a programming error anyway, so these should not matter
> in the field.
I don't think that's (necessarily) correct. These callbacks are
accessible to extensions, and if you load sufficiently many of those
you could still run out of slots even if each extension stayed well
within a reasonable threshold.
> > I think Heikki's suggestion for a FATAL critical section option would
> > be a good alternative. It wouldn't always be sufficient, but would fix
> > issues here.
>
> That sounds like an interesting idea, potentially reusable for other
> areas, but I'm not really convinced that we need to add this kind of
> facility for the case dealt with here. To me, that's also where we
> could use a TRY/CATCH block and call it a day. If others feel
> differently about this matter, I'm fine to be outvoted.
While TRY/CATCH would work, I'm not so keen on adding those to
system-initalizing code; the allocations generally go into contexts
that aren't cleaned up nicely during error handling. E.g. a partial
hash initialization for any of the cache hashmaps due to OOM will leak
its allocations.
Failing the connection for that makes sure we complete the right
cleanup procedures and not leak those resources (and it adds another
item to the multi-threading concerns list).
-Matthias
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-06-19 11:12 ` Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 32+ messages in thread
From: Michael Paquier @ 2026-06-19 11:12 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Fri, Jun 19, 2026 at 09:18:03AM +0200, Matthias van de Meent wrote:
> On Fri, 19 Jun 2026 at 01:55, Michael Paquier <michael@paquier.xyz> wrote:
>> We don't ERROR when failing to register a syscache/relcache callback,
>> we FATAL if we reach one of the thresholds.
>
> Ah, thanks for correcting me. I'm not sure why I had ERROR in mind,
> but you're obviously correct. Your patch v2 LGTM.
Cool, thanks.
>> Reaching these thresholds
>> points to me to a programming error anyway, so these should not matter
>> in the field.
>
> I don't think that's (necessarily) correct. These callbacks are
> accessible to extensions, and if you load sufficiently many of those
> you could still run out of slots even if each extension stayed well
> within a reasonable threshold.
Sure, but then the only way to get out of the problem is to patch the
backend so there are more slots available. At the end, when it comes
to core (and there should be some margin anyway), I am not really
worried.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-20 07:45 ` Michael Paquier <michael@paquier.xyz>
2026-06-20 08:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
0 siblings, 2 replies; 32+ messages in thread
From: Michael Paquier @ 2026-06-20 07:45 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Fri, Jun 19, 2026 at 08:12:47PM +0900, Michael Paquier wrote:
> On Fri, Jun 19, 2026 at 09:18:03AM +0200, Matthias van de Meent wrote:
>> Ah, thanks for correcting me. I'm not sure why I had ERROR in mind,
>> but you're obviously correct. Your patch v2 LGTM.
>
> Cool, thanks.
And done that as well. If we invent a new facility, I'd be curious to
see how this would apply here or to other parts of the backend. And
perhaps not only for initialization steps?
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-20 08:00 ` Alexander Lakhin <exclusion@gmail.com>
1 sibling, 0 replies; 32+ messages in thread
From: Alexander Lakhin @ 2026-06-20 08:00 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: pgsql-hackers
Hello Michael and Matthias,
20.06.2026 10:45, Michael Paquier wrote:
> On Fri, Jun 19, 2026 at 08:12:47PM +0900, Michael Paquier wrote:
>> On Fri, Jun 19, 2026 at 09:18:03AM +0200, Matthias van de Meent wrote:
>>> Ah, thanks for correcting me. I'm not sure why I had ERROR in mind,
>>> but you're obviously correct. Your patch v2 LGTM.
>> Cool, thanks.
> And done that as well. If we invent a new facility, I'd be curious to
> see how this would apply here or to other parts of the backend. And
> perhaps not only for initialization steps?
Thank you for working on the fixes!
Best regards,
Alexander
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-07-17 09:00 ` Alexander Lakhin <exclusion@gmail.com>
2026-07-17 14:15 ` Re: Unexpected behavior after OOM errors Alex Masterov <amasterov@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-20 11:51 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-21 12:24 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-27 14:33 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
1 sibling, 5 replies; 32+ messages in thread
From: Alexander Lakhin @ 2026-07-17 09:00 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: pgsql-hackers
Hello Michael and Matthias,
Could you please look at other similar anomalies I have discovered?:
(Assuming the attached OOM injection patch applied.)
1) An issue in generate_partition_qual():
inline patch 1: src/backend/utils/cache/partcache.c (+2/-0 lines) download inline-1.patch
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -419,3 +419,5 @@ generate_partition_qual(Relation rel)
oldcxt = MemoryContextSwitchTo(rel->rd_partcheckcxt);
+oom_prob = 0.1;
rel->rd_partcheck = copyObject(result);
+oom_prob = 0;
MemoryContextSwitchTo(oldcxt);
for i in {1..100}; do
echo "
CREATE TABLE t1(a INT PRIMARY KEY) PARTITION BY RANGE (a);
CREATE TABLE t1p1 PARTITION OF t1 FOR VALUES FROM (1) TO (2) PARTITION BY LIST (a);
CREATE TABLE t2 (a INT, CONSTRAINT fkey FOREIGN KEY(a) REFERENCES t1(a));
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (1);
DROP TABLE t1, t2 CASCADE;
" | psql
grep 'TRAP' server.log && break;
done
triggers
TRAP: failed Assert("cache->cc_tupdesc != NULL"), File: "catcache.c", Line: 1112, PID: 43932
2) lookup_type_cache():
inline patch 2: src/backend/utils/cache/typcache.c (+2/-0 lines) download inline-2.patch
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -463,8 +463,10 @@ lookup_type_cache(Oid type_id, int flags)
in_progress_list[in_progress_offset] = type_id;
+oom_prob = 0.1;
/* Try to look up an existing entry */
typentry = (TypeCacheEntry *) hash_search(TypeCacheHash,
&type_id,
HASH_FIND, NULL);
+oom_prob = 0;
if (typentry == NULL)
{
for i in {1..10}; do
echo "
CREATE TABLE t(a int);
\c
SELECT * FROM t ORDER BY a;
DROP TABLE t;
" | psql
grep 'TRAP' server.log && break;
done
triggers
TRAP: failed Assert("cache->cc_tupdesc != NULL"), File: "catcache.c", Line: 1112, PID: 43932
3) pgstat_prep_pending_entry() / pgstat_write_statsfiles():
inline patch 3: src/backend/utils/activity/pgstat.c (+2/-0 lines) download inline-3.patch
--- a/src/backend/utils/activity/pgstat.c
+++ b/src/backend/utils/activity/pgstat.c
@@ -1333,3 +1333,5 @@ pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *creat
+oom_prob = 0.005;
entry_ref->pending = MemoryContextAllocZero(pgStatPendingContext, entrysize);
+oom_prob = 0;
dlist_push_tail(&pgStatPending, &entry_ref->pending_node);
for i in {1..100}; do
pg_ctl -l server.log start
echo "
CREATE TABLE t (a int);
ALTER TABLE t SET (parallel_workers = 20);
SET parallel_setup_cost = 0;
SELECT SUM(a) FROM t;
DROP TABLE t;
" | psql
pg_ctl -l server.log stop
grep 'TRAP' server.log && break;
done
triggers
TRAP: failed Assert("!ps->dropped"), File: "pgstat.c", Line: 1730, PID: 844901
maybe this Assert can be removed, because there is no corresponding
assert in pgstat_build_snapshot(), but I saw also:
TRAP: failed Assert("rel->pgstat_info->relation == NULL"), File: "pgstat_relation.c", Line: 142, PID: 157820
TRAP: failed Assert("ent->entry_ref != NULL"), File: "pgstat_shmem.c", Line: 827, PID: 190431
4) make_new_heap():
inline patch 4: src/backend/commands/repack.c (+2/-0 lines) download inline-4.patch
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -1255,3 +1255,5 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod,
*/
+oom_prob = 0.01;
CommandCounterIncrement();
+oom_prob = 0;
for i in {1..100}; do
echo "
CREATE TABLE t1(i int PRIMARY KEY);
CLUSTER t1 USING t1_pkey;
CREATE TABLE t2(i int PRIMARY KEY);
CLUSTER t2 USING t2_pkey;
DROP TABLE t2;
DROP TABLE t1;
" | psql
grep 'TRAP' server.log && break;
done
triggers:
TRAP: failed Assert("ItemIdIsNormal(lp)"), File: "heapam.c", Line: 2813, PID: 943626
also:
ERROR: attempted to delete invisible tuple
(similar to [1], which can also be triggered with OOM inside
CommandCounterIncrement(), but this one is even more interesting, IMO)
[1] https://www.postgresql.org/message-id/21363eb7-606c-468d-88f4-c14162ddafc8%40gmail.com
Best regards,
Alexander
Patches and attachments: download all (5 files, .tar.gz)
random-oom-errors.patch (text/x-patch, 2.1K) download
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index 6a9ea367107..af4d55f9b4c 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -51,6 +51,7 @@
#include "utils/memutils.h"
#include "utils/memutils_internal.h"
#include "utils/memutils_memorychunk.h"
+#include "common/pg_prng.h"
/*--------------------
* Chunk freelist k holds chunks of size 1 << (k + ALLOC_MINBITS),
@@ -946,6 +947,7 @@ AllocSetAllocFromNewBlock(MemoryContext context, Size size, int flags,
while (blksize < required_size)
blksize <<= 1;
+if (pg_prng_double(&pg_global_prng_state) < oom_prob) { oom_prob = 0; return MemoryContextAllocationFailure(context, size, flags); }
/* Try to allocate it */
block = (AllocBlock) malloc(blksize);
@@ -1023,6 +1025,7 @@ AllocSetAlloc(MemoryContext context, Size size, int flags)
/* due to the keeper block set->blocks should never be NULL */
Assert(set->blocks != NULL);
+if (pg_prng_double(&pg_global_prng_state) < oom_prob) { oom_prob = 0; return MemoryContextAllocationFailure(context, size, flags); }
/*
* If requested size exceeds maximum for chunks we hand the request off to
* AllocSetAllocLarge().
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 930fc457328..af050ed870d 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -46,6 +46,7 @@
#include "utils/memutils_internal.h"
#include "utils/memutils_memorychunk.h"
+double oom_prob = 0;
static void BogusFree(void *pointer);
static void *BogusRealloc(void *pointer, Size size, int flags);
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index 0e934158b60..90033ddc5a3 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -163,5 +163,6 @@ extern char *pchomp(const char *in);
/* sprintf into a palloc'd buffer --- these are in psprintf.c */
extern char *psprintf(const char *fmt, ...) pg_attribute_printf(1, 2);
extern size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pg_attribute_printf(3, 0);
+extern double oom_prob;
#endif /* PALLOC_H */
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
@ 2026-07-17 14:15 ` Alex Masterov <amasterov@gmail.com>
2026-07-18 00:47 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
4 siblings, 1 reply; 32+ messages in thread
From: Alex Masterov @ 2026-07-17 14:15 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
Hello Michael, Matthias, and Alexander,
The assertion in issue #3 (ent->entry_ref != NULL, pgstat_shmem.c) also has
a separate trigger I'd like to report — a different code path that poisons
the same hash in pgstat_get_entry_ref_cached().
pgstat_get_entry_ref_cached() inserts a zero-filled hash slot — entry_ref
== NULL — before allocating memory for it. If MemoryContextAlloc() fails
with OOM it longjmps out, leaving the NULL slot permanently poisoned in
pgStatEntryRefHash. The hash is backend-local and cross-transaction, so
abort does not clean it up.
Crash vectors:
- Debug builds: backend exit hits Assert(ent->entry_ref != NULL) in
pgstat_release_matching_entry_refs()
- Release builds: any GC pass (DROP TABLE etc.) causes
pgstat_gc_entry_refs() to unconditionally dereference the NULL → SIGSEGV
This is the backend-local sibling of the shared/DSA-path issue fixed in
8191e0c16a. Present since 5891c7a8ed8 (2022); affects PG15, PG17, PG18, and
master.
The bug can be reproduced without your OOM injection patch using the
built-in injection points infrastructure (--enable-injection-points
--enable-cassert). Apply this one-liner to pgstat_get_entry_ref_cached():
inline patch 1: src/backend/utils/activity/pgstat_shmem.c (+3/-0 lines) download inline-1.patch
--- a/src/backend/utils/activity/pgstat_shmem.c
+++ b/src/backend/utils/activity/pgstat_shmem.c
@@ -14,6 +14,7 @@
#include "pgstat.h"
#include "storage/shmem.h"
+#include "utils/injection_point.h"
#include "utils/memutils.h"
#include "utils/pgstat_internal.h"
@@ -387,6 +388,9 @@
if (!found || !cache_entry->entry_ref)
{
PgStat_EntryRef *entry_ref;
+
+ /* slot exists, entry_ref == NULL -- same window a real OOM
longjmps from */
+ INJECTION_POINT("pgstat-entry-ref-oom");
cache_entry->entry_ref = entry_ref =
MemoryContextAlloc(pgStatSharedRefContext,
Then:
CREATE EXTENSION injection_points;
CREATE TABLE t (id int PRIMARY KEY, v int);
INSERT INTO t VALUES (1, 0);
SELECT injection_points_attach('pgstat-entry-ref-oom', 'error');
UPDATE t SET v = v + 1 WHERE id = 1;
SELECT injection_points_detach('pgstat-entry-ref-oom');
-- disconnect; backend exit crashes
The UPDATE fails as expected:
ERROR: error triggered for injection point pgstat-entry-ref-oom
But on session exit, the backend crashes:
TRAP: failed Assert("ent->entry_ref != NULL"), File: "pgstat_shmem.c",
Line: 781
server process (PID ...) was terminated by signal 6: Abort trap
Alexey
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-17 14:15 ` Re: Unexpected behavior after OOM errors Alex Masterov <amasterov@gmail.com>
@ 2026-07-18 00:47 ` Michael Paquier <michael@paquier.xyz>
2026-07-18 02:57 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 32+ messages in thread
From: Michael Paquier @ 2026-07-18 00:47 UTC (permalink / raw)
To: Alex Masterov <amasterov@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
On Fri, Jul 17, 2026 at 04:15:15PM +0200, Alex Masterov wrote:
> The assertion in issue #3 (ent->entry_ref != NULL, pgstat_shmem.c) also has
> a separate trigger I'd like to report — a different code path that poisons
> the same hash in pgstat_get_entry_ref_cached().
> pgstat_get_entry_ref_cached() inserts a zero-filled hash slot — entry_ref
> == NULL — before allocating memory for it. If MemoryContextAlloc() fails
> with OOM it longjmps out, leaving the NULL slot permanently poisoned in
> pgStatEntryRefHash. The hash is backend-local and cross-transaction, so
> abort does not clean it up.
>
> Crash vectors:
> - Debug builds: backend exit hits Assert(ent->entry_ref != NULL) in
> pgstat_release_matching_entry_refs()
> - Release builds: any GC pass (DROP TABLE etc.) causes
> pgstat_gc_entry_refs() to unconditionally dereference the NULL → SIGSEGV
>
> This is the backend-local sibling of the shared/DSA-path issue fixed in
> 8191e0c16a. Present since 5891c7a8ed8 (2022); affects PG15, PG17, PG18, and
> master.
Yeah, I can buy this one. MemoryContextAlloc() would fail an longjmp
on OOM, so we'd better keep the backend data clean. Perhaps we should
just use the Extended() flavor to bypass the failure and do cleanup
actions.. Will look later.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-17 14:15 ` Re: Unexpected behavior after OOM errors Alex Masterov <amasterov@gmail.com>
2026-07-18 00:47 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-07-18 02:57 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 32+ messages in thread
From: Michael Paquier @ 2026-07-18 02:57 UTC (permalink / raw)
To: Alex Masterov <amasterov@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
On Sat, Jul 18, 2026 at 09:47:43AM +0900, Michael Paquier wrote:
> On Fri, Jul 17, 2026 at 04:15:15PM +0200, Alex Masterov wrote:
>> This is the backend-local sibling of the shared/DSA-path issue fixed in
>> 8191e0c16a. Present since 5891c7a8ed8 (2022); affects PG15, PG17, PG18, and
>> master.
>
> Yeah, I can buy this one. MemoryContextAlloc() would fail an longjmp
> on OOM, so we'd better keep the backend data clean. Perhaps we should
> just use the Extended() flavor to bypass the failure and do cleanup
> actions.. Will look later.
On HEAD, I am getting a different symptom, which is still an incorrect
thing to have but I think that this is just because entry_ref finishes
with non-NULL garbage when the allocation fails due to the lose end of
the hash insert to caring about this data:
FATAL: releasing ref with pending data
But that's to me the same thing as what you are seeing. The only
difference is that I think that entry_ref is just pointing to some
garbage, making the assertion accidentally work.
So, what I think we should do is the attached:
- Switch to Extended(MCXT_ALLOC_NO_OOM)
- For the cases of !found and !cache_entry->entry_ref, clean up the
hash table if the allocation fails.
Actually, the found && !entry_ref has always been a kind of dead code
pattern? Due to the use an Alloc() that could fail, this would mess
up with the backend shutdown, which is worse than assuming that
entry_ref could be NULL on secondary lookup? Keeping the check is a
defensive thing, which is fine at the end. Just mentioning in
passing..
Alex, what do you think? That works with your scenario. The
injection point should be removed at the end, just kept it here to
demonstrate the problem reusing your scenario (leaks memory of course,
but we don't care as long as the hash table is left untouched).
--
Michael
Attachments:
0001-Improve-pgstat_get_entry_ref_cached-behavior-on-OOMs.patch (text/plain, 1.7K) download
From f75a7c14155a953af56ba3fda16e66ed8f4065d8 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Sat, 18 Jul 2026 11:47:00 +0900
Subject: [PATCH] Improve pgstat_get_entry_ref_cached() behavior on OOMs
---
src/backend/utils/activity/pgstat_shmem.c | 26 ++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c
index 5ea3f1973f90..22c6ed4981a3 100644
--- a/src/backend/utils/activity/pgstat_shmem.c
+++ b/src/backend/utils/activity/pgstat_shmem.c
@@ -15,6 +15,7 @@
#include "pgstat.h"
#include "storage/shmem.h"
#include "storage/subsystems.h"
+#include "utils/injection_point.h"
#include "utils/memutils.h"
#include "utils/pgstat_internal.h"
@@ -432,9 +433,28 @@ pgstat_get_entry_ref_cached(PgStat_HashKey key, PgStat_EntryRef **entry_ref_p)
{
PgStat_EntryRef *entry_ref;
- cache_entry->entry_ref = entry_ref =
- MemoryContextAlloc(pgStatSharedRefContext,
- sizeof(PgStat_EntryRef));
+ entry_ref = MemoryContextAllocExtended(pgStatSharedRefContext,
+ sizeof(PgStat_EntryRef),
+ MCXT_ALLOC_NO_OOM);
+
+ /* emulate OOM */
+ if (IS_INJECTION_POINT_ATTACHED("pgstat-entry-ref-oom"))
+ entry_ref = NULL;
+
+ if (unlikely(entry_ref == NULL))
+ {
+ /*
+ * Clean the hash entry to keep the table consistent in the
+ * backend.
+ */
+ pgstat_entry_ref_hash_delete(pgStatEntryRefHash, key);
+
+ ereport(ERROR,
+ (errcode(ERRCODE_OUT_OF_MEMORY),
+ errmsg("out of memory")));
+ }
+
+ cache_entry->entry_ref = entry_ref;
entry_ref->shared_stats = NULL;
entry_ref->shared_entry = NULL;
entry_ref->pending = NULL;
--
2.55.0
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
@ 2026-07-18 07:49 ` Michael Paquier <michael@paquier.xyz>
2026-07-19 12:16 ` Re: Unexpected behavior after OOM errors Alex Masterov <amasterov@gmail.com>
2026-07-20 17:48 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
4 siblings, 2 replies; 32+ messages in thread
From: Michael Paquier @ 2026-07-18 07:49 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
On Fri, Jul 17, 2026 at 12:00:01PM +0300, Alexander Lakhin wrote:
> (Assuming the attached OOM injection patch applied.)
> 1) An issue in generate_partition_qual():
> --- a/src/backend/utils/cache/partcache.c
> +++ b/src/backend/utils/cache/partcache.c
> @@ -419,3 +419,5 @@ generate_partition_qual(Relation rel)
> oldcxt = MemoryContextSwitchTo(rel->rd_partcheckcxt);
> +oom_prob = 0.1;
> rel->rd_partcheck = copyObject(result);
> +oom_prob = 0;
> MemoryContextSwitchTo(oldcxt);
This one is again an ordering problem: let's assign rd_partcheckcxt
and rd_partcheck once we are sure that all the allocations have
succeeded, so as we don't finish with a semi-allocated transient
state.
> 2) lookup_type_cache():
> --- a/src/backend/utils/cache/typcache.c
> +++ b/src/backend/utils/cache/typcache.c
> @@ -463,8 +463,10 @@ lookup_type_cache(Oid type_id, int flags)
> in_progress_list[in_progress_offset] = type_id;
>
> +oom_prob = 0.1;
> /* Try to look up an existing entry */
> typentry = (TypeCacheEntry *) hash_search(TypeCacheHash,
> &type_id,
> HASH_FIND, NULL);
> +oom_prob = 0;
>
> triggers
> TRAP: failed Assert("cache->cc_tupdesc != NULL"), File:
> "catcache.c", Line: 1112, PID: 43932
This one is tricky. That's obviously due to the fact that we store a
type ID in the in_progress_list and on OOM we finish with a stale
entry in the list, no cleaned up. My first impression was: could we
delay the registration of the type ID in the in_progress_list? But
the answer to that is no; we want it from the point where we to the
lookups in the typcache hash table to protect from concurrent
invalidation. So I am not sure what to do here yet.
> 3) pgstat_prep_pending_entry() / pgstat_write_statsfiles():
> --- a/src/backend/utils/activity/pgstat.c
> +++ b/src/backend/utils/activity/pgstat.c
> @@ -1333,3 +1333,5 @@ pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *creat
>
> +oom_prob = 0.005;
> entry_ref->pending = MemoryContextAllocZero(pgStatPendingContext, entrysize);
> +oom_prob = 0;
> dlist_push_tail(&pgStatPending, &entry_ref->pending_node);
>
> triggers
> TRAP: failed Assert("!ps->dropped"), File: "pgstat.c", Line: 1730, PID: 844901
> maybe this Assert can be removed, because there is no corresponding
Yes, perhaps we should do that. I am not completely sure if this is
the best thing to do, though.
> 4) make_new_heap():
> --- a/src/backend/commands/repack.c
> +++ b/src/backend/commands/repack.c
> @@ -1255,3 +1255,5 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod,
> */
> +oom_prob = 0.01;
> CommandCounterIncrement();
> +oom_prob = 0;
>
> triggers:
> TRAP: failed Assert("ItemIdIsNormal(lp)"), File: "heapam.c", Line: 2813, PID: 943626
> also:
> ERROR: attempted to delete invisible tuple
I'll let Alvaro comment on this one. It deserves an open item.
For now, I have 1 out of 4, the partcache one. 25% is still better
than 0%. :p
--
Michael
Attachments:
partcache-oom.patch (text/plain, 1.6K) download
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index 3107075c9ad6..b25751b3793f 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -404,21 +404,28 @@ generate_partition_qual(Relation rel)
/*
* Save a copy in the relcache. The order of these operations is fairly
* critical to avoid memory leaks and ensure that we don't leave a corrupt
- * relcache entry if we fail partway through copyObject.
+ * relcache entry if we fail partway through copyObject. rd_partcheckcxt
+ * and rd_partcheck are assigned last, after copyObject() succeeds.
*
* If, as is definitely possible, the partcheck list is NIL, then we do
* not need to make a context to hold it.
*/
if (result != NIL)
{
- rel->rd_partcheckcxt = AllocSetContextCreate(CacheMemoryContext,
- "partition constraint",
- ALLOCSET_SMALL_SIZES);
- MemoryContextCopyAndSetIdentifier(rel->rd_partcheckcxt,
+ MemoryContext partcheckcxt;
+ List *partcheck;
+
+ partcheckcxt = AllocSetContextCreate(CacheMemoryContext,
+ "partition constraint",
+ ALLOCSET_SMALL_SIZES);
+ MemoryContextCopyAndSetIdentifier(partcheckcxt,
RelationGetRelationName(rel));
- oldcxt = MemoryContextSwitchTo(rel->rd_partcheckcxt);
- rel->rd_partcheck = copyObject(result);
+ oldcxt = MemoryContextSwitchTo(partcheckcxt);
+ partcheck = copyObject(result);
MemoryContextSwitchTo(oldcxt);
+
+ rel->rd_partcheckcxt = partcheckcxt;
+ rel->rd_partcheck = partcheck;
}
else
rel->rd_partcheck = NIL;
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-07-19 12:16 ` Alex Masterov <amasterov@gmail.com>
2026-07-20 06:54 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
1 sibling, 1 reply; 32+ messages in thread
From: Alex Masterov @ 2026-07-19 12:16 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Alexander Lakhin <exclusion@gmail.com>; Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
>
>
> Hi Michael,
The patch looks correct to me. Deleting the hash slot before raising the
error is exactly the right cleanup, and MCXT_ALLOC_NO_OOM is the cleanest
way to get there.
On the different symptom you see on HEAD (FATAL: releasing ref with pending
data vs. the Assert I got on 17.10): I think this is just a matter of
what's in the hash at exit time. The FATAL fires when the iterator hits a
valid entry_ref with unflushed pending stats before it reaches the poisoned
slot; the Assert fires if it reaches the NULL slot first. My repro sequence
(INSERT committed, then UPDATE aborted) likely leaves no pending stats, so
the NULL slot is always hit first. Anyway, it's the same root cause.
Regarding found && !cache_entry->entry_ref being dead code, I agree.
Thanks for picking this up so quickly!
Alexey
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-19 12:16 ` Re: Unexpected behavior after OOM errors Alex Masterov <amasterov@gmail.com>
@ 2026-07-20 06:54 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 32+ messages in thread
From: Michael Paquier @ 2026-07-20 06:54 UTC (permalink / raw)
To: Alex Masterov <amasterov@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
On Sun, Jul 19, 2026 at 02:16:47PM +0200, Alex Masterov wrote:
> The patch looks correct to me. Deleting the hash slot before raising the
> error is exactly the right cleanup, and MCXT_ALLOC_NO_OOM is the cleanest
> way to get there.
Thanks for looking. Applied the portion touching
pgstat_get_entry_ref_cached() as of 16ebc196d892, for now.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-07-20 17:48 ` Antonin Houska <ah@cybertec.at>
2026-07-20 19:02 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
1 sibling, 1 reply; 32+ messages in thread
From: Antonin Houska @ 2026-07-20 17:48 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Alexander Lakhin <exclusion@gmail.com>; Matthias van de Meent <boekewurm+postgres@gmail.com>; pgsql-hackers
Michael Paquier <michael@paquier.xyz> wrote:
> On Fri, Jul 17, 2026 at 12:00:01PM +0300, Alexander Lakhin wrote:
> > 4) make_new_heap():
> > --- a/src/backend/commands/repack.c
> > +++ b/src/backend/commands/repack.c
> > @@ -1255,3 +1255,5 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod,
> > */
> > +oom_prob = 0.01;
> > CommandCounterIncrement();
> > +oom_prob = 0;
> >
> > triggers:
> > TRAP: failed Assert("ItemIdIsNormal(lp)"), File: "heapam.c", Line: 2813, PID: 943626
> > also:
> > ERROR: attempted to delete invisible tuple
>
> I'll let Alvaro comment on this one. It deserves an open item.
I was also curious because I worked on repack.c recently. After applying (a
bit rebased) random-oom-errors.patch from [1] and after turning some "out of
memory" errors to PANIC, I could reproduce the error even on PG 18. The stack
trace is below. So it does not seem to be PG 19 specific.
#3 0x0000000000c1837a in errfinish (filename=0xee1d80 "mcxt.c", lineno=1164, funcname=0xee24a0 <__func__.6> "MemoryContextAllocationFailure") at elog.c:600
#4 0x0000000000c58e0c in MemoryContextAllocationFailure (context=0x2fb3a60, size=344, flags=0) at mcxt.c:1164
#5 0x0000000000c4bc1e in AllocSetAlloc (context=0x2fb3a60, size=344, flags=0) at aset.c:983
#6 0x0000000000c59504 in palloc0 (size=344) at mcxt.c:1388
#7 0x00000000007898a8 in MakeTupleTableSlot (tupleDesc=0x7f3eef0aa228, tts_ops=0xdfddc0 <TTSOpsBufferHeapTuple>) at execTuples.c:1321
#8 0x0000000000789b76 in MakeSingleTupleTableSlot (tupdesc=0x7f3eef0aa228, tts_ops=0xdfddc0 <TTSOpsBufferHeapTuple>) at execTuples.c:1430
#9 0x00000000005712a0 in table_slot_create (relation=0x7f3eef0a9f08, reglist=0x0) at tableam.c:98
#10 0x000000000052a812 in systable_beginscan (heapRelation=0x7f3eef0a9f08, indexId=2659, indexOK=true, snapshot=0x0, nkeys=2, key=0x7fffa5230e00) at genam.c:408
#11 0x0000000000c028dc in RelationBuildTupleDesc (relation=0x7f3eef091378) at relcache.c:564
#12 0x0000000000c03ad5 in RelationBuildDesc (targetRelId=32768, insertIt=false) at relcache.c:1206
#13 0x0000000000c05ffa in RelationRebuildRelation (relation=0x7f3eef08f1b8) at relcache.c:2661
#14 0x0000000000c06671 in RelationFlushRelation (relation=0x7f3eef08f1b8) at relcache.c:2847
#15 0x0000000000c06864 in RelationCacheInvalidateEntry (relationId=32768) at relcache.c:2949
#16 0x0000000000bf6f7b in LocalExecuteInvalidationMessage (msg=0x30898d0) at inval.c:856
#17 0x0000000000bf6908 in ProcessInvalidationMessages (group=0x30895d0, func=0xbf6e6f <LocalExecuteInvalidationMessage>) at inval.c:578
#18 0x0000000000bf7ac4 in CommandEndInvalidationMessages () at inval.c:1419
#19 0x000000000058b462 in AtCCI_LocalCache () at xact.c:1591
#20 0x000000000058adef in CommandCounterIncrement () at xact.c:1139
#21 0x0000000000699f03 in make_new_heap (OIDOldHeap=16384, NewTableSpace=0, NewAccessMethod=2, relpersistence=112 'p', lockmode=0) at cluster.c:788
#22 0x0000000000699bca in rebuild_relation (OldHeap=0x7f3eef08e998, index=0x7f3eef08ec88, verbose=false) at cluster.c:659
#23 0x0000000000699624 in cluster_rel (OldHeap=0x7f3eef08e998, indexOid=16388, params=0x7fffa52314d4) at cluster.c:472
[1] https://www.postgresql.org/message-id/95c64dc2-3abe-4f4e-b285-4c681f565d9f%40gmail.com
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-20 17:48 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
@ 2026-07-20 19:02 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-21 13:28 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
0 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-07-20 19:02 UTC (permalink / raw)
To: Antonin Houska <ah@cybertec.at>; +Cc: Michael Paquier <michael@paquier.xyz>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Mon, 20 Jul 2026 at 19:48, Antonin Houska <ah@cybertec.at> wrote:
>
> Michael Paquier <michael@paquier.xyz> wrote:
>
> > On Fri, Jul 17, 2026 at 12:00:01PM +0300, Alexander Lakhin wrote:
> > > 4) make_new_heap():
> > > --- a/src/backend/commands/repack.c
> > > +++ b/src/backend/commands/repack.c
> > > @@ -1255,3 +1255,5 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod,
> > > */
> > > +oom_prob = 0.01;
> > > CommandCounterIncrement();
> > > +oom_prob = 0;
> > >
> > > triggers:
> > > TRAP: failed Assert("ItemIdIsNormal(lp)"), File: "heapam.c", Line: 2813, PID: 943626
> > > also:
> > > ERROR: attempted to delete invisible tuple
> >
> > I'll let Alvaro comment on this one. It deserves an open item.
>
> I was also curious because I worked on repack.c recently. After applying (a
> bit rebased) random-oom-errors.patch from [1] and after turning some "out of
> memory" errors to PANIC, I could reproduce the error even on PG 18. The stack
> trace is below. So it does not seem to be PG 19 specific.
A PANIC with AllocSetAlloc on the stacktrace isn't an indication of a
bug when you add both an OOM probability on palloc, and set the
OOM-error-thrower to PANIC instead of ERROR.
This thread contains various examples of backend-local state remaining
in various levels of incomplete modifications/corruptions even after
the ERROR handling of an OOM has been completed. PANICs cause the
backend to be terminated, and so are much less likely to cause
problems down the line.
Note, too, that the problem that Alexander reported is a failing
Assert(), and an ERROR reporting "attempted to delete invisible
tuple", rather than actual "out of memory" ERRORs.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-20 17:48 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
2026-07-20 19:02 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-07-21 13:28 ` Antonin Houska <ah@cybertec.at>
2026-07-22 08:41 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
0 siblings, 1 reply; 32+ messages in thread
From: Antonin Houska @ 2026-07-21 13:28 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
Matthias van de Meent <boekewurm+postgres@gmail.com> wrote:
> On Mon, 20 Jul 2026 at 19:48, Antonin Houska <ah@cybertec.at> wrote:
> >
> > Michael Paquier <michael@paquier.xyz> wrote:
> >
> > > On Fri, Jul 17, 2026 at 12:00:01PM +0300, Alexander Lakhin wrote:
> > > > 4) make_new_heap():
> > > > --- a/src/backend/commands/repack.c
> > > > +++ b/src/backend/commands/repack.c
> > > > @@ -1255,3 +1255,5 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod,
> > > > */
> > > > +oom_prob = 0.01;
> > > > CommandCounterIncrement();
> > > > +oom_prob = 0;
> > > >
> > > > triggers:
> > > > TRAP: failed Assert("ItemIdIsNormal(lp)"), File: "heapam.c", Line: 2813, PID: 943626
> > > > also:
> > > > ERROR: attempted to delete invisible tuple
> > >
> > > I'll let Alvaro comment on this one. It deserves an open item.
> >
> > I was also curious because I worked on repack.c recently. After applying (a
> > bit rebased) random-oom-errors.patch from [1] and after turning some "out of
> > memory" errors to PANIC, I could reproduce the error even on PG 18. The stack
> > trace is below. So it does not seem to be PG 19 specific.
>
> A PANIC with AllocSetAlloc on the stacktrace isn't an indication of a
> bug when you add both an OOM probability on palloc, and set the
> OOM-error-thrower to PANIC instead of ERROR.
>
> This thread contains various examples of backend-local state remaining
> in various levels of incomplete modifications/corruptions even after
> the ERROR handling of an OOM has been completed. PANICs cause the
> backend to be terminated, and so are much less likely to cause
> problems down the line.
>
> Note, too, that the problem that Alexander reported is a failing
> Assert(), and an ERROR reporting "attempted to delete invisible
> tuple", rather than actual "out of memory" ERRORs.
I supposed that these problems happen because relcache remains in wrong state
due to the "out of memory" ERROR. So the point of using PANIC was to find out
when exactly the cache gets broken. However, I missed the fact that
Alexander's patch triggers the ERROR at several different places, so the stack
trace I posted might be unrelated.
Nevertheless, on a closer look I concluded that the problem is not related to
OOM. Rather, *any* ERROR that happens during cache invalidation can cause
this. Attached here is cache_inval_failure.diff that reproduces the problem
reliably:
postgres=# CREATE TABLE t1(i int PRIMARY KEY); CLUSTER t1 USING t1_pkey; DROP TABLE t1;
CREATE TABLE
ERROR: failure during cache invalidation
ERROR: attempted to delete invisible tuple
(The Assert(ItemIdIsNormal(lp)) IMO fires only if VACUUM manages to reset the
item pointer before heap_delete() gets called. With autovacuum=off, I get only
the "failure during cache invalidation" error.)
So I think we need to make sure that ERROR during cache invalidation becomes
FATAL.
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
Attachments:
cache_inval_failure.diff (text/x-diff, 1.8K) download
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 94a5aee90b5..7d9812804ce 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -784,7 +784,9 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod,
* Advance command counter so that the newly-created relation's catalog
* tuples will be visible to table_open.
*/
+ invalidation_failure = true;
CommandCounterIncrement();
+ invalidation_failure = false;
/*
* If necessary, create a TOAST table for the new relation.
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 30048e153e5..ca8a16c50f6 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -180,6 +180,8 @@ typedef struct InvalMessageArray
static InvalMessageArray InvalMessageArrays[2];
+bool invalidation_failure = false;
+
/* Control information for one logical group of messages */
typedef struct InvalidationMsgsGroup
{
@@ -1419,6 +1421,9 @@ CommandEndInvalidationMessages(void)
ProcessInvalidationMessages(&transInvalInfo->ii.CurrentCmdInvalidMsgs,
LocalExecuteInvalidationMessage);
+ if (invalidation_failure)
+ elog(ERROR, "failure during cache invalidation");
+
/* WAL Log per-command invalidation messages for wal_level=logical */
if (XLogLogicalInfoActive())
LogLogicalInvalidations();
diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h
index b5fbd754c2c..1512e47d38d 100644
--- a/src/include/utils/inval.h
+++ b/src/include/utils/inval.h
@@ -20,6 +20,8 @@
extern PGDLLIMPORT int debug_discard_caches;
+extern bool invalidation_failure;
+
typedef void (*SyscacheCallbackFunction) (Datum arg, int cacheid, uint32 hashvalue);
typedef void (*RelcacheCallbackFunction) (Datum arg, Oid relid);
typedef void (*RelSyncCallbackFunction) (Datum arg, Oid relid);
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-18 07:49 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-20 17:48 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
2026-07-20 19:02 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-21 13:28 ` Re: Unexpected behavior after OOM errors Antonin Houska <ah@cybertec.at>
@ 2026-07-22 08:41 ` Antonin Houska <ah@cybertec.at>
0 siblings, 0 replies; 32+ messages in thread
From: Antonin Houska @ 2026-07-22 08:41 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
Antonin Houska <ah@cybertec.at> wrote:
> Nevertheless, on a closer look I concluded that the problem is not related to
> OOM. Rather, *any* ERROR that happens during cache invalidation can cause
> this. Attached here is cache_inval_failure.diff that reproduces the problem
> reliably:
>
> postgres=# CREATE TABLE t1(i int PRIMARY KEY); CLUSTER t1 USING t1_pkey; DROP TABLE t1;
> CREATE TABLE
> ERROR: failure during cache invalidation
> ERROR: attempted to delete invisible tuple
>
> (The Assert(ItemIdIsNormal(lp)) IMO fires only if VACUUM manages to reset the
> item pointer before heap_delete() gets called. With autovacuum=off, I get only
> the "failure during cache invalidation" error.)
>
> So I think we need to make sure that ERROR during cache invalidation becomes
> FATAL.
Maybe something like this?
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
Attachments:
make_cache_invalidation_fatal.diff (text/x-diff, 664B) download
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 30048e153e5..97456e8888d 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -574,8 +574,15 @@ static void
ProcessInvalidationMessages(InvalidationMsgsGroup *group,
void (*func) (SharedInvalidationMessage *msg))
{
+ bool ExitOnAnyErrorSave = ExitOnAnyError;
+
+ /*
+ * Failure to invalidate cache is serious enough for the backend to exit.
+ */
+ ExitOnAnyError = true;
ProcessMessageSubGroup(group, CatCacheMsgs, func(msg));
ProcessMessageSubGroup(group, RelCacheMsgs, func(msg));
+ ExitOnAnyError = ExitOnAnyErrorSave;
}
/*
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
@ 2026-07-20 11:51 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-20 22:41 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
4 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-07-20 11:51 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; pgsql-hackers
On Fri, 17 Jul 2026 at 11:00, Alexander Lakhin <exclusion@gmail.com> wrote:
>
> Hello Michael and Matthias,
>
> Could you please look at other similar anomalies I have discovered?:
>
> (Assuming the attached OOM injection patch applied.)
> 1) An issue in generate_partition_qual():
> --- a/src/backend/utils/cache/partcache.c
> +++ b/src/backend/utils/cache/partcache.c
> @@ -419,3 +419,5 @@ generate_partition_qual(Relation rel)
> oldcxt = MemoryContextSwitchTo(rel->rd_partcheckcxt);
> +oom_prob = 0.1;
> rel->rd_partcheck = copyObject(result);
> +oom_prob = 0;
> MemoryContextSwitchTo(oldcxt);
[...]
> triggers
> TRAP: failed Assert("cache->cc_tupdesc != NULL"), File: "catcache.c", Line: 1112, PID: 43932
While the Assert is caused by other effects, it would still leave an
incorrect rd_partcheck around in relcaches, so here's a patch that
fixes that issue with rd_partcheckcxt. It also avoids leaking the
context itself into the CacheMemoryContext when an OOM happens, so
that's a neat addition.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
Attachments:
v1-0001-Fix-corrupted-caches-when-we-OOM-getting-the-part.patch (application/octet-stream, 1.9K) download
From cf601684ac54afe888d35154d2e14e2d37fd5912 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Fri, 17 Jul 2026 18:48:00 +0200
Subject: [PATCH v1] Fix corrupted caches when we OOM getting the partition
check
---
src/backend/utils/cache/partcache.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index 3107075c9ad..a4596ff8c2c 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -411,14 +411,31 @@ generate_partition_qual(Relation rel)
*/
if (result != NIL)
{
- rel->rd_partcheckcxt = AllocSetContextCreate(CacheMemoryContext,
- "partition constraint",
- ALLOCSET_SMALL_SIZES);
- MemoryContextCopyAndSetIdentifier(rel->rd_partcheckcxt,
+ /*
+ * Take care to order operations so that allocation errors don't
+ * leave the catcache in an invalid state; first allocate everything
+ * into a transactional context, then associate it with CacheContext
+ * and update the relation data. This also avoids leaking memory if
+ * we ever hit OOM here.
+ */
+ List *partcheck;
+ MemoryContext partctx;
+
+ partctx = AllocSetContextCreate(CurrentMemoryContext,
+ "partition constraint",
+ ALLOCSET_SMALL_SIZES);
+ MemoryContextCopyAndSetIdentifier(partctx,
RelationGetRelationName(rel));
- oldcxt = MemoryContextSwitchTo(rel->rd_partcheckcxt);
- rel->rd_partcheck = copyObject(result);
+
+ oldcxt = MemoryContextSwitchTo(partctx);
+ partcheck = copyObject(result);
MemoryContextSwitchTo(oldcxt);
+
+ /* finally, link the allocations and memctx into the right places */
+ MemoryContextSetParent(partctx, CacheMemoryContext);
+
+ rel->rd_partcheckcxt = partctx;
+ rel->rd_partcheck = partcheck;
}
else
rel->rd_partcheck = NIL;
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-20 11:51 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-07-20 22:41 ` Michael Paquier <michael@paquier.xyz>
2026-07-21 07:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 32+ messages in thread
From: Michael Paquier @ 2026-07-20 22:41 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Mon, Jul 20, 2026 at 01:51:33PM +0200, Matthias van de Meent wrote:
> While the Assert is caused by other effects, it would still leave an
> incorrect rd_partcheck around in relcaches, so here's a patch that
> fixes that issue with rd_partcheckcxt. It also avoids leaking the
> context itself into the CacheMemoryContext when an OOM happens, so
> that's a neat addition.
Neater to not call AllocSetContextCreate() in the cache context this
way, indeed. That's better than what I have sent.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-20 11:51 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-20 22:41 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-07-21 07:55 ` Michael Paquier <michael@paquier.xyz>
2026-07-21 09:41 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Michael Paquier @ 2026-07-21 07:55 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Tue, Jul 21, 2026 at 07:41:23AM +0900, Michael Paquier wrote:
> Neater to not call AllocSetContextCreate() in the cache context this
> way, indeed. That's better than what I have sent.
Applied this one. I have not looked more at the three others.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-20 11:51 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-20 22:41 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-21 07:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-07-21 09:41 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
0 siblings, 0 replies; 32+ messages in thread
From: Matthias van de Meent @ 2026-07-21 09:41 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Tue, 21 Jul 2026 at 09:55, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Tue, Jul 21, 2026 at 07:41:23AM +0900, Michael Paquier wrote:
> > Neater to not call AllocSetContextCreate() in the cache context this
> > way, indeed. That's better than what I have sent.
>
> Applied this one. I have not looked more at the three others.
Thanks! Sorry for the conflicting patches, I'd missed the mail with yours.
Kind regards,
Matthias
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
@ 2026-07-21 12:24 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-22 00:56 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
4 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-07-21 12:24 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; pgsql-hackers
On Fri, 17 Jul 2026 at 11:00, Alexander Lakhin <exclusion@gmail.com> wrote:
> (Assuming the attached OOM injection patch applied.)
> 1) An issue in generate_partition_qual():
> --- a/src/backend/utils/cache/partcache.c
> +++ b/src/backend/utils/cache/partcache.c
> @@ -419,3 +419,5 @@ generate_partition_qual(Relation rel)
> oldcxt = MemoryContextSwitchTo(rel->rd_partcheckcxt);
> +oom_prob = 0.1;
> rel->rd_partcheck = copyObject(result);
> +oom_prob = 0;
> MemoryContextSwitchTo(oldcxt);
[...]
> triggers
> TRAP: failed Assert("cache->cc_tupdesc != NULL"), File: "catcache.c", Line: 1112, PID: 43932
> 2) lookup_type_cache():
> --- a/src/backend/utils/cache/typcache.c
> +++ b/src/backend/utils/cache/typcache.c
> @@ -463,8 +463,10 @@ lookup_type_cache(Oid type_id, int flags)
> in_progress_list[in_progress_offset] = type_id;
>
> +oom_prob = 0.1;
> /* Try to look up an existing entry */
> typentry = (TypeCacheEntry *) hash_search(TypeCacheHash,
> &type_id,
> HASH_FIND, NULL);
> +oom_prob = 0;
> if (typentry == NULL)
> {
[...]
> triggers
> TRAP: failed Assert("cache->cc_tupdesc != NULL"), File: "catcache.c", Line: 1112, PID: 43932
I think I found the source of these Asserts; the attached fixes it.
The problem is that we're registering the type entry handling as 'in
progress' before the cache is initialized, and the error handling hook
for in-progress type entries initializes the TYPEOID cache if there's
an in-progress entry and the cache wasn't already initialized. And,
initializing this catcache in non-transactional contexts isn't
allowed, so the error handling causes the assertion to fail.
It'd be nice if we could initialize a cache unconditionally without
relying on function's side effects, but the attached is a
(theoretically) backportable fix without changing code in unrelated
code.
Next, I'll be looking at the last issue.
Kind regards,
Matthias van de Meent
Attachments:
v1-0001-Fix-Assert-in-typcache.c.patch (application/octet-stream, 1.9K) download
From 699073b75d71a8c0d1873bd7f6612e79ebde1a5f Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Tue, 21 Jul 2026 14:16:50 +0200
Subject: [PATCH v1] Fix Assert() in typcache.c
If an error is thrown in the initialization of the TYPEOID catcache
as part of lookup_type_cache, the error handling of that lookup would
cause Assert() failure: It needs to initialize the TYPEOID catcache
to handle the in_progress_list.
---
src/backend/utils/cache/typcache.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 650b5d9bad9..85808d27369 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -459,13 +459,27 @@ lookup_type_cache(Oid type_id, int flags)
allocsize * sizeof(*in_progress_list));
in_progress_list_maxlen = allocsize;
}
- in_progress_offset = in_progress_list_len++;
- in_progress_list[in_progress_offset] = type_id;
/* Try to look up an existing entry */
typentry = (TypeCacheEntry *) hash_search(TypeCacheHash,
&type_id,
HASH_FIND, NULL);
+
+ /*
+ * Only mark the new entry as "in progress" after the initial lookup: the
+ * TypeCacheHash uses type_cache_syshash(), which can initialize the
+ * TYPEOID catcache, which in turn could fail on OOM. The error handling
+ * would then try to look up this in-progress typeid, and try to look up
+ * the type in the caches, try to initialize the cache, which then fails
+ * because we can't initialize catalog caches in the non-transactional
+ * state of error wind-down.
+ *
+ * So, in short, we can't have an in-progress type cache element while
+ * the TYPEOID catcache is initializing.
+ */
+ in_progress_offset = in_progress_list_len++;
+ in_progress_list[in_progress_offset] = type_id;
+
if (typentry == NULL)
{
/*
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-07-21 12:24 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-07-22 00:56 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 32+ messages in thread
From: Michael Paquier @ 2026-07-22 00:56 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Tue, Jul 21, 2026 at 02:24:13PM +0200, Matthias van de Meent wrote:
> I think I found the source of these Asserts; the attached fixes it.
> The problem is that we're registering the type entry handling as 'in
> progress' before the cache is initialized, and the error handling hook
> for in-progress type entries initializes the TYPEOID cache if there's
> an in-progress entry and the cache wasn't already initialized. And,
> initializing this catcache in non-transactional contexts isn't
> allowed, so the error handling causes the assertion to fail.
I was wondering if this update should happen further down, but that
led to an inconsistent handling of the in-progress list within the
post-error callback. Looking at that a second time, just moving it
down the initial lookup seems fine enough. Applied after an edit of
the comment section.
> Next, I'll be looking at the last issue.
The pgstat one? That would help a lot, thanks! If you are not
familiar with the internals of this area in the backend, this problem
should give a pretty good introduction.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 09:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-07-17 09:00 ` Re: Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
@ 2026-07-27 14:33 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
4 siblings, 0 replies; 32+ messages in thread
From: Matthias van de Meent @ 2026-07-27 14:33 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; pgsql-hackers
On Fri, 17 Jul 2026 at 11:00, Alexander Lakhin <exclusion@gmail.com> wrote:
>
> Hello Michael and Matthias,
>
> Could you please look at other similar anomalies I have discovered?:
>
> (Assuming the attached OOM injection patch applied.)
> 3) pgstat_prep_pending_entry() / pgstat_write_statsfiles():
> --- a/src/backend/utils/activity/pgstat.c
> +++ b/src/backend/utils/activity/pgstat.c
> @@ -1333,3 +1333,5 @@ pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *creat
>
> +oom_prob = 0.005;
> entry_ref->pending = MemoryContextAllocZero(pgStatPendingContext, entrysize);
> +oom_prob = 0;
> dlist_push_tail(&pgStatPending, &entry_ref->pending_node);
>
> for i in {1..100}; do
> pg_ctl -l server.log start
> echo "
> CREATE TABLE t (a int);
> ALTER TABLE t SET (parallel_workers = 20);
> SET parallel_setup_cost = 0;
> SELECT SUM(a) FROM t;
> DROP TABLE t;
> " | psql
> pg_ctl -l server.log stop
>
> grep 'TRAP' server.log && break;
> done
>
> triggers
> TRAP: failed Assert("!ps->dropped"), File: "pgstat.c", Line: 1730, PID: 844901
> maybe this Assert can be removed, because there is no corresponding
> assert in pgstat_build_snapshot(), but I saw also:
> TRAP: failed Assert("rel->pgstat_info->relation == NULL"), File: "pgstat_relation.c", Line: 142, PID: 157820
> TRAP: failed Assert("ent->entry_ref != NULL"), File: "pgstat_shmem.c", Line: 827, PID: 190431
After instrumenting MemoryContextAllocationFailure with an
errbacktrace() in its ereport(), I found that the
Assert("!ps->dropped") seems to be triggered exclusively by errors
flushing stats in the pgstats shutdown hook in earlier terminated
backends. This can happen because the call stack
pgstat_shutdown_hook()->pgstat_report_stat(true)->pgstat_update_dbstats(now)
can allocate a pending entry if it didn't already have one, and only
after the call to pgstat_update_dbstats() we'll start handling and
unlinking the still-referenced pgstat entries.
I'm having some trouble figuring out what to do to fix it.
ERRORs during shutdown hooks elevate to FATAL, but the FATAL mechanism
assumes the backend will do a clean detach from shmem, which it can't
do if there's an error in the shutdown hook.
It's not clear whether before_shmem_exit()/on_shmem_exit() callbacks
are allowed to (try to) allocate memory, let alone whether it's OK for
them to raise errors: even if errors in that path may be handled in a
reasonably safe manner, I don't think they're expected or allowed to
raise.
I believe adjusting the error level of ERROR to PANIC during the shmem
exit callback handling would fix the Assert() failure caused by the
(leaked) shared pgstat entries with dropped=true, at the cost of
having to restart the cluster on any errors in shmem shutdown hooks.
See attached.
Note: The attached has other issues, though: The PANIC doesn't seem to
cause the server to fully restart in some cases in the provided test
script... I'm not sure if it's this script or a more general issue
with PANIC handling.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
Attachments:
v1-0001-Prevent-ERRORs-in-exit-handling-from-causing-shme.patch (application/x-patch, 1.6K) download
From ed036ea6fea2b5637722530ba3ff36c2596c8ca3 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Mon, 27 Jul 2026 15:48:32 +0200
Subject: [PATCH v1] Prevent ERRORs in exit handling from causing shmem
corruption
Shmem shutdown hooks can raise errors before they finish from detaching
the process from the shared memory segments they're responsible for.
This leaves the shmem components in a broken state, which no other
process is expected to be able to fix. To avoid leaving shmem in such
a corrupted state, we need to increase the level of shmem exit's ERRORs
to PANIC.
---
src/backend/utils/error/elog.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index b9d2c96b97a..2650852d455 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -383,6 +383,11 @@ errstart(int elevel, const char *domain)
* 3. the error occurred after proc_exit has begun to run. (It's
* proc_exit's responsibility to see that this doesn't turn into
* infinite recursion!)
+ *
+ * When handling shmem exit callbacks, even FATAL is insufficient:
+ * if a subsystem is only partially detached we're likely to leak
+ * memory or otherwise leave shmem in a corrupted state. In that
+ * case, we promote the ERROR all the way to PANIC.
*/
if (elevel == ERROR)
{
@@ -390,6 +395,9 @@ errstart(int elevel, const char *domain)
ExitOnAnyError ||
proc_exit_inprogress)
elevel = FATAL;
+
+ if (proc_exit_inprogress && shmem_exit_inprogress)
+ elevel = PANIC;
}
/*
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-18 15:27 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:29 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-06-18 15:27 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Thu, 18 Jun 2026 at 06:37, Michael Paquier <michael@paquier.xyz> wrote:
> >> 3) An issue in StandbyAcquireAccessExclusiveLock()
> > <snip>
> >
> > I'm not sure how to solve this correctly; I think ideally the
> > StandbyAcquireAccessExclusiveLock() hash code would be wrapped by a
> > critical section, but I'm not 100% sure if that will be a sufficient
> > approach; and it'd definitely need some code to allow the various
> > hashmaps' memctxs to alloc during critical sections.
>
> Not checked this one yet.
I found that the attached patch v3 solves that issue. The assert fires
because we link the lock into the transaction's exclusive locks ahead
of actually having acquired the lock, and when that lock acquisition
fails, as part of the error handling we hit
StartupProcExit->ShutdownRecoveryTransactionEnvironment->StandbyReleaseAllLocks,
which causes this assertion failure because the lock was not taken by
this backend.
By moving StandbyAcquireAccessExclusiveLock's LockAcquire ahead of
when it links the lock to the transaction, the local data structure
doesn't know to clean up the lock until after it's acquired, so
failure in that process won't make error cleanup try to clean up the
lock.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
Attachments:
v3-0001-IPC-standby-keep-better-track-of-taken-locks.patch (application/octet-stream, 1.7K) download
From f260f9e275effca846361f213e0f08c3865394b0 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Thu, 18 Jun 2026 17:06:55 +0200
Subject: [PATCH v3] IPC/standby: keep better track of taken locks
Previously, a lock that wasn't taken (e.g. due to a lack of available
locks) could cause all kinds of havoc in recovery-local lock state.
Now, we're more robust against that, by only registering the relation
lock once the lock is taken: If LockAcquire() fails, the failed lock
won't be present in the xidentry's list.
---
src/backend/storage/ipc/standby.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 872679ca447..0ba78bf63d6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1016,14 +1016,20 @@ StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid relOid)
lockentry = hash_search(RecoveryLockHash, &key, HASH_ENTER, &found);
if (!found)
{
- /* It's new, so link it into the XID's list ... */
- lockentry->next = xidentry->head;
- xidentry->head = lockentry;
-
- /* ... and acquire the lock locally. */
+ /* First, acquire the lock ... */
SET_LOCKTAG_RELATION(locktag, dbOid, relOid);
(void) LockAcquire(&locktag, AccessExclusiveLock, true, false);
+
+ /*
+ * ... and then, link it into the local state.
+ *
+ * This avoids issues in StandbyReleaseXidEntryLocks when LockAcquire
+ * fails to acquire a lock (e.g. due to lock entry exhaustion); in that
+ * case the xidentry isn't inconsistent.
+ */
+ lockentry->next = xidentry->head;
+ xidentry->head = lockentry;
}
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 15:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-06-18 23:29 ` Michael Paquier <michael@paquier.xyz>
2026-06-19 07:22 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Michael Paquier @ 2026-06-18 23:29 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Thu, Jun 18, 2026 at 05:27:57PM +0200, Matthias van de Meent wrote:
> By moving StandbyAcquireAccessExclusiveLock's LockAcquire ahead of
> when it links the lock to the transaction, the local data structure
> doesn't know to clean up the lock until after it's acquired, so
> failure in that process won't make error cleanup try to clean up the
> lock.
Yep, reordering these two actions would take care of the list
inconsistency where the startup process goes down following the ERROR
promoted to a FATAL.
I have been fingering the idea of backpatching this fix for a few
minutes, actually, but discarded the idea at the end. It does not
require a random pattern to cause the failure, being actionable
through a combination of GUCs as Alexander has proved. Still, the
only consequence is an extra LOG entry telling that the lock is not
being tracked for non-assert builds. Confusing, OK, but not really
critical.
Comments?
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 15:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:29 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
@ 2026-06-19 07:22 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-20 06:03 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 32+ messages in thread
From: Matthias van de Meent @ 2026-06-19 07:22 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Fri, 19 Jun 2026 at 01:30, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Thu, Jun 18, 2026 at 05:27:57PM +0200, Matthias van de Meent wrote:
> > By moving StandbyAcquireAccessExclusiveLock's LockAcquire ahead of
> > when it links the lock to the transaction, the local data structure
> > doesn't know to clean up the lock until after it's acquired, so
> > failure in that process won't make error cleanup try to clean up the
> > lock.
>
> Yep, reordering these two actions would take care of the list
> inconsistency where the startup process goes down following the ERROR
> promoted to a FATAL.
>
> I have been fingering the idea of backpatching this fix for a few
> minutes, actually, but discarded the idea at the end. It does not
> require a random pattern to cause the failure, being actionable
> through a combination of GUCs as Alexander has proved. Still, the
> only consequence is an extra LOG entry telling that the lock is not
> being tracked for non-assert builds. Confusing, OK, but not really
> critical.
>
> Comments?
Because it fixes an assertion, I'd vote for backpatching; but because
the case is handled safely without assertions I also wouldn't be upset
if it wasn't backpatched.
-Matthias
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: Unexpected behavior after OOM errors
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-18 15:27 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:29 ` Re: Unexpected behavior after OOM errors Michael Paquier <michael@paquier.xyz>
2026-06-19 07:22 ` Re: Unexpected behavior after OOM errors Matthias van de Meent <boekewurm+postgres@gmail.com>
@ 2026-06-20 06:03 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 32+ messages in thread
From: Michael Paquier @ 2026-06-20 06:03 UTC (permalink / raw)
To: Matthias van de Meent <boekewurm+postgres@gmail.com>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Fri, Jun 19, 2026 at 09:22:28AM +0200, Matthias van de Meent wrote:
> Because it fixes an assertion, I'd vote for backpatching; but because
> the case is handled safely without assertions I also wouldn't be upset
> if it wasn't backpatched.
With some tweaks to the comments, applied this one on HEAD, without a
backpatch.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 32+ messages in thread
end of thread, other threads:[~2026-07-27 14:33 UTC | newest]
Thread overview: 32+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 06:00 Unexpected behavior after OOM errors Alexander Lakhin <exclusion@gmail.com>
2026-06-17 12:27 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 04:37 ` Michael Paquier <michael@paquier.xyz>
2026-06-18 06:42 ` Heikki Linnakangas <hlinnaka@iki.fi>
2026-06-18 09:27 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:55 ` Michael Paquier <michael@paquier.xyz>
2026-06-19 07:18 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-19 11:12 ` Michael Paquier <michael@paquier.xyz>
2026-06-20 07:45 ` Michael Paquier <michael@paquier.xyz>
2026-06-20 08:00 ` Alexander Lakhin <exclusion@gmail.com>
2026-07-17 09:00 ` Alexander Lakhin <exclusion@gmail.com>
2026-07-17 14:15 ` Alex Masterov <amasterov@gmail.com>
2026-07-18 00:47 ` Michael Paquier <michael@paquier.xyz>
2026-07-18 02:57 ` Michael Paquier <michael@paquier.xyz>
2026-07-18 07:49 ` Michael Paquier <michael@paquier.xyz>
2026-07-19 12:16 ` Alex Masterov <amasterov@gmail.com>
2026-07-20 06:54 ` Michael Paquier <michael@paquier.xyz>
2026-07-20 17:48 ` Antonin Houska <ah@cybertec.at>
2026-07-20 19:02 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-21 13:28 ` Antonin Houska <ah@cybertec.at>
2026-07-22 08:41 ` Antonin Houska <ah@cybertec.at>
2026-07-20 11:51 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-20 22:41 ` Michael Paquier <michael@paquier.xyz>
2026-07-21 07:55 ` Michael Paquier <michael@paquier.xyz>
2026-07-21 09:41 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-21 12:24 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-07-22 00:56 ` Michael Paquier <michael@paquier.xyz>
2026-07-27 14:33 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 15:27 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-18 23:29 ` Michael Paquier <michael@paquier.xyz>
2026-06-19 07:22 ` Matthias van de Meent <boekewurm+postgres@gmail.com>
2026-06-20 06:03 ` Michael Paquier <michael@paquier.xyz>
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