Book Image

PostgreSQL Replication, Second Edition

Book Image

PostgreSQL Replication, Second Edition

Overview of this book

Table of Contents (22 chapters)
PostgreSQL Replication Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Dealing with timelines


Timelines are an important concept you have to be aware of, especially when you are planning a large-scale setup.

So what is a timeline? In fact, it is a certain branch of the XLOG. Normally, a database instance that has been freshly set up utilizes timeline number 1. Let's assume that we are starting to replicate our master database to a slave system. The slave will also operate in timeline 1. At some point, your master might die and your slave will be promoted to a new master. This is the time when a timeline switch happens. The new master will create a transaction log of its own now. Logically, we want to make sure that its XLOG is not mixed with some other XLOG made in the good old times.

How can we figure out that the timeline has advanced? Let's take a look at the XLOG directory of a system that was just turned into a master:

00000002.history
000000020000000000000006
000000020000000000000007
000000020000000000000008

The first part of the XLOG files is an interesting...