You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by zt...@apache.org on 2022/09/15 06:14:16 UTC
[hawq] branch master updated: HAWQ-1847. add guc gp_max_plan_slice to limit number of plan slice
This is an automated email from the ASF dual-hosted git repository.
ztao1987 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hawq.git
The following commit(s) were added to refs/heads/master by this push:
new 94def68f6 HAWQ-1847. add guc gp_max_plan_slice to limit number of plan slice
94def68f6 is described below
commit 94def68f6dacec81688f0c281f43a1149a33d8d9
Author: ztao1987 <zh...@gmail.com>
AuthorDate: Thu Sep 15 14:13:57 2022 +0800
HAWQ-1847. add guc gp_max_plan_slice to limit number of plan slice
---
src/backend/cdb/cdbvars.c | 2 ++
src/backend/cdb/dispatcher_new.c | 11 +++++++++++
src/backend/utils/misc/guc.c | 10 ++++++++++
src/include/cdb/cdbvars.h | 3 +++
4 files changed, 26 insertions(+)
diff --git a/src/backend/cdb/cdbvars.c b/src/backend/cdb/cdbvars.c
index 219743a2e..1603ce74e 100644
--- a/src/backend/cdb/cdbvars.c
+++ b/src/backend/cdb/cdbvars.c
@@ -438,6 +438,8 @@ int gp_segworker_relative_priority = PRIO_MAX;
/* Max size of dispatched plans; 0 if no limit */
int gp_max_plan_size = 0;
+int gp_max_plan_slice = 0;
+
/* Disable setting of tuple hints while reading */
bool gp_disable_tuple_hints = false;
int gp_hashagg_compress_spill_files = 0;
diff --git a/src/backend/cdb/dispatcher_new.c b/src/backend/cdb/dispatcher_new.c
index 77939efe3..9ba96c4c8 100644
--- a/src/backend/cdb/dispatcher_new.c
+++ b/src/backend/cdb/dispatcher_new.c
@@ -1036,6 +1036,17 @@ void mainDispatchPrepare(struct MainDispatchData *data,
}
Assert(splan != NULL && splan_len > 0 && splan_len_uncompressed > 0);
+ // limit plan slice number
+ if (0 < gp_max_plan_slice && num_slices > gp_max_plan_slice) {
+ ereport(
+ ERROR,
+ (errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
+ (errmsg("Query plan slice number limit exceeded, current: " UINT64_FORMAT
+ ", max allowed: %d",
+ num_slices, gp_max_plan_slice),
+ errhint("Slice number controlled by gp_max_plan_slice"))));
+ }
+
char *sparams;
int sparams_len;
if (queryDesc->params != NULL && queryDesc->params->numParams > 0) {
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 4cd84ab42..29524a33c 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -5177,6 +5177,16 @@ static struct config_int ConfigureNamesInt[] =
0, 0, MAX_KILOBYTES, NULL, NULL
},
+ {
+ {"gp_max_plan_slice", PGC_USERSET, RESOURCES_MEM,
+ gettext_noop("Sets the maximum slice number of a plan to be dispatched."),
+ gettext_noop("Use 0 for no limit."),
+ NULL
+ },
+ &gp_max_plan_slice,
+ 0, 0, INT_MAX, NULL, NULL
+ },
+
{
{"gp_max_partition_level", PGC_SUSET, PRESET_OPTIONS,
gettext_noop("Sets the maximum number of levels allowed when creating a partitioned table."),
diff --git a/src/include/cdb/cdbvars.h b/src/include/cdb/cdbvars.h
index 2b6bfdc01..78703fcc8 100644
--- a/src/include/cdb/cdbvars.h
+++ b/src/include/cdb/cdbvars.h
@@ -916,6 +916,9 @@ extern int gp_segworker_relative_priority;
/* Max size of dispatched plans; 0 if no limit */
extern int gp_max_plan_size;
+// max slice number of dispatched plan; 0 if no limit
+extern int gp_max_plan_slice;
+
/* The maximum number of times on average that the hybrid hashed aggregation
* algorithm will plan to spill an input row to disk before including it in
* an aggregation. Increasing this parameter will cause the planner to choose