Skip to content

Commit 86746e5

Browse files
committed
Merge branch 'PGPROEE9_6_MULTIMASTER' of https://gitlab.postgrespro.ru/pgpro-dev/postgrespro into PGPROEE9_6_MULTIMASTER
2 parents af0ec3e + 427a82c commit 86746e5

File tree

8 files changed

+71
-114
lines changed

8 files changed

+71
-114
lines changed

src/backend/access/rmgrdesc/xactdesc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
4242
* present */
4343

4444
parsed->xact_time = xlrec->xact_time;
45-
parsed->n_changes = xlrec->n_changes;
4645

4746
if (info & XLOG_XACT_HAS_INFO)
4847
{

src/backend/access/transam/twophase.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ typedef struct TwoPhaseFileHeader
210210
int32 ncommitrels; /* number of delete-on-commit rels */
211211
int32 nabortrels; /* number of delete-on-abort rels */
212212
int32 ninvalmsgs; /* number of cache invalidation messages */
213-
int64 n_changes; /* number of changes done by transaction */
214213
bool initfileinval; /* does relcache init file need invalidation? */
215214
uint16 gidlen; /* length of the GID - GID follows the header */
216215
xl_xact_origin xl_origin; /* replication origin information */
@@ -331,7 +330,7 @@ TwoPhaseShmemInit(void)
331330
((char *) TwoPhaseState +
332331
MAXALIGN(offsetof(TwoPhaseStateData, prepXacts) +
333332
sizeof(GlobalTransaction) * 2 * max_prepared_xacts));
334-
333+
335334
TwoPhaseState->hashTable = &TwoPhaseState->prepXacts[max_prepared_xacts];
336335

337336
for (i = 0; i < max_prepared_xacts; i++)
@@ -531,10 +530,10 @@ MarkAsPreparing(TransactionId xid, const char *gid,
531530
proc->lwWaitMode = 0;
532531
proc->waitLock = NULL;
533532
proc->waitProcLock = NULL;
534-
533+
535534
cached_xid = xid;
536535
cached_gxact = gxact;
537-
536+
538537
for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
539538
SHMQueueInit(&(proc->myProcLocks[i]));
540539
/* subxid data must be filled later by GXactLoadSubxactData */
@@ -548,15 +547,15 @@ MarkAsPreparing(TransactionId xid, const char *gid,
548547
gxact->owner = owner;
549548
gxact->locking_pid = MyProcPid;
550549
gxact->valid = false;
551-
gxact->ondisk = false;
550+
gxact->ondisk = false;
552551
gxact->prep_index = TwoPhaseState->numPrepXacts;
553552
strcpy(gxact->gid, gid);
554553
*gxact->state_3pc = '\0';
555554

556555
/* And insert it into the active array */
557556
Assert(TwoPhaseState->numPrepXacts < max_prepared_xacts);
558557
TwoPhaseState->prepXacts[TwoPhaseState->numPrepXacts++] = gxact;
559-
558+
560559
/*
561560
* Remember that we have this GlobalTransaction entry locked for us. If we
562561
* abort after this, we must release it.
@@ -656,7 +655,7 @@ LockGXact(const char *gid, Oid user)
656655
LWLockRelease(TwoPhaseStateLock);
657656

658657
if (MyLockedGxact != gxact) {
659-
if (MyLockedGxact != NULL) {
658+
if (MyLockedGxact != NULL) {
660659
SpinLockRelease(&MyLockedGxact->spinlock);
661660
}
662661
MyLockedGxact = gxact;
@@ -671,13 +670,13 @@ LockGXact(const char *gid, Oid user)
671670
errmsg("prepared transaction with identifier \"%s\" is not valid",
672671
gid)));
673672
}
674-
673+
675674
if (user != gxact->owner && !superuser_arg(user)) {
676675
ereport(ERROR,
677676
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
678677
errmsg("permission denied to finish prepared transaction"),
679678
errhint("Must be superuser or the user that prepared the transaction.")));
680-
}
679+
}
681680

682681
/*
683682
* Note: it probably would be possible to allow committing from
@@ -698,11 +697,11 @@ LockGXact(const char *gid, Oid user)
698697
gxact->locking_pid = MyProcPid;
699698

700699
return gxact;
701-
}
700+
}
702701
}
703702

704703
LWLockRelease(TwoPhaseStateLock);
705-
if (MyLockedGxact != NULL) {
704+
if (MyLockedGxact != NULL) {
706705
SpinLockRelease(&MyLockedGxact->spinlock);
707706
MyLockedGxact = NULL;
708707
}
@@ -830,13 +829,13 @@ bool GetPreparedTransactionState(char const* gid, char* state)
830829
* Alter 3PC state of prepared transaction
831830
*/
832831
void SetPreparedTransactionState(char const* gid, char const* state)
833-
{
832+
{
834833
GlobalTransaction gxact;
835834
PGXACT *pgxact;
836835
TwoPhaseFileHeader *hdr;
837836
char* buf;
838837
bool replorigin;
839-
838+
840839

841840
if (strlen(state) >= MAX_3PC_STATE_SIZE)
842841
ereport(ERROR,
@@ -847,7 +846,7 @@ void SetPreparedTransactionState(char const* gid, char const* state)
847846
replorigin = (replorigin_session_origin != InvalidRepOriginId &&
848847
replorigin_session_origin != DoNotReplicateId);
849848

850-
gxact = LockGXact(gid, GetUserId());
849+
gxact = LockGXact(gid, GetUserId());
851850
pgxact = &ProcGlobal->allPgXact[gxact->pgprocno];
852851
strcpy(gxact->state_3pc, state);
853852

@@ -905,7 +904,7 @@ pg_precommit_prepared(PG_FUNCTION_ARGS)
905904
char const* state = PG_GETARG_CSTRING(1);
906905
SetPreparedTransactionState(gid, state);
907906
PG_RETURN_VOID();
908-
}
907+
}
909908

910909
/*
911910
* pg_prepared_xact
@@ -1153,7 +1152,6 @@ StartPrepare(GlobalTransaction gxact)
11531152
hdr.nabortrels = smgrGetPendingDeletes(false, &abortrels);
11541153
hdr.ninvalmsgs = xactGetCommittedInvalidationMessages(&invalmsgs,
11551154
&hdr.initfileinval);
1156-
hdr.n_changes = MyXactLogicalChanges;
11571155
hdr.gidlen = strlen(gxact->gid) + 1; /* Include '\0' */
11581156
*hdr.state_3pc = '\0';
11591157

@@ -1211,7 +1209,7 @@ EndPrepare(GlobalTransaction gxact)
12111209
Assert(hdr->magic == TWOPHASE_MAGIC);
12121210
hdr->total_len = records.total_len + sizeof(pg_crc32c);
12131211

1214-
if (replorigin) {
1212+
if (replorigin) {
12151213
Assert(replorigin_session_origin_lsn != InvalidXLogRecPtr);
12161214
hdr->xl_origin.origin_lsn = replorigin_session_origin_lsn;
12171215
hdr->xl_origin.origin_timestamp = replorigin_session_origin_timestamp;
@@ -1447,7 +1445,7 @@ ParsePrepareRecord(uint8 info, char *xlrec, xl_xact_parsed_prepare *parsed)
14471445

14481446
hdr = (TwoPhaseFileHeader *) xlrec;
14491447
bufptr = xlrec + MAXALIGN(sizeof(TwoPhaseFileHeader));
1450-
1448+
14511449
parsed->origin_lsn = hdr->xl_origin.origin_lsn;
14521450
parsed->origin_timestamp = hdr->xl_origin.origin_timestamp;
14531451
parsed->xinfo = hdr->xl_origin.origin_lsn != InvalidXLogRecPtr ? XACT_XINFO_HAS_ORIGIN : 0;
@@ -1461,8 +1459,7 @@ ParsePrepareRecord(uint8 info, char *xlrec, xl_xact_parsed_prepare *parsed)
14611459
parsed->nsubxacts = hdr->nsubxacts;
14621460
parsed->nrels = hdr->ncommitrels;
14631461
parsed->nmsgs = hdr->ninvalmsgs;
1464-
parsed->n_changes = hdr->n_changes;
1465-
1462+
14661463
parsed->subxacts = (TransactionId *) bufptr;
14671464
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
14681465

@@ -1578,10 +1575,10 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
15781575
int i;
15791576

15801577

1581-
if (isCommit)
1582-
{
1578+
if (isCommit)
1579+
{
15831580
CallXactCallbacks(XACT_EVENT_PRE_COMMIT_PREPARED);
1584-
}
1581+
}
15851582

15861583
/*
15871584
* Validate the GID, and lock the GXACT to ensure that two backends do not
@@ -1647,7 +1644,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
16471644
gid);
16481645
CallXactCallbacks(XACT_EVENT_ABORT_PREPARED);
16491646
}
1650-
1647+
16511648

16521649
ProcArrayRemove(proc, latestXid);
16531650

src/backend/access/transam/xact.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int DefaultXactIsoLevel = XACT_READ_COMMITTED;
7474
int XactIsoLevel;
7575

7676
bool DefaultXactReadOnly = false;
77-
/*
77+
/*
7878
* We need initialization because only initialized vars appear in
7979
* postges.def and accssible from loadable extension
8080
*/
@@ -119,10 +119,6 @@ TransactionId *ParallelCurrentXids;
119119
*/
120120
bool MyXactAccessedTempRel = false;
121121

122-
/*
123-
* Number of logical changes (insert,delte,update,lgical message) performed by transaction
124-
*/
125-
int64 MyXactLogicalChanges = 0;
126122

127123
/*
128124
* transaction states - transaction state from server perspective
@@ -1920,8 +1916,6 @@ StartTransaction(void)
19201916
XactIsoLevel = DefaultXactIsoLevel;
19211917
forceSyncCommit = false;
19221918
MyXactAccessedTempRel = false;
1923-
MyXactLogicalChanges = 0;
1924-
19251919

19261920
/*
19271921
* reinitialize within-transaction counters
@@ -2187,7 +2181,7 @@ CommitTransaction(void)
21872181
* waiting for lock on a relation we've modified, we want them to know
21882182
* about the catalog change before they start using the relation).
21892183
*/
2190-
xactHasCatcacheInvalidationMessages = HasCatcacheInvalidationMessages();
2184+
xactHasCatcacheInvalidationMessages = HasCatcacheInvalidationMessages();
21912185
xactHasRelcacheInvalidationMessages = HasRelcacheInvalidationMessages();
21922186
AtEOXact_Inval(true);
21932187

@@ -2202,7 +2196,7 @@ CommitTransaction(void)
22022196
RESOURCE_RELEASE_AFTER_LOCKS,
22032197
true, true);
22042198

2205-
if (!is_autonomous_transaction)
2199+
if (!is_autonomous_transaction)
22062200
{
22072201
/*
22082202
* Likewise, dropping of files deleted during the transaction is best done
@@ -2221,13 +2215,13 @@ CommitTransaction(void)
22212215

22222216
AtCommit_Notify();
22232217
AtEOXact_GUC(true, s->gucNestLevel);
2224-
if (!is_autonomous_transaction)
2218+
if (!is_autonomous_transaction)
22252219
{
22262220
AtEOXact_SPI(true);
22272221
}
22282222
AtEOXact_on_commit_actions(true);
22292223
AtEOXact_Namespace(true, is_parallel_worker);
2230-
if (!is_autonomous_transaction)
2224+
if (!is_autonomous_transaction)
22312225
{
22322226
AtEOXact_SMgr();
22332227
AtEOXact_Files();
@@ -2695,7 +2689,7 @@ AbortTransaction(void)
26952689
AtEOXact_Buffers(false);
26962690
}
26972691
AtEOXact_RelationCache(false);
2698-
xactHasCatcacheInvalidationMessages = HasCatcacheInvalidationMessages();
2692+
xactHasCatcacheInvalidationMessages = HasCatcacheInvalidationMessages();
26992693
xactHasRelcacheInvalidationMessages = HasRelcacheInvalidationMessages();
27002694
AtEOXact_Inval(false);
27012695
AtEOXact_MultiXact();
@@ -3543,14 +3537,14 @@ void SuspendTransaction(void)
35433537
sus->TopTransactionStateData = TopTransactionStateData;
35443538

35453539
sus->SnapshotState = SuspendSnapshot(); /* only before the resource-owner stuff */
3546-
3547-
if (HasCatcacheInvalidationMessages())
3540+
3541+
if (HasCatcacheInvalidationMessages())
35483542
{
35493543
ResetCatalogCaches();
35503544
}
3551-
if (HasRelcacheInvalidationMessages())
3545+
if (HasRelcacheInvalidationMessages())
35523546
{
3553-
RelationCacheInvalidate();
3547+
RelationCacheInvalidate();
35543548
}
35553549
sus->InvalidationInfo = SuspendInvalidationInfo();
35563550
xactHasCatcacheInvalidationMessages = false;
@@ -3607,7 +3601,7 @@ void SuspendTransaction(void)
36073601

36083602
sus->PgStatState = PgStatSuspend();
36093603
sus->TriggerState = TriggerSuspend();
3610-
sus->SPIState = SuspendSPI();
3604+
sus->SPIState = SuspendSPI();
36113605
}
36123606

36133607
AtStart_Memory();
@@ -3666,13 +3660,13 @@ bool ResumeTransaction(void)
36663660

36673661
ResumeSnapshot(sus->SnapshotState); /* only after the resource-owner stuff */
36683662
ResumeInvalidationInfo(sus->InvalidationInfo);
3669-
if (xactHasCatcacheInvalidationMessages)
3663+
if (xactHasCatcacheInvalidationMessages)
36703664
{
36713665
ResetCatalogCaches();
36723666
}
3673-
if (xactHasRelcacheInvalidationMessages)
3667+
if (xactHasRelcacheInvalidationMessages)
36743668
{
3675-
RelationCacheInvalidate();
3669+
RelationCacheInvalidate();
36763670
}
36773671

36783672
MyProc->backendId = sus->vxid.backendId;
@@ -3870,7 +3864,7 @@ EndTransactionBlock(bool autonomous)
38703864
* to COMMIT.
38713865
*/
38723866
case TBLOCK_INPROGRESS:
3873-
if (autonomous && getNestLevelATX() == 0) {
3867+
if (autonomous && getNestLevelATX() == 0) {
38743868
ereport(WARNING,
38753869
(errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
38763870
errmsg("there is no autonomous transaction in progress")));
@@ -3999,7 +3993,7 @@ UserAbortTransactionBlock(bool autonomous)
39993993
* exit the transaction block.
40003994
*/
40013995
case TBLOCK_INPROGRESS:
4002-
if (autonomous && getNestLevelATX() == 0) {
3996+
if (autonomous && getNestLevelATX() == 0) {
40033997
ereport(WARNING,
40043998
(errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
40053999
errmsg("there is no autonomous transaction in progress")));
@@ -5179,7 +5173,7 @@ EstimateTransactionStateSpace(void)
51795173
nxids = add_size(nxids, s->nChildXids);
51805174
}
51815175

5182-
nxids = add_size(nxids, nParallelCurrentXids);
5176+
nxids = add_size(nxids, nParallelCurrentXids);
51835177
nxids = mul_size(nxids, sizeof(TransactionId));
51845178
return add_size(nxids, TM->GetTransactionStateSize());
51855179
}
@@ -5495,7 +5489,6 @@ XactLogCommitRecord(TimestampTz commit_time,
54955489
/* First figure out and collect all the information needed */
54965490

54975491
xlrec.xact_time = commit_time;
5498-
xlrec.n_changes = MyXactLogicalChanges;
54995492

55005493
if (relcacheInval)
55015494
xl_xinfo.xinfo |= XACT_COMPLETION_UPDATE_RELCACHE_FILE;
@@ -5897,7 +5890,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
58975890
* because subtransaction commit is never WAL logged.
58985891
*/
58995892
static void
5900-
xact_redo_abort(xl_xact_parsed_abort *parsed,
5893+
xact_redo_abort(xl_xact_parsed_abort *parsed,
59015894
TransactionId xid,
59025895
XLogRecPtr lsn,
59035896
RepOriginId origin_id)
@@ -6043,9 +6036,9 @@ xact_redo(XLogReaderState *record)
60436036
RecreateTwoPhaseFile(XLogRecGetXid(record),
60446037
XLogRecGetData(record), XLogRecGetDataLen(record));
60456038

6046-
if (originId != InvalidRepOriginId && originId != DoNotReplicateId)
6039+
if (originId != InvalidRepOriginId && originId != DoNotReplicateId)
60476040
{
6048-
xl_xact_parsed_prepare parsed;
6041+
xl_xact_parsed_prepare parsed;
60496042
ParsePrepareRecord(XLogRecGetXid(record), XLogRecGetData(record), &parsed);
60506043
Assert(parsed.origin_lsn != InvalidXLogRecPtr);
60516044
/* recover apply progress */
@@ -6066,17 +6059,17 @@ xact_redo(XLogReaderState *record)
60666059
}
60676060

60686061
Datum pg_current_tx_nest_level(PG_FUNCTION_ARGS)
6069-
{
6062+
{
60706063
PG_RETURN_INT64(GetCurrentTransactionNestLevel());
60716064
}
60726065

60736066
Datum pg_current_atx_nest_level(PG_FUNCTION_ARGS)
6074-
{
6067+
{
60756068
PG_RETURN_INT64(getNestLevelATX());
60766069
}
60776070

60786071
Datum pg_current_atx_has_ancestor(PG_FUNCTION_ARGS)
6079-
{
6072+
{
60806073
int64 xid = PG_GETARG_INT64(0);
60816074
PG_RETURN_BOOL(TransactionIdIsAncestorOfCurrentATX(xid));
60826075
}

src/backend/access/transam/xloginsert.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,6 @@ XLogInsert(RmgrId rmid, uint8 info)
423423

424424
TRACE_POSTGRESQL_XLOG_INSERT(rmid, info);
425425

426-
if (rmid == RM_LOGICALMSG_ID || rmid == RM_HEAP_ID)
427-
{
428-
MyXactLogicalChanges += 1;
429-
}
430-
431-
432426
/*
433427
* In bootstrap mode, we don't actually log anything but XLOG resources;
434428
* return a phony record pointer.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy