Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit252dd43

Browse files
knizhnikkelvich
authored andcommitted
Fix memory context usage for concurrent DDL statements
1 parented18103 commit252dd43

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

‎multimaster.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,18 +3941,18 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
39413941
break;
39423942

39433943
caseT_VacuumStmt:
3944-
if (context==PROCESS_UTILITY_TOPLEVEL) {
3944+
skipCommand= true;
3945+
if (context==PROCESS_UTILITY_TOPLEVEL) {
39453946
MtmProcessDDLCommand(queryString, false, true);
39463947
MtmTx.isDistributed= false;
3947-
skipCommand= true;
3948-
break;
3949-
}else {
3948+
}elseif (MtmApplyContext!=NULL) {
39503949
MemoryContextoldContext=MemoryContextSwitchTo(MtmApplyContext);
39513950
Assert(oldContext!=MtmApplyContext);
39523951
MtmVacuumStmt= (VacuumStmt*)copyObject(parsetree);
39533952
MemoryContextSwitchTo(oldContext);
39543953
return;
39553954
}
3955+
break;
39563956

39573957
caseT_CreateDomainStmt:
39583958
/* Detect temp tables access */
@@ -4049,10 +4049,10 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
40494049
MtmProcessDDLCommand(queryString, false, true);
40504050
MtmTx.isDistributed= false;
40514051
skipCommand= true;
4052-
}else {
4052+
}elseif (MtmApplyContext!=NULL){
40534053
MemoryContextoldContext=MemoryContextSwitchTo(MtmApplyContext);
40544054
Assert(oldContext!=MtmApplyContext);
4055-
MtmIndexStmt=indexStmt;
4055+
MtmIndexStmt=(IndexStmt*)copyObject(indexStmt);
40564056
MemoryContextSwitchTo(oldContext);
40574057
return;
40584058
}
@@ -4069,10 +4069,10 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
40694069
MtmProcessDDLCommand(queryString, false, true);
40704070
MtmTx.isDistributed= false;
40714071
skipCommand= true;
4072-
}else {
4072+
}elseif (MtmApplyContext!=NULL){
40734073
MemoryContextoldContext=MemoryContextSwitchTo(MtmApplyContext);
40744074
Assert(oldContext!=MtmApplyContext);
4075-
MtmDropStmt=stmt;
4075+
MtmDropStmt=(DropStmt*)copyObject(stmt);
40764076
MemoryContextSwitchTo(oldContext);
40774077
return;
40784078
}

‎pglogical_apply.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,21 @@ process_remote_message(StringInfo s)
390390
if (rc<0) {
391391
elog(ERROR,"Failed to execute utility statement %s",messageBody);
392392
}else {
393+
PushActiveSnapshot(GetTransactionSnapshot());
394+
393395
if (MtmVacuumStmt!=NULL) {
394396
ExecVacuum(MtmVacuumStmt,1);
395397
}elseif (MtmIndexStmt!=NULL) {
398+
MemoryContextoldContext=MemoryContextSwitchTo(MtmApplyContext);
396399
Oidrelid=RangeVarGetRelidExtended(MtmIndexStmt->relation,ShareUpdateExclusiveLock,
397400
false, false,
398401
NULL,
399402
NULL);
400403

401404
/* Run parse analysis ... */
402-
//MtmIndexStmt = transformIndexStmt(relid, MtmIndexStmt, messageBody);
403-
404-
PushActiveSnapshot(GetTransactionSnapshot());
405+
MtmIndexStmt=transformIndexStmt(relid,MtmIndexStmt,messageBody);
405406

407+
MemoryContextSwitchTo(oldContext);
406408

407409
DefineIndex(relid,/* OID of heap relation */
408410
MtmIndexStmt,
@@ -412,12 +414,11 @@ process_remote_message(StringInfo s)
412414
false,/* skip_build */
413415
false);/* quiet */
414416

415-
if (ActiveSnapshotSet())
416-
PopActiveSnapshot();
417-
418417
}elseif (MtmDropStmt!=NULL) {
419418
RemoveObjects(MtmDropStmt);
420419
}
420+
if (ActiveSnapshotSet())
421+
PopActiveSnapshot();
421422
}
422423
if (standalone) {
423424
CommitTransactionCommand();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp