本文介绍了WAL缓冲区在事务提交之前填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究Postgresql中的崩溃恢复机制,这让我很震惊.在WAL日志记录中,在事务START处,基于查询,XAL记录将填充WAL缓冲区.在事务COMMIT时,将刷新WAL缓冲区.现在,假设我开始进行一系列插入操作.当现有的WAL段被填充时,它将创建新的WAL段.但是,当我批量插入或复制大量数据(例如4-5GB),并且在事务提交之前WAL Buffer(1-2GB)被填充时,会发生什么?在这种情况下,WAL会发生什么?

I have been going around the crash recovery mechanism in Postgresql and this hit me. In WAL logging, At the transaction START, based on the queries, WAL Buffers are filled with XLOG records. At transaction COMMIT, the WAL buffer gets flushed. Now, Assume that i start a transaction with series of inserts. When the existing WAL segments gets filled, it creates new ones. But what happens, when i do bulk insert or copy heavy data or something (say 4-5GB), and the WAL Buffer(1-2GB) gets filled before the transaction commits? In this case, what happens to the WAL?

推荐答案

WAL缓冲区已满时,它们将刷新到磁盘.没有什么可以说WAL缓冲区只能在事务提交时才刷新.重要的是,在将事务报告为已提交之前(假定为同步提交),应清除与该事务有关的所有WAL记录.但是事实并非如此:可以在提交事务之前清除WAL记录.

When the WAL buffers are full, they are flushed to disk. There is nothing that says that WAL buffers can only be flushed when a transaction commits. What is important is that all WAL records pertaining to a transaction are flushed before a transaction is reported as committed (assuming synchronous commit). But the reverse is not true: A WAL record can be flushed before a transaction is committed.

这篇关于WAL缓冲区在事务提交之前填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 05:50