Ultimate access to all questions.
How can you restore availability to a Cloud SQL for PostgreSQL instance with a primary in region 1 and a read replica in region 2 after a region 1 failure, while minimizing data loss and adhering to Google's best practices?
Explanation:
To minimize data loss and follow Google-recommended practices after a failure of region 1 where your primary Cloud SQL for PostgreSQL instance is located, the best approach is to promote the read replica in region 2. This is because read replicas in PostgreSQL are designed to be asynchronously updated copies of the primary instance, and promoting a read replica to be the new primary is a supported method for disaster recovery. Before promoting the read replica, it's important to check the replication lag (Lag Bytes) and the replication status using pg_catalog.pg_last_wal_receive_lsn() to ensure that the read replica is as up-to-date as possible. This approach minimizes data loss by utilizing the most recent data available in the read replica. Restoring from automatic backups (options A and B) would result in data loss up to the time of the last backup, which is not ideal for minimizing data loss. Option D suggests checking for automatic failover status, but automatic failover is not a feature for Cloud SQL for PostgreSQL, making this option incorrect.