Corregir error FATAL: could not start WAL streaming: ERROR: replication slot “something” is active for PID ###

Categorías:

Este errror se genera cuando arrancamos nuestro servicio de postgres en el servidor esclavo o standby y el master detecta que otro servidor esclavo tiene el mismo tag o nombre.

El error es el siguiente

[root@srvedbprdrepasinc ~]# systemctl status edb-as-12
● edb-as-12.service - EDB Postgres Advanced Server 12
   Loaded: loaded (/usr/lib/systemd/system/edb-as-12.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-08-06 11:33:50 -05; 1min 7s ago
  Process: 300083 ExecStartPre=/usr/edb/as12/bin/edb-as-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 300088 (edb-postmaster)
    Tasks: 6 (limit: 616780)
   Memory: 3.7G
   CGroup: /system.slice/edb-as-12.service
           ├─300088 /usr/edb/as12/bin/edb-postmaster -D /datos/edb/as12
           ├─300091 postgres: logger   
           ├─300092 postgres: startup   recovering 0000000100003380000000B6
           ├─300093 postgres: checkpointer   
           ├─300094 postgres: background writer   
           └─300095 postgres: stats collector   

Aug 06 11:33:50 srvedbprdrepasinc postgres[300096]: [8-1] 2023-08-06 11:33:50 -05 pid=300096 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:33:50 srvedbprdrepasinc postgres[300100]: [8-1] 2023-08-06 11:33:50 -05 pid=300100 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:33:55 srvedbprdrepasinc postgres[300103]: [8-1] 2023-08-06 11:33:55 -05 pid=300103 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:34:00 srvedbprdrepasinc postgres[300106]: [8-1] 2023-08-06 11:34:00 -05 pid=300106 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:34:10 srvedbprdrepasinc postgres[300108]: [8-1] 2023-08-06 11:34:10 -05 pid=300108 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:34:20 srvedbprdrepasinc postgres[300110]: [8-1] 2023-08-06 11:34:20 -05 pid=300110 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:34:30 srvedbprdrepasinc postgres[300117]: [8-1] 2023-08-06 11:34:30 -05 pid=300117 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
Aug 06 11:34:45 srvedbprdrepasinc postgres[300120]: [8-1] 2023-08-06 11:34:45 -05 pid=300120 db= user=  host= FATAL:  could not start WAL streaming: ERROR:  replication slot "replica_6" is active for PID 2653479
[root@srvedbprdrepasinc ~]#

Como se puede apreciar, el tag replica_6 puede ser usado en otro servidor. Para corregir este error debemos editar el archivo postgresql.auto.conf o postgresql.conf

postgresql.auto.conf:primary_slot_name = 'replica_6'

Una vez que cambiamos este valor por uno distinto, reiniciamos el servicio y ya con esto solucionamos el inconveniente.