Re: "unexpected duplicate for tablespace" problem in logical replication

From: Andres Freund <andres(at)anarazel(dot)de>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, vignesh C <vignesh21(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, wangsh(dot)fnst(at)fujitsu(dot)com, osumi(dot)takamichi(at)fujitsu(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: "unexpected duplicate for tablespace" problem in logical replication
Date: 2025-09-18 12:17:49
Message-ID: bysczui5rgxmrnzeq6jczo3u5g2lwallqrduubnayq2g5dhzwh@l64sg7jl52sf
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2025-09-18 17:37:10 +0530, Ashutosh Bapat wrote:
> From 6a3562b4ac8917c8b577797e5468416a90cc04f5 Mon Sep 17 00:00:00 2001
> From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
> Date: Thu, 18 Sep 2025 17:24:09 +0530
> Subject: [PATCH] Negative RelfilenumberMap cache entries from
> pg_filenode_relation()
>
> RelidByRelfilenumber() adds negative entries to the cache. It has three
> users, logical replication, autoprewarm and pg_filenode_relation(). The
> first two need negative entries in the cache in case they happen to
> lookup non-existent mapping again and again. However such mappings will
> be smaller in number and usually come from some database object e.g. WAL
> or autoprewarm metadata.
>
> But pg_filenode_relation(), which is SQL callable, may be invoked many
> times with invalid tablespace and relfilenode pairs, causing the cache
> to be bloated with negative cache entries. This can be used as a denial
> of service attack since any user can execute it. This commit avoids such
> a bloat.

I don't really understand why this is worth fixing for the relfilenode stuff
specifically - isn't this true for just about *all* of our caches? Many, if
not most, can be reached via SQL?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2025-09-18 12:22:58 Re: "unexpected duplicate for tablespace" problem in logical replication
Previous Message Ashutosh Bapat 2025-09-18 12:07:10 Re: "unexpected duplicate for tablespace" problem in logical replication