- Mastering PostgreSQL 10
- Hans Jürgen Sch?nig
- 407字
- 2021-06-30 19:03:52
Digging into transaction wraparound-related issues
There are two more settings in postgresql.conf that are quite important to understand:
autovacuum_freeze_max_age = 200000000 autovacuum_multixact_freeze_max_age = 400000000
To understand the overall problem, it is important to understand how PostgreSQL handles concurrency. The PostgreSQL transaction machinery is based on the comparison of transaction IDs and the states transactions are in.
Let's look at an example. If I am transaction ID 4711 and if you happen to be 4712, I won't see you because you are still running. If I am transaction ID 4711 but you are transaction ID 3900, I will see you provided you have committed, and I will ignore you if you failed.
The trouble is as follows: transaction IDs are finite, not unlimited. At some point, they will start to wrap around. In reality, this means that transaction number 5 might actually be after transaction number 800,000,000. How does PostgreSQL know what was first? It does so by storing a watermark. At some point, those watermarks will be adjusted, and this is exactly when VACUUM starts to be relevant. By running VACUUM (or autovacuum), you can ensure that the watermark is adjusted in a way that there are always enough future transaction IDs left to work with.
autovacuum_freeze_max_age defines the maximum number of transactions (age) that a table's pg_class.relfrozenxid field can attain before a VACUUM operation is forced to prevent transaction ID wraparound within the table. This value is fairly low because it also has an impact on clog cleanup (the clog or commit log is a data structure that stores two bits per transaction, which indicate whether a transaction is running, aborted, committed, or still in a subtransaction).
autovacuum_multixact_freeze_max_age configures the maximum age (in multixacts) that a table's pg_class.relminmxid field can attain before a VACUUM operation is forced to prevent multixact ID wraparound within the table. Freezing tuples is an important performance issue and there will be more about this process in Chapter 6, Optimizing Queries for Good Performance, where we will discuss query optimization.
In general, trying to reduce the VACUUM load while maintaining operational security is a good idea. A VACUUM instance on large tables can be expensive, and therefore keeping an eye on these settings makes perfect sense.
- 玩轉(zhuǎn)智能機器人程小奔
- Dreamweaver CS3網(wǎng)頁制作融會貫通
- Hands-On Machine Learning on Google Cloud Platform
- 圖形圖像處理(Photoshop)
- Maya 2012從入門到精通
- 傳感器技術(shù)應(yīng)用
- PHP開發(fā)手冊
- AWS Certified SysOps Administrator:Associate Guide
- OpenStack Cloud Computing Cookbook
- Blender 3D Printing by Example
- PLC與變頻技術(shù)應(yīng)用
- Linux系統(tǒng)下C程序開發(fā)詳解
- 3ds Max造型表現(xiàn)藝術(shù)
- 空間機器人智能感知技術(shù)
- 局域網(wǎng)組建與使用完全自學(xué)手冊