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

Commit 1b0c0ec

Browse files
author
Andrei Krichinin
committed
Merge with changes made for Postgres 14
2 parents 44623f2 + 27702af commit 1b0c0ec

File tree

7 files changed

+321
-1917
lines changed

7 files changed

+321
-1917
lines changed

Cluster.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ sub init
233233
{
234234
$node->init(allows_streaming => 'logical');
235235
$node->append_conf('postgresql.conf', qq{
236-
enable_self_join_removal = off
237236
max_connections = 50
238237
log_line_prefix = '%m [%p] [xid%x] %i '
239238
log_statement = all

expected/regression_ee.diff

Lines changed: 273 additions & 1900 deletions
Large diffs are not rendered by default.

src/commit.c

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,39 @@ mtm_commit_cleanup(int status, Datum arg)
135135
/* there was no precommit, we can abort */
136136
PG_TRY();
137137
{
138-
AbortOutOfAnyTransaction();
139-
StartTransactionCommand();
138+
#ifdef PGPRO_EE
139+
int atxLevel = DatumGetInt32(arg);
140+
141+
/*
142+
* If we are inside ATX transaction, we can not call
143+
* AbortOutOfAnyTransaction() because this call will abort
144+
* ALL transactions and we will have problems if the
145+
* calling code is not designed for this case.
146+
*/
147+
if (atxLevel)
148+
{
149+
/* Abort (current ATX transaction only): */
150+
AbortCurrentTransaction();
151+
/* Restart ATX transaction if it was resumed: */
152+
if (atxLevel > getNestLevelATX())
153+
SuspendTransaction();
154+
}
155+
else
156+
#endif
157+
{
158+
AbortOutOfAnyTransaction();
159+
StartTransactionCommand();
160+
}
140161
FinishPreparedTransaction(mtm_commit_state.gid, false, false);
141162
mtm_commit_state.gtx->state.status = GTXAborted;
142163
mtm_log(MtmTxFinish, "%s aborted as own orphaned not precomitted",
143164
mtm_commit_state.gid);
144165
CommitTransactionCommand();
145-
166+
#ifdef PGPRO_EE
167+
/* Restart ATX transaction if it was resumed: */
168+
if (atxLevel > getNestLevelATX())
169+
SuspendTransaction();
170+
#endif
146171
}
147172
/*
148173
* this should be extremely unlikely, but if we fail, don't
@@ -218,7 +243,7 @@ MtmBeginTransaction()
218243
* register gtx hook first (it will be called last)
219244
*/
220245
GlobalTxEnsureBeforeShmemExitHook();
221-
before_shmem_exit(mtm_commit_cleanup, Int32GetDatum(1));
246+
before_shmem_exit(mtm_commit_cleanup, Int32GetDatum(0));
222247
mtm_commit_state.mctx = AllocSetContextCreate(TopMemoryContext,
223248
"MtmCommitContext",
224249
ALLOCSET_DEFAULT_SIZES);
@@ -373,6 +398,9 @@ MtmTwoPhaseCommit(void)
373398
MtmGeneration xact_gen;
374399
char dmq_stream_name[DMQ_STREAM_NAME_MAXLEN];
375400
GTxState gtx_state;
401+
#ifdef PGPRO_EE
402+
int atxLevel = getNestLevelATX();
403+
#endif
376404

377405
if (MtmNo3PC)
378406
{
@@ -714,7 +742,7 @@ MtmTwoPhaseCommit(void)
714742
}
715743
PG_CATCH();
716744
{
717-
mtm_commit_cleanup(0, Int32GetDatum(0));
745+
mtm_commit_cleanup(0, Int32GetDatum(atxLevel));
718746

719747
PG_RE_THROW();
720748
}

src/include/compat.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#ifndef MTMCOMPAT_H
22
#define MTMCOMPAT_H
33

4+
#if 0 /* built-in connection pool ported */
5+
/* EE pooler gets rid of static variable */
6+
#ifdef PGPRO_EE
7+
#define FeBeWaitSetCompat() (MyProcPort->pqcomm_waitset)
8+
#else
49
#define FeBeWaitSetCompat() (FeBeWaitSet)
10+
#endif
11+
#else
12+
#define FeBeWaitSetCompat() (FeBeWaitSet)
13+
#endif
514

615
#ifdef PGPRO_EE /* atx */
716
#define BeginTransactionBlockCompat() (BeginTransactionBlock(false, NIL))

src/multimaster.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,10 @@ NULL);
751751

752752
DetectGlobalDeadLock = MtmDetectGlobalDeadLock;
753753

754-
#if 0
755754
#ifdef PGPRO_EE
756755
SuspendTransactionHook = MtmSuspendTransaction;
757756
ResumeTransactionHook = MtmResumeTransaction;
758757
#endif
759-
#endif
760758
}
761759

762760
#if PG_VERSION_NUM >= 150000

src/pglogical_apply.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ create_rel_estate(Relation rel)
166166
EState *estate;
167167
ResultRelInfo *resultRelInfo;
168168
RangeTblEntry *rte;
169-
List *rangeTable;
170169

171170
estate = CreateExecutorState();
172171

@@ -178,12 +177,8 @@ create_rel_estate(Relation rel)
178177
rte->relid = RelationGetRelid(rel);
179178
rte->relkind = rel->rd_rel->relkind;
180179
rte->rellockmode = AccessShareLock;
181-
rangeTable = list_make1(rte);
182180
ExecInitRangeTable(estate, list_make1(rte));
183181

184-
ExecInitRangeTable(estate, rangeTable);
185-
ExecInitResultRelation(estate, resultRelInfo, 1);
186-
187182
estate->es_result_relation_info = resultRelInfo;
188183
estate->es_output_cid = GetCurrentCommandId(true);
189184

t/001_regress.pl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@
7575
CREATE VIEW pg_prepared_xacts AS
7676
select * from _pg_prepared_xacts where gid not like 'MTM-%'
7777
ORDER BY transaction::text::bigint;
78-
ALTER TABLE pg_publication RENAME TO _pg_publication;
79-
CREATE VIEW pg_catalog.pg_publication AS SELECT * FROM pg_catalog._pg_publication WHERE pubname<>'multimaster';
80-
ALTER TABLE pg_subscription RENAME TO _pg_subscription;
81-
CREATE VIEW pg_catalog.pg_subscription AS SELECT * FROM pg_catalog._pg_subscription WHERE subname NOT LIKE 'mtm_sub_%';
8278
});
8379

8480
$cluster->{nodes}->[0]->safe_psql('regression', q{
@@ -104,6 +100,7 @@
104100
$schedule =~ s/test: cfs/#test: cfs/g;
105101
$schedule =~ s/test: largeobject//; # serial schedule
106102
$schedule =~ s/largeobject//; # parallel schedule
103+
$schedule =~ s/atx0//; # parallel schedule
107104
unlink('parallel_schedule');
108105
if ($Cluster::pg_15_modules)
109106
{
@@ -195,6 +192,11 @@
195192
{
196193
$expected_file = "expected/regression_vanilla.diff"
197194
}
195+
# Remove lines which contains random data (like ports, users, etc) from output file
196+
# Remove line which starts with '+ mtm_sub_' from output file because it contains random user
197+
run [ "sed", "-i.bak", "/+ mtm_sub_/d", "$ENV{TESTDIR}/results/regression.diff" ];
198+
# Remove line which starts from '+ multimaster' from output file because it contains random port number
199+
run [ "sed", "-i.bak", "/+ multimaster/d", "$ENV{TESTDIR}/results/regression.diff" ];
198200
if ($Cluster::pg_15_modules)
199201
{
200202
$diff = PostgreSQL::Test::Utils::system_log("diff -U3 ${expected_file} $ENV{TESTDIR}/results/regression.diff");

0 commit comments

Comments
 (0)