From: | Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Unlogged tables cleanup |
Date: | 2016-11-09 16:56:19 |
Message-ID: | 58235533.4070306@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi, hackers
I wonder if such behavior can be considered as a bug:
knizhnik(at)knizhnik:~/dtm-data$ psql postgres
psql (10devel)
Type "help" for help.
postgres=# create tablespace fs location '/home/knizhnik/dtm-data/fs';
CREATE TABLESPACE
postgres=# set default_tablespace=fs;
SET
postgres=# create unlogged table foo(x integer);
CREATE TABLE
postgres=# insert into foo values(generate_series(1,100000));
INSERT 0 100000
Now simulate server crash using using "pkill -9 postgres".
knizhnik(at)knizhnik:~/dtm-data$ rm -f logfile ; pg_ctl -D pgsql.master -l
logfile start
pg_ctl: another server might be running; trying to start server anyway
server starting
knizhnik(at)knizhnik:~/dtm-data$ psql postgres
psql (10devel)
Type "help" for help.
postgres=# select * from foo;
ERROR: could not open file
"pg_tblspc/16384/PG_10_201611041/12289/16385": No such file or directory
knizhnik(at)knizhnik:~/dtm-data$ ls fs
PG_10_201611041
knizhnik(at)knizhnik:~/dtm-data$ ls fs/PG_10_201611041/
So all relation directory is removed!
It happens only for first table created in tablespace.
If you create table in Postgres data directory everything is ok: first
segment of relation is truncated but not deleted.
Also if you create one more unlogged table in tablespace it is truncated
correctly:
postgres=# set default_tablespace=fs;
SET
postgres=# create unlogged table foo1(x integer);
CREATE TABLE
postgres=# insert into foo1 values(generate_series(1,100000));
INSERT 0 100000
postgres=# \q
knizhnik(at)knizhnik:~/dtm-data$ pkill -9 postgres
knizhnik(at)knizhnik:~/dtm-data$ rm -f logfile ; pg_ctl -D pgsql.master -l
logfile start
pg_ctl: another server might be running; trying to start server anyway
server starting
knizhnik(at)knizhnik:~/dtm-data$ psql postgres
psql (10devel)
Type "help" for help.
postgres=# select * from foo1;
x
---
(0 rows)
knizhnik(at)knizhnik:~/dtm-data$ ls -l fs/PG_10_201611041/12289/*
-rw------- 1 knizhnik knizhnik 0 Nov 9 19:52 fs/PG_10_201611041/12289/32768
-rw------- 1 knizhnik knizhnik 0 Nov 9 19:52
fs/PG_10_201611041/12289/32768_init
--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Yury Zhuravlev | 2016-11-09 16:58:38 | Re: WIP: About CMake v2 |
Previous Message | Amit Kapila | 2016-11-09 16:41:14 | Re: Hash Indexes |