UNLISTEN, DISCARD ALL and readonly standby

From: Shay Rojansky <roji(at)roji(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: UNLISTEN, DISCARD ALL and readonly standby
Date: 2018-10-25 07:53:14
Message-ID: CADT4RqBweu7QKRYAYzeRW77b+MhJdUikNe45m+fL4GJSq_u2Fg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

Hi hackers.

The documentation for DISCARD ALL[1] state that it is equivalent to a
series of commands which includes UNLISTEN *. On the other hand, the docs
for hot standby mode[1], state that UNLISTEN * is unsupported while DISCARD
is (although the docs don't specify whether this includes DISCARD ALL). I
haven't done a test, but this seems to indicate that while DISCARD ALL is
supported in hot standby mode, UNLISTEN is not, although its functionality
is included in the former.

If this is indeed the case, is there any specific reason UNLISTEN can't be
supported? This is actually quite important in the case of Npgsql (.NET
driver). When a connection is returned to the connection pool, its state is
reset - usually with a DISCARD ALL. However, if prepared statements exist,
we avoid DISCARD ALL since it destroys those (the DEALLOCATE ALL component
of DISCARD ALL), and we want to keep prepared statements across connection
lifecycles for performance. So instead of issuing DISCARD ALL, Npgsql sends
the equivalent commands excluding DEALLOCATE ALL - but UNLISTEN * fails
when in recovery.

So ideally UNLISTEN would be made to work in standby model, just like
DISCARD ALL. If DISCARD ALL is in fact unsupported in hot standby mode,
then the docs should probably be updated to reflect that.

Thanks for any information or advice on this!

[1] https://www.postgresql.org/docs/current/static/sql-discard.html


Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2018-10-25 08:16:03 Re: Online verification of checksums
Previous Message Richard Guo 2018-10-25 07:42:05 Re: Pull up sublink of type 'NOT NOT (expr)'