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

Commitdad1f46

Browse files
committed
TransferPredicateLocksToNewTarget should initialize a new lock
entry's commitSeqNo to that of the old one being transferred, or takethe minimum commitSeqNo if it is merging two lock entries.Also, CreatePredicateLock should initialize commitSeqNo for toInvalidSerCommitSeqNo instead of to 0. (I don't think using 0 wouldactually affect anything, but we should be consistent.)I also added a couple of assertions I used to track this down: alock's commitSeqNo should never be zero, and it should beInvalidSerCommitSeqNo if and only if the lock is not held byOldCommittedSxact.Dan Ports, to fix leak of predicate locks reported by YAMAMOTO Takashi.
1 parent7c797e7 commitdad1f46

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
20742074
SHMQueueInsertBefore(&(target->predicateLocks),&(lock->targetLink));
20752075
SHMQueueInsertBefore(&(sxact->predicateLocks),
20762076
&(lock->xactLink));
2077-
lock->commitSeqNo=0;
2077+
lock->commitSeqNo=InvalidSerCommitSeqNo;
20782078
}
20792079

20802080
LWLockRelease(partitionLock);
@@ -2508,6 +2508,7 @@ TransferPredicateLocksToNewTarget(const PREDICATELOCKTARGETTAG oldtargettag,
25082508
SHM_QUEUE*predlocktargetlink;
25092509
PREDICATELOCK*nextpredlock;
25102510
PREDICATELOCK*newpredlock;
2511+
SerCommitSeqNooldCommitSeqNo=oldpredlock->commitSeqNo;
25112512

25122513
predlocktargetlink=&(oldpredlock->targetLink);
25132514
nextpredlock= (PREDICATELOCK*)
@@ -2552,8 +2553,17 @@ TransferPredicateLocksToNewTarget(const PREDICATELOCKTARGETTAG oldtargettag,
25522553
&(newpredlock->targetLink));
25532554
SHMQueueInsertBefore(&(newpredlocktag.myXact->predicateLocks),
25542555
&(newpredlock->xactLink));
2555-
newpredlock->commitSeqNo=InvalidSerCommitSeqNo;
2556+
newpredlock->commitSeqNo=oldCommitSeqNo;
25562557
}
2558+
else
2559+
{
2560+
if (newpredlock->commitSeqNo<oldCommitSeqNo)
2561+
newpredlock->commitSeqNo=oldCommitSeqNo;
2562+
}
2563+
2564+
Assert(newpredlock->commitSeqNo!=0);
2565+
Assert((newpredlock->commitSeqNo==InvalidSerCommitSeqNo)
2566+
|| (newpredlock->tag.myXact==OldCommittedSxact));
25572567

25582568
oldpredlock=nextpredlock;
25592569
}
@@ -3137,6 +3147,8 @@ ClearOldPredicateLocks(void)
31373147
offsetof(PREDICATELOCK,xactLink));
31383148

31393149
LWLockAcquire(SerializableXactHashLock,LW_SHARED);
3150+
Assert(predlock->commitSeqNo!=0);
3151+
Assert(predlock->commitSeqNo!=InvalidSerCommitSeqNo);
31403152
canDoPartialCleanup= (predlock->commitSeqNo <=PredXact->CanPartialClearThrough);
31413153
LWLockRelease(SerializableXactHashLock);
31423154

@@ -3261,6 +3273,8 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
32613273
errhint("You might need to increase max_pred_locks_per_transaction.")));
32623274
if (found)
32633275
{
3276+
Assert(predlock->commitSeqNo!=0);
3277+
Assert(predlock->commitSeqNo!=InvalidSerCommitSeqNo);
32643278
if (predlock->commitSeqNo<sxact->commitSeqNo)
32653279
predlock->commitSeqNo=sxact->commitSeqNo;
32663280
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp