Re: Unexpected behavior after OOM errors - Mailing list pgsql-hackers

From Matthias van de Meent
Subject Re: Unexpected behavior after OOM errors
Date
Msg-id CAEze2Wj2ELVRZXhcXuz920jj+jftAoSrhGUT6o66E84LckAmKw@mail.gmail.com
Whole thread
In response to Re: Unexpected behavior after OOM errors  (Alexander Lakhin <exclusion@gmail.com>)
Responses Re: Unexpected behavior after OOM errors
List 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)

Attachment

pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Cover get_json_table_plan() with tests
Next
From: Jim Jones
Date:
Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE