Postgresql 中 restart_lsn 和 confirmed_flush_lsn 有什么区别?

What is the difference between restart_lsn and confirmed_flush_lsn in Postgresql?

正如 documentation 所说 - restart_lsn 是:

The address (LSN) of oldest WAL which still might be required by the consumer of this slot and thus won't be automatically removed during checkpoints unless this LSN gets behind more than max_slot_wal_keep_size from the current LSN. NULL if the LSN of this slot has never been reserved.

confirmed_flush_lsn是:

The address (LSN) up to which the logical slot's consumer has confirmed receiving data. Data older than this is not available anymore. NULL for physical slots.

我不明白的是(在逻辑插槽的情况下)- 这两个属性如何相互连接? confirmed_flush_lsn 描述说旧日志已删除,但 restart_lsn 听起来不是 100% 正确。如果不是,并且 restart_lsnconfirmed_flush_lsn 之间有一定数量的事务日志 - 这个数字可能是多少?它是一些预定义的和不可变的值,比方说几个 MB 还是它真的可以提高到 max_slot_wal_keep_size?它是如何决定的 - WAL still might be required by the consumer 什么不是?

confirmed_flush_lsn 是 WAL 中消费者已经接收到解码数据的最新位置,因此逻辑解码不会为任何早于此的位置发出数据。

但是,逻辑解码可能仍然需要比 WAL 更早的 WAL,以便计算所需的信息,WAL 来自 confirmed_flush_lsn 之前开始的事务。于是就有了restart_lsn,它标志着服务器上必须保留WAL才能继续解码的点。