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

Commit5282ad8

Browse files
knizhnikkelvich
authored andcommitted
Avoid redundand sending of relation to replicas
1 parent38f35b9 commit5282ad8

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

‎pglogical_apply.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct TupleData
6262
boolchanged[MaxTupleAttributeNumber];
6363
}TupleData;
6464

65+
6566
staticRelationread_rel(StringInfos,LOCKMODEmode);
6667
staticvoidread_tuple_parts(StringInfos,Relationrel,TupleData*tup);
6768
staticEState*create_rel_estate(Relationrel);
@@ -581,6 +582,15 @@ read_tuple_parts(StringInfo s, Relation rel, TupleData *tup)
581582
}
582583
}
583584

585+
staticvoid
586+
close_rel(Relationrel)
587+
{
588+
if (rel!=NULL)
589+
{
590+
heap_close(rel,NoLock);
591+
}
592+
}
593+
584594
staticRelation
585595
read_rel(StringInfos,LOCKMODEmode)
586596
{
@@ -823,7 +833,6 @@ process_remote_insert(StringInfo s, Relation rel)
823833
MtmMakeRelationLocal(RelationGetRelid(rel));
824834
}
825835

826-
heap_close(rel,NoLock);
827836
ExecResetTupleTable(estate->es_tupleTable, true);
828837
FreeExecutorState(estate);
829838

@@ -944,7 +953,6 @@ process_remote_update(StringInfo s, Relation rel)
944953

945954
/* release locks upon commit */
946955
index_close(idxrel,NoLock);
947-
heap_close(rel,NoLock);
948956

949957
ExecResetTupleTable(estate->es_tupleTable, true);
950958
FreeExecutorState(estate);
@@ -1019,7 +1027,6 @@ process_remote_delete(StringInfo s, Relation rel)
10191027
PopActiveSnapshot();
10201028

10211029
index_close(idxrel,NoLock);
1022-
heap_close(rel,NoLock);
10231030

10241031
ExecResetTupleTable(estate->es_tupleTable, true);
10251032
FreeExecutorState(estate);
@@ -1071,6 +1078,7 @@ void MtmExecutor(void* work, size_t size)
10711078
}
10721079
/* COMMIT */
10731080
case'C':
1081+
close_rel(rel);
10741082
process_remote_commit(&s);
10751083
break;
10761084
/* INSERT */
@@ -1086,6 +1094,7 @@ void MtmExecutor(void* work, size_t size)
10861094
process_remote_delete(&s,rel);
10871095
continue;
10881096
case'R':
1097+
close_rel(rel);
10891098
rel=read_rel(&s,RowExclusiveLock);
10901099
continue;
10911100
case'F':

‎pglogical_proto.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static bool MtmIsFilteredTxn;
4343
staticTransactionIdMtmCurrentXid;
4444
staticboolDDLInProgress= false;
4545
staticOidMtmSenderTID;/* transaction identifier for WAL sender */
46+
staticOidMtmLastRelId;/* last relation ID sent to the receiver in this transaction */
4647

4748
staticvoidpglogical_write_rel(StringInfoout,PGLogicalOutputData*data,Relationrel);
4849

@@ -95,6 +96,11 @@ pglogical_write_rel(StringInfo out, PGLogicalOutputData *data, Relation rel)
9596

9697
relid=RelationGetRelid(rel);
9798

99+
if (relid==MtmLastRelId) {
100+
return;
101+
}
102+
MtmLastRelId=relid;
103+
98104
pq_sendbyte(out,'R');/* sending RELATION */
99105
pq_sendint(out,relid,sizeofrelid);/* use Oid as relation identifier */
100106

@@ -143,6 +149,7 @@ pglogical_write_begin(StringInfo out, PGLogicalOutputData *data,
143149
pglogical_relid_map_reset();
144150
MtmSenderTID+=1;/* skip InvalidOid */
145151
}
152+
MtmLastRelId=InvalidOid;
146153
MtmCurrentXid=txn->xid;
147154
MtmIsFilteredTxn= false;
148155
MTM_LOG3("%d: pglogical_write_begin XID=%d node=%d CSN=%lld recovery=%d restart_decoding_lsn=%llx first_lsn=%llx end_lsn=%llx confirmed_flush=%llx",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp