mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Check slot->restart_lsn validity in a few more places
Lack of these checks could cause visible misbehavior, including
assertion failures. This was missed in commit c655077639
, whereby
restart_lsn becomes invalid when the size limit is exceeded.
Also reword some existing error messages, and add errdetail(), so that
the reported errors all match in spirit.
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/20200408.093710.447591748588426656.horikyota.ntt@gmail.com
This commit is contained in:
@@ -237,6 +237,19 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
|
||||
LogicalOutputPrepareWrite,
|
||||
LogicalOutputWrite, NULL);
|
||||
|
||||
/*
|
||||
* After the sanity checks in CreateDecodingContext, make sure the
|
||||
* restart_lsn is valid. Avoid "cannot get changes" wording in this
|
||||
* errmsg because that'd be confusingly ambiguous about no changes
|
||||
* being available.
|
||||
*/
|
||||
if (XLogRecPtrIsInvalid(MyReplicationSlot->data.restart_lsn))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("can no longer get changes from replication slot \"%s\"",
|
||||
NameStr(*name)),
|
||||
errdetail("This slot has never previously reserved WAL, or has been invalidated.")));
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user