Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit977654d

Browse files
committed
Massimo's Deadlock patches w/o the #ifdefs
1 parent766bdd2 commit977654d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎src/backend/commands/async.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.12 1997/01/24 23:48:25 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.13 1997/03/10 00:18:09 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -84,6 +84,8 @@
8484

8585
#include<port-protos.h>/* for strdup() */
8686

87+
#include<storage/lmgr.h>
88+
8789
staticintnotifyFrontEndPending=0;
8890
staticintnotifyIssued=0;
8991
staticDllist*pendingNotifies=NULL;
@@ -194,6 +196,7 @@ Async_Notify(char *relname)
194196

195197
lRel=heap_openr(ListenerRelationName);
196198
tdesc=RelationGetTupleDescriptor(lRel);
199+
RelationSetLockForWrite(lRel);
197200
sRel=heap_beginscan(lRel,0,NowTimeQual,1,&key);
198201

199202
nulls[0]=nulls[1]=nulls[2]=' ';
@@ -212,6 +215,7 @@ Async_Notify(char *relname)
212215
ReleaseBuffer(b);
213216
}
214217
heap_endscan(sRel);
218+
RelationUnsetLockForWrite(lRel);
215219
heap_close(lRel);
216220
notifyIssued=1;
217221
}
@@ -269,6 +273,7 @@ Async_NotifyAtCommit()
269273
Integer32EqualRegProcedure,
270274
Int32GetDatum(1));
271275
lRel=heap_openr(ListenerRelationName);
276+
RelationSetLockForWrite(lRel);
272277
sRel=heap_beginscan(lRel,0,NowTimeQual,1,&key);
273278
tdesc=RelationGetTupleDescriptor(lRel);
274279
ourpid=getpid();
@@ -302,6 +307,7 @@ Async_NotifyAtCommit()
302307
ReleaseBuffer(b);
303308
}
304309
heap_endscan(sRel);
310+
RelationUnsetLockForWrite(lRel);
305311
heap_close(lRel);
306312

307313
CommitTransactionCommand();
@@ -405,6 +411,7 @@ Async_Listen(char *relname, int pid)
405411
values[i++]= (Datum)0;/* no notifies pending */
406412

407413
lDesc=heap_openr(ListenerRelationName);
414+
RelationSetLockForWrite(lDesc);
408415

409416
/* is someone already listening. One listener per relation */
410417
tdesc=RelationGetTupleDescriptor(lDesc);
@@ -440,6 +447,8 @@ Async_Listen(char *relname, int pid)
440447
/* if (alreadyListener) {
441448
elog(NOTICE,"Async_Listen: already one listener on %s (possibly dead)",relname);
442449
}*/
450+
451+
RelationUnsetLockForWrite(lDesc);
443452
heap_close(lDesc);
444453

445454
/*
@@ -480,9 +489,13 @@ Async_Unlisten(char *relname, int pid)
480489
Int32GetDatum(pid),
481490
0,0);
482491
lDesc=heap_openr(ListenerRelationName);
492+
RelationSetLockForWrite(lDesc);
493+
483494
if (lTuple!=NULL) {
484495
heap_delete(lDesc,&lTuple->t_ctid);
485496
}
497+
498+
RelationUnsetLockForWrite(lDesc);
486499
heap_close(lDesc);
487500
}
488501

@@ -549,6 +562,7 @@ Async_NotifyFrontEnd()
549562
Integer32EqualRegProcedure,
550563
Int32GetDatum(ourpid));
551564
lRel=heap_openr(ListenerRelationName);
565+
RelationSetLockForWrite(lRel);
552566
tdesc=RelationGetTupleDescriptor(lRel);
553567
sRel=heap_beginscan(lRel,0,NowTimeQual,2,key);
554568

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp