mirror of
https://github.com/postgres/postgres.git
synced 2026-05-27 20:27:28 -04:00
Fix xid_advance_interval when max_retention_duration is 0.
When a subscription has retain_dead_tuples enabled and maxretention is zero (unlimited), adjust_xid_advance_interval() mistakenly caps xid_advance_interval to zero. This zero interval forces get_candidate_xid() to evaluate TimestampDifferenceExceeds() as always true, causing the apply worker to call GetOldestActiveTransactionId() for every WAL message. This leads to unnecessary ProcArrayLock acquisitions. Fix this by only capping the interval when maxretention > 0, allowing the exponential back-off to function properly. Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Discussion: https://postgr.es/m/CAHg+QDdKVnCLHot=AcoPpEiSyDzGz7wGYjAFHVOw57oDtmUDWQ@mail.gmail.com
This commit is contained in:
parent
7424aac088
commit
c210647aeb
1 changed files with 3 additions and 2 deletions
|
|
@ -4997,9 +4997,10 @@ adjust_xid_advance_interval(RetainDeadTuplesData *rdt_data, bool new_xid_found)
|
|||
|
||||
/*
|
||||
* Ensure the wait time remains within the maximum retention time limit
|
||||
* when retention is active.
|
||||
* when retention is active. Skip this cap when maxretention is zero,
|
||||
* which means unlimited retention (no timeout).
|
||||
*/
|
||||
if (MySubscription->retentionactive)
|
||||
if (MySubscription->retentionactive && MySubscription->maxretention > 0)
|
||||
rdt_data->xid_advance_interval = Min(rdt_data->xid_advance_interval,
|
||||
MySubscription->maxretention);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue