PostgreSQL checkpoint logging is disabled

Use Cloud SQL for PostgreSQL checkpoint logs to investigate write load and performance.

Description

log_checkpoints records when PostgreSQL checkpoints and restartpoints occur, how many buffers they write and how long they take.

Potential impact

Without these records, it is harder to link a spike in disk I/O to a checkpoint.

Remediation

Set log_checkpoints to the string on under settings.database_flags. Keep the other flags you need. After the next checkpoint, find its entry in the PostgreSQL log and check the retention period.

Examples

The Ansible google.cloud 1.14.0 example creates an instance. Supply your PostgreSQL version and service account JSON file. For an existing instance, edit its flags in Cloud SQL.

Before

yaml
- name: create instance
  google.cloud.gcp_sql_instance:
    name: gcp-instance
    settings:
      database_flags:
        - name: log_checkpoints
          value: "off"
      tier: db-n1-standard-1
    region: us-central1
    project: "{{ gcp_project_id }}"
    database_version: "{{ postgres_version }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_credentials_file }}"
    state: present

After

yaml
- name: create a instance
  google.cloud.gcp_sql_instance:
    name: gcp-instance
    settings:
      database_flags:
        - name: log_checkpoints
          value: "on"
      tier: db-n1-standard-1
    region: us-central1
    project: "{{ gcp_project_id }}"
    database_version: "{{ postgres_version }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_credentials_file }}"
    state: present

References