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

Commit7a5e3d7

Browse files
Nikhil Sontakkearssher
Nikhil Sontakke
authored andcommitted
Cleaning up of flags in ReorderBufferTXN structure
1 parenta41bdab commit7a5e3d7

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ AssertTXNLsnOrder(ReorderBuffer *rb)
680680
Assert(prev_first_lsn<cur_txn->first_lsn);
681681

682682
/* known-as-subtxn txns must not be listed */
683-
Assert(!cur_txn->is_known_as_subxact);
683+
Assert(!rbtxn_is_known_subxact(cur_txn));
684684

685685
prev_first_lsn=cur_txn->first_lsn;
686686
}
@@ -700,7 +700,7 @@ AssertTXNLsnOrder(ReorderBuffer *rb)
700700
Assert(prev_base_snap_lsn<cur_txn->base_snapshot_lsn);
701701

702702
/* known-as-subtxn txns must not be listed */
703-
Assert(!cur_txn->is_known_as_subxact);
703+
Assert(!rbtxn_is_known_subxact(cur_txn));
704704

705705
prev_base_snap_lsn=cur_txn->base_snapshot_lsn;
706706
}
@@ -723,7 +723,7 @@ ReorderBufferGetOldestTXN(ReorderBuffer *rb)
723723

724724
txn=dlist_head_element(ReorderBufferTXN,node,&rb->toplevel_by_lsn);
725725

726-
Assert(!txn->is_known_as_subxact);
726+
Assert(!rbtxn_is_known_subxact(txn));
727727
Assert(txn->first_lsn!=InvalidXLogRecPtr);
728728
returntxn;
729729
}
@@ -783,7 +783,7 @@ ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid,
783783

784784
if (!new_sub)
785785
{
786-
if (subtxn->is_known_as_subxact)
786+
if (rbtxn_is_known_subxact(subtxn))
787787
{
788788
/* already associated, nothing to do */
789789
return;
@@ -799,7 +799,7 @@ ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid,
799799
}
800800
}
801801

802-
subtxn->is_known_as_subxact= true;
802+
subtxn->txn_flags |=RBTXN_IS_SUBXACT;
803803
subtxn->toplevel_xid=xid;
804804
Assert(subtxn->nsubtxns==0);
805805

@@ -1009,7 +1009,7 @@ ReorderBufferIterTXNInit(ReorderBuffer *rb, ReorderBufferTXN *txn)
10091009
{
10101010
ReorderBufferChange*cur_change;
10111011

1012-
if (txn->serialized)
1012+
if (rbtxn_is_serialized(txn))
10131013
{
10141014
/* serialize remaining changes */
10151015
ReorderBufferSerializeTXN(rb,txn);
@@ -1038,7 +1038,7 @@ ReorderBufferIterTXNInit(ReorderBuffer *rb, ReorderBufferTXN *txn)
10381038
{
10391039
ReorderBufferChange*cur_change;
10401040

1041-
if (cur_txn->serialized)
1041+
if (rbtxn_is_serialized(cur_txn))
10421042
{
10431043
/* serialize remaining changes */
10441044
ReorderBufferSerializeTXN(rb,cur_txn);
@@ -1204,7 +1204,7 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
12041204
* they originally were happening inside another subtxn, so we won't
12051205
* ever recurse more than one level deep here.
12061206
*/
1207-
Assert(subtxn->is_known_as_subxact);
1207+
Assert(rbtxn_is_known_subxact(subtxn));
12081208
Assert(subtxn->nsubtxns==0);
12091209

12101210
ReorderBufferCleanupTXN(rb,subtxn);
@@ -1245,7 +1245,7 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
12451245
/*
12461246
* Remove TXN from its containing list.
12471247
*
1248-
* Note: if txn->is_known_as_subxact, we are deleting the TXN from its
1248+
* Note: if txn is known as subxact, we are deleting the TXN from its
12491249
* parent's list of known subxacts; this leaves the parent's nsubxacts
12501250
* count too high, but we don't care. Otherwise, we are deleting the TXN
12511251
* from the LSN-ordered list of toplevel TXNs.
@@ -1260,7 +1260,7 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
12601260
Assert(found);
12611261

12621262
/* remove entries spilled to disk */
1263-
if (txn->serialized)
1263+
if (rbtxn_is_serialized(txn))
12641264
ReorderBufferRestoreCleanup(rb,txn);
12651265

12661266
/* deallocate */
@@ -1277,7 +1277,7 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb, ReorderBufferTXN *txn)
12771277
dlist_iteriter;
12781278
HASHCTLhash_ctl;
12791279

1280-
if (!txn->has_catalog_changes||dlist_is_empty(&txn->tuplecids))
1280+
if (!rbtxn_has_catalog_changes(txn)||dlist_is_empty(&txn->tuplecids))
12811281
return;
12821282

12831283
memset(&hash_ctl,0,sizeof(hash_ctl));
@@ -1891,7 +1891,7 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
18911891
* final_lsn to that of their last change; this causes
18921892
* ReorderBufferRestoreCleanup to do the right thing.
18931893
*/
1894-
if (txn->serialized&&txn->final_lsn==0)
1894+
if (rbtxn_is_serialized(txn)&&txn->final_lsn==0)
18951895
{
18961896
ReorderBufferChange*last=
18971897
dlist_tail_element(ReorderBufferChange,node,&txn->changes);
@@ -2039,7 +2039,7 @@ ReorderBufferSetBaseSnapshot(ReorderBuffer *rb, TransactionId xid,
20392039
* operate on its top-level transaction instead.
20402040
*/
20412041
txn=ReorderBufferTXNByXid(rb,xid, true,&is_new,lsn, true);
2042-
if (txn->is_known_as_subxact)
2042+
if (rbtxn_is_known_subxact(txn))
20432043
txn=ReorderBufferTXNByXid(rb,txn->toplevel_xid, false,
20442044
NULL,InvalidXLogRecPtr, false);
20452045
Assert(txn->base_snapshot==NULL);
@@ -2146,7 +2146,7 @@ ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid,
21462146

21472147
txn=ReorderBufferTXNByXid(rb,xid, true,NULL,lsn, true);
21482148

2149-
txn->has_catalog_changes= true;
2149+
txn->txn_flags |=RBTXN_HAS_CATALOG_CHANGES;
21502150
}
21512151

21522152
/*
@@ -2163,7 +2163,7 @@ ReorderBufferXidHasCatalogChanges(ReorderBuffer *rb, TransactionId xid)
21632163
if (txn==NULL)
21642164
return false;
21652165

2166-
returntxn->has_catalog_changes;
2166+
returnrbtxn_has_catalog_changes(txn);
21672167
}
21682168

21692169
/*
@@ -2183,7 +2183,7 @@ ReorderBufferXidHasBaseSnapshot(ReorderBuffer *rb, TransactionId xid)
21832183
return false;
21842184

21852185
/* a known subtxn? operate on top-level txn instead */
2186-
if (txn->is_known_as_subxact)
2186+
if (rbtxn_is_known_subxact(txn))
21872187
txn=ReorderBufferTXNByXid(rb,txn->toplevel_xid, false,
21882188
NULL,InvalidXLogRecPtr, false);
21892189

@@ -2304,7 +2304,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
23042304
Assert(spilled==txn->nentries_mem);
23052305
Assert(dlist_is_empty(&txn->changes));
23062306
txn->nentries_mem=0;
2307-
txn->serialized= true;
2307+
txn->txn_flags |=RBTXN_IS_SERIALIZED;
23082308

23092309
if (fd!=-1)
23102310
CloseTransientFile(fd);

‎src/include/replication/reorderbuffer.h

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,34 @@ typedef struct ReorderBufferChange
150150
dlist_nodenode;
151151
}ReorderBufferChange;
152152

153+
/* ReorderBufferTXN flags */
154+
#defineRBTXN_HAS_CATALOG_CHANGES 0x0001
155+
#defineRBTXN_IS_SUBXACT 0x0002
156+
#defineRBTXN_IS_SERIALIZED 0x0004
157+
158+
/* does the txn have catalog changes */
159+
#definerbtxn_has_catalog_changes(txn) (txn->txn_flags & RBTXN_HAS_CATALOG_CHANGES)
160+
/* is the txn known as a subxact? */
161+
#definerbtxn_is_known_subxact(txn) (txn->txn_flags & RBTXN_IS_SUBXACT)
162+
/*
163+
* Has this transaction been spilled to disk? It's not always possible to
164+
* deduce that fact by comparing nentries with nentries_mem, because e.g.
165+
* subtransactions of a large transaction might get serialized together
166+
* with the parent - if they're restored to memory they'd have
167+
* nentries_mem == nentries.
168+
*/
169+
#definerbtxn_is_serialized(txn) (txn->txn_flags & RBTXN_IS_SERIALIZED)
170+
153171
typedefstructReorderBufferTXN
154172
{
173+
inttxn_flags;
174+
155175
/*
156176
* The transactions transaction id, can be a toplevel or sub xid.
157177
*/
158178
TransactionIdxid;
159179

160-
/* did the TX have catalog changes */
161-
boolhas_catalog_changes;
162-
163180
/* Do we know this is a subxact? Xid of top-level txn if so */
164-
boolis_known_as_subxact;
165181
TransactionIdtoplevel_xid;
166182

167183
/*
@@ -229,15 +245,6 @@ typedef struct ReorderBufferTXN
229245
*/
230246
uint64nentries_mem;
231247

232-
/*
233-
* Has this transaction been spilled to disk? It's not always possible to
234-
* deduce that fact by comparing nentries with nentries_mem, because e.g.
235-
* subtransactions of a large transaction might get serialized together
236-
* with the parent - if they're restored to memory they'd have
237-
* nentries_mem == nentries.
238-
*/
239-
boolserialized;
240-
241248
/*
242249
* List of ReorderBufferChange structs, including new Snapshots and new
243250
* CommandIds

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp