mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-05 10:19:21 +02:00
Fix one-off bug causing missing commit timestamps for subtransactions
The logic in charge of writing commit timestamps (enabled with
track_commit_timestamp) for subtransactions had a one-bug bug,
where it would be possible that commit timestamps go missing for the
last subtransaction committed.
While on it, simplify a bit the iteration logic in the loop writing the
commit timestamps, as per suggestions from Kyotaro Horiguchi and Tom
Lane, so as some variable initializations are not part of the loop
itself.
Issue introduced in 73c986a
.
Analyzed-by: Alex Kingsborough
Author: Alex Kingsborough, Kyotaro Horiguchi
Discussion: https://postgr.es/m/73A66172-4050-4F2A-B7F1-13508EDA2144@amazon.com
Backpatch-through: 10
This commit is contained in:
parent
f0b0b1ddb5
commit
1c0452c48c
@ -184,7 +184,9 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
|
|||||||
* subxid not on the previous page as head. This way, we only have to
|
* subxid not on the previous page as head. This way, we only have to
|
||||||
* lock/modify each SLRU page once.
|
* lock/modify each SLRU page once.
|
||||||
*/
|
*/
|
||||||
for (i = 0, headxid = xid;;)
|
headxid = xid;
|
||||||
|
i = 0;
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
int pageno = TransactionIdToCTsPage(headxid);
|
int pageno = TransactionIdToCTsPage(headxid);
|
||||||
int j;
|
int j;
|
||||||
@ -200,7 +202,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
|
|||||||
pageno);
|
pageno);
|
||||||
|
|
||||||
/* if we wrote out all subxids, we're done. */
|
/* if we wrote out all subxids, we're done. */
|
||||||
if (j + 1 >= nsubxids)
|
if (j >= nsubxids)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -208,7 +210,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
|
|||||||
* just wrote.
|
* just wrote.
|
||||||
*/
|
*/
|
||||||
headxid = subxids[j];
|
headxid = subxids[j];
|
||||||
i += j - i + 1;
|
i = j + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the cached value in shared memory */
|
/* update the cached value in shared memory */
|
||||||
|
Loading…
Reference in New Issue
Block a user