Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Configuration parameter in pg_autoctl.cfg for the ability to clear PGDATA before running pg_basebackup

Aperta
#1,024 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
c, postgresql
Ambito
databases

Direzione di ricerca

Inizia leggendo la funzione pg_basebackup mostrata nell’issue e la gestione della configurazione pg_autoctl.cfg relativa al comportamento dei backup. Segui il percorso di switchover/failover in cui pg_rewind ricorre a pg_basebackup; il lavoro è completato quando la configurazione fornisce la scelta richiesta mantenendo il comportamento esistente per impostazione predefinita.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Good afternoon.

As far as I can see from the behavior of the cluster and the source code, if after switchover/failover the replica cannot be connected using pg_rewind and the replica is recreated using pg_basebackup. At the same time, PGDATA on the replica is not cleared until the procedure for copying data from the wizard to the backup_directory directory specified in pg_autoctl.cfg is completed. After the pg_basebackup copy is successfully completed, the PGDATA is cleared and the backup_directory data is moved to the PGDATA location:

/*
 * Call pg_basebackup, using a temporary directory for the duration of the data
 * transfer.
 */
bool
pg_basebackup(const char *pgdata,
              const char *pg_ctl,
              ReplicationSource *replicationSource)
{

  ...

    returnCode = program.returnCode;
    free_program(&program);

    if (returnCode != 0)
    {
        log_error("Failed to run pg_basebackup: exit code %d", returnCode);
        return false;
    }

    /* replace $pgdata with the backup directory */
    if (directory_exists(pgdata))
    {
        if (!rmtree(pgdata, true))
        {
            log_error("Failed to remove directory \"%s\": %m", pgdata);
            return false;
        }
    }

    log_debug("mv \"%s\" \"%s\"", replicationSource->backupDir, pgdata);

    if (rename(replicationSource->backupDir, pgdata) != 0)
    {
        log_error(
            "Failed to install pg_basebackup dir " " \"%s\" in \"%s\": %m",
            replicationSource->backupDir, pgdata);
        return false;
    }

    return true;
}

This behavior can lead to the fact that disk space in the pg_basebackup process will run out if there is a lot of data and there is not enough disk space for PGDATA and a fresh copy from primary.
This is a particularly unpleasant situation with a failover, when we hope that automation will bring the cluster back to normal after changing server roles.

It would be convenient to have a parameter in the pg_autoctl.cfg configuration file, setting it to true, PGDATA on this server was cleared before running pg_basebackup (if pg_rewind did not help) during switchover/failover. This would solve the problem and allow for a choice of behavior.

Thank you.

Lingua principale
C
Stelle
1.4k
Fork
142
Merge medio
5h 8m
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hapostgres/pg_auto_failover

Tutte le issue di hapostgres/pg_auto_failover

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.