1 /*
2  * repmgr.h
3  * Copyright (c) 2ndQuadrant, 2010-2020
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _REPMGR_CONFIG_H
20 #define _REPMGR_CONFIG_H
21 #include <config.h>
22 #endif
23 
24 #ifdef vsnprintf
25 #undef vsnprintf
26 #endif
27 #ifdef snprintf
28 #undef snprintf
29 #endif
30 #ifdef vsprintf
31 #undef vsprintf
32 #endif
33 #ifdef sprintf
34 #undef sprintf
35 #endif
36 #ifdef vfprintf
37 #undef vfprintf
38 #endif
39 #ifdef fprintf
40 #undef fprintf
41 #endif
42 #ifdef vprintf
43 #undef vprintf
44 #endif
45 #ifdef printf
46 #undef printf
47 #endif
48 #ifdef strerror
49 #undef strerror
50 #endif
51 #ifdef strerror_r
52 #undef strerror_r
53 #endif
54 
55 #ifndef _REPMGR_H_
56 #define _REPMGR_H_
57 
58 #include <stdio.h>
59 #include <stdlib.h>
60 #include <unistd.h>
61 #include <sys/types.h>
62 #include <sys/wait.h>
63 
64 #include <libpq-fe.h>
65 #include <postgres_fe.h>
66 #include <pqexpbuffer.h>
67 
68 
69 #include "repmgr_version.h"
70 #include "errcode.h"
71 #include "strutil.h"
72 #include "configfile.h"
73 #include "dbutils.h"
74 #include "log.h"
75 #include "sysutils.h"
76 
77 #define MIN_SUPPORTED_VERSION		"9.4"
78 #define MIN_SUPPORTED_VERSION_NUM	90400
79 
80 #define REPLICATION_TYPE_PHYSICAL 1
81 
82 #define UNKNOWN_SERVER_VERSION_NUM -1
83 #define UNKNOWN_REPMGR_VERSION_NUM -1
84 
85 #define UNKNOWN_TIMELINE_ID -1
86 #define UNKNOWN_SYSTEM_IDENTIFIER 0
87 #define UNKNOWN_DATA_CHECKSUM_VERSION -1
88 #define UNKNOWN_PID			-1
89 #define UNKNOWN_REPLICATION_LAG	-1
90 #define UNKNOWN_VALUE		-1
91 
92 #define NODE_NOT_FOUND		-1
93 #define NO_UPSTREAM_NODE	-1
94 #define UNKNOWN_NODE_ID		-1
95 #define MIN_NODE_ID          1
96 #define ELECTION_RERUN_NOTIFICATION -2
97 #define VOTING_TERM_NOT_SET -1
98 #define ARCHIVE_STATUS_DIR_ERROR -1
99 #define NO_DEGRADED_MONITORING_ELAPSED -1
100 
101 #define WALRECEIVER_DISABLE_TIMEOUT_VALUE    86400000 /* milliseconds */
102 
103 /*
104  * Default command line option parameter values
105  */
106 #define DEFAULT_WAIT_START                   30  /* seconds */
107 
108 /*
109  * Default configuration file parameter values - ensure repmgr.conf.sample
110  * is update if any of these are changed
111  */
112 
113 #define DEFAULT_USE_REPLICATION_SLOTS        false
114 #define DEFAULT_USE_PRIMARY_CONNINFO_PASSWORD false
115 #define DEFAULT_PROMOTE_CHECK_TIMEOUT        60  /* seconds */
116 #define DEFAULT_PROMOTE_CHECK_INTERVAL       1   /* seconds */
117 #define DEFAULT_PRIMARY_FOLLOW_TIMEOUT       60  /* seconds */
118 #define DEFAULT_STANDBY_FOLLOW_TIMEOUT       30  /* seconds */
119 #define DEFAULT_STANDBY_FOLLOW_RESTART       false
120 #define DEFAULT_SHUTDOWN_CHECK_TIMEOUT       60  /* seconds */
121 #define DEFAULT_STANDBY_RECONNECT_TIMEOUT    60  /* seconds */
122 #define DEFAULT_NODE_REJOIN_TIMEOUT          60  /* seconds */
123 #define DEFAULT_ARCHIVE_READY_WARNING        16  /* WAL files */
124 #define DEFAULT_ARCHIVE_READY_CRITICAL       128 /* WAL files */
125 #define	DEFAULT_REPLICATION_LAG_WARNING      300 /* seconds */
126 #define DEFAULT_REPLICATION_LAG_CRITICAL     600 /* seconds */
127 #define DEFAULT_WITNESS_SYNC_INTERVAL        15  /* seconds */
128 #define DEFAULT_WAL_RECEIVE_CHECK_TIMEOUT    30  /* seconds */
129 #define DEFAULT_LOCATION                     "default"
130 #define DEFAULT_PRIORITY                     100
131 #define DEFAULT_MONITORING_INTERVAL          2	 /* seconds */
132 #define DEFAULT_RECONNECTION_ATTEMPTS        6	 /* seconds */
133 #define DEFAULT_RECONNECTION_INTERVAL        10  /* seconds */
134 #define DEFAULT_MONITORING_HISTORY           false
135 #define DEFAULT_DEGRADED_MONITORING_TIMEOUT  -1  /* seconds */
136 #define DEFAULT_ASYNC_QUERY_TIMEOUT          60  /* seconds */
137 #define DEFAULT_PRIMARY_NOTIFICATION_TIMEOUT 60  /* seconds */
138 #define DEFAULT_REPMGRD_STANDBY_STARTUP_TIMEOUT -1 /*seconds */
139 #define DEFAULT_STANDBY_DISCONNECT_ON_FAILOVER false
140 #define DEFAULT_SIBLING_NODES_DISCONNECT_TIMEOUT 30 /* seconds */
141 #define DEFAULT_CONNECTION_CHECK_TYPE        CHECK_PING
142 #define DEFAULT_PRIMARY_VISIBILITY_CONSENSUS false
143 #define DEFAULT_ALWAYS_PROMOTE               false
144 #define DEFAULT_ELECTION_RERUN_INTERVAL      15  /* seconds */
145 #define DEFAULT_CHILD_NODES_CHECK_INTERVAL   5   /* seconds */
146 #define DEFAULT_CHILD_NODES_DISCONNECT_MIN_COUNT -1
147 #define DEFAULT_CHILD_NODES_CONNECTED_MIN_COUNT -1
148 #define DEFAULT_CHILD_NODES_CONNECTED_INCLUDE_WITNESS false
149 #define DEFAULT_CHILD_NODES_DISCONNECT_TIMEOUT 30 /* seconds */
150 #define DEFAULT_SSH_OPTIONS                  "-q -o ConnectTimeout=10"
151 
152 
153 #ifndef RECOVERY_COMMAND_FILE
154 #define RECOVERY_COMMAND_FILE "recovery.conf"
155 #endif
156 
157 #ifndef STANDBY_SIGNAL_FILE
158 #define STANDBY_SIGNAL_FILE "standby.signal"
159 #define RECOVERY_SIGNAL_FILE "recovery.signal"
160 #endif
161 
162 #ifndef TABLESPACE_MAP
163 #define TABLESPACE_MAP "tablespace_map"
164 #endif
165 
166 #define REPMGR_URL "https://repmgr.org/"
167 
168 #endif							/* _REPMGR_H_ */
169