1

I would like to simulate putting postgresql into "recovery mode". Few times i have situation where postgresql puted himself into recovery mode. In logs i had:

Oct 18 06:37:35 xx postgres[5738]: [19-1] 2014-10-18 06:37:35.441 CEST|5738|xx|yy|FATAL: the database system is in recovery mode

It was caused by oom which killed one of process. But when i try to simulate it in test environment - postgresql restarts.

How to prevent postgresql from restart and let him stay in recovery mode?

undefine
  • 113
  • 1
  • 5

2 Answers2

3

If you want to force PostgreSQL into recovery, you can create a recovery.conf with no restore_command or streaming replication configuration set. Leave hot_standby set to off in postgresql.conf.

Personally I recommend taking a base backup (pg_basebackup -X stream) and using that, rather than doing it to the original DB.

Craig Ringer
  • 57,821
  • 6
  • 162
  • 193
1

You can put the database into recovery mode by forcing an unclean shutdown of any of the backend processes, other than the postmaster itself. For example, with kill -9.

Yes, PostgreSQL restarts. That is why it going into recovery mode. Recovery mode is a part of starting up again after an unclean shutdown. If the database was idle when it crashed, then the recovery mode might only last a fraction of a second before the database reopens for business, so you might not observe it passing through this mode.

jjanes
  • 42,332
  • 3
  • 44
  • 54