Patronictl TL mean?

hi all,
when ı list patronictl list get the TL. what does it mean TL ?
how can we do 0 ?

[server01 ~]$ patronictl -c /etc/patroni/patroni.yml list

  • Cluster: name ---------------------------±—±----------+
    | Member | Host | Role | State | TL | Lag in MB |
    ±----------±----------------------±----------±—±----------+
    | s1| 1.1.1.1:5432 | Sync Standby | streaming | 11 | 0 |
    | s2| 1.1.1.2:5432 | Sync Standby | streaming | 11 | 0 |
    | s3| 1.1.1.3:5432 | Leader | running | 11 | |
    ±----------±----------------------±----------±—±----------+
1 Like

Hi
In the context of Patroni, TL stands for Timeline. It is a unique identifier for a particular point in the replication history of a PostgreSQL cluster. The timeline ID is used to determine which WAL files are needed for a particular server to catch up with the rest of the cluster

It seems it can’t be 0, it’s an ID.

Thank you for response. I know this doc. Before ı saw this doc.
But ı am not response my questions :frowning:
Are u find this resolve ?

What kind of response do you expect?
What’s your problem?

I want to change TL value.
Now this value 11. I want to change this value 0 or 1

We can’t change it.
It tells us that there were 10 times switchovers/failovers happened before.
After every recovery and promotion happens, PostgreSQL starts a new incarnation (New Timeline) to avoid conflict with the previous one.
You may use the following SQL statement to check the current Time-Line of PostgreSQL

SELECT timeline_id FROM pg_control_checkpoint();
1 Like

Thank you for response.
I was wondered this situation.

Okey, ı can’t change.

@parttime actually, you can change it, but it should be done on a database instance level, not on Patroni, as TimeLine is DB instance attribute. This can be accomplished in a number of ways, the basic idea being to rebuild the entire cluster and instances from scratch:

  1. remove the cluster information from DCS: {{patronictl remove}}
  2. create dump of the data stored in the database (pg_dump) and backup
  3. stop patroni on all nodes
  4. physically remove database instances
  5. initialize database instance on one of the nodes (initdb). After that you will have timeline = 0
  6. load the data to the database using the dump created earlier
  7. start Patroni on the node with the reinitilized database
  8. make sure there are no issues and the node is identified as Leader (patronictl list)
  9. start Patroni on other nodes. Probably, after that you’ll need to reiniitialize the databases on them (patronictl reinit)

In general, the whole idea seems pointless, because, as already written in the comments, after the first switchover/failover the counter will increase by 1. So after 2 switchover/failover TL will already be 2.

1 Like