"Orphaned" files after initdb

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: "Orphaned" files after initdb
Date: 2013-04-01 18:43:36
Message-ID: CABUevEzOGQtPavjpkFqAp6sKUfm=4k4CBrGSuW44WtMcMQO7Wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Maybe my thinking is just missing something obvious here. But looking
at a fresh initdb, I'm seeing a number of files in the data directory
for this database that don't have corresponding entries in pg_class. I
looked for entries based on relfilenode in pg_class - am I missing
some other way we put files in there?

I'm seeing the same on both head and 9.1 as an example, but different oids.

I feel I'm either missing something obvious, or we have a problem
here? And somehow the first one seems more likely..

The query I ran (yeah, i'm sure it can be written prettier, but this
was quick-n-dirty):

with t as (
select * from pg_ls_dir('<datadir>/base/1') l(f)
where f not in (
select relfilenode::text from pg_class
union all select relfilenode::text || '_vm' from pg_class
union all select relfilenode::text || '_fsm' from pg_class)
)
select f,
size,
modification
from t, pg_stat_file('<datadir>/base/1/' || f)
order by 1;

Which gives me:
f | size | modification
-----------------+--------+------------------------
11809 | 65536 | 2013-04-01 20:34:45+02
11809_fsm | 24576 | 2013-04-01 20:34:45+02
11809_vm | 8192 | 2013-04-01 20:34:45+02
11811 | 16384 | 2013-04-01 20:34:45+02
11812 | 32768 | 2013-04-01 20:34:45+02
11821 | 344064 | 2013-04-01 20:34:45+02
11821_fsm | 24576 | 2013-04-01 20:34:45+02
11821_vm | 8192 | 2013-04-01 20:34:45+02
11823 | 131072 | 2013-04-01 20:34:45+02
11824 | 90112 | 2013-04-01 20:34:45+02
11825 | 507904 | 2013-04-01 20:34:45+02
11825_fsm | 24576 | 2013-04-01 20:34:45+02
11825_vm | 8192 | 2013-04-01 20:34:45+02
11827 | 0 | 2013-04-01 20:34:45+02
11829 | 8192 | 2013-04-01 20:34:45+02
11830 | 73728 | 2013-04-01 20:34:45+02
11831 | 196608 | 2013-04-01 20:34:45+02
11832 | 65536 | 2013-04-01 20:34:45+02
11832_fsm | 24576 | 2013-04-01 20:34:45+02
11832_vm | 8192 | 2013-04-01 20:34:45+02
11834 | 16384 | 2013-04-01 20:34:45+02
11835 | 32768 | 2013-04-01 20:34:45+02
pg_filenode.map | 512 | 2013-04-01 20:34:45+02
PG_VERSION | 4 | 2013-04-01 20:34:44+02
(24 rows)

The filenode map and pg_version obviously make sense, but where are
the others from?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-04-01 18:51:17 cross-version upgrade testing
Previous Message Jeff Janes 2013-04-01 18:00:07 Re: pgbench --startup option