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

add more log of utf8 failure #530

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion apps/indexer-proxy/proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subql-indexer-proxy"
version = "2.6.3-beta.2"
version = "2.6.3-beta.4"
edition = "2021"

[dependencies]
Expand Down
8 changes: 7 additions & 1 deletion apps/indexer-proxy/proxy/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,13 @@ async fn handle_group(
)
.await
{
Ok((res_query, res_signature, res_state, _limit)) => {
Ok((
res_query,
res_signature,
res_state,
_limit,
_inactive,
)) => {
json!({
"result": general_purpose::STANDARD.encode(&res_query),
"signature": res_signature,
Expand Down
10 changes: 5 additions & 5 deletions apps/indexer-proxy/proxy/src/payg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ pub async fn query_single_state(
state: QueryState,
network_type: MetricsNetwork,
no_sig: bool,
) -> Result<(Vec<u8>, String, String, Option<(i64, i64)>)> {
) -> Result<(Vec<u8>, String, String, Option<(i64, i64)>, bool)> {
let project: Project = get_project(project_id).await?;

// compute unit count times
Expand Down Expand Up @@ -529,7 +529,7 @@ pub async fn query_single_state(
})?;

debug!("Handle query channel success");
Ok((data, signature, post_state.to_bs64_old2(), limit))
Ok((data, signature, post_state.to_bs64_old2(), limit, true))
}

// query with multiple state mode
Expand Down Expand Up @@ -658,7 +658,7 @@ pub async fn query_multiple_state(
state: MultipleQueryState,
network_type: MetricsNetwork,
no_sig: bool,
) -> Result<(Vec<u8>, String, String, Option<(i64, i64)>)> {
) -> Result<(Vec<u8>, String, String, Option<(i64, i64)>, bool)> {
let project = get_project(project_id).await?;

// compute unit count times
Expand All @@ -675,7 +675,7 @@ pub async fn query_multiple_state(
}
})?;
if inactive {
return Ok((vec![], "".to_owned(), state.to_bs64(), None));
return Ok((vec![], "".to_owned(), state.to_bs64(), None, inactive));
}

// query the data.
Expand All @@ -701,7 +701,7 @@ pub async fn query_multiple_state(
post_query_multiple_state(keyname, state_cache).await;

debug!("Handle query channel success");
Ok((data, signature, state.to_bs64(), limit))
Ok((data, signature, state.to_bs64(), limit, inactive))
}

pub async fn extend_channel(
Expand Down
45 changes: 34 additions & 11 deletions apps/indexer-proxy/proxy/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use subql_indexer_utils::{
};
use tower_http::cors::{Any, CorsLayer};

use crate::account::ACCOUNT;
use crate::ai::api_stream;
use crate::auth::{create_jwt, AuthQuery, AuthQueryLimit, Payload};
use crate::cli::COMMAND;
Expand Down Expand Up @@ -484,7 +485,7 @@ async fn ep_payg_handler(
return payg_stream(endpoint.endpoint.clone(), v, state, false).await;
}

let (data, signature, state_data, limit) = match block.to_str() {
let (data, signature, state_data, limit, inactive) = match block.to_str() {
Ok("multiple") => {
let state = match MultipleQueryState::from_bs64(auth) {
Ok(p) => p,
Expand Down Expand Up @@ -527,19 +528,41 @@ async fn ep_payg_handler(

let (body, mut headers) = match res_fmt.to_str() {
Ok("inline") => {
let return_body = if let Ok(return_data) = String::from_utf8(data.clone()) {
return_data
} else {
let unique_title = format!(
let return_body = match String::from_utf8(data.clone()) {
Ok(return_data) => {
if data.is_empty() {
let account = ACCOUNT.read().await;
let indexer = account.indexer;
drop(account);
let indexer_string = format!("{:?}", indexer);
let unique_title = format!(
"payg ep_query_handler, proxy get empty and lead to inline returns empty, deployment_id: {}, ep_name: {}",
deployment, ep_name
);
let msg = format!(
"res_fmt: {:#?}, headers: {:#?}, body: {}, data: {:#?}, data length is {}, base64 data is {:#?}, account address is {:#?}, inactive is {}",
res_fmt, headers, body, data, data.len(), general_purpose::STANDARD.encode(&data), indexer_string, inactive
);
make_sentry_message(&unique_title, &msg);
}
return_data
}
Err(err) => {
let account = ACCOUNT.read().await;
let indexer = account.indexer;
drop(account);
let indexer_string = format!("{:?}", indexer);
let unique_title = format!(
"payg ep_query_handler, inline returns empty, deployment_id: {}, ep_name: {}",
deployment, ep_name
);
let msg = format!(
"res_fmt: {:#?}, headers: {:#?}, body: {}, data: {:?}",
res_fmt, headers, body, data
);
make_sentry_message(&unique_title, &msg);
"".to_owned()
let msg = format!(
"res_fmt: {:#?}, headers: {:#?}, body: {}, data: {:#?}, data length is {}, err is {:#?}, base64 data is {:#?}, account address is {:#?}, inactive is {}",
res_fmt, headers, body, data, data.len(), err, general_purpose::STANDARD.encode(&data), indexer_string,inactive
);
make_sentry_message(&unique_title, &msg);
"".to_owned()
}
};
(
return_body,
Expand Down
Loading