Skip to content

Feature: Listen/Notify Support with Transaction Pooling #655

Description

@merarischroeder

Problem

  • NOTIFY/LISTEN doesn't work with Transaction Pooling, only with Session Pooling
  • NOTIFY/LISTEN is quite useful for SIGNALLING (not for queued data), so a NOTIFIED process knows to Query again (instead of polling on an interval).
  • I would like to use just PostgreSQL and not have to add more infrastructure

Inadequate workarounds

  • Session Mode doesn't scale. If there are 1000x pgbouncer clients there needs to be 1000x PostgreSQL connections (no pooling).
  • If other infrastructure is used, there needs to be a connection-per-client maintained anyway, and when SIGNALLED there will be a maximum of 2x Connections per client (one for PosgreSQL and one for some other Signalling system)
  • Some PostgreSQL installations don't have integration with other infrastructure. That is, if you planned to call NOTIFY in a trigger, there may be no alternative when using other infrastructure (with limitations from the IaaS provider).

Solution

  • Maintain a single [Listen Connection] to the PostgreSQL server
  • Isolate LISTEN commands from connections in Transaction Pooling mode
  • Read the LISTEN command and map it against the PGBounce TCP connection - using a simple PUB/SUB mechanism
  • Send each distinct LISTEN command onward to the [Listen Connection] instead
  • Upon NOTIFY from the [Listen Connection] convert to an internal PUB message and distribute to subscribers (forwarding the original NOTIFY message).

PGBounce PubSub drawio

Resourcing

  • Does PGBouncer have a bounty/donation system? I will pay for this, or have my team build it

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurediscussion about functionality that does not exist yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions