Content-Length: 265138 | pFad | http://github.com/postgrespro/postgres_cluster/commit/fddf45b38097d14301d249fbeebca32e40233bd2

29 Plug race in dsa_attach. · postgrespro/postgres_cluster@fddf45b · GitHub
Skip to content

Commit fddf45b

Browse files
committed
Plug race in dsa_attach.
With sufficiently bad luck, it was possible for a parallel worker to attempt attach to a DSA area after all other backends have detached from it, which is not legal. If the worker had waited a little longer to get started, the DSM itself would have been destroyed, which is why this wasn't noticed before. Thomas Munro, per a report from Andreas Seltenreich Discussion: http://postgr.es/m/87h92g83t3.fsf@credativ.de
1 parent 3582b22 commit fddf45b

File tree

1 file changed

+7
-0
lines changed
  • src/backend/utils/mmgr

1 file changed

+7
-0
lines changed

src/backend/utils/mmgr/dsa.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,13 @@ attach_internal(void *place, dsm_segment *segment, dsa_handle handle)
13141314

13151315
/* Bump the reference count. */
13161316
LWLockAcquire(DSA_AREA_LOCK(area), LW_EXCLUSIVE);
1317+
if (control->refcnt == 0)
1318+
{
1319+
/* We can't attach to a DSA area that has already been destroyed. */
1320+
ereport(ERROR,
1321+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1322+
errmsg("could not attach to dsa_area")));
1323+
}
13171324
++control->refcnt;
13181325
LWLockRelease(DSA_AREA_LOCK(area));
13191326

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/fddf45b38097d14301d249fbeebca32e40233bd2

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy