Streaming replication, some small issues

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>

From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2009-12-08T08:30:59Z
Lists: pgsql-hackers
A couple of small issues spotted while reviewing the streaming
replication patch:

- Because sentPtr is initialized to zeros, GetOldestWALSendPointer will
return zero before a just-launched WAL sender has sent its first
message. That can lead to WAL files that are still needed by another
standby to be deleted prematurely.

- If a WAL file is not found in the master for some reason, standby goes
into an infinite loop retrying it:

ERROR:  could not read xlog records: FATAL:  could not open file
"pg_xlog/000000010000000000000000" (log file 0, segment 0): No such file
or directory
	
ERROR:  could not read xlog records: FATAL:  could not open file
"pg_xlog/000000010000000000000000" (log file 0, segment 0): No such file
or directory
	
ERROR:  could not read xlog records: FATAL:  could not open file
"pg_xlog/000000010000000000000000" (log file 0, segment 0): No such file
or directory

...
	
- It's possible to shut down master, change max_wal_senders to 0,
restart and do an operation like CLUSTER which then skips WAL-logging.
Then shutdown, change max_wal_senders back to non-zero. All this while
the standby is running. Leads to a corrupt standby.


I've also pushed a couple of small cosmetic changes to replication
branch at git://git.postgresql.org/git/users/heikki/postgres.git

I'll continue reviewing...

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com