Skip to content
Snippets Groups Projects
Commit 933c953b authored by Michael Paquier's avatar Michael Paquier
Browse files

pg_rep_state: Fix one-off bug insufficient lock in WAL sender lookups

When checking for the PID of active backends, make sure that those lookups
are protected by ProcArrayLock. At the same time fix a one-off bug in the
proc array lookup, which would lead to looking at an unwanted memory area.

Both issues have been pointed out by Peter Geoghegan offlist.
parent a4111375
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -72,8 +72,9 @@ pg_syncrep_state(PG_FUNCTION_ARGS)
rsinfo->setDesc = tupdesc;
MemoryContextSwitchTo(oldcontext);
 
LWLockAcquire(ProcArrayLock, LW_SHARED);
LWLockAcquire(SyncRepLock, LW_SHARED);
for (i = 0; i <= ProcGlobal->allProcCount; i++)
for (i = 0; i < ProcGlobal->allProcCount; i++)
{
Datum values[3];
bool nulls[3];
Loading
Loading
@@ -130,6 +131,7 @@ pg_syncrep_state(PG_FUNCTION_ARGS)
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
}
LWLockRelease(SyncRepLock);
LWLockRelease(ProcArrayLock);
 
/* clean up and return the tuplestore */
tuplestore_donestoring(tupstore);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment