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

Commit 1a6deb8

Browse files
committed
Don't set no_3pc for syncpoint table modification.
It is much more consistent to simply prevent 3pc when only local tables were modified in the transaction. I've kept the GUC though because it might be useful for testing/debugging/manual fixing in other circumstances. (cherry picked from commit 828495ef92b8ed53f288fdb1f6a8b299dce4be65)
1 parent 2037cfa commit 1a6deb8

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

multimaster--1.0.sql

+5-25
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ CREATE TRIGGER on_node_drop
5252
CREATE FUNCTION mtm.after_node_drop_plpgsql() RETURNS TRIGGER AS $$
5353
BEGIN
5454
DELETE FROM mtm.syncpoints WHERE node_id = OLD.id;
55-
/*
56-
* Trigger on sp table modification will set no_3pc, but in case of node drop
57-
* we still want to go through distributed commit. mtm.local_tables ensures
58-
* sp table changes won't be streamed though as they are not consistent
59-
* among the nodes.
60-
*/
61-
SET multimaster.no_3pc TO FALSE;
6255
RETURN NULL; -- result is ignored since this is an AFTER trigger
6356
END
6457
$$ LANGUAGE plpgsql;
@@ -226,24 +219,11 @@ $$
226219
LANGUAGE sql;
227220

228221
/*
229-
* Don't perform 3pc on syncpoint tables updates.
230-
*/
231-
CREATE FUNCTION mtm.syncpoint_dml() RETURNS TRIGGER AS $$
232-
BEGIN
233-
SET LOCAL multimaster.no_3pc TO TRUE;
234-
RETURN NULL; -- result is ignored since this is an AFTER trigger
235-
END
236-
$$ LANGUAGE plpgsql;
237-
238-
CREATE TRIGGER on_syncpoint_dml
239-
AFTER INSERT OR DELETE OR UPDATE ON mtm.syncpoints
240-
FOR EACH ROW EXECUTE FUNCTION mtm.syncpoint_dml();
241-
242-
/*
243-
* Note that pg_filter_decode_txn currently prevents plain COMMITs replay, so
244-
* this automatically ensures manual modifications won't be streamed. However, we
245-
* cleanup node syncpoints on its removal, and drop_node surely ought to go
246-
* through 3pc -- and there we do need to filter out these changes.
222+
* Note that pg_filter_decode_txn currently prevents plain COMMITs replay and if
223+
* xact modified only local tables we don't perform 3pc, so there is no empty
224+
* sp table modification xacts flowing around. However, we cleanup node
225+
* syncpoints on its removal, and drop_node surely ought to go through 3pc.
226+
* Thus local_tables semantics does here exactly what we want.
247227
*/
248228
INSERT INTO mtm.local_tables VALUES ('mtm', 'syncpoints');
249229

src/commit.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,12 @@ MtmTwoPhaseCommit(void)
387387
nodemask_t pc_success_cohort;
388388
MtmGeneration xact_gen;
389389

390-
/* don't run 3pc on syncpoint table update */
391390
if (MtmNo3PC)
392391
{
393-
/* SET LOCAL semantics ensures GUC value is reset to false on xact commit */
392+
/*
393+
* SET LOCAL which ensures GUC value is reset on xact commit is
394+
* strongly recommended for this (internal) variable manipulations.
395+
*/
394396
return false;
395397
}
396398

src/ddl.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,10 @@ MtmExecutorFinish(QueryDesc *queryDesc)
12361236
{
12371237
Relation rel = estate->es_result_relations[i].ri_RelationDesc;
12381238

1239-
if (RelationNeedsWAL(rel))
1239+
/*
1240+
* Don't run 3pc unless we modified at least one non-local table.
1241+
*/
1242+
if (RelationNeedsWAL(rel) && !MtmIsRelationLocal(rel))
12401243
{
12411244
if (MtmIgnoreTablesWithoutPk)
12421245
{

src/multimaster.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,13 @@ NULL,
551551
NULL);
552552

553553
DefineCustomBoolVariable("multimaster.no_3pc",
554-
"Don't perform 3pc for current xact. For internal usage only.",
554+
"Don't perform 3pc for current xact. Mostly for internal usage, you should really know what you are doing.",
555555
NULL,
556556
&MtmNo3PC,
557557
false,
558558
PGC_USERSET,
559-
0,
559+
/* construct a few obstacles preventing broad usage */
560+
GUC_NO_SHOW_ALL | GUC_DISALLOW_IN_FILE,
560561
NULL,
561562
NULL,
562563
NULL

0 commit comments

Comments
 (0)