On 1/6/15 12:57 AM, Josh Berkus wrote: > On 01/05/2015 05:43 PM, Peter Eisentraut wrote: >> The wins on the other hand are obscure: You can now use SHOW to inspect >> recovery settings. You can design your own configuration file include >> structures to set them. These are not bad, but is that all? > > That's not the only potential win, and it's not small either. I'll be > able to tell what master a replica is replicating from using via a port > 5432 connection (currently there is absolutely no way to do this).
That's one particular case of what I mentioned above under using SHOW to inspect recovery settings. I agree that that's important, but it doesn't look like there is a consensus that it justifies all the drawbacks. That said, there is a much simpler way to achieve that specific functionality: Expose all the recovery settings as fake read-only GUC variables. See attached patch for an example. Btw., I'm not sure that everyone will be happy to have primary_conninfo visible, since it might contain passwords. > ... and there you hit on one of the other issues with recovery.conf, > which is that it's a configuration file with configuration parameters > which gets automatically renamed when a standby is promoted. This plays > merry hell with configuration management systems. The amount of > conditional logic I've had to write for Salt to handle recovery.conf > truly doesn't bear thinking about. There may be some other way to make > recovery.conf configuration-management friendly, but I haven't thought > of it. I have written similar logic, and while it's not pleasant, it's doable. This issue would really only go away if you don't use a file to signal recovery at all, which you have argued for, but which is really a separate and more difficult problem.
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 218de87..477b906 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -237,10 +237,10 @@ static int recovery_min_apply_delay = 0; static TimestampTz recoveryDelayUntilTime; /* options taken from recovery.conf for XLOG streaming */ -static bool StandbyModeRequested = false; -static char *PrimaryConnInfo = NULL; -static char *PrimarySlotName = NULL; -static char *TriggerFile = NULL; +bool StandbyModeRequested = false; +char *PrimaryConnInfo = NULL; +char *PrimarySlotName = NULL; +char *TriggerFile = NULL; /* are we currently in standby mode? */ bool StandbyMode = false; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f6df077..6caadff 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -864,6 +864,15 @@ static struct config_bool ConfigureNamesBool[] = NULL, NULL, NULL }, { + {"standby_mode", PGC_INTERNAL, WAL_SETTINGS, + gettext_noop("TODO"), + NULL + }, + &StandbyModeRequested, + false, + NULL, NULL, NULL + }, + { {"fsync", PGC_SIGHUP, WAL_SETTINGS, gettext_noop("Forces synchronization of updates to disk."), gettext_noop("The server will use the fsync() system call in several places to make " @@ -3275,6 +3284,37 @@ static struct config_string ConfigureNamesString[] = }, { + {"primary_conninfo", PGC_INTERNAL, WAL_SETTINGS, + gettext_noop("TODO"), + NULL, + GUC_SUPERUSER_ONLY + }, + &PrimaryConnInfo, + NULL, + NULL, NULL, NULL + }, + + { + {"primary_slot_name", PGC_INTERNAL, WAL_SETTINGS, + gettext_noop("TODO"), + NULL + }, + &PrimarySlotName, + NULL, + NULL, NULL, NULL + }, + + { + {"trigger_file", PGC_INTERNAL, WAL_SETTINGS, + gettext_noop("TODO"), + NULL + }, + &TriggerFile, + NULL, + NULL, NULL, NULL + }, + + { {"application_name", PGC_USERSET, LOGGING_WHAT, gettext_noop("Sets the application name to be reported in statistics and logs."), NULL, diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 138deaf..eeb9461 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -100,6 +100,11 @@ extern bool fullPageWrites; extern bool wal_log_hints; extern bool log_checkpoints; +extern bool StandbyModeRequested; +extern char *PrimaryConnInfo; +extern char *PrimarySlotName; +extern char *TriggerFile; + /* WAL levels */ typedef enum WalLevel {
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers