Skip to content

Commit 08aa89b

Browse files
committed
Remove COMMIT_TS_SETTS record.
Commit 438fc4a prevented the WAL replay from writing COMMIT_TS_SETTS record. By this change there is no code that generates COMMIT_TS_SETTS record in PostgreSQL core. Also we can think that there are no extensions using the record because we've not received so far any complaints about the issue that commit 438fc4a fixed. Therefore this commit removes COMMIT_TS_SETTS record and its related code. Even without this record, the timestamp required for commit timestamp feature can be acquired from the COMMIT record. Bump WAL page magic. Reported-by: lx zou <zoulx1982@163.com> Author: Fujii Masao Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/16931-620d0f2fdc6108f1@postgresql.org
1 parent df5efaf commit 08aa89b

File tree

6 files changed

+6
-96
lines changed

6 files changed

+6
-96
lines changed

src/backend/access/rmgrdesc/committsdesc.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,6 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
3838
appendStringInfo(buf, "pageno %d, oldestXid %u",
3939
trunc->pageno, trunc->oldestXid);
4040
}
41-
else if (info == COMMIT_TS_SETTS)
42-
{
43-
xl_commit_ts_set *xlrec = (xl_commit_ts_set *) rec;
44-
int nsubxids;
45-
46-
appendStringInfo(buf, "set %s/%d for: %u",
47-
timestamptz_to_str(xlrec->timestamp),
48-
xlrec->nodeid,
49-
xlrec->mainxid);
50-
nsubxids = ((XLogRecGetDataLen(record) - SizeOfCommitTsSet) /
51-
sizeof(TransactionId));
52-
if (nsubxids > 0)
53-
{
54-
int i;
55-
TransactionId *subxids;
56-
57-
subxids = palloc(sizeof(TransactionId) * nsubxids);
58-
memcpy(subxids,
59-
XLogRecGetData(record) + SizeOfCommitTsSet,
60-
sizeof(TransactionId) * nsubxids);
61-
for (i = 0; i < nsubxids; i++)
62-
appendStringInfo(buf, ", %u", subxids[i]);
63-
pfree(subxids);
64-
}
65-
}
6641
}
6742

6843
const char *
@@ -74,8 +49,6 @@ commit_ts_identify(uint8 info)
7449
return "ZEROPAGE";
7550
case COMMIT_TS_TRUNCATE:
7651
return "TRUNCATE";
77-
case COMMIT_TS_SETTS:
78-
return "SETTS";
7952
default:
8053
return NULL;
8154
}

src/backend/access/transam/commit_ts.c

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ static void ActivateCommitTs(void);
114114
static void DeactivateCommitTs(void);
115115
static void WriteZeroPageXlogRec(int pageno);
116116
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
117-
static void WriteSetTimestampXlogRec(TransactionId mainxid, int nsubxids,
118-
TransactionId *subxids, TimestampTz timestamp,
119-
RepOriginId nodeid);
120117

121118
/*
122119
* TransactionTreeSetCommitTsData
@@ -133,18 +130,11 @@ static void WriteSetTimestampXlogRec(TransactionId mainxid, int nsubxids,
133130
* permanent) so we need to keep the information about them here. If the
134131
* subtrans implementation changes in the future, we might want to revisit the
135132
* decision of storing timestamp info for each subxid.
136-
*
137-
* The write_xlog parameter tells us whether to include an XLog record of this
138-
* or not. Normally, this is called from transaction commit routines (both
139-
* normal and prepared) and the information will be stored in the transaction
140-
* commit XLog record, and so they should pass "false" for this. The XLog redo
141-
* code should use "false" here as well. Other callers probably want to pass
142-
* true, so that the given values persist in case of crashes.
143133
*/
144134
void
145135
TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
146136
TransactionId *subxids, TimestampTz timestamp,
147-
RepOriginId nodeid, bool write_xlog)
137+
RepOriginId nodeid)
148138
{
149139
int i;
150140
TransactionId headxid;
@@ -161,13 +151,6 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
161151
if (!commitTsShared->commitTsActive)
162152
return;
163153

164-
/*
165-
* Comply with the WAL-before-data rule: if caller specified it wants this
166-
* value to be recorded in WAL, do so before touching the data.
167-
*/
168-
if (write_xlog)
169-
WriteSetTimestampXlogRec(xid, nsubxids, subxids, timestamp, nodeid);
170-
171154
/*
172155
* Figure out the latest Xid in this batch: either the last subxid if
173156
* there's any, otherwise the parent xid.
@@ -993,28 +976,6 @@ WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
993976
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_TRUNCATE);
994977
}
995978

996-
/*
997-
* Write a SETTS xlog record
998-
*/
999-
static void
1000-
WriteSetTimestampXlogRec(TransactionId mainxid, int nsubxids,
1001-
TransactionId *subxids, TimestampTz timestamp,
1002-
RepOriginId nodeid)
1003-
{
1004-
xl_commit_ts_set record;
1005-
1006-
record.timestamp = timestamp;
1007-
record.nodeid = nodeid;
1008-
record.mainxid = mainxid;
1009-
1010-
XLogBeginInsert();
1011-
XLogRegisterData((char *) &record,
1012-
offsetof(xl_commit_ts_set, mainxid) +
1013-
sizeof(TransactionId));
1014-
XLogRegisterData((char *) subxids, nsubxids * sizeof(TransactionId));
1015-
XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_SETTS);
1016-
}
1017-
1018979
/*
1019980
* CommitTS resource manager's routines
1020981
*/
@@ -1055,29 +1016,6 @@ commit_ts_redo(XLogReaderState *record)
10551016

10561017
SimpleLruTruncate(CommitTsCtl, trunc->pageno);
10571018
}
1058-
else if (info == COMMIT_TS_SETTS)
1059-
{
1060-
xl_commit_ts_set *setts = (xl_commit_ts_set *) XLogRecGetData(record);
1061-
int nsubxids;
1062-
TransactionId *subxids;
1063-
1064-
nsubxids = ((XLogRecGetDataLen(record) - SizeOfCommitTsSet) /
1065-
sizeof(TransactionId));
1066-
if (nsubxids > 0)
1067-
{
1068-
subxids = palloc(sizeof(TransactionId) * nsubxids);
1069-
memcpy(subxids,
1070-
XLogRecGetData(record) + SizeOfCommitTsSet,
1071-
sizeof(TransactionId) * nsubxids);
1072-
}
1073-
else
1074-
subxids = NULL;
1075-
1076-
TransactionTreeSetCommitTsData(setts->mainxid, nsubxids, subxids,
1077-
setts->timestamp, setts->nodeid, false);
1078-
if (subxids)
1079-
pfree(subxids);
1080-
}
10811019
else
10821020
elog(PANIC, "commit_ts_redo: unknown op code %u", info);
10831021
}

src/backend/access/transam/twophase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
22462246

22472247
TransactionTreeSetCommitTsData(xid, nchildren, children,
22482248
replorigin_session_origin_timestamp,
2249-
replorigin_session_origin, false);
2249+
replorigin_session_origin);
22502250

22512251
/*
22522252
* We don't currently try to sleep before flush here ... nor is there any

src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ RecordTransactionCommit(void)
13661366

13671367
TransactionTreeSetCommitTsData(xid, nchildren, children,
13681368
replorigin_session_origin_timestamp,
1369-
replorigin_session_origin, false);
1369+
replorigin_session_origin);
13701370
}
13711371

13721372
/*
@@ -5804,7 +5804,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
58045804

58055805
/* Set the transaction commit timestamp and metadata */
58065806
TransactionTreeSetCommitTsData(xid, parsed->nsubxacts, parsed->subxacts,
5807-
commit_time, origin_id, false);
5807+
commit_time, origin_id);
58085808

58095809
if (standbyState == STANDBY_DISABLED)
58105810
{

src/include/access/commit_ts.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern bool check_track_commit_timestamp(bool *newval, void **extra,
2525

2626
extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
2727
TransactionId *subxids, TimestampTz timestamp,
28-
RepOriginId nodeid, bool write_xlog);
28+
RepOriginId nodeid);
2929
extern bool TransactionIdGetCommitTsData(TransactionId xid,
3030
TimestampTz *ts, RepOriginId *nodeid);
3131
extern TransactionId GetLatestCommitTsData(TimestampTz *ts,
@@ -50,7 +50,6 @@ extern int committssyncfiletag(const FileTag *ftag, char *path);
5050
/* XLOG stuff */
5151
#define COMMIT_TS_ZEROPAGE 0x00
5252
#define COMMIT_TS_TRUNCATE 0x10
53-
#define COMMIT_TS_SETTS 0x20
5453

5554
typedef struct xl_commit_ts_set
5655
{

src/include/access/xlog_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/*
3232
* Each page of XLOG file has a header like this:
3333
*/
34-
#define XLOG_PAGE_MAGIC 0xD10C /* can be used as WAL version indicator */
34+
#define XLOG_PAGE_MAGIC 0xD10D /* can be used as WAL version indicator */
3535

3636
typedef struct XLogPageHeaderData
3737
{

0 commit comments

Comments
 (0)