mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Fix walsender error cleanup code
In commit 850196b610
I (Álvaro) failed to handle the case of walsender
shutting down on an error before setting up its 'xlogreader' pointer;
the error handling code dereferences the pointer, causing a crash.
Fix by testing the pointer before trying to dereference it.
Kyotaro authored the code fix; I adopted Nathan's test case to be used
by the TAP tests and added the necessary PostgresNode change.
Reported-by: Nathan Bossart <bossartn@amazon.com>
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/C04FC24E-903D-4423-B312-6910E4D846E5@amazon.com
This commit is contained in:
@@ -315,7 +315,7 @@ WalSndErrorCleanup(void)
|
||||
ConditionVariableCancelSleep();
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (xlogreader->seg.ws_file >= 0)
|
||||
if (xlogreader != NULL && xlogreader->seg.ws_file >= 0)
|
||||
wal_segment_close(xlogreader);
|
||||
|
||||
if (MyReplicationSlot != NULL)
|
||||
|
Reference in New Issue
Block a user