• ukuina 2 hours ago

    > It stores these commands BEFORE any changes are made. Once the change is committed, the record is marked, indicating to the system that the change was already made. If the system fails, it can read the commands sequentially within the logs, starting from the one it left off on.

    What happens if power is lost AFTER the change is made, but BEFORE the record is marked?

    • j-cheong an hour ago

      Good question. Actually it's not possible for a power loss to occur after a change is made to the database but before the record is marked in the WAL. This is because Postgres ensures that all changes are written to the WAL and flushed to disk before they are applied to the database. This write-ahead mechanism guarantees that even if a power outage occurs immediately after a change is applied, the transaction's record is already safely stored in the WAL.

    • qianli_cs 3 hours ago

      Interesting post but the format is broken on mobile devices. It cuts off sentences on the right.

      • tang8330 3 hours ago

        Thanks for the flag. We'll get that fixed!

      • undefined 2 hours ago
        [deleted]