PostgreSQL 有一个很好的监听/通知系统。 Documentation说:
There is a queue that holds notifications that have been sent but not yet processed by all listening sessions. If this queue becomes full, transactions calling NOTIFY will fail at commit.
但我无法查明没有监听器的指定 channel 中的事件发生了什么。通知队列会溢出还是 PG 会从队列中删除这些事件?
最佳答案
手册中可能会更清楚,但是有明确的指示表明只要没有 session 在主动等待通知,队列就会被清理。 Per documentation:
However, no cleanup can take place if a session executes
LISTEN
and then enters a transaction for a very long time. Once the queue is half full you will see warnings in the log file pointing you to the session that is preventing cleanup. In this case you should make sure that this session ends its current transaction so that cleanup can proceed.
这意味着,如果没有人在监听(没有事件 session 在同一 channel 上发出 LISTEN
命令),没有什么可以阻止 Postgres 立即清理队列。 p>
关于postgresql - 在 PostgreSQL 中没有 session 发出 LISTEN 时 NOTIFY 会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23087347/