Re: Removing pgsql_tmp files

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Glaesemann <michael(dot)glaesemann(at)myyearbook(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Removing pgsql_tmp files
Date: 2010-11-09 01:29:28
Message-ID: 3135.1289266168@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Michael Glaesemann <michael(dot)glaesemann(at)myyearbook(dot)com> writes:
> On Nov 8, 2010, at 16:03 , Tom Lane wrote:
>> That's very peculiar. Do you keep query logs? It would be useful to
>> try to correlate the temp files' PIDs and timestamps with the specific
>> queries that must have created them.

> We don't log all of them, but I checked those we did. It looks like it's happening when queries are timing out. I'm seeing this pattern pretty consistently:

> temporary file + query
> canceling statement due to statement timeout
> second temp file

> Here's a sample:

> pid | 877
> sess_id | 4ccf7257.36d
> sess_line | 16
> filename | pgsql_tmp877.0
> accessed_at | 2010-09-15 12:14:45-04
> modified_at | 2010-11-01 22:37:00-04
> logged_at | 2010-11-01 22:37:01.412-04
> error | LOG
> sql_state | 00000
> message | temporary file: path "pg_tblspc/16384/pgsql_tmp/pgsql_tmp877.0", size 87184416

Oh, so you've got log_temp_files enabled?

Hmm. If you look at FileClose() in fd.c, you'll discover that that
"temporary file" log message is emitted immediately before unlink'ing
the file. It looks pretty safe ... but, scratching around, I notice
that there's a CHECK_FOR_INTERRUPTS at the end of ereport(). So a
cancel that was caught by that exact CHECK_FOR_INTERRUPTS call could
provoke this symptom. The window for this is larger than it might seem
since the CHECK_FOR_INTERRUPTS could be responding to an interrupt that
came in sometime before that.

I think we need to re-order the operations there to ensure that the
unlink will still happen if the ereport gets interrupted.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Henrique Reimer 2010-11-09 01:31:02 Re: Linux x Windows LOCALE/ENCODING compatibility
Previous Message Scott Marlowe 2010-11-09 00:56:45 Re: It is possible to update more than 1 table in the same update statement?

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-11-09 01:56:38 Re: Removing pgsql_tmp files
Previous Message Josh Berkus 2010-11-09 01:09:55 Re: Avoid memory leaks during ANALYZE's compute_index_stats() ?