Re: Fix bug with accessing to temporary tables of other sessions

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Daniil Davydov <3danissimo(at)gmail(dot)com>
Cc: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>, Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stepan Neretin <slpmcf(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Mohamed Ali <moali(dot)pg(at)gmail(dot)com>, Nazneen Jafri <jafrinazneen(at)gmail(dot)com>, Shawn McCoy <shawn(dot)the(dot)mccoy(at)gmail(dot)com>
Subject: Re: Fix bug with accessing to temporary tables of other sessions
Date: 2026-05-07 08:04:16
Message-ID: CAPpHfdsS49OTo2Af2GeoKJD-1Dy-hOzbje_AWOa_bw5Q9kEi7w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 4, 2026 at 12:31 PM Daniil Davydov <3danissimo(at)gmail(dot)com> wrote:
>
> On Sun, May 3, 2026 at 7:49 PM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
> >
> > On 03/05/2026 10:53, Daniil Davydov wrote:
> > > Please, see the attached patch that ensures that cross-session LOCK TABLE works
> > > properly.
> >
> > I guess you should either add it to the 0001 sent by Alexander, or
> > create a 0003. Right now the cfbot is complaining, as
> > 013_temp_obj_multisession.pl still does not exist :)
> >
>
> OK, I'll attach this patch as a third one, just for review purposes. After
> agreement on its content, it should be included into the 0001 and 0002 patches.

Thank you. I've integrated your check into 0001, and added an
explicit check that the table gets removed once the lock by other
session is removed.

Let me do a quick summary:
* Our buffer manager is not capable for reading temp tables of other sessions.
* This was covered by explicit checks, but broken since b7b0f3f27241
introduced alternative code path for reading tables.
* This doesn't apply to DROP TABLE. DROP TABLE is a conscious
exclusion and the only operation we can do correctly for other
session' temp tables. There is an explicit exclusion in the code to
skip the attempt to cleanup buffers of other session' temp tables.
* This patchset consists of tests (0001) for various operations with
other session's temp tables including buggy behavior, and the fix
(0002) including changes for tests.

Thus, I don't see the reason why this shouldn't be committed and
backpatched to PG17 (first release containing b7b0f3f27241).
Opinions? Michael?

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v22-0002-Prevent-access-to-other-sessions-temp-tables.patch application/octet-stream 8.8 KB
v22-0001-Add-tests-for-cross-session-temp-table-access.patch application/octet-stream 15.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message André Verwijs 2026-05-07 08:31:09 Postgresql 18 Linux (all flavors) - with installation, create new instance/main database
Previous Message Hayato Kuroda (Fujitsu) 2026-05-07 07:47:01 RE: [PATCH] Preserve replication origin OIDs in pg_upgrade