Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5051e72

Browse files
committed
Correctly handle toast data in find_heap_tuple
1 parent e8d1259 commit 5051e72

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

contrib/mmts/arbiter.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,23 @@ static void MtmCheckResponse(MtmArbiterMessage* resp)
355355
}
356356
}
357357

358+
#include <execinfo.h>
359+
358360
static void MtmScheduleHeartbeat()
359361
{
360-
if (!stop) {
362+
if (last_sent_heartbeat != 0 && last_sent_heartbeat + MSEC_TO_USEC(MtmHeartbeatSendTimeout)*2 < now) {
363+
#define MCO_MAX_BACK_TRACE_DEPTH 256
364+
int sp;
365+
void* back_trace[MCO_MAX_BACK_TRACE_DEPTH];
366+
int depth = backtrace(back_trace, MCO_MAX_BACK_TRACE_DEPTH);
367+
char** bt = backtrace_symbols(back_trace, depth);
368+
MTM_LOG1("Hearbeat interrupt: more than %lld microseconds since last heartbeat", now - last_sent_heartbeat);
369+
for (sp = 0; sp < depth; sp++) {
370+
MTM_LOG1("\t%s", bt[sp]);
371+
}
372+
free(bt);
373+
}
374+
if (!stop) {
361375
enable_timeout_after(heartbeat_timer, MtmHeartbeatSendTimeout);
362376
send_heartbeat = true;
363377
}

contrib/mmts/pglogical_apply.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ bool find_heap_tuple(TupleData *tup, Relation rel, TupleTableSlot *slot, bool lo
119119
continue;
120120
else if (nulls[i] ^ tup->isnull[i]) /* one is null and one is not null */
121121
break;
122-
else if (!datumIsEqual(tup->values[i], values[i], att->attbyval, att->attlen))
122+
else if (!(att->attlen == -1
123+
? datumIsEqual(PointerGetDatum(PG_DETOAST_DATUM_PACKED(tup->values[i])), PointerGetDatum(PG_DETOAST_DATUM_PACKED(values[i])), att->attbyval, -1)
124+
: datumIsEqual(tup->values[i], values[i], att->attbyval, att->attlen)))
123125
break;
124126
}
125127
if (i == natts)
@@ -168,6 +170,7 @@ bool find_heap_tuple(TupleData *tup, Relation rel, TupleTableSlot *slot, bool lo
168170
ereport(LOG,
169171
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
170172
MTM_ERRMSG("concurrent update, retrying")));
173+
heap_rescan(scan, NULL);
171174
goto retry;
172175
default:
173176
MTM_ELOG(ERROR, "unexpected HTSU_Result after locking: %u", res);

0 commit comments

Comments
 (0)