def latest_checkpoint_location(self) -> Optional[int]:
        """Get shutdown checkpoint location.

        .. note::
            In case if checkpoint was written to the new WAL file due to the archive_mode=on
            we return LSN of the previous wal record (SWITCH).

        :returns: checkpoint LSN for the cleanly shut down primary.
        """
        checkpoint_locations = self._checkpoint_locations_from_controldata(self.controldata())
        if checkpoint_locations:
            return checkpoint_locations[1]
Get shutdown checkpoint location.

        .. note::
            In case if checkpoint was written to the new WAL file due to the archive_mode=on
            we return LSN of the previous wal record (SWITCH).

        :returns: checkpoint LSN for the cleanly shut down primary.
        
patroni/postgresql/__init__.py