template1=# BEGIN;
BEGIN
template1=# CREATE TABLE foobar (foo char(10));
CREATE TABLE
template1=# select relname, relfilenode from pg_class where
relname='foobar';relname | relfilenode
---------+-------------foobar | 66372
(1 row)
> killall -9 postmaster
> ll data/base/1/
-rw------- 1 hlinnaka hlinnaka 0 Jun 12 15:33 data/base/1/66372
Unless I'm missing something, that file is left there forever. Not such a
big deal with an empty file, but if you create a new table and load it
with data in the same transaction...
Can you guys confirm?
The problem seems to be in storage/smgr.c. The code keeps track of files
created in the transaction in backend memory. That information is lost on
crash, and there is nothing to clean up the mess later.
I wonder if we could clean up those lost files on database recovery or
vacuum. Do we have a list of valid relfilenodes somewhere? Is pg_class
enough?
- Heikki