Re: [BUG] temporary file usage report with extended protocol and unnamed portals

From: Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Benoit Lobréau <benoit(dot)lobreau(at)dalibo(dot)com>, Guillaume Lelarge <guillaume(dot)lelarge(at)dalibo(dot)com>, Pierrick Chovelon <pierrick(dot)chovelon(at)dalibo(dot)com>
Subject: Re: [BUG] temporary file usage report with extended protocol and unnamed portals
Date: 2025-06-18 08:30:57
Message-ID: 5254f288-f1c5-4e1e-bb32-f5b22df3b90b@dalibo.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4/26/25 20:57, Sami Imseih wrote:
> I found several issues with v4. It does not deal correctly with pipelining,
> and we should only really be concerned with dropping an unnamed
> portal only.
>
> So, v5 now moves the DropPortal call after the unnamed portal was
> executed to completion ( as v4 was doing ), but does so only in the
> case in which we are not inside a transaction-control statement or
> the portal was executing a command that can be run inside a
> transaction block.
>

I've tested your v5, and it works well.

I've also attached a TAP test that checks the following cases:

1. An unnamed statement followed by a simple query, both in the same
transaction;
2. An unnamed statement in an implicit transaction;
3. Unnamed statements in pipeline mode.

Patch handles these three cases correctly, while pre-patch blames the
wrong query for cases 1. and 3., and logs no query at all for case 2.

Initially, I've tried to use pg_regress, but the query is only written
in the server log (it is not sent to the frontend). Furthermore, the pid
number in the first line of the log makes it impossible (it seems) to
write the expected output file.

> Also, I realize that explicit cursors ( DECLARE CURSOR ) will
> only log temp file at cursor close and in which case, the statement
> associated with the temp file logging is the CLOSE command:
>
> i.e.
>
> ```
> 2025-04-26 18:46:38.084 UTC [10415] LOG: temporary file: path
> "base/pgsql_tmp/pgsql_tmp10415.0", size 1014030336
> 2025-04-26 18:46:38.084 UTC [10415] STATEMENT: close mycursor_1;
> ```
>
> I don't think there is much we can do there, or should we.
>

I don't think either.

Best regards,
Frédéric

Attachment Content-Type Size
008_log_temp_files.pl application/x-perl 1.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Arseniy Mukhin 2025-06-18 08:33:38 Re: amcheck support for BRIN indexes
Previous Message Daniil Davydov 2025-06-18 08:03:10 Re: POC: Parallel processing of indexes in autovacuum