Search code examples
postgresqlpostgresql-9.4postgresql-9.6pitr

Why is pg_clog not mentioned in the postgresql document of Point-in-Time Recovery (PITR)?


Firstly, please forgive my poor English.

The key word, "pg_clog" is not mentioned in the chapter "Continuous Archiving and Point-in-Time Recovery (PITR)" of postgresql 9.x documents. But as I learned from the book, Database System Implementation, commit logs are necessites for a database to recover from a failure or from a backup, because they help the database to be restored to consistency.

Is it because the commit records are also written in other files? For example, WALs?

Thank you.


Solution

  • The commit log contains the information whether a particular transaction was committed or rolled back.

    When rows are written to a table, it is not yet clear if the transaction will succeed or not. Rather that storing that information in each row version (“tuple”) when the transaction is committed or restored, PostgreSQL only marks the state of the transaction in the commit log.

    So it is necessary to have the commit log to determine if a certain tuple is visible or not; without it the database is unusable.

    The commit log is not specifically mentioned in the recovery documentation, because it is part of the data directory and is written to disk at checkpoint time.

    For recovery, it is not necessary to have commit log information beyond the checkpoint from which you recover: since COMMIT and ROLLBACK are recorded in the transaction log (“WAL”), all the information is there and will be written to the commit log during recovery.