Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e5eb4fa

Browse files
committed
Remove obsolete SLRU wrapping and warnings from predicate.c.
When SSI was developed, slru.c was limited to segment files with names in the range 0000-FFFF. This didn't allow enough space for predicate.c to store every possible XID when spilling old transactions to disk, so it would wrap around sooner and print warnings. Since commits 638cf09 and 73c986a increased the number of segment files slru.c could manage, that behavior is unnecessary. Therefore remove that code. Also remove the macro OldSerXidSegment, which has been unused since 4cd3fb6. Thomas Munro, reviewed by Anastasia Lubennikova Discussion: https://postgr.es/m/CAEepm=3XfsTSxgEbEOmxu0QDiXy0o18NUg2nC89JZcCGE+XFPA@mail.gmail.com
1 parent 1bb9e73 commit e5eb4fa

File tree

1 file changed

+3
-49
lines changed

1 file changed

+3
-49
lines changed

src/backend/storage/lmgr/predicate.c

+3-49
Original file line numberDiff line numberDiff line change
@@ -318,27 +318,23 @@ static SlruCtlData OldSerXidSlruCtlData;
318318
#define OLDSERXID_ENTRIESPERPAGE (OLDSERXID_PAGESIZE / OLDSERXID_ENTRYSIZE)
319319

320320
/*
321-
* Set maximum pages based on the lesser of the number needed to track all
322-
* transactions and the maximum that SLRU supports.
321+
* Set maximum pages based on the number needed to track all transactions.
323322
*/
324-
#define OLDSERXID_MAX_PAGE Min(SLRU_PAGES_PER_SEGMENT * 0x10000 - 1, \
325-
(MaxTransactionId) / OLDSERXID_ENTRIESPERPAGE)
323+
#define OLDSERXID_MAX_PAGE (MaxTransactionId / OLDSERXID_ENTRIESPERPAGE)
326324

327325
#define OldSerXidNextPage(page) (((page) >= OLDSERXID_MAX_PAGE) ? 0 : (page) + 1)
328326

329327
#define OldSerXidValue(slotno, xid) (*((SerCommitSeqNo *) \
330328
(OldSerXidSlruCtl->shared->page_buffer[slotno] + \
331329
((((uint32) (xid)) % OLDSERXID_ENTRIESPERPAGE) * OLDSERXID_ENTRYSIZE))))
332330

333-
#define OldSerXidPage(xid) ((((uint32) (xid)) / OLDSERXID_ENTRIESPERPAGE) % (OLDSERXID_MAX_PAGE + 1))
334-
#define OldSerXidSegment(page) ((page) / SLRU_PAGES_PER_SEGMENT)
331+
#define OldSerXidPage(xid) (((uint32) (xid)) / OLDSERXID_ENTRIESPERPAGE)
335332

336333
typedef struct OldSerXidControlData
337334
{
338335
int headPage; /* newest initialized page */
339336
TransactionId headXid; /* newest valid Xid in the SLRU */
340337
TransactionId tailXid; /* oldest xmin we might be interested in */
341-
bool warningIssued; /* have we issued SLRU wrap-around warning? */
342338
} OldSerXidControlData;
343339

344340
typedef struct OldSerXidControlData *OldSerXidControl;
@@ -826,7 +822,6 @@ OldSerXidInit(void)
826822
oldSerXidControl->headPage = -1;
827823
oldSerXidControl->headXid = InvalidTransactionId;
828824
oldSerXidControl->tailXid = InvalidTransactionId;
829-
oldSerXidControl->warningIssued = false;
830825
}
831826
}
832827

@@ -882,47 +877,6 @@ OldSerXidAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
882877
if (isNewPage)
883878
oldSerXidControl->headPage = targetPage;
884879

885-
/*
886-
* Give a warning if we're about to run out of SLRU pages.
887-
*
888-
* slru.c has a maximum of 64k segments, with 32 (SLRU_PAGES_PER_SEGMENT)
889-
* pages each. We need to store a 64-bit integer for each Xid, and with
890-
* default 8k block size, 65536*32 pages is only enough to cover 2^30
891-
* XIDs. If we're about to hit that limit and wrap around, warn the user.
892-
*
893-
* To avoid spamming the user, we only give one warning when we've used 1
894-
* billion XIDs, and stay silent until the situation is fixed and the
895-
* number of XIDs used falls below 800 million again.
896-
*
897-
* XXX: We have no safeguard to actually *prevent* the wrap-around,
898-
* though. All you get is a warning.
899-
*/
900-
if (oldSerXidControl->warningIssued)
901-
{
902-
TransactionId lowWatermark;
903-
904-
lowWatermark = tailXid + 800000000;
905-
if (lowWatermark < FirstNormalTransactionId)
906-
lowWatermark = FirstNormalTransactionId;
907-
if (TransactionIdPrecedes(xid, lowWatermark))
908-
oldSerXidControl->warningIssued = false;
909-
}
910-
else
911-
{
912-
TransactionId highWatermark;
913-
914-
highWatermark = tailXid + 1000000000;
915-
if (highWatermark < FirstNormalTransactionId)
916-
highWatermark = FirstNormalTransactionId;
917-
if (TransactionIdFollows(xid, highWatermark))
918-
{
919-
oldSerXidControl->warningIssued = true;
920-
ereport(WARNING,
921-
(errmsg("memory for serializable conflict tracking is nearly exhausted"),
922-
errhint("There might be an idle transaction or a forgotten prepared transaction causing this.")));
923-
}
924-
}
925-
926880
if (isNewPage)
927881
{
928882
/* Initialize intervening pages. */

0 commit comments

Comments
 (0)