---
title: "Discussion on \"Running Postgres-based event-driven systems in production — LISTEN/NOTIFY limits, outbox lag, and knowing when you've outgrown it\" | Hashnode"
description: "Discussion on \"Running Postgres-based event-driven systems in production — LISTEN/NOTIFY limits, outbox lag, and knowing when you've outgrown it\". LISTEN/NOTIFY limits, outbox lag, and knowing when you've outgrown it"
url: "https://hashnode.com/posts/running-postgres-based-event-driven-systems-in-production-listen-notify-limits-outbox-lag-and-knowing-when-you-ve-outgrown-it/6aaebcef3c66a655c3a341ea"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Running Postgres-based event-driven systems in production — LISTEN/NOTIFY limits, outbox lag, and knowing when you've outgrown it](https://md-blogs.hashnode.dev/running-postgres-based-event-driven-systems-in-production-listen-notify-limits-outbox-lag-and-knowing-when-you-ve-outgrown-it?utm_source=hashnode&utm_medium=feed)

LISTEN/NOTIFY limits, outbox lag, and knowing when you've outgrown it

Sep 19 · 11 min read · md-blogs.hashnode.dev  
Read the article

-   [#postgresql](https://hashnode.com/tag/postgresql)
-   [#eventdriven](https://hashnode.com/tag/eventdriven)
-   [#code](https://hashnode.com/tag/code)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Mona Lisa](https://hashnode.com/@mlisa1501)

@mlisa1501 · Mumbai, India

  
[View profile](https://hashnode.com/@mlisa1501)

## Responses 1

Markdown supported · ⌘↵ to post

[Mihai\_LeanZero](https://hashnode.com/@mihaileanzero)

[Sep 19](https://hashnode.com/posts/running-postgres-based-event-driven-systems-in-production-listen-notify-limits-outbox-lag-and-knowing-when-you-ve-outgrown-it/6aaebcef3c66a655c3a341ea/comment/6aaf2152fb26376ca113057a)

The PgBouncer trap you found for LISTEN/NOTIFY has a second victim I hadn't thought about until reading this: the advisory-lock connection for the poller failover. pg\_try\_advisory\_lock is scoped to the physical session, same as LISTEN. If that connection ever gets routed through a transaction-mode pooler instead of staying direct, the lock either evaporates between polls or two instances both end up believing they hold it, for the exact same reason the notifications went missing. It's the kind of thing that passes every test because nobody adds the pooler until months later, for a completely unrelated reason, and then the poller starts double-processing with no error anywhere. Worth a comment right on POLLER\_LOCK\_KEY warning future-you not to move that connection behind a pooler.
