Обсуждение: What should I do after a power loss?

Поиск
Список
Период
Сортировка

What should I do after a power loss?

От
Patrik Karlsson
Дата:
...Besides buying an UPS

I had a power loss on a Windows 7 machine running PostgreSQL 9.4.4.

After booting, the database started just fine and so did the program that stores information into the database. As far as I can tell that is. (And I cant tell that much since postgres is new to me)

My backup at the time was 6 hours old but for the last 24 hours I have been storing new data into the database.

I would like to confirm that everything is ok, how can I do that, (with pgAdmin)?

Re: What should I do after a power loss?

От
Kevin Grittner
Дата:
Patrik Karlsson <pata.karlsson@gmail.com> wrote:

> I had a power loss on a Windows 7 machine running PostgreSQL
> 9.4.4.

Kudos on being up-to-date with minor releases -- that alone rules
out some possible data corruption problems.

> After booting, the database started just fine and so did the
> program that stores information into the database. As far as I
> can tell that is. (And I cant tell that much since postgres is
> new to me)

As long as you were running with fsync = on and full_page_writes =
on, and the OS and hardware honor fsync requests, your database
should not have been corrupted.  If you were running with
synchronous_commit = on then any commit request (or DML outside of
an explict transaction) which completed without error should be
reflected in the database.  If you were running with
synchronous_commit = off you might have a small number of commits
which are not reflected (usually a fraction of a second's worth).

> My backup at the time was 6 hours old but for the last 24 hours I
> have been storing new data into the database.

It sounds unlikely that you will need to go back to the backup, but
out of paranoia I would keep that particular backup around for a
few months, in addition to the usual backup rotation.

> I would like to confirm that everything is ok, how can I do that,
> (with pgAdmin)?

PostgreSQL is designed to come back from such an event without data
loss or corruption, and there is no one tool to comprehensively
look for all forms of inconsistency.  You might want to consider
running pg_catcheck, just to make sure it doesn't find anything
odd.

https://github.com/EnterpriseDB/pg_catcheck

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: What should I do after a power loss?

От
Patrik Karlsson
Дата:


2015-08-18 21:48 GMT+02:00 Kevin Grittner <kgrittn@ymail.com>:
Patrik Karlsson <pata.karlsson@gmail.com> wrote:

> I had a power loss on a Windows 7 machine running PostgreSQL
> 9.4.4.

As long as you were running with fsync = on and full_page_writes =
on, and the OS and hardware honor fsync requests, your database
should not have been corrupted.  If you were running with

Yes it was, I verified it and it was the default setting I had.
 
It sounds unlikely that you will need to go back to the backup, but
out of paranoia I would keep that particular backup around for a
few months, in addition to the usual backup rotation.

I kept it but I have not felt the need to use it, everything is ok.
 

> I would like to confirm that everything is ok, how can I do that,
> (with pgAdmin)?

PostgreSQL is designed to come back from such an event without data
loss or corruption, and there is no one tool to comprehensively
look for all forms of inconsistency.  You might want to consider
running pg_catcheck, just to make sure it doesn't find anything
odd.

https://github.com/EnterpriseDB/pg_catcheck


I could not get it to work on the windows machine but I'll keep it in mind.

This was a while back and I have now moved the database to a more stable and monitored environment.

Thanks for your advice.

/Patrik