mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Revert "Cannot use WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE."
This reverts commit3a9e64aa0d. Commit4bad60e3fixed the root of the problem that3a9e64aaworked around. This enables proper pipelining of commands after terminating replication, eliminating an undocumented limitation. Discussion: https://postgr.es/m/3d57bc29-4459-578b-79cb-7641baf53c57%40iki.fi Backpatch-through: 9.5
This commit is contained in:
		@@ -1440,7 +1440,12 @@ ProcessRepliesIfAny(void)
 | 
			
		||||
 | 
			
		||||
	last_processing = GetCurrentTimestamp();
 | 
			
		||||
 | 
			
		||||
	for (;;)
 | 
			
		||||
	/*
 | 
			
		||||
	 * If we already received a CopyDone from the frontend, any subsequent
 | 
			
		||||
	 * message is the beginning of a new command, and should be processed in
 | 
			
		||||
	 * the main processing loop.
 | 
			
		||||
	 */
 | 
			
		||||
	while (!streamingDoneReceiving)
 | 
			
		||||
	{
 | 
			
		||||
		pq_startmsgread();
 | 
			
		||||
		r = pq_getbyte_if_available(&firstchar);
 | 
			
		||||
@@ -1469,19 +1474,6 @@ ProcessRepliesIfAny(void)
 | 
			
		||||
			proc_exit(0);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
		 * If we already received a CopyDone from the frontend, the frontend
 | 
			
		||||
		 * should not send us anything until we've closed our end of the COPY.
 | 
			
		||||
		 * XXX: In theory, the frontend could already send the next command
 | 
			
		||||
		 * before receiving the CopyDone, but libpq doesn't currently allow
 | 
			
		||||
		 * that.
 | 
			
		||||
		 */
 | 
			
		||||
		if (streamingDoneReceiving && firstchar != 'X')
 | 
			
		||||
			ereport(FATAL,
 | 
			
		||||
					(errcode(ERRCODE_PROTOCOL_VIOLATION),
 | 
			
		||||
					 errmsg("unexpected standby message type \"%c\", after receiving CopyDone",
 | 
			
		||||
							firstchar)));
 | 
			
		||||
 | 
			
		||||
		/* Handle the very limited subset of commands expected in this phase */
 | 
			
		||||
		switch (firstchar)
 | 
			
		||||
		{
 | 
			
		||||
@@ -1963,8 +1955,10 @@ WalSndLoop(WalSndSendDataCallback send_data)
 | 
			
		||||
			long		sleeptime;
 | 
			
		||||
			int			wakeEvents;
 | 
			
		||||
 | 
			
		||||
			wakeEvents = WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_TIMEOUT |
 | 
			
		||||
				WL_SOCKET_READABLE;
 | 
			
		||||
			wakeEvents = WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_TIMEOUT;
 | 
			
		||||
 | 
			
		||||
			if (!streamingDoneReceiving)
 | 
			
		||||
				wakeEvents |= WL_SOCKET_READABLE;
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
			 * Use fresh timestamp, not last_processed, to reduce the chance
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user