PostgreSQL 19 正式发布
2026年11月19日 - 链接博客
PostgreSQL 19 发布(来源) 往年 PostgreSQL 大多在 9 月发布新版本,但今年的版本晚了两个月,主要原因是 PostgreSQL 团队需要处理大量问题——这是持续上演的“AI 报告漏洞末日”的一部分。
这个版本绝对值得等待。我最喜欢的新功能是这个:
对于将读请求发送到备库的应用,PostgreSQL 19 通过新的 WAIT FOR LSN 命令加入了“读己之写”一致性。备库上的会话可以使用 WAIT FOR LSN,等待备库将预写式日志(WAL)重放到指定的日志序列号(LSN)之后再执行查询,这样应用就能读到它刚刚在主库上写入的数据。
实际使用起来是这样的:
UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama'; SELECT pg_current_wal_insert_lsn();
WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s'); SELECT * FROM movie WHERE genre = 'Drama';
超时是可选项——如果你设置了超时,而你所连接的副本未能在指定时间内追上进度,就会收到一个错误。
我第一次遇到这种模式是在 Wikipedia,它针对 MySQL 复制自行实现了一套手写版本:
除此之外,MediaWiki 还试图确保用户按时间顺序看到 wiki 上发生的事件。只要用户从后续请求中看到一致的画面,几秒钟的延迟是可以容忍的。具体做法是把主库的 binlog 位置保存在会话中,然后在每次请求开始时,先等待副本追赶到该位置,再从中进行任何读取。
以下是相关的 MediaWiki 代码,如今它使用 MySQL 的 WAIT_FOR_EXECUTED_GTID_SET() 函数,并回退到 SOURCE_POS_WAIT()。
发布于 2026 年 11 月 19 日晚上 8:43
这是 Simon Willison 的一篇链接帖,发布于 2026 年 11 月 19 日。
以每月 10 美元赞助我,即可获得当月最重要 LLM 进展的精选邮件摘要。
付钱给我,让我给你少发点邮件!
译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。
查看英文原文(PostgreSQL 19 Released)
19th November 2026 - Link Blog
PostgreSQL 19 Released (via) Most years PostgreSQL ships a new release in September, but this year's release came two months later thanks mainly to the flurry of issues that the PostgreSQL team needed to address as part of the ongoing AI-reported vulnerability apocalypse.
This release was definitely worth the wait. My favorite new feature is this one:
For applications that send reads to standbys, PostgreSQL 19 adds "read-your-writes" consistency with the new WAIT FOR LSN command. A session on a standby can use WAIT FOR LSN to wait until the standby has replayed the write-ahead log (WAL) up to a specific log sequence number (LSN) before running a query, so the application can read data it just wrote on the primary.
In practice, that looks like this:
UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama';
SELECT pg_current_wal_insert_lsn();
That returns a value like 0/0306EE20. Store that somewhere (a signed cookie would work) such that on a subsequent request your application can do:
WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s');
SELECT * FROM movie WHERE genre = 'Drama';
The timeout is optional - if you provide one you'll get an error if the replica you are talking to doesn't catch up within the specified time.
I first encountered this pattern in Wikipedia, which has a hand-rolled version of this built against MySQL replication:
In addition to this, MediaWiki attempts to ensure that the user sees events occurring on the wiki in chronological order. A few seconds of lag can be tolerated, as long as the user sees a consistent picture from subsequent requests. This is done by saving the primary binlog position in the session, and then at the start of each request, waiting for the replica to catch up to that position before doing any reads from it.
Here's the relevant MediaWiki code, which these days uses MySQL's WAIT_FOR_EXECUTED_GTID_SET() function and falls back to SOURCE_POS_WAIT().
Posted 19th November 2026 at 8:43 pm
This is a link post by Simon Willison, posted on 19th November 2026.
Sponsor me for $10/month and get a curated email digest of the month's most important LLM developments.
Pay me to send you less!
原文为英文,正文由自动抓取并保留原文。
原文发布于 Simon Willison(PostgreSQL 19 Released),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。