Skip to content

Commit 4aca16c

Browse files
committed
Check for in progress before setting HEAP_XMIN_INVALID hint
1 parent 80daa6b commit 4aca16c

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

contrib/mmts/pglogical_proto.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ pglogical_write_rel(StringInfo out, PGLogicalOutputData *data, Relation rel)
7777
Oid relid;
7878

7979
if (MtmTransactionSnapshot(MtmCurrentXid) == INVALID_CSN) {
80-
MTM_LOG1("%d: pglogical_write_message filtered", MyProcPid);
80+
MTM_LOG2("%d: pglogical_write_message filtered", MyProcPid);
8181
return;
8282
}
8383

8484
if (DDLInProress) {
85-
MTM_LOG1("%d: pglogical_write_message filtered DDLInProress", MyProcPid);
85+
MTM_LOG2("%d: pglogical_write_message filtered DDLInProress", MyProcPid);
8686
return;
8787
}
8888

@@ -141,7 +141,7 @@ pglogical_write_message(StringInfo out,
141141
{
142142
if (MtmTransactionSnapshot(MtmCurrentXid) == INVALID_CSN)
143143
{
144-
MTM_LOG1("%d: pglogical_write_message filtered", MyProcPid);
144+
MTM_LOG2("%d: pglogical_write_message filtered", MyProcPid);
145145
return;
146146
}
147147
DDLInProress = true;
@@ -263,12 +263,12 @@ pglogical_write_insert(StringInfo out, PGLogicalOutputData *data,
263263
Relation rel, HeapTuple newtuple)
264264
{
265265
if (MtmTransactionSnapshot(MtmCurrentXid) == INVALID_CSN){
266-
MTM_LOG1("%d: pglogical_write_insert filtered", MyProcPid);
266+
MTM_LOG2("%d: pglogical_write_insert filtered", MyProcPid);
267267
return;
268268
}
269269

270270
if (DDLInProress) {
271-
MTM_LOG1("%d: pglogical_write_insert filtered DDLInProress", MyProcPid);
271+
MTM_LOG2("%d: pglogical_write_insert filtered DDLInProress", MyProcPid);
272272
return;
273273
}
274274

@@ -286,12 +286,12 @@ pglogical_write_update(StringInfo out, PGLogicalOutputData *data,
286286
Relation rel, HeapTuple oldtuple, HeapTuple newtuple)
287287
{
288288
if (MtmTransactionSnapshot(MtmCurrentXid) == INVALID_CSN){
289-
MTM_LOG1("%d: pglogical_write_update filtered", MyProcPid);
289+
MTM_LOG2("%d: pglogical_write_update filtered", MyProcPid);
290290
return;
291291
}
292292

293293
if (DDLInProress) {
294-
MTM_LOG1("%d: pglogical_write_update filtered DDLInProress", MyProcPid);
294+
MTM_LOG2("%d: pglogical_write_update filtered DDLInProress", MyProcPid);
295295
return;
296296
}
297297

@@ -319,12 +319,12 @@ pglogical_write_delete(StringInfo out, PGLogicalOutputData *data,
319319
Relation rel, HeapTuple oldtuple)
320320
{
321321
if (MtmTransactionSnapshot(MtmCurrentXid) == INVALID_CSN){
322-
MTM_LOG1("%d: pglogical_write_delete filtered", MyProcPid);
322+
MTM_LOG2("%d: pglogical_write_delete filtered", MyProcPid);
323323
return;
324324
}
325325

326326
if (DDLInProress) {
327-
MTM_LOG1("%d: pglogical_write_delete filtered DDLInProress", MyProcPid);
327+
MTM_LOG2("%d: pglogical_write_delete filtered DDLInProress", MyProcPid);
328328
return;
329329
}
330330

@@ -356,12 +356,12 @@ pglogical_write_tuple(StringInfo out, PGLogicalOutputData *data,
356356
uint16 nliveatts = 0;
357357

358358
if (MtmTransactionSnapshot(MtmCurrentXid) == INVALID_CSN){
359-
MTM_LOG1("%d: pglogical_write_tuple filtered", MyProcPid);
359+
MTM_LOG2("%d: pglogical_write_tuple filtered", MyProcPid);
360360
return;
361361
}
362362

363363
if (DDLInProress) {
364-
MTM_LOG1("%d: pglogical_write_tuple filtered DDLInProress", MyProcPid);
364+
MTM_LOG2("%d: pglogical_write_tuple filtered DDLInProress", MyProcPid);
365365
return;
366366
}
367367

contrib/mmts/pglogical_receiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ pglogical_receiver_main(Datum main_arg)
524524
MtmSpillToFile(spill_file, buf.data, buf.used);
525525
ByteBufferReset(&buf);
526526
}
527-
if (stmt[0] == 'L') {
527+
if (stmt[0] == 'M' && stmt[1] == 'L') {
528528
MTM_LOG3("Process deadlock message from %d", nodeId);
529529
MtmExecutor(stmt, rc - hdr_len);
530530
} else {

regress.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create extension multimaster;
1+
--create extension multimaster;
22
ALTER DATABASE "regression" SET lc_messages TO 'C';
33
ALTER DATABASE "regression" SET lc_monetary TO 'C';
44
ALTER DATABASE "regression" SET lc_numeric TO 'C';

src/backend/utils/time/tqual.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,9 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
989989
{
990990
if (TransactionIdDidCommit(xvac))
991991
{
992-
SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
993-
InvalidTransactionId);
992+
if (!TransactionIdIsInProgress(xvac))
993+
SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
994+
InvalidTransactionId);
994995
return false;
995996
}
996997
SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
@@ -1011,8 +1012,9 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
10111012
InvalidTransactionId);
10121013
else
10131014
{
1014-
SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
1015-
InvalidTransactionId);
1015+
if (!TransactionIdIsInProgress(xvac))
1016+
SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
1017+
InvalidTransactionId);
10161018
return false;
10171019
}
10181020
}
@@ -1067,8 +1069,9 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
10671069
else
10681070
{
10691071
/* it must have aborted or crashed */
1070-
SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
1071-
InvalidTransactionId);
1072+
if (!TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
1073+
SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
1074+
InvalidTransactionId);
10721075
return false;
10731076
}
10741077
}

0 commit comments

Comments
 (0)