On Mon, Jun 21, 2021 at 4:17 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > On Mon, Jun 21, 2021 at 11:19 AM Amit Kapila <amit.kapil...@gmail.com> wrote: > > > > I think we should store the input from the user (like disable_on_error > flag or xid to skip) in the system catalog pg_subscription and send > the error information (subscrtion_id, rel_id, xid of failed xact, > error_code, error_message, etc.) to the stats collector which can be > used to display such information via a stat view. > > The disable_on_error flag handling could be that on error it sends the > required error info to stats collector and then updates the subenabled > in pg_subscription. In rare conditions, where we are able to send the > message but couldn't update the subenabled info in pg_subscription > either due to some error or server restart, the apply worker would > again try to apply the same change and would hit the same error again > which I think should be fine because it will ultimately succeed. > > The skip xid handling will also be somewhat similar where on an error, > we will send the error information to stats collector which will be > displayed via stats view. Then the user is expected to ask for skip > xid (Alter Subscription ... SKIP <xid_value>) based on information > displayed via stat view. Now, the apply worker can skip changes from > such a transaction, and then during processing of commit record of the > skipped transaction, it should update xid to invalid value, so that > next time that shouldn't be used. I think it is important to update > xid to an invalid value as part of the skipped transaction because > otherwise, after the restart, we won't be able to decide whether we > still want to skip the xid stored for a subscription. >
One minor detail I missed in the above sketch for skipped transaction feature was that actually we only need replication origin state from the commit record of the skipped transaction and then I think we need to start a transaction, update the xid value to invalid, set the replication origin state and commit that transaction. -- With Regards, Amit Kapila.