mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 21:57:20 +02:00
Disable synchronous commits in pg_rewind.
If you point pg_rewind to a server that is using synchronous replication, with "pg_rewind --source-server=...", and the replication is not working for some reason, pg_rewind will get stuck because it creates a temporary table, which needs to be replicated. You could call broken replication a pilot error, but pg_rewind is often used in special circumstances, when there are changes to the replication setup. We don't do any "real" updates, and we don't care about fsyncing or replicating the operations on the temporary tables, so fix that by setting synchronous_commit off. Michael Banck, Michael Paquier. Backpatch to 9.5, where pg_rewind was introduced. Discussion: <20161005143938.GA12247@nighthawk.caipicrew.dd-dns.de>
This commit is contained in:
parent
ce603a34a4
commit
69da71254b
@ -49,6 +49,7 @@ void
|
|||||||
libpqConnect(const char *connstr)
|
libpqConnect(const char *connstr)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
PGresult *res;
|
||||||
|
|
||||||
conn = PQconnectdb(connstr);
|
conn = PQconnectdb(connstr);
|
||||||
if (PQstatus(conn) == CONNECTION_BAD)
|
if (PQstatus(conn) == CONNECTION_BAD)
|
||||||
@ -77,6 +78,19 @@ libpqConnect(const char *connstr)
|
|||||||
if (strcmp(str, "on") != 0)
|
if (strcmp(str, "on") != 0)
|
||||||
pg_fatal("full_page_writes must be enabled in the source server\n");
|
pg_fatal("full_page_writes must be enabled in the source server\n");
|
||||||
pg_free(str);
|
pg_free(str);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Although we don't do any "real" updates, we do work with a temporary
|
||||||
|
* table. We don't care about synchronous commit for that. It doesn't
|
||||||
|
* otherwise matter much, but if the server is using synchronous
|
||||||
|
* replication, and replication isn't working for some reason, we don't
|
||||||
|
* want to get stuck, waiting for it to start working again.
|
||||||
|
*/
|
||||||
|
res = PQexec(conn, "SET synchronous_commit = off");
|
||||||
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
|
pg_fatal("could not set up connection context: %s",
|
||||||
|
PQresultErrorMessage(res));
|
||||||
|
PQclear(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user