postgresql - 在 PostgreSQL 中没有 session 发出 LISTEN 时 NOTIFY 会发生什么?

标签 postgresql notify listen

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/

相关文章:

postgresql - 在 postgres 中可以创建多少个模式

java - 在等待另一个类中按下按钮时,如何使用等待通知来停止暂停方法

Java:线程不会等待

java - 等待和通知不是静态的

android - 没有为类 'listen' 定义方法 'Function' 吗?

sockets - 我应该在bind()或listen()错误上调用close()吗

linux - 是否可以在套接字上取消监听?

sql - 如何用 except 替换 2 个查询

java - Spring boot - 带返回 ID 的 Jdbc 批量插入

python - 如何在 python 中以 pgcrypto 兼容的方式加密