Skip to content

Commit 4d22043

Browse files
yjhjstzmy-ship-it
authored andcommitted
Revert "ORCA: Support create plan in singlenode mode"
This reverts commit 36c1e7a.
1 parent a337ea2 commit 4d22043

15 files changed

Lines changed: 103 additions & 154 deletions

File tree

.github/workflows/build-cloudberry.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ jobs:
273273
"make_configs":["src/test/isolation:installcheck-singlenode",
274274
"src/test/singlenode_regress:installcheck-singlenode",
275275
"src/test/singlenode_isolation2:installcheck-singlenode"],
276-
"num_primary_mirror_pairs":0,
277-
"pg_settings":{"optimizer":"off"}
276+
"num_primary_mirror_pairs":0
278277
},
279278
{"test":"ic-resgroup-v2",
280279
"make_configs":["src/test/isolation2:installcheck-resgroup-v2"],
@@ -319,6 +318,9 @@ jobs:
319318
},
320319
{"test":"ic-parallel-retrieve-cursor",
321320
"make_configs":["src/test/isolation2:installcheck-parallel-retrieve-cursor"]
321+
},
322+
{"test":"ic-cbdb-parallel",
323+
"make_configs":["src/test/regress:installcheck-cbdb-parallel"]
322324
}
323325
]
324326
}'

src/backend/gpopt/config/CConfigParamMapping.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
extern "C" {
1717
#include "postgres.h"
18-
#include "cdb/cdbvars.h"
18+
1919
#include "utils/guc.h"
2020
}
2121

@@ -386,12 +386,6 @@ CConfigParamMapping::PackConfigParamInBitset(
386386
}
387387
}
388388

389-
if (IS_SINGLENODE()) {
390-
traceflag_bitset->ExchangeSet(EopttraceSingleNodeMode);
391-
} else {
392-
traceflag_bitset->ExchangeClear(EopttraceSingleNodeMode);
393-
}
394-
395389
if (!optimizer_enable_nljoin)
396390
{
397391
CBitSet *nl_join_bitset = CXform::PbsNLJoinXforms(mp);

src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ CTranslatorQueryToDXL::CTranslatorQueryToDXL(
210210
}
211211
}
212212

213-
// check if query has insert/update/delete when is_master_only is true.
214-
CheckUnsupportedDDLInSingleMode(m_mp, query);
215-
216213
// check if the query has any unsupported node types
217214
CheckUnsupportedNodeTypes(query);
218215

@@ -283,50 +280,6 @@ CTranslatorQueryToDXL::~CTranslatorQueryToDXL()
283280
}
284281
}
285282

286-
//---------------------------------------------------------------------------
287-
// @function:
288-
// CTranslatorQueryToDXL::CheckUnsupportedNodeTypes
289-
//
290-
// @doc:
291-
// Check for unsupported node types, and throws an exception when found
292-
//
293-
//---------------------------------------------------------------------------
294-
void
295-
CTranslatorQueryToDXL::CheckUnsupportedDDLInSingleMode(CMemoryPool *mp, Query *query)
296-
{
297-
static const SUnsupportedFeature unsupported_features[] = {
298-
{T_SubLink, GPOS_WSZ_LIT("Sublink")},
299-
{T_SubqueryScan, GPOS_WSZ_LIT("Subscan")},
300-
};
301-
302-
List *unsupported_list = NIL;
303-
for (ULONG ul = 0; ul < GPOS_ARRAY_SIZE(unsupported_features); ul++)
304-
{
305-
unsupported_list = gpdb::LAppendInt(unsupported_list,
306-
unsupported_features[ul].node_tag);
307-
}
308-
309-
INT unsupported_node = gpdb::FindNodes((Node *) query, unsupported_list);
310-
gpdb::GPDBFree(unsupported_list);
311-
312-
if (GPOS_FTRACE(EopttraceSingleNodeMode) || GPOS_FTRACE(EopttraceDisableMotions)) {
313-
if (query->commandType == CMD_INSERT || query->commandType == CMD_UPDATE ||
314-
query->commandType == CMD_DELETE) {
315-
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLUnsupportedFeature,
316-
GPOS_WSZ_LIT("Single-mode not support insert/update/delete"));
317-
}
318-
319-
if (0 <= unsupported_node) {
320-
CWStringDynamic error_message(mp);
321-
error_message.AppendFormat(GPOS_WSZ_LIT("Single-mode not support %s"),
322-
unsupported_features[unsupported_node].m_feature_name);
323-
324-
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLUnsupportedFeature,
325-
error_message.GetBuffer());
326-
}
327-
}
328-
}
329-
330283
//---------------------------------------------------------------------------
331284
// @function:
332285
// CTranslatorQueryToDXL::CheckUnsupportedNodeTypes

src/backend/gpopt/translate/CTranslatorUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ CTranslatorUtils::GetTableDescr(CMemoryPool *mp, CMDAccessor *md_accessor,
150150
}
151151
else if (IMDRelation::ErelstorageForeign != rel->RetrieveRelStorageType() &&
152152
!optimizer_enable_master_only_queries &&
153-
!GPOS_FTRACE(EopttraceSingleNodeMode) &&
154153
(IMDRelation::EreldistrMasterOnly == distribution_policy))
155154
{
156155
// fall back to the planner for queries on master-only table if they are disabled with Orca. This is due to

src/backend/gpopt/utils/COptTasks.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,10 @@ COptTasks::OptimizeTask(void *ptr)
953953
query_to_dxl_translator->GetCTEs();
954954
GPOS_ASSERT(nullptr != query_output_dxlnode_array);
955955

956-
BOOL is_master_only = GPOS_FTRACE(EopttraceDisableMotions) ||
957-
GPOS_FTRACE(EopttraceSingleNodeMode) ||
958-
!query_to_dxl_translator->HasDistributedTables();
956+
BOOL is_master_only =
957+
!optimizer_enable_motions ||
958+
(!optimizer_enable_motions_masteronly_queries &&
959+
!query_to_dxl_translator->HasDistributedTables());
959960
// See NoteDistributionPolicyOpclasses() in src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
960961
BOOL use_legacy_opfamilies =
961962
(query_to_dxl_translator->GetDistributionHashOpsKind() ==

src/backend/gporca/libnaucrates/include/naucrates/traceflags/traceflags.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ enum EOptTraceFlag
8383
// print debug info of CTE
8484
EopttraceDebugCTE = 101020,
8585

86-
// Is singlenode
87-
EopttraceSingleNodeMode = 101021,
88-
8986
///////////////////////////////////////////////////////
9087
////////////////// transformations flags //////////////
9188
///////////////////////////////////////////////////////

src/backend/optimizer/plan/planner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
384384
* PARALLEL RETRIEVE CURSOR is not supported by ORCA yet.
385385
*/
386386
if (optimizer &&
387-
IS_QD_OR_SINGLENODE() &&
387+
GP_ROLE_DISPATCH == Gp_role &&
388388
IS_QUERY_DISPATCHER() &&
389389
(cursorOptions & CURSOR_OPT_SKIP_FOREIGN_PARTITIONS) == 0 &&
390390
(cursorOptions & CURSOR_OPT_PARALLEL_RETRIEVE) == 0)

src/backend/utils/misc/guc_gp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ char *optimizer_search_strategy_path = NULL;
324324
/* GUCs to tell Optimizer to enable a physical operator */
325325
bool optimizer_enable_nljoin;
326326
bool optimizer_enable_indexjoin;
327+
bool optimizer_enable_motions_masteronly_queries;
327328
bool optimizer_enable_motions;
328329
bool optimizer_enable_motion_broadcast;
329330
bool optimizer_enable_motion_gather;
@@ -2180,6 +2181,16 @@ struct config_bool ConfigureNamesBool_gp[] =
21802181
true,
21812182
NULL, NULL, NULL
21822183
},
2184+
{
2185+
{"optimizer_enable_motions_masteronly_queries", PGC_USERSET, DEVELOPER_OPTIONS,
2186+
gettext_noop("Enable plans with Motion operators in the optimizer for queries with no distributed tables."),
2187+
NULL,
2188+
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
2189+
},
2190+
&optimizer_enable_motions_masteronly_queries,
2191+
false,
2192+
NULL, NULL, NULL
2193+
},
21832194
{
21842195
{"optimizer_enable_motions", PGC_USERSET, DEVELOPER_OPTIONS,
21852196
gettext_noop("Enable plans with Motion operators in the optimizer."),

src/include/gpopt/translate/CTranslatorQueryToDXL.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ class CTranslatorQueryToDXL
147147
// node is found
148148
static void CheckUnsupportedNodeTypes(Query *query);
149149

150-
static void CheckUnsupportedDDLInSingleMode(CMemoryPool *mp, Query *query);
151-
152150
// walker to check if SUBLINK node is present in the security quals
153151
static BOOL CheckSublinkInSecurityQuals(Node *node, void *context);
154152

src/include/utils/guc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ extern char *optimizer_search_strategy_path;
507507
/* GUCs to tell Optimizer to enable a physical operator */
508508
extern bool optimizer_enable_nljoin;
509509
extern bool optimizer_enable_indexjoin;
510+
extern bool optimizer_enable_motions_masteronly_queries;
510511
extern bool optimizer_enable_motions;
511512
extern bool optimizer_enable_motion_broadcast;
512513
extern bool optimizer_enable_motion_gather;

0 commit comments

Comments
 (0)