Re: Conflict detection for update_deleted in logical replication
От | Amit Kapila |
---|---|
Тема | Re: Conflict detection for update_deleted in logical replication |
Дата | |
Msg-id | CAA4eK1+HcrkKfXAwEsXK0waDK8VSx1qjBVj95SmZKPM0vMF=Qg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Conflict detection for update_deleted in logical replication (Amit Kapila <amit.kapila16@gmail.com>) |
Ответы |
Re: Conflict detection for update_deleted in logical replication
|
Список | pgsql-hackers |
On Mon, Aug 25, 2025 at 5:05 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > A few comments on 0001: > Some more comments: 1. + /* + * Return false if the leader apply worker has stopped retaining + * information for detecting conflicts. This implies that update_deleted + * can no longer be reliably detected. + */ + if (!retention_active) + return false; + /* * For conflict detection, we use the conflict slot's xmin value instead * of invoking GetOldestNonRemovableTransactionId(). The slot.xmin acts as @@ -3254,7 +3315,15 @@ FindDeletedTupleInLocalRel(Relation localrel, Oid localidxoid, oldestxmin = slot->data.xmin; SpinLockRelease(&slot->mutex); - Assert(TransactionIdIsValid(oldestxmin)); + /* + * Return false if the conflict detection slot.xmin is set to + * InvalidTransactionId. This situation arises if the current worker is + * either a table synchronization or parallel apply worker, and the leader + * stopped retention immediately after checking the + * oldest_nonremovable_xid above. + */ + if (!TransactionIdIsValid(oldestxmin)) + return false; If the current worker is tablesync or parallel_apply, it should have exited from the above check of retention_active as we get the leader's oldest_nonremovable_xid to decide that. What am, I missing? This made me wonder whether we need to use slot's xmin after we have fetched leader's oldest_nonremovable_xid to find deleted tuple? 2. - * The interval is reset to a minimum value of 100ms once there is some - * activity on the node. + * The interval is reset to the lesser of 100ms and + * max_conflict_retention_duration once there is some activities on the node. AFAICS, this is not adhered in the code because you are using it when there is no activity aka when new_xid_found is false. IS the comment wrong or code needs some updation? 3. + + /* Ensure the wait time remains within the maximum limit */ + rdt_data->xid_advance_interval = Min(rdt_data->xid_advance_interval, + MySubscription->maxconflretention); Can't we combine it with calculation of max_interval few lines above this change? And also adjust comments atop adjust_xid_advance_interval() accordingly? 4. if (am_leader_apply_worker() && - MySubscription->retaindeadtuples && + MySubscription->retaindeadtuples && MySubscription->retentionactive && !TransactionIdIsValid(MyLogicalRepWorker->oldest_nonremovable_xid)) I think this code can look neat if you have one condition per line. Apart from above comments, I have tried to improve some code comments in the attached. -- With Regards, Amit Kapila.
Вложения
В списке pgsql-hackers по дате отправления: