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

Commit f208c16

Browse files
knizhnikkelvich
authored andcommitted
Add [MTM] prefix to all multimaster messages
1 parent fbeac1b commit f208c16

9 files changed

+247
-252
lines changed

arbiter.c

+58-58
Large diffs are not rendered by default.

multimaster.c

+112-128
Large diffs are not rendered by default.

multimaster.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
#include "libpq-fe.h"
1212

1313
#ifndef DEBUG_LEVEL
14-
#define DEBUG_LEVEL 0
14+
#define DEBUG_LEVEL 0
1515
#endif
1616

1717
#ifndef MTM_TRACE
18-
#define MTM_TRACE 0
18+
#define MTM_TRACE 0
1919
#endif
2020

21+
#define MTM_TAG "[MTM] "
22+
#define MTM_ELOG(level,fmt,...) elog(level, MTM_TAG fmt, ## __VA_ARGS__)
23+
#define MTM_ERRMSG(fmt,...) errmsg(MTM_TAG fmt, ## __VA_ARGS__)
24+
2125
#if DEBUG_LEVEL == 0
22-
#define MTM_LOG1(fmt, ...) elog(LOG, fmt, ## __VA_ARGS__)
26+
#define MTM_LOG1(fmt, ...) elog(LOG, "[MTM] " fmt, ## __VA_ARGS__)
2327
#define MTM_LOG2(fmt, ...)
2428
#define MTM_LOG3(fmt, ...)
2529
#define MTM_LOG4(fmt, ...)
@@ -44,12 +48,11 @@
4448
#define MTM_TXTRACE(tx, event)
4549
#else
4650
#define MTM_TXTRACE(tx, event) \
47-
fprintf(stderr, "[MTM_TXTRACE], %s, %lld, %s, %d\n", tx->gid, (long long)MtmGetSystemTime(), event, MyProcPid)
51+
fprintf(stderr, MTM_TAG "%s, %lld, %s, %d\n", tx->gid, (long long)MtmGetSystemTime(), event, MyProcPid)
4852
#endif
4953

5054
#define MULTIMASTER_NAME "multimaster"
5155
#define MULTIMASTER_SCHEMA_NAME "mtm"
52-
#define MULTIMASTER_DDL_TABLE "ddl_log"
5356
#define MULTIMASTER_LOCAL_TABLES_TABLE "local_tables"
5457
#define MULTIMASTER_SLOT_PATTERN "mtm_slot_%d"
5558
#define MULTIMASTER_MIN_PROTO_VERSION 1

pglogical_apply.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ find_pkey_tuple(ScanKey skey, Relation rel, Relation idxrel,
154154
/* XXX: Improve handling here */
155155
ereport(LOG,
156156
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
157-
errmsg("concurrent update, retrying")));
157+
MTM_ERRMSG("concurrent update, retrying")));
158158
goto retry;
159159
default:
160-
elog(ERROR, "unexpected HTSU_Result after locking: %u", res);
160+
MTM_ELOG(ERROR, "unexpected HTSU_Result after locking: %u", res);
161161
break;
162162
}
163163
}
@@ -253,7 +253,7 @@ build_index_scan_key(ScanKey skey, Relation rel, Relation idxrel, TupleData *tup
253253
BTEqualStrategyNumber);
254254

255255
if (!OidIsValid(operator))
256-
elog(ERROR,
256+
MTM_ELOG(ERROR,
257257
"could not lookup equality operator for type %u, optype %u in opfamily %u",
258258
atttype, optype, opfamily);
259259

@@ -305,7 +305,7 @@ UserTableUpdateOpenIndexes(EState *estate, TupleTableSlot *slot)
305305
if (recheckIndexes != NIL)
306306
ereport(ERROR,
307307
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
308-
errmsg("bdr doesn't support index rechecks")));
308+
MTM_ERRMSG("bdr doesn't support index rechecks")));
309309
}
310310

311311
/* FIXME: recheck the indexes */
@@ -359,7 +359,7 @@ process_remote_begin(StringInfo s)
359359
rc = SPI_execute("RESET SESSION AUTHORIZATION; reset all;", false, 0);
360360
SPI_finish();
361361
if (rc < 0) {
362-
elog(ERROR, "Failed to set reset context: %d", rc);
362+
MTM_ELOG(ERROR, "Failed to set reset context: %d", rc);
363363
}
364364
}
365365

@@ -398,7 +398,7 @@ process_remote_message(StringInfo s)
398398
rc = SPI_execute(messageBody, false, 0);
399399
SPI_finish();
400400
if (rc < 0) {
401-
elog(ERROR, "Failed to execute utility statement %s", messageBody);
401+
MTM_ELOG(ERROR, "Failed to execute utility statement %s", messageBody);
402402
} else {
403403
PushActiveSnapshot(GetTransactionSnapshot());
404404

@@ -483,15 +483,15 @@ read_tuple_parts(StringInfo s, Relation rel, TupleData *tup)
483483
action = pq_getmsgbyte(s);
484484

485485
if (action != 'T')
486-
elog(ERROR, "expected TUPLE, got %c", action);
486+
MTM_ELOG(ERROR, "expected TUPLE, got %c", action);
487487

488488
memset(tup->isnull, 1, sizeof(tup->isnull));
489489
memset(tup->changed, 1, sizeof(tup->changed));
490490

491491
rnatts = pq_getmsgint(s, 2);
492492

493493
if (desc->natts < rnatts)
494-
elog(ERROR, "tuple natts mismatch, %u vs %u", desc->natts, rnatts);
494+
MTM_ELOG(ERROR, "tuple natts mismatch, %u vs %u", desc->natts, rnatts);
495495

496496
/* FIXME: unaligned data accesses */
497497

@@ -555,7 +555,7 @@ read_tuple_parts(StringInfo s, Relation rel, TupleData *tup)
555555
if (buf.len != buf.cursor)
556556
ereport(ERROR,
557557
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
558-
errmsg("incorrect binary data format")));
558+
MTM_ERRMSG("incorrect binary data format")));
559559
break;
560560
}
561561
case 't': /* text format */
@@ -574,11 +574,11 @@ read_tuple_parts(StringInfo s, Relation rel, TupleData *tup)
574574
}
575575
break;
576576
default:
577-
elog(ERROR, "unknown column type '%c'", kind);
577+
MTM_ELOG(ERROR, "unknown column type '%c'", kind);
578578
}
579579

580580
if (att->attisdropped && !tup->isnull[i])
581-
elog(ERROR, "data for dropped column");
581+
MTM_ELOG(ERROR, "data for dropped column");
582582
}
583583
}
584584

@@ -703,7 +703,7 @@ process_remote_commit(StringInfo in)
703703
MtmSetCurrentTransactionCSN(csn);
704704
MtmSetCurrentTransactionGID(gid);
705705
FinishPreparedTransaction(gid, true);
706-
MTM_LOG1("Distributed transaction %s is committed", gid);
706+
MTM_LOG2("Distributed transaction %s is committed", gid);
707707
CommitTransactionCommand();
708708
Assert(!MtmTransIsActive());
709709
MtmEndSession(origin_node, true);
@@ -755,7 +755,7 @@ process_remote_insert(StringInfo s, Relation rel)
755755
}
756756

757757
// if (rel->rd_rel->relkind != RELKIND_RELATION) // RELKIND_MATVIEW
758-
// elog(ERROR, "unexpected relkind '%c' rel \"%s\"",
758+
// MTM_ELOG(ERROR, "unexpected relkind '%c' rel \"%s\"",
759759
// rel->rd_rel->relkind, RelationGetRelationName(rel));
760760

761761
/* debug output */
@@ -804,7 +804,7 @@ process_remote_insert(StringInfo s, Relation rel)
804804
/* TODO: Report tuple identity in log */
805805
ereport(ERROR,
806806
(errcode(ERRCODE_UNIQUE_VIOLATION),
807-
errmsg("Unique constraints violated by remotely INSERTed tuple"),
807+
MTM_ERRMSG("Unique constraints violated by remotely INSERTed tuple"),
808808
errdetail("Cannot apply transaction because remotely INSERTed tuple conflicts with a local tuple on UNIQUE constraint and/or PRIMARY KEY")));
809809
}
810810
CHECK_FOR_INTERRUPTS();
@@ -851,7 +851,7 @@ process_remote_update(StringInfo s, Relation rel)
851851

852852
/* old key present, identifying key changed */
853853
if (action != 'K' && action != 'N')
854-
elog(ERROR, "expected action 'N' or 'K', got %c",
854+
MTM_ELOG(ERROR, "expected action 'N' or 'K', got %c",
855855
action);
856856

857857
estate = create_rel_estate(rel);
@@ -871,11 +871,11 @@ process_remote_update(StringInfo s, Relation rel)
871871

872872
/* check for new tuple */
873873
if (action != 'N')
874-
elog(ERROR, "expected action 'N', got %c",
874+
MTM_ELOG(ERROR, "expected action 'N', got %c",
875875
action);
876876

877877
if (rel->rd_rel->relkind != RELKIND_RELATION)
878-
elog(ERROR, "unexpected relkind '%c' rel \"%s\"",
878+
MTM_ELOG(ERROR, "unexpected relkind '%c' rel \"%s\"",
879879
rel->rd_rel->relkind, RelationGetRelationName(rel));
880880

881881
/* read new tuple */
@@ -887,7 +887,7 @@ process_remote_update(StringInfo s, Relation rel)
887887
idxoid = rel->rd_replidindex;
888888
if (!OidIsValid(idxoid))
889889
{
890-
elog(ERROR, "could not find primary key for table with oid %u",
890+
MTM_ELOG(ERROR, "could not find primary key for table with oid %u",
891891
RelationGetRelid(rel));
892892
return;
893893
}
@@ -936,7 +936,7 @@ process_remote_update(StringInfo s, Relation rel)
936936
{
937937
ereport(ERROR,
938938
(errcode(ERRCODE_NO_DATA_FOUND),
939-
errmsg("Record with specified key can not be located at this node"),
939+
MTM_ERRMSG("Record with specified key can not be located at this node"),
940940
errdetail("Most likely we have DELETE-UPDATE conflict")));
941941

942942
}
@@ -976,7 +976,7 @@ process_remote_delete(StringInfo s, Relation rel)
976976
idxoid = rel->rd_replidindex;
977977
if (!OidIsValid(idxoid))
978978
{
979-
elog(ERROR, "could not find primary key for table with oid %u",
979+
MTM_ELOG(ERROR, "could not find primary key for table with oid %u",
980980
RelationGetRelid(rel));
981981
return;
982982
}
@@ -985,7 +985,7 @@ process_remote_delete(StringInfo s, Relation rel)
985985
idxrel = index_open(idxoid, RowExclusiveLock);
986986

987987
if (rel->rd_rel->relkind != RELKIND_RELATION)
988-
elog(ERROR, "unexpected relkind '%c' rel \"%s\"",
988+
MTM_ELOG(ERROR, "unexpected relkind '%c' rel \"%s\"",
989989
rel->rd_rel->relkind, RelationGetRelationName(rel));
990990

991991
#ifdef VERBOSE_DELETE
@@ -1013,7 +1013,7 @@ process_remote_delete(StringInfo s, Relation rel)
10131013
{
10141014
ereport(ERROR,
10151015
(errcode(ERRCODE_NO_DATA_FOUND),
1016-
errmsg("Record with specified key can not be located at this node"),
1016+
MTM_ERRMSG("Record with specified key can not be located at this node"),
10171017
errdetail("Most likely we have DELETE-DELETE conflict")));
10181018
}
10191019

@@ -1127,7 +1127,7 @@ void MtmExecutor(void* work, size_t size)
11271127
break;
11281128
}
11291129
default:
1130-
elog(ERROR, "unknown action of type %c", action);
1130+
MTM_ELOG(ERROR, "unknown action of type %c", action);
11311131
}
11321132
break;
11331133
}

pglogical_config.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "utils/syscache.h"
3333
#include "utils/typcache.h"
3434

35+
#include "multimaster.h"
36+
3537
typedef enum PGLogicalOutputParamType
3638
{
3739
OUTPUT_PARAM_TYPE_BOOL,
@@ -253,7 +255,7 @@ process_parameters_v1(List *options, PGLogicalOutputData *data)
253255

254256
case PARAM_UNRECOGNISED:
255257
ereport(DEBUG1,
256-
(errmsg("Unrecognised pglogical parameter %s ignored", elem->defname)));
258+
(MTM_ERRMSG("Unrecognised pglogical parameter %s ignored", elem->defname)));
257259
break;
258260
}
259261
}
@@ -298,7 +300,7 @@ get_param_value(DefElem *elem, bool null_ok, PGLogicalOutputParamType type)
298300
else
299301
ereport(ERROR,
300302
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
301-
errmsg("parameter \"%s\" cannot be NULL", elem->defname)));
303+
MTM_ERRMSG("parameter \"%s\" cannot be NULL", elem->defname)));
302304
}
303305

304306
switch (type)
@@ -348,7 +350,7 @@ get_param(List *options, const char *name, bool missing_ok, bool null_ok,
348350
if (!missing_ok)
349351
ereport(ERROR,
350352
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
351-
errmsg("missing required parameter \"%s\"", name)));
353+
MTM_ERRMSG("missing required parameter \"%s\"", name)));
352354

353355
return (Datum) 0;
354356
}
@@ -361,7 +363,7 @@ parse_param_bool(DefElem *elem)
361363
if (!parse_bool(strVal(elem->arg), &res))
362364
ereport(ERROR,
363365
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
364-
errmsg("could not parse boolean value \"%s\" for parameter \"%s\"",
366+
MTM_ERRMSG("could not parse boolean value \"%s\" for parameter \"%s\"",
365367
strVal(elem->arg), elem->defname)));
366368

367369
return res;
@@ -375,13 +377,13 @@ parse_param_uint32(DefElem *elem)
375377
if (!scanint8(strVal(elem->arg), true, &res))
376378
ereport(ERROR,
377379
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
378-
errmsg("could not parse integer value \"%s\" for parameter \"%s\"",
380+
MTM_ERRMSG("could not parse integer value \"%s\" for parameter \"%s\"",
379381
strVal(elem->arg), elem->defname)));
380382

381383
if (res > PG_UINT32_MAX || res < 0)
382384
ereport(ERROR,
383385
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
384-
errmsg("value \"%s\" out of range for parameter \"%s\"",
386+
MTM_ERRMSG("value \"%s\" out of range for parameter \"%s\"",
385387
strVal(elem->arg), elem->defname)));
386388

387389
return (uint32) res;

pglogical_hooks.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "pglogical_hooks.h"
1818
#include "pglogical_output.h"
1919

20+
#include "multimaster.h"
21+
2022
/*
2123
* Returns Oid of the hooks function specified in funcname.
2224
*
@@ -39,15 +41,15 @@ get_hooks_function_oid(List *funcname)
3941
{
4042
ereport(ERROR,
4143
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
42-
errmsg("function %s must return void",
44+
MTM_ERRMSG("function %s must return void",
4345
NameListToString(funcname))));
4446
}
4547

4648
if (func_volatile(funcid) == PROVOLATILE_VOLATILE)
4749
{
4850
ereport(ERROR,
4951
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
50-
errmsg("function %s must not be VOLATILE",
52+
MTM_ERRMSG("function %s must not be VOLATILE",
5153
NameListToString(funcname))));
5254
}
5355

@@ -61,7 +63,7 @@ get_hooks_function_oid(List *funcname)
6163
#endif
6264
ereport(ERROR,
6365
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
64-
errmsg("current user %s does not have permission to call function %s",
66+
MTM_ERRMSG("current user %s does not have permission to call function %s",
6567
username, NameListToString(funcname))));
6668
}
6769

0 commit comments

Comments
 (0)