Re: Unexpected behavior after OOM errors

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unexpected behavior after OOM errors
Date: 2026-07-20 11:51:33
Message-ID: CAEze2Wj2ELVRZXhcXuz920jj+jftAoSrhGUT6o66E84LckAmKw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 17 Jul 2026 at 11:00, Alexander Lakhin <exclusion(at)gmail(dot)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 Content-Type Size
v1-0001-Fix-corrupted-caches-when-we-OOM-getting-the-part.patch application/octet-stream 1.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-07-20 11:52:23 Re: COMMENTS are not being copied in CREATE TABLE LIKE
Previous Message Aleksander Alekseev 2026-07-20 11:42:56 Re: [PATCH] Cover get_json_table_plan() with tests