Skip to content

Commit

Permalink
config: fix parsing of "replication_type"
Browse files Browse the repository at this point in the history
This is a legacy parameter which can currently only contain one value,
"physical" (the default).

It can be safely omitted.

Addresses GitHub EnterpriseDB#672.
  • Loading branch information
ibarwick committed Oct 30, 2020
1 parent 9671815 commit 293e376
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
3 changes: 3 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
5.2.1 2020-??-??
config: fix parsing of "replication_type"

5.2.0 2020-10-22
general: add support for PostgreSQL 13 (Ian)
general: remove support for PostgreSQL 9.3 (Ian)
Expand Down
8 changes: 4 additions & 4 deletions configdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ struct ConfigFileSetting config_file_settings[] =
/* replication_type */
{
"replication_type",
CONFIG_INT,
{ .intptr = &config_file_options.replication_type },
{ .intdefault = REPLICATION_TYPE_PHYSICAL },
{ .intminval = -1 },
CONFIG_REPLICATION_TYPE,
{ .replicationtypeptr = &config_file_options.replication_type },
{ .replicationtypedefault = DEFAULT_REPLICATION_TYPE },
{},
{},
{}
},
Expand Down
36 changes: 36 additions & 0 deletions configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ _parse_config(ItemList *error_list, ItemList *warning_list)
case CONFIG_CONNECTION_CHECK_TYPE:
*setting->val.checktypeptr = setting->defval.checktypedefault;
break;
case CONFIG_REPLICATION_TYPE:
*setting->val.replicationtypeptr = setting->defval.replicationtypedefault;
break;
case CONFIG_EVENT_NOTIFICATION_LIST:
case CONFIG_TABLESPACE_MAPPING:
/* no default for these types; lists cleared above */
Expand Down Expand Up @@ -566,6 +569,20 @@ parse_configuration_item(ItemList *error_list, ItemList *warning_list, const cha
}
break;
}
case CONFIG_REPLICATION_TYPE:
{
if (strcasecmp(value, "physical") == 0)
{
*(ReplicationType *)setting->val.replicationtypeptr = REPLICATION_TYPE_PHYSICAL;
}
else
{
item_list_append_format(error_list,
_("value for \"%s\" must be \"physical\"\n"),
name);
}
break;
}
case CONFIG_EVENT_NOTIFICATION_LIST:
{
parse_event_notifications_list((EventNotificationList *)setting->val.notificationlistptr,
Expand Down Expand Up @@ -1394,6 +1411,11 @@ dump_config(void)
case CONFIG_CONNECTION_CHECK_TYPE:
printf("%s", print_connection_check_type(*setting->val.checktypeptr));
break;
case CONFIG_REPLICATION_TYPE:
{
printf("%s", print_replication_type(*setting->val.replicationtypeptr));
break;
}
case CONFIG_EVENT_NOTIFICATION_LIST:
{
char *list = print_event_notification_list(setting->val.notificationlistptr);
Expand Down Expand Up @@ -2167,6 +2189,20 @@ parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_opti
}


const char *
print_replication_type(ReplicationType type)
{
switch (type)
{
case REPLICATION_TYPE_PHYSICAL:
return "physical";
}

/* should never reach here */
return "UNKNOWN";
}


const char *
print_connection_check_type(ConnectionCheckType type)
{
Expand Down
13 changes: 11 additions & 2 deletions configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ typedef enum
CHECK_CONNECTION
} ConnectionCheckType;

typedef enum
{
REPLICATION_TYPE_PHYSICAL
} ReplicationType;

typedef struct EventNotificationListCell
{
struct EventNotificationListCell *next;
Expand Down Expand Up @@ -86,7 +91,8 @@ typedef enum
CONFIG_FAILOVER_MODE,
CONFIG_CONNECTION_CHECK_TYPE,
CONFIG_EVENT_NOTIFICATION_LIST,
CONFIG_TABLESPACE_MAPPING
CONFIG_TABLESPACE_MAPPING,
CONFIG_REPLICATION_TYPE
} ConfigItemType;


Expand All @@ -103,13 +109,15 @@ typedef struct ConfigFileSetting
ConnectionCheckType *checktypeptr;
EventNotificationList *notificationlistptr;
TablespaceList *tablespacemappingptr;
ReplicationType *replicationtypeptr;
} val;
union {
int intdefault;
const char *strdefault;
bool booldefault;
failover_mode_opt failovermodedefault;
ConnectionCheckType checktypedefault;
ReplicationType replicationtypedefault;
} defval;
union {
int intminval;
Expand Down Expand Up @@ -138,7 +146,7 @@ typedef struct
char config_directory[MAXPGPATH];
char pg_bindir[MAXPGPATH];
char repmgr_bindir[MAXPGPATH];
int replication_type;
ReplicationType replication_type;

/* log settings */
char log_level[MAXLEN];
Expand Down Expand Up @@ -356,6 +364,7 @@ const char *format_failover_mode(failover_mode_opt failover);
void exit_with_cli_errors(ItemList *error_list, const char *repmgr_command);

void print_item_list(ItemList *item_list);
const char *print_replication_type(ReplicationType type);
const char *print_connection_check_type(ConnectionCheckType type);
char *print_event_notification_list(EventNotificationList *list);
char *print_tablespace_mapping(TablespaceList *tablespacemappingptr);
Expand Down
3 changes: 1 addition & 2 deletions repmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@
#define MIN_SUPPORTED_VERSION "9.4"
#define MIN_SUPPORTED_VERSION_NUM 90400

#define REPLICATION_TYPE_PHYSICAL 1

#define UNKNOWN_SERVER_VERSION_NUM -1
#define UNKNOWN_REPMGR_VERSION_NUM -1

Expand Down Expand Up @@ -122,6 +120,7 @@
#define DEFAULT_NODE_REJOIN_TIMEOUT 60 /* seconds */
#define DEFAULT_ARCHIVE_READY_WARNING 16 /* WAL files */
#define DEFAULT_ARCHIVE_READY_CRITICAL 128 /* WAL files */
#define DEFAULT_REPLICATION_TYPE REPLICATION_TYPE_PHYSICAL
#define DEFAULT_REPLICATION_LAG_WARNING 300 /* seconds */
#define DEFAULT_REPLICATION_LAG_CRITICAL 600 /* seconds */
#define DEFAULT_WITNESS_SYNC_INTERVAL 15 /* seconds */
Expand Down

0 comments on commit 293e376

Please sign in to comment.