This is an automated email from the ASF dual-hosted git repository.
jiacai2050 pushed a commit to branch memtable-poc
in repository https://gitbox.apache.org/repos/asf/incubator-horaedb.git
The following commit(s) were added to refs/heads/memtable-poc by this push:
new 2836ef42 chore: include table in error
2836ef42 is described below
commit 2836ef4227846cf5cdc05fe0dde6dac05550c9e1
Author: jiacai2050 <[email protected]>
AuthorDate: Wed Jan 3 16:48:44 2024 +0800
chore: include table in error
---
proxy/src/limiter.rs | 16 ++++++++++++++--
proxy/src/metrics.rs | 6 ++++++
proxy/src/read.rs | 2 +-
query_frontend/src/plan.rs | 10 ++++++++++
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/proxy/src/limiter.rs b/proxy/src/limiter.rs
index d2422b72..7dc115dc 100644
--- a/proxy/src/limiter.rs
+++ b/proxy/src/limiter.rs
@@ -20,6 +20,8 @@ use query_frontend::plan::Plan;
use serde::{Deserialize, Serialize};
use snafu::Snafu;
+use crate::metrics::BLOCKED_REQUEST_COUNTER_VEC_GLOBAL;
+
#[derive(Snafu, Debug)]
#[snafu(visibility(pub))]
pub enum Error {
@@ -173,8 +175,18 @@ impl Limiter {
///
/// Error will throws if the plan is forbidden to execute.
pub fn try_limit(&self, plan: &Plan) -> Result<()> {
- self.try_limit_by_block_list(plan)?;
- self.try_limit_by_rules(plan)
+ let result = {
+ self.try_limit_by_block_list(plan)?;
+ self.try_limit_by_rules(plan)
+ };
+
+ if result.is_err() {
+ BLOCKED_REQUEST_COUNTER_VEC_GLOBAL
+ .with_label_values(&[plan.plan_type()])
+ .inc();
+ }
+
+ result
}
pub fn add_write_block_list(&self, block_list: Vec<String>) {
diff --git a/proxy/src/metrics.rs b/proxy/src/metrics.rs
index c55c47c2..3478b6bd 100644
--- a/proxy/src/metrics.rs
+++ b/proxy/src/metrics.rs
@@ -61,6 +61,12 @@ lazy_static! {
pub static ref HTTP_HANDLER_COUNTER_VEC_GLOBAL: IntCounterVec =
register_int_counter_vec!("http_handler_counter", "Http handler
counter", &["type"])
.unwrap();
+ pub static ref BLOCKED_REQUEST_COUNTER_VEC_GLOBAL: IntCounterVec =
register_int_counter_vec!(
+ "blocked_request_counter",
+ "Blocked request counter",
+ &["type"]
+ )
+ .unwrap();
}
lazy_static! {
diff --git a/proxy/src/read.rs b/proxy/src/read.rs
index ffdcd819..a6e5eb7e 100644
--- a/proxy/src/read.rs
+++ b/proxy/src/read.rs
@@ -240,7 +240,7 @@ impl Proxy {
.try_limit(&plan)
.box_err()
.context(Internal {
- msg: "Request is blocked",
+ msg: format!("Request is blocked,
table_name:{table_name:?}, sql:{sql}"),
})?;
}
diff --git a/query_frontend/src/plan.rs b/query_frontend/src/plan.rs
index 581fae52..3dbee6ff 100644
--- a/query_frontend/src/plan.rs
+++ b/query_frontend/src/plan.rs
@@ -77,6 +77,16 @@ pub enum Plan {
Exists(ExistsTablePlan),
}
+impl Plan {
+ pub fn plan_type(&self) -> &str {
+ match self {
+ Self::Query(_) => "query",
+ Self::Insert(_) => "insert",
+ _ => "other",
+ }
+ }
+}
+
pub struct QueryPlan {
pub df_plan: DataFusionLogicalPlan,
pub table_name: Option<String>,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]