Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a56dc3

Browse files
committed
Fix various possible problems with synchronous replication.
1. Don't ignore query cancel interrupts. Instead, if the user asks tocancel the query after we've already committed it, but before it's onthe standby, just emit a warning and let the COMMIT finish.2. Don't ignore die interrupts (pg_terminate_backend or fast shutdown).Instead, emit a warning message and close the connection withoutacknowledging the commit. Other backends will still see the effect ofthe commit, but there's no getting around that; it's too late to abortat this point, and ignoring die interrupts altogether doesn't seem likea good idea.3. If synchronous_standby_names becomes empty, wake up all backendswaiting for synchronous replication to complete. Without this, someoneattempting to shut synchronous replication off could easily wedge theentire system instead.4. Avoid depending on the assumption that if a walsender updatesMyProc->syncRepState, we'll see the change even if we read it withoutholding the lock. The window for this appears to be quite narrow (andprobably doesn't exist at all on machines with strong memory ordering)but protecting against it is practically free, so do that.5. Remove useless state SYNC_REP_MUST_DISCONNECT, which isn't needed anddoesn't actually do anything.There's still some further work needed here to make the behavior of fastshutdown plausible, but that looks complex, so I'm leaving it for aseparate commit. Review by Fujii Masao.
1 parente148443 commit9a56dc3

File tree

6 files changed

+214
-114
lines changed

6 files changed

+214
-114
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,7 @@ SET ENABLE_SEQSCAN TO OFF;
21002100
If a standby is removed from the list of servers then it will stop
21012101
being the synchronous standby, allowing another to take its place.
21022102
If the list is empty, synchronous replication will not be
2103-
possible, whatever the setting of <varname>synchronous_replication</>,
2104-
however, already waiting commits will continue to wait.
2103+
possible, whatever the setting of <varname>synchronous_replication</>.
21052104
Standbys may also be added to the list without restarting the server.
21062105
</para>
21072106
</listitem>

‎src/backend/postmaster/walwriter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include"libpq/pqsignal.h"
5050
#include"miscadmin.h"
5151
#include"postmaster/walwriter.h"
52+
#include"replication/syncrep.h"
5253
#include"storage/bufmgr.h"
5354
#include"storage/fd.h"
5455
#include"storage/ipc.h"
@@ -216,6 +217,9 @@ WalWriterMain(void)
216217
*/
217218
PG_SETMASK(&UnBlockSig);
218219

220+
/* Do this once before starting the loop, then just at SIGHUP time. */
221+
SyncRepUpdateSyncStandbysDefined();
222+
219223
/*
220224
* Loop forever
221225
*/
@@ -237,6 +241,8 @@ WalWriterMain(void)
237241
{
238242
got_SIGHUP= false;
239243
ProcessConfigFile(PGC_SIGHUP);
244+
/* update global shmem state for sync rep */
245+
SyncRepUpdateSyncStandbysDefined();
240246
}
241247
if (shutdown_requested)
242248
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp