pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: zhq651@126.com
Subject: BUG #15791: WalSndCtl->sync_standbys_defined modified too late
Date: Sun, 05 May 2019 08:56:08 +0000
Message-ID: <15791-eac704d9ebfbdfea@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15791
Logged by:          DamionZ Zhao
Email address:      zhq651@126.com
PostgreSQL version: 11.2
Operating system:   linux
Description:        

1.when commit transaction, we need to kwow it is sync or async . There is a
step : call function SyncRepWaitForLSN in function
RecordTransactionCommit.

void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
{
        ....
	if (!WalSndCtl->sync_standbys_defined ||
		lsn <= WalSndCtl->lsn[mode] )
	{
                ...
		return;
	}
}

2.when modify WalSndCtl->sync_standbys_defined?  

2.1 in function SyncRepUpdateSyncStandbysDefined,
WalSndCtl->sync_standbys_defined will be modified.
----------------------------------------------------
void SyncRepUpdateSyncStandbysDefined(void)
{
	bool		sync_standbys_defined = SyncStandbysDefined();

	if (sync_standbys_defined != WalSndCtl->sync_standbys_defined)
	{
		
		WalSndCtl->sync_standbys_defined = sync_standbys_defined;
		LWLockRelease(SyncRepLock);
	}
}

2.2 SyncRepUpdateSyncStandbysDefined call stack is:
------------------------------------------
(1)CheckpointerMain(start checkpoint)-
	UpdateSharedMemoryConfig
		SyncRepUpdateSyncStandbysDefined
(2)CheckPointGuts --	Flush all data in shared memory to disk, and fsync	
	CheckPointBuffers	--Flush all dirty blocks in buffer pool to disk at
checkpoint time.
		BufferSync	-- Write out all dirty buffers in the pool.	
			CheckpointWriteDelay
				UpdateSharedMemoryConfig
					SyncRepUpdateSyncStandbysDefined

2.3 when any checkpoint situation happened, WalSndCtl->sync_standbys_defined
will be modified.

3.my question:
----------------

when modify synchronous_standby_names in postgres.conf, and no checkpoint
happenes, will  synchronous_standby_names  take effect?



view thread (3+ messages)  latest in thread

Message-ID: <15791-eac704d9ebfbdfea@postgresql.org>
Permalink:  ../15791-eac704d9ebfbdfea@postgresql.org/
Also on:    postgresql.org/message-id/15791-eac704d9ebfbdfea@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, zhq651@126.com
  Subject: Re: BUG #15791: WalSndCtl->sync_standbys_defined modified too late
  In-Reply-To: <15791-eac704d9ebfbdfea@postgresql.org>
  References: <15791-eac704d9ebfbdfea@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox