PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16498
PG Version10.12
OSlinux
Opened2020-06-18 03:20:03+00
Reported byyi Ding
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16498
Logged by:          yi Ding
Email address:      (redacted)
PostgreSQL version: 10.12
Operating system:   linux
Description:        

Master PGserver:
1、Table test_1 currently has no data
postgres=# select * from test_1;
 a
---
(0 rows)

2、Synchronous streaming replication
postgres=# show synchronous_standby_names ;
 synchronous_standby_names
---------------------------
 sb2019abcd514
(1 row)

3、Stop the standby PGserver

4、Insert data

postgres=# begin;
BEGIN
postgres=# insert into test_1 values(2);
INSERT 0 1
postgres=# insert into test_1 values(3);
INSERT 0 1
postgres=# commit;

commit stuck

5、Restart the database

6、Check table test_1, data is still committed

postgres=# select * from test_1;
 a
---
2
3
(0 rows)

7、Code structure
CommitTransaction->RecordTransactionCommit::
    if ((wrote_xlog && markXidCommitted && synchronous_commit >
SYNCHRONOUS_COMMIT_OFF) || forceSyncCommit || nrels > 0){
         XLogFlush(XactLastRecEnd);
         /*
          * Now we may update the CLOG, if we wrote a COMMIT record above
          */
        if (markXidCommitted)
            TransactionIdCommitTree(xid, nchildren, children);
    }else{
        XLogSetAsyncXactLSN(XactLastRecEnd);
        if (markXidCommitted)
            TransactionIdAsyncCommitTree(xid, nchildren, children,
XactLastRecEnd);
    }
    ...
    if (wrote_xlog && markXidCommitted)
        SyncRepWaitForLSN(XactLastRecEnd, true);
	  	if (!SyncRepRequested())
	      	return;
	  	for(;;){
	     	  
	    }
    ...
#define SyncRepRequested() \
	(max_wal_senders > 0 && synchronous_commit >
SYNCHRONOUS_COMMIT_LOCAL_FLUSH)

Messages

DateAuthorSubject
2020-06-18 03:20:03+00PG Bug reporting formBUG #16498: The master inserts data successfully when the standby stopped in synchronous stream replication
2020-06-18 15:40:12+00Tom LaneRe: BUG #16498: The master inserts data successfully when the standby stopped in synchronous stream replication