Re: Optimize LISTEN/NOTIFY

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Chao Li" <li(dot)evan(dot)chao(at)gmail(dot)com>, "Arseniy Mukhin" <arseniy(dot)mukhin(dot)dev(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Optimize LISTEN/NOTIFY
Date: 2025-10-26 07:08:42
Message-ID: 17b2225a-90d6-4b6f-af45-f6ec243893e5@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Oct 26, 2025, at 07:33, Joel Jacobson wrote:
> Trying to apply them on top of current master
> (39dcfda2d23ac39f14ecf4b83e01eae85d07d9e5):
>
> ```
> % git apply 0001-optimize_listen_notify-v20.patch
> % git apply 0002-optimize_listen_notify-v20.patch
> % git apply 0002-optimize_listen_notify-v20-alt3.txt
> % git apply 0001-TAP-test-with-listener-pos-race.patch.nocfbot
> % git apply fix-race.patch
> fix-race.patch:100: indent with spaces.
> (QUEUE_POS_PRECEDES(queueHeadBeforeWrite, pos) &&
> QUEUE_POS_PRECEDES(pos, queueHeadAfterWrite))) &&
> error: patch failed: src/backend/commands/async.c:250
> error: src/backend/commands/async.c: patch does not apply
> error: patch failed: src/test/authentication/t/008_listen-pos-race.pl:8
> error: src/test/authentication/t/008_listen-pos-race.pl: patch does not
> apply
> ```
>
> I'll try to resolve it manually, but in case you're quicker to reply,
> I'm sending this now.

I see the problem; seems like you based fix-race.patch on top of
0002-optimize_listen_notify-v19-alt3.txt because fix-race.patch contains
this diff block which is only present in that version:

```
@@ -2441,21 +2485,29 @@ asyncQueueReadAllNotifications(void)
page_buffer.buf,
snapshot);

- /*
- * Update our position in shared memory. The 'pos' variable now
- * holds our new position (advanced past all messages we just
- * processed). This ensures that if we fail while processing
```

I've compared 0002-optimize_listen_notify-v19-alt3.txt with
0002-optimize_listen_notify-v20-alt3.txt and it's only the addition of
QUEUE_POS_PRECEDES which fix-race.patch also adds, and some locking and
pos handling differences.

/Joel

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Filip Janus 2025-10-26 10:20:53 Re: Channel binding for post-quantum cryptography
Previous Message Joel Jacobson 2025-10-26 06:33:32 Re: Optimize LISTEN/NOTIFY