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

Commit49c2c5f

Browse files
committed
Fix bugs in GetSafeSnapshotBlockingPids(), introduced in9600371
While removing the use of SHM_QUEUE from predicate.c, in9600371, I madetwo mistakes in GetSafeSnapshotBlockingPids():- Removed the check for output_size- Previously, when the first loop didn't find a matching proc, sxact would be NULL. But with naive use of dlist_foreach() it ends up as the value of the last iteration.The second issue is the cause of occasional failures in the deadlock-hard anddeadlock-soft isolation tests that we have been observing on CI. The issue wasvery hard to reproduce, as it requires the transactions.sql regression test torun at the same time as the deadlock-{hard,soft} isolation test.I did not find other similar mistakes in9600371.Discussion:https://postgr.es/m/20230208221145.bwzhancellclrgia@awork3.anarazel.de
1 parent969509c commit49c2c5f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/backend/storage/lmgr/predicate.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,29 +1563,36 @@ GetSafeSnapshotBlockingPids(int blocked_pid, int *output, int output_size)
15631563
{
15641564
intnum_written=0;
15651565
dlist_iteriter;
1566-
SERIALIZABLEXACT*sxact=NULL;
1566+
SERIALIZABLEXACT*blocking_sxact=NULL;
15671567

15681568
LWLockAcquire(SerializableXactHashLock,LW_SHARED);
15691569

15701570
/* Find blocked_pid's SERIALIZABLEXACT by linear search. */
15711571
dlist_foreach(iter,&PredXact->activeList)
15721572
{
1573-
sxact=dlist_container(SERIALIZABLEXACT,xactLink,iter.cur);
1573+
SERIALIZABLEXACT*sxact=
1574+
dlist_container(SERIALIZABLEXACT,xactLink,iter.cur);
15741575

15751576
if (sxact->pid==blocked_pid)
1577+
{
1578+
blocking_sxact=sxact;
15761579
break;
1580+
}
15771581
}
15781582

15791583
/* Did we find it, and is it currently waiting in GetSafeSnapshot? */
1580-
if (sxact!=NULL&&SxactIsDeferrableWaiting(sxact))
1584+
if (blocking_sxact!=NULL&&SxactIsDeferrableWaiting(blocking_sxact))
15811585
{
15821586
/* Traverse the list of possible unsafe conflicts collecting PIDs. */
1583-
dlist_foreach(iter,&sxact->possibleUnsafeConflicts)
1587+
dlist_foreach(iter,&blocking_sxact->possibleUnsafeConflicts)
15841588
{
15851589
RWConflictpossibleUnsafeConflict=
15861590
dlist_container(RWConflictData,inLink,iter.cur);
15871591

15881592
output[num_written++]=possibleUnsafeConflict->sxactOut->pid;
1593+
1594+
if (num_written >=output_size)
1595+
break;
15891596
}
15901597
}
15911598

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp