| From: | Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> |
|---|---|
| To: | Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru> |
| Cc: | Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Gleb Kashkin <g(dot)kashkin(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Bug in asynchronous Append |
| Date: | 2026-08-03 13:57:53 |
| Message-ID: | CAPmGK17KynGdQKEDkrXHFwcuU28CX7GF6mO7zJ1S7cSFriT25Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Mon, Aug 3, 2026 at 6:45 PM Alexander Pyhalov
<a(dot)pyhalov(at)postgrespro(dot)ru> wrote:
> I've looked on the suggested patch more attentively in Async Merge
> Append thread[1].
> There it's a bit more obvious that ExecReScanAppend() behavior in
> ExecAppendAsyncProcessPending()
> depends on node->as_syncdone. It either sleeps on latch in
> ExecAppendAsyncEventWait() or busy loops.
> The first behavior seems to be more appropriate, as we still should wait
> for all requests
> with set callback_pending to complete. Or perhaps, it's not a big
> problem, given that this case should
> be rare?
Good catch! Incorporated. Attached is an updated version of the
patch. Other changes are:
* Add CHECK_FOR_INTERRUPTS() to the for loop in ExecAppendAsyncProcessPending.
* Merge the async-state-reset code in ExecReScanAppend into
ExecAppendAsyncProcessPending, for readability, and rename that
function to ExecAppendAsyncReset.
* Remove this bit from postgresReScanForeignScan:
/*
* If the node is async-capable, and an asynchronous fetch for it has
* begun, the asynchronous fetch might not have yet completed. Check if
* the node is async-capable, and an asynchronous fetch for it is still in
* progress; if so, complete the asynchronous fetch before restarting the
* scan.
*/
if (fsstate->async_capable &&
fsstate->conn_state->pendingAreq &&
fsstate->conn_state->pendingAreq->requestee == (PlanState *) node)
fetch_more_data(node);
and instead add an assertion, as it's no longer needed due to the
handling in ExecAppendAsyncReset.
* As a test case causing an issue (infinite loop!) on a
non-assert-enabled build, add (a modified version of) Gleb's test case
as well. (The original test case only causes an assertion failure.)
Best regards,
Etsuro Fujita
| Attachment | Content-Type | Size |
|---|---|---|
| Fix-bug-in-async-append-efujita-v2.patch | application/octet-stream | 10.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Tom Lane | 2026-08-03 13:44:25 | Re: Update our timezone code to IANA tzcode2026b |