35
35
#include "access/xlogrecovery.h"
36
36
#include "catalog/pg_database.h"
37
37
#include "commands/dbcommands.h"
38
- #include "replication/logical .h"
38
+ #include "replication/slot .h"
39
39
#include "replication/slotsync.h"
40
40
#include "storage/ipc.h"
41
41
#include "storage/lmgr.h"
@@ -368,14 +368,13 @@ update_and_persist_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid)
368
368
* XXX should this be changed to elog(DEBUG1) perhaps?
369
369
*/
370
370
ereport (LOG ,
371
- errmsg ("could not sync slot information as remote slot precedes local slot:"
372
- " remote slot \"%s\": LSN (%X/%X), catalog xmin (%u) local slot: LSN (%X/%X), catalog xmin (%u)" ,
373
- remote_slot -> name ,
374
- LSN_FORMAT_ARGS (remote_slot -> restart_lsn ),
375
- remote_slot -> catalog_xmin ,
376
- LSN_FORMAT_ARGS (slot -> data .restart_lsn ),
377
- slot -> data .catalog_xmin ));
378
-
371
+ errmsg ("could not sync slot \"%s\" as remote slot precedes local slot" ,
372
+ remote_slot -> name ),
373
+ errdetail ("Remote slot has LSN %X/%X and catalog xmin %u, but local slot has LSN %X/%X and catalog xmin %u." ,
374
+ LSN_FORMAT_ARGS (remote_slot -> restart_lsn ),
375
+ remote_slot -> catalog_xmin ,
376
+ LSN_FORMAT_ARGS (slot -> data .restart_lsn ),
377
+ slot -> data .catalog_xmin ));
379
378
return ;
380
379
}
381
380
@@ -569,8 +568,12 @@ synchronize_slots(WalReceiverConn *wrconn)
569
568
570
569
WalRcvExecResult * res ;
571
570
TupleTableSlot * tupslot ;
572
- StringInfoData s ;
573
571
List * remote_slot_list = NIL ;
572
+ const char * query = "SELECT slot_name, plugin, confirmed_flush_lsn,"
573
+ " restart_lsn, catalog_xmin, two_phase, failover,"
574
+ " database, conflict_reason"
575
+ " FROM pg_catalog.pg_replication_slots"
576
+ " WHERE failover and NOT temporary" ;
574
577
575
578
SpinLockAcquire (& SlotSyncCtx -> mutex );
576
579
if (SlotSyncCtx -> syncing )
@@ -586,19 +589,8 @@ synchronize_slots(WalReceiverConn *wrconn)
586
589
587
590
syncing_slots = true;
588
591
589
- initStringInfo (& s );
590
-
591
- /* Construct query to fetch slots with failover enabled. */
592
- appendStringInfo (& s ,
593
- "SELECT slot_name, plugin, confirmed_flush_lsn,"
594
- " restart_lsn, catalog_xmin, two_phase, failover,"
595
- " database, conflict_reason"
596
- " FROM pg_catalog.pg_replication_slots"
597
- " WHERE failover and NOT temporary" );
598
-
599
592
/* Execute the query */
600
- res = walrcv_exec (wrconn , s .data , SLOTSYNC_COLUMN_COUNT , slotRow );
601
- pfree (s .data );
593
+ res = walrcv_exec (wrconn , query , SLOTSYNC_COLUMN_COUNT , slotRow );
602
594
603
595
if (res -> status != WALRCV_OK_TUPLES )
604
596
ereport (ERROR ,
@@ -743,12 +735,12 @@ validate_remote_info(WalReceiverConn *wrconn)
743
735
ereport (ERROR ,
744
736
errmsg ("could not fetch primary_slot_name \"%s\" info from the primary server: %s" ,
745
737
PrimarySlotName , res -> err ),
746
- errhint ("Check if \" primary_slot_name\" is configured correctly." ));
738
+ errhint ("Check if primary_slot_name is configured correctly." ));
747
739
748
740
tupslot = MakeSingleTupleTableSlot (res -> tupledesc , & TTSOpsMinimalTuple );
749
741
if (!tuplestore_gettupleslot (res -> tuplestore , true, false, tupslot ))
750
742
elog (ERROR ,
751
- "failed to fetch tuple for the primary server slot specified by \" primary_slot_name\" " );
743
+ "failed to fetch tuple for the primary server slot specified by primary_slot_name" );
752
744
753
745
remote_in_recovery = DatumGetBool (slot_getattr (tupslot , 1 , & isnull ));
754
746
Assert (!isnull );
@@ -764,9 +756,9 @@ validate_remote_info(WalReceiverConn *wrconn)
764
756
if (!primary_slot_valid )
765
757
ereport (ERROR ,
766
758
errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
767
- errmsg ("bad configuration for slot synchronization " ),
759
+ errmsg ("slot synchronization requires valid primary_slot_name " ),
768
760
/* translator: second %s is a GUC variable name */
769
- errdetail ("The replication slot \"%s\" specified by \"%s\" does not exist on the primary server." ,
761
+ errdetail ("The replication slot \"%s\" specified by %s does not exist on the primary server." ,
770
762
PrimarySlotName , "primary_slot_name" ));
771
763
772
764
ExecClearTuple (tupslot );
@@ -792,8 +784,7 @@ ValidateSlotSyncParams(void)
792
784
ereport (ERROR ,
793
785
/* translator: %s is a GUC variable name */
794
786
errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
795
- errmsg ("bad configuration for slot synchronization" ),
796
- errhint ("\"%s\" must be defined." , "primary_slot_name" ));
787
+ errmsg ("slot synchronization requires %s to be defined" , "primary_slot_name" ));
797
788
798
789
/*
799
790
* hot_standby_feedback must be enabled to cooperate with the physical
@@ -804,15 +795,14 @@ ValidateSlotSyncParams(void)
804
795
ereport (ERROR ,
805
796
/* translator: %s is a GUC variable name */
806
797
errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
807
- errmsg ("bad configuration for slot synchronization" ) ,
808
- errhint ( "\"%s\" must be enabled." , "hot_standby_feedback" ));
798
+ errmsg ("slot synchronization requires %s to be enabled" ,
799
+ "hot_standby_feedback" ));
809
800
810
801
/* Logical slot sync/creation requires wal_level >= logical. */
811
802
if (wal_level < WAL_LEVEL_LOGICAL )
812
803
ereport (ERROR ,
813
804
errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
814
- errmsg ("bad configuration for slot synchronization" ),
815
- errhint ("\"wal_level\" must be >= logical." ));
805
+ errmsg ("slot synchronization requires wal_level >= \"logical\"" ));
816
806
817
807
/*
818
808
* The primary_conninfo is required to make connection to primary for
@@ -822,8 +812,8 @@ ValidateSlotSyncParams(void)
822
812
ereport (ERROR ,
823
813
/* translator: %s is a GUC variable name */
824
814
errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
825
- errmsg ("bad configuration for slot synchronization" ) ,
826
- errhint ( "\"%s\" must be defined." , "primary_conninfo" ));
815
+ errmsg ("slot synchronization requires %s to be defined" ,
816
+ "primary_conninfo" ));
827
817
828
818
/*
829
819
* The slot synchronization needs a database connection for walrcv_exec to
@@ -834,12 +824,11 @@ ValidateSlotSyncParams(void)
834
824
ereport (ERROR ,
835
825
836
826
/*
837
- * translator: 'dbname' is a specific option; %s is a GUC variable
838
- * name
827
+ * translator: dbname is a specific option; %s is a GUC variable name
839
828
*/
840
829
errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
841
- errmsg ("bad configuration for slot synchronization" ) ,
842
- errhint ( "'dbname' must be specified in \"%s\"." , "primary_conninfo" ));
830
+ errmsg ("slot synchronization requires dbname to be specified in %s" ,
831
+ "primary_conninfo" ));
843
832
}
844
833
845
834
/*
0 commit comments