[BUG] temp_table_max_size parameter may entail an error within ReadBuffer function

From: Daniil Davydov <3danissimo(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [BUG] temp_table_max_size parameter may entail an error within ReadBuffer function
Date: 2024-12-06 09:54:30
Message-ID: CAJDiXgiFqaoqvFGLeyuda28EfFOV+yD3aTk2ST7kvzR0bASjZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I noticed that this sequence of actions (for temporary table) leads to
an error, if
temp_table_max_size parameter is set :
***
LockRelationForExtension(relation, ExclusiveLock);
buf = ReadBuffer(relation, P_NEW);
***

Error occurs during total temporary table size calculation
(find_total_temp_relation_size function,
that can be called only if temp_table_max_size parameter > 0) : we are
trying to open all table's
indexes and append their size to the total size of the temporary
table. But inside relation_open function
(called for index) we meet this assert (and, of course, fail on it):

***
/*
* We don't acquire any other heavyweight lock while holding the relation
* extension lock. We do allow to acquire the same relation extension
* lock more than once but that case won't reach here.
*/
Assert(!IsRelationExtensionLockHeld);
***

I suppose that the simplest way out of the situation would be to skip
locking temporary tables for
extension

--
Best regards,
Daniil Davydov

Attachment Content-Type Size
0001-Fix-bug-with-locking-temp-relation-for-extension.patch text/x-patch 787 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2024-12-06 10:50:25 Re: postgres_fdw: Provide better emulation of READ COMMITTED behavior
Previous Message Nazir Bilal Yavuz 2024-12-06 09:41:55 Re: Make pg_stat_io view count IOs as bytes instead of blocks