aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xloginsert.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-11-02 08:35:29 +0530
committerAmit Kapila <akapila@postgresql.org>2021-11-02 08:35:29 +0530
commit71db6459e6e4ef623e98f3b1e3e9fed1bfb0ae3b (patch)
tree6194a420c627bd423f9bb4f47e35384eef5a539c /src/backend/access/transam/xloginsert.c
parent43a134f28b350c4b731db9dddf2f53c407a7077f (diff)
downloadpostgresql-71db6459e6e4ef623e98f3b1e3e9fed1bfb0ae3b.tar.gz
postgresql-71db6459e6e4ef623e98f3b1e3e9fed1bfb0ae3b.zip
Replace XLOG_INCLUDE_XID flag with a more localized flag.
Commit 0bead9af484c introduced XLOG_INCLUDE_XID flag to indicate that the WAL record contains subXID-to-topXID association. It uses that flag later to mark in CurrentTransactionState that top-xid is logged so that we should not try to log it again with the next WAL record in the current subtransaction. However, we can use a localized variable to pass that information. In passing, change the related function and variable names to make them consistent with what the code is actually doing. Author: Dilip Kumar Reviewed-by: Alvaro Herrera, Amit Kapila Discussion: https://postgr.es/m/E1mSoYz-0007Fh-D9@gemulon.postgresql.org
Diffstat (limited to 'src/backend/access/transam/xloginsert.c')
-rw-r--r--src/backend/access/transam/xloginsert.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index b492c656d7a..689384a411f 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -123,7 +123,8 @@ static MemoryContext xloginsert_cxt;
static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info,
XLogRecPtr RedoRecPtr, bool doPageWrites,
- XLogRecPtr *fpw_lsn, int *num_fpi);
+ XLogRecPtr *fpw_lsn, int *num_fpi,
+ bool *topxid_included);
static bool XLogCompressBackupBlock(char *page, uint16 hole_offset,
uint16 hole_length, char *dest, uint16 *dlen);
@@ -209,10 +210,6 @@ XLogResetInsertion(void)
{
int i;
- /* reset the subxact assignment flag (if needed) */
- if (curinsert_flags & XLOG_INCLUDE_XID)
- MarkSubTransactionAssigned();
-
for (i = 0; i < max_registered_block_id; i++)
registered_buffers[i].in_use = false;
@@ -409,8 +406,6 @@ XLogRegisterBufData(uint8 block_id, char *data, int len)
* - XLOG_MARK_UNIMPORTANT, to signal that the record is not important for
* durability, which allows to avoid triggering WAL archiving and other
* background activity.
- * - XLOG_INCLUDE_XID, a message-passing hack between XLogRecordAssemble
- * and XLogResetInsertion.
*/
void
XLogSetRecordFlags(uint8 flags)
@@ -465,6 +460,7 @@ XLogInsert(RmgrId rmid, uint8 info)
{
XLogRecPtr RedoRecPtr;
bool doPageWrites;
+ bool topxid_included = false;
XLogRecPtr fpw_lsn;
XLogRecData *rdt;
int num_fpi = 0;
@@ -477,9 +473,10 @@ XLogInsert(RmgrId rmid, uint8 info)
GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,
- &fpw_lsn, &num_fpi);
+ &fpw_lsn, &num_fpi, &topxid_included);
- EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi);
+ EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi,
+ topxid_included);
} while (EndPos == InvalidXLogRecPtr);
XLogResetInsertion();
@@ -498,11 +495,14 @@ XLogInsert(RmgrId rmid, uint8 info)
* of all of them, *fpw_lsn is set to the lowest LSN among such pages. This
* signals that the assembled record is only good for insertion on the
* assumption that the RedoRecPtr and doPageWrites values were up-to-date.
+ *
+ * *topxid_included is set if the topmost transaction ID is logged with the
+ * current subtransaction.
*/
static XLogRecData *
XLogRecordAssemble(RmgrId rmid, uint8 info,
XLogRecPtr RedoRecPtr, bool doPageWrites,
- XLogRecPtr *fpw_lsn, int *num_fpi)
+ XLogRecPtr *fpw_lsn, int *num_fpi, bool *topxid_included)
{
XLogRecData *rdt;
uint32 total_len = 0;
@@ -788,12 +788,12 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
}
/* followed by toplevel XID, if not already included in previous record */
- if (IsSubTransactionAssignmentPending())
+ if (IsSubxactTopXidLogPending())
{
TransactionId xid = GetTopTransactionIdIfAny();
- /* update the flag (later used by XLogResetInsertion) */
- XLogSetRecordFlags(XLOG_INCLUDE_XID);
+ /* Set the flag that the top xid is included in the WAL */
+ *topxid_included = true;
*(scratch++) = (char) XLR_BLOCK_ID_TOPLEVEL_XID;
memcpy(scratch, &xid, sizeof(TransactionId));