gpt4 book ai didi

postgresql - 日志序列号在 postgres 中真的是单调的吗?

转载 作者:行者123 更新时间:2023-11-29 12:02:00 25 4
gpt4 key购买 nike

阅读 postgreSQL 文档时:

WAL records are appended to the WAL logs as each new record is written. The insert position is described by a Log Sequence Number (LSN) that is a byte offset into the logs, increasing monotonically with each new record. LSN values are returned as the datatype pg_lsn. Values can be compared to calculate the volume of WAL data that separates them, so they are used to measure the progress of replication and recovery.

我们可以相信这个序列号是严格单调的吗?是否存在将此偏移量重置为先前位置的时间点(由于 WAL 存档或其他类型的操作)?

最佳答案

它是严格单调的,但LSN 指向某个段文件中的物理偏移量。

Isn't there a point in time where this offset resetting to a previous position (due to WAL archive, or another type of operations ) ?

有这么一个时间点但是在另一个segment文件中。

仅供引用,这里有一个来自 PG 代码的宏,它从 LSN ( https://github.com/postgres/postgres/blob/master/src/include/access/xlog_internal.h ) 中提取段号:

/*
* Compute a segment number from an XLogRecPtr.
........
*/
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes) \
logSegNo = (xlrp) / (wal_segsz_bytes)

关于postgresql - 日志序列号在 postgres 中真的是单调的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53629031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com