mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 08:06:29 +00:00
Add sanity checks to be sure pg_rewind can be used before executing a switchover
This commit is contained in:
31
dbutils.c
31
dbutils.c
@@ -26,6 +26,8 @@
|
||||
#include "strutil.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "catalog/pg_control.h"
|
||||
|
||||
char repmgr_schema[MAXLEN] = "";
|
||||
char repmgr_schema_quoted[MAXLEN] = "";
|
||||
|
||||
@@ -1709,3 +1711,32 @@ parse_node_type(const char *type)
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
get_data_checksum_version(const char *data_directory)
|
||||
{
|
||||
ControlFileData control_file;
|
||||
int fd;
|
||||
char control_file_path[MAXPGPATH];
|
||||
|
||||
snprintf(control_file_path, MAXPGPATH, "%s/global/pg_control", data_directory);
|
||||
if ((fd = open(control_file_path, O_RDONLY | PG_BINARY, 0)) == -1)
|
||||
{
|
||||
log_err(_("Unable to open control file \"%s\" for reading: %s\n"),
|
||||
control_file_path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read(fd, &control_file, sizeof(ControlFileData)) != sizeof(ControlFileData))
|
||||
{
|
||||
log_err(_("could not read file \"%s\": %s\n"),
|
||||
control_file_path, strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return (int)control_file.data_checksum_version;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user