Re: Deleting a table file does not raise an error when the table is touched afterwards, why?

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: Deleting a table file does not raise an error when the table is touched afterwards, why?
Дата
в 18:50:18
Msg-id
21020.1464634208@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
Deleting a table file does not raise an error when the table is touched afterwards, why? Daniel Westermann <daniel.westermann@dbi-services.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Alex Ignatov <a.ignatov@postgrespro.ru>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? David W Noon <david.w.noon@googlemail.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Daniel Westermann <daniel.westermann@dbi-services.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Tom Lane <tgl@sss.pgh.pa.us>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? "David G. Johnston" <david.g.johnston@gmail.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? "David G. Johnston" <david.g.johnston@gmail.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Daniel Westermann <daniel.westermann@dbi-services.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Francisco Olarte <folarte@peoplecall.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? David W Noon <david.w.noon@googlemail.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Francisco Olarte <folarte@peoplecall.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Simon Riggs <simon@2ndQuadrant.com>
Re: Deleting a table file does not raise an error when the table is touched afterwards, why? Melvin Davidson <melvin6925@gmail.com>
Daniel Westermann  writes:
> - if the above is correct why does PostgreSQL only write a partial file back to disk/wal? For me this still seems dangerous as potentially nobody will notice it 

In quiescent circumstances, Postgres wouldn't have written anything at
all, and the file would have disappeared completely at server shutdown,
and you would have gotten some sort of file-not-found error when you tried
the "count(*)" after restarting.  I hypothesize that you did an unclean
shutdown leading to replaying some amount of WAL at restart, and that WAL
included writing at least one block of the file (perhaps as a result of a
hint-bit update, or some other not-user-visible maintenance operation,
rather than anything you did explicitly).  The WAL replay code will
recreate the file if it doesn't exist on-disk --- this is important for
robustness.  Then you'd have a file that exists on-disk but is partially
filled with empty pages, which matches the observed behavior.  Depending
on various details you haven't provided, this might be indistinguishable
from a valid database state.

> - PostgreSQL assumes that someone with write access to the files knows what she/he is doing. ok, but still, in the real world cases like this happen (for whatever reason) 

[ shrug... ] There's also an implied contract that you don't do "rm -rf /",
or shoot the disk drive full of holes with a .45, or various other
unrecoverable actions.  We're not really prepared to expend large amounts
of developer effort, or large amounts of runtime overhead, to detect such
cases.  (In particular, the fact that all-zero pages are a valid state is
unfortunate from this perspective, but it's more or less forced by
robustness concerns associated with table-extension behavior.  Most users
would not thank us for making table extension slower in order to issue a
more intelligible error for examples like this one.)

			regards, tom lane

В списке pgsql-general по дате отправления
От: Attila Soki
Дата:
От: David G. Johnston
Дата:
FAQ