Skip to content

[Feat]: check empty WAL destination when bootstrap method is pg_basebackup #8897

Description

@mnencia

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new issue.

What problem is this feature going to solve? Why should it be added?

When bootstrapping a PostgreSQL instance using the pg_basebackup bootstrap method, the validation that ensures the empty WAL archive destination doesn't run. That validation runs for other bootstrap methods (initdb, recovery) but is skipped for pg_basebackup. As a result, users can supply a configuration that points to an archive containing unrelated files, which can cause issues that are very hard to debug.

Describe the solution you'd like

Ensure that the archive destination path is empty also when the bootstrap method is pg_basebackup

Cluster resource

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cluster-replica
spec:
  instances: 3
  imagePullPolicy: Always
  backup:
    barmanObjectStore:
      destinationPath: s3://backups/
      endpointURL: https://minio:9000
      endpointCA:
        key: ca.crt
        name: my-minio-server-cert
      s3Credentials:
        accessKeyId:
          name: minio
          key: ACCESS_KEY_ID
        secretAccessKey:
          name: minio
          key: ACCESS_SECRET_KEY
      wal:
        compression: zstd
      data:
        immediateCheckpoint: true
  bootstrap:
    pg_basebackup:
      source: source
  replica:
    enabled: true
    source: source
  externalClusters:
  - name: source
    connectionParameters:
      host: cluster-example-rw.default.svc
      user: streaming_replica
      sslmode: verify-full
      dbname: postgres
    sslKey:
      name: cluster-example-replication
      key: tls.key
    sslCert:
      name: cluster-example-replication
      key: tls.crt
    sslRootCert:
      name: cluster-example-ca
      key: ca.crt

  storage:
    size: 1Gi

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    triage
    on Oct 21, 2025
  2. changed the title [-][Bug]: empty WAL destination check not performed when bootstrap method is pg_basebackup[/-] [+][Feat]: check empty WAL destination when bootstrap method is pg_basebackup[/+] on Oct 21, 2025
  3. dosubot commented on Oct 21, 2025

    @dosubot

    You are correct—there is currently no validation for an empty WAL archive destination when using the pg_basebackup bootstrap method. The codebase implements this check for other bootstrap methods like initdb and recovery (using barman-cloud-check-wal-archive), but the pg_basebackup path does not invoke any similar validation or safety check before or after cloning the data directory. This means users can configure a WAL archive destination that already contains unrelated files, which can lead to subtle and hard-to-debug issues. This gap appears to be an oversight or unimplemented feature, not an intentional design decision. For reference, see the pg_basebackup bootstrap implementation and the WAL archive validation logic used in recovery.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about cloudnative-pg Share Dosu with your team

  4. added
    enhancement 🪄
    and removed
    triage
    on Oct 21, 2025
  5. added theissue type on Oct 21, 2025
  6. moved this to Waiting for Second Review in CloudNativePG operator developmenton Oct 21, 2025
  7. added this to the 1.27.1 milestone on Oct 21, 2025
  8. moved this from Waiting for Second Review to Done in CloudNativePG operator developmenton Oct 22, 2025
  9. added 3 commits that reference this issue on Oct 22, 2025
    81c5332
    a13d140
    d18af64
  10. added a commit that references this issue on Oct 22, 2025
    9137570
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement 🪄

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions