| From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
|---|---|
| To: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] Table sync race with REFRESH PUBLICATION |
| Date: | 2026-09-28 09:18:17 |
| Message-ID: | CAHut+PvAkFGO1=Y+2z1C5kJ7yv3d9NsweZdGwPZtjiv6XeyTsQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
A couple of comments for 0001.
======
1.
+ if (GetSubscriptionRelState(MyLogicalRepWorker->subid,
+ rstate->relid, &statelsn) != SUBREL_STATE_SYNCDONE ||
+ current_lsn < statelsn)
+ continue;
1.
Would a local variable simplify the condition?
Also, the related SEQUENCE code [1] had
i) logging if COPYSEQ_NOT_SUBSCRIBED was detected. Should this do
something similar?
ii) a comment saying the error must be avoided. Should this do
something similar?
Something like:
current_relstate = GetSubscriptionRelState(...);
if (current_relstate != SUBREL_STATE_SYNCDONE || current_lsn < statelsn)
{
char * msg = (current_relstate == SUBREL_STATE_UNKNOWN) ?
"a concurrent refresh has removed relation oid %u of
subscription \"%s\"" :
"a concurrent refresh has changed relation oid %u of
subscription \"%s\"";
ereport(LOG, errmsg(msg, rstate->relid, MySubscription->name));
/*
* Skipping is the only sensible action. It must not be treated as an error
* because when disable_on_error is true, that would disable the entire
* subscription, including unrelated tables.
*/
continue;
}
~~~
2.
IIUC,
i) If the concurrent REFRESH removed the relation, then the new
relstate will be SUBREL_STATE_UNKNOWN.
ii) If there were multiple concurrent REFRESHes and the same relation
got re-added, then the state would be SUBREL_STATE_INIT.
Either way, the state is not SUBREL_STATE_SYNCDONE.
AFAIK, there is no way for a newly added same relation to get back to
SUBREL_STATE_SYNCDONE while we are still blocked on this lock. IOW,
was that extra LSN check (current_lsn < statelsn) really needed? Is
just checking the state enough?
Kind Regards,
Peter Smith.
Fujitsu Australia
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-09-28 09:46:45 | Re: Stabilize and shorten test_checksums/013_rewind test |
| Previous Message | Jakub Wartak | 2026-09-28 08:58:58 | Re: enhancing pg_basebackup speeds up to ~23Gbps (small fixes + io_uring/Direct I/O) |