Re: Parallel Apply

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Andrei Lepikhov <lepihov(at)gmail(dot)com>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Subject: Re: Parallel Apply
Date: 2026-10-07 14:39:59
Message-ID: CANhcyEXuDB3SSsQGADwCfLxn8J=D_Gf7T2wfgX4vBa-=de5F8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> The version number now becomes v27 by the internal reviews. I adjusted each
> patches to work well and pass tests, and fixed test codes to extract the
> dependent transaction correctly.

Hi,

I found one more issue. It is related to changes in 0007 patch:

Parallel apply can resume while a transaction for which dependency
recording was stopped is still in progress.
This can allow a later transaction to be applied first, causing an
update to be skipped and the subscriber to diverge from the publisher.

When dependency memory reaches the limit, 'maybe_suspend_parallel_apply()' sets:
+ parallel_apply_suspended = true;

Subsequent changes are applied without recording dependencies:
+ /*
+ * If the estimated memory usage of dependency tracking exceeds the limit,
+ * suspend parallel apply until the usage drops below half of the limit.
+ */
+ if (maybe_suspend_parallel_apply(winfo))
+ return;

However, maybe_resume_parallel_apply() considers only memory usage:
+ if (dependency_mem_usage > PARALLEL_DEPENDENCY_MEMORY_LIMIT / 2)
+ return;
+
+ parallel_apply_suspended = false;
It does not check whether a transaction with unrecorded changes is
still in progress.

Attached a test to reproduce the issue.

Thanks,
Shlok Kyal

Attachment Content-Type Size
test.patch application/octet-stream 4.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-10-07 15:01:00 Use mbsnrtowcs() in char2wchar() to avoid temporary string copies
Previous Message David Geier 2026-10-07 14:34:01 Re: [PATCH v1] Batch B-tree TIDs when building a bitmap