mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
During Hot Standby, fix drop database when sessions idle.
Previously we only cancelled sessions that were in-transaction. Simple fix is to just cancel all sessions without waiting. Doing it this way avoids complicating common code paths, which would not be worth the trouble to cover this rare case. Problem report and fix by Andres Freund, edited somewhat by me
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.54 2010/01/02 16:57:51 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.55 2010/01/10 15:44:28 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1826,6 +1826,32 @@ CountDBBackends(Oid databaseid)
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
* CancelDBBackends --- cancel backends that are using specified database
|
||||
*/
|
||||
void
|
||||
CancelDBBackends(Oid databaseid)
|
||||
{
|
||||
ProcArrayStruct *arrayP = procArray;
|
||||
int index;
|
||||
|
||||
/* tell all backends to die */
|
||||
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
|
||||
|
||||
for (index = 0; index < arrayP->numProcs; index++)
|
||||
{
|
||||
volatile PGPROC *proc = arrayP->procs[index];
|
||||
|
||||
if (proc->databaseId == databaseid)
|
||||
{
|
||||
proc->recoveryConflictMode = CONFLICT_MODE_FATAL;
|
||||
kill(proc->pid, SIGINT);
|
||||
}
|
||||
}
|
||||
|
||||
LWLockRelease(ProcArrayLock);
|
||||
}
|
||||
|
||||
/*
|
||||
* CountUserBackends --- count backends that are used by specified user
|
||||
*/
|
||||
|
Reference in New Issue
Block a user