diff options
| author | Simon Riggs | 2010-01-10 15:44:28 +0000 |
|---|---|---|
| committer | Simon Riggs | 2010-01-10 15:44:28 +0000 |
| commit | 3bfcccc2954ce251e2aea6503c0d937c493db781 (patch) | |
| tree | 4f8aa5492ae4baa610027cf97e2b5cd5920a3fb7 /src/backend/storage/ipc/procarray.c | |
| parent | 87091cb1f1ed914e2ddca424fa28f94fdf8461d2 (diff) | |
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
Diffstat (limited to 'src/backend/storage/ipc/procarray.c')
| -rw-r--r-- | src/backend/storage/ipc/procarray.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index ccaf8420f5d..01a7c2123f1 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -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 $ * *------------------------------------------------------------------------- */ @@ -1827,6 +1827,32 @@ CountDBBackends(Oid databaseid) } /* + * 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 */ int |
