Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove body limit for influxql request #783

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions server/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::{

use common_util::error::BoxError;
use handlers::query::QueryRequest;
use http::Method;
use log::{error, info};
use logger::RuntimeLevel;
use profile::Profiler;
Expand Down Expand Up @@ -265,8 +264,11 @@ impl<Q: QueryExecutor + 'static> Service<Q> {
fn influxdb_api(
&self,
) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + Clone {
let body_limit = warp::body::content_length_limit(self.config.max_body_size);

let write_api = warp::path!("write")
.and(warp::post())
.and(body_limit)
.and(self.with_context())
.and(self.with_influxdb())
.and(warp::query::<WriteParams>())
Expand All @@ -276,25 +278,22 @@ impl<Q: QueryExecutor + 'static> Service<Q> {
influxdb::write(ctx, db, request).await
});

// Query support both get and post method, so we can't add `body_limit` here.
// Otherwise it will throw `Rejection(LengthRequired)`
// TODO: support body limit for POST request
let query_api = warp::path!("query")
.and(warp::method())
.and(self.with_context())
.and(self.with_influxdb())
.and(warp::query::<InfluxqlParams>())
.and(warp::body::form::<HashMap<String, String>>())
.and_then(|method, ctx, db, params, body| async move {
if method != Method::POST && method != Method::GET {
return Err(reject::reject());
}

let request =
InfluxqlRequest::try_new(method, body, params).map_err(reject::custom)?;
influxdb::query(ctx, db, QueryRequest::Influxql(request)).await
});

warp::path!("influxdb" / "v1" / ..)
.and(warp::body::content_length_limit(self.config.max_body_size))
.and(write_api.or(query_api))
warp::path!("influxdb" / "v1" / ..).and(write_api.or(query_api))
}

// POST /debug/flush_memtable
Expand Down Expand Up @@ -630,7 +629,8 @@ async fn handle_rejection(
} else {
error!("handle error: {:?}", rejection);
code = StatusCode::INTERNAL_SERVER_ERROR;
message = format!("UNKNOWN_ERROR: {rejection:?}");
message = error_util::remove_backtrace_from_err(&format!("UNKNOWN_ERROR: {rejection:?}"))
.to_string();
}

let json = reply::json(&ErrorResponse {
Expand Down