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(query): filter response session settings with ScopeLevel::Session #14702

Merged
merged 2 commits into from
Feb 22, 2024
Merged
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
3 changes: 2 additions & 1 deletion scripts/ci/deploy/databend-query-standalone-hive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BUILD_PROFILE=${BUILD_PROFILE:-debug}

killall databend-query || true
killall databend-meta || true
killall open-sharing || true
sleep 1

for bin in databend-query databend-meta; do
Expand All @@ -31,4 +32,4 @@ echo 'Start databend-query...'
nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-hive.toml &

echo "Waiting on databend-query 10 seconds..."
python3 scripts/ci/wait_tcp.py --timeout 30 --port 3307
python3 scripts/ci/wait_tcp.py --timeout 30 --port 8000
3 changes: 1 addition & 2 deletions scripts/ci/deploy/databend-query-standalone-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ echo "Waiting on databend-meta 10 seconds..."
python3 scripts/ci/wait_tcp.py --timeout 30 --port 9191

echo 'Start databend-query with native...'

nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-native.toml --internal-enable-sandbox-tenant &

echo "Waiting on databend-query 10 seconds..."
python3 scripts/ci/wait_tcp.py --timeout 30 --port 3307
python3 scripts/ci/wait_tcp.py --timeout 30 --port 8000
2 changes: 1 addition & 1 deletion scripts/ci/deploy/databend-query-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ echo 'Start databend-query...'
nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-1.toml --internal-enable-sandbox-tenant &

echo "Waiting on databend-query 10 seconds..."
python3 scripts/ci/wait_tcp.py --timeout 30 --port 3307
python3 scripts/ci/wait_tcp.py --timeout 30 --port 8000
10 changes: 5 additions & 5 deletions src/query/service/src/servers/http/v1/query/http_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use databend_common_base::runtime::TrySpawn;
use databend_common_catalog::table_context::StageAttachment;
use databend_common_exception::ErrorCode;
use databend_common_exception::Result;
use databend_common_settings::ScopeLevel;
use log::info;
use log::warn;
use minitrace::prelude::*;
Expand Down Expand Up @@ -220,11 +221,10 @@ impl HttpQuery {
return Err(ErrorCode::BadArguments(
"last query on the session not finished",
));
} else {
let _ = http_query_manager
.remove_query(&query_id, RemoveReason::Canceled)
.await;
}
let _ = http_query_manager
.remove_query(&query_id, RemoveReason::Canceled)
.await;
}
// wait for Arc<QueryContextShared> to drop and detach itself from session
// should not take too long
Expand Down Expand Up @@ -473,7 +473,7 @@ impl HttpQuery {
.settings
.as_ref()
.into_iter()
.filter(|item| item.default_value != item.user_value)
.filter(|item| matches!(item.level, ScopeLevel::Session))
.map(|item| (item.name.to_string(), item.user_value.as_string()))
.collect::<BTreeMap<_, _>>();
let database = session_state.current_database.clone();
Expand Down
18 changes: 18 additions & 0 deletions src/query/service/tests/it/servers/http/http_query_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,24 @@ async fn test_affect() -> Result<()> {
)])),
}),
),
(
serde_json::json!({"sql": "set global max_threads=2", "session": {"settings": {"max_threads": "4", "timezone": "Asia/Shanghai"}}}),
Some(QueryAffect::ChangeSettings {
keys: vec!["max_threads".to_string()],
values: vec!["2".to_string()],
is_globals: vec![true],
}),
Some(HttpSessionConf {
database: Some("default".to_string()),
role: Some("account_admin".to_string()),
secondary_roles: None,
keep_server_session_secs: None,
settings: Some(BTreeMap::from([(
"timezone".to_string(),
"Asia/Shanghai".to_string(),
)])),
}),
),
];

for (json, affect, session_conf) in sqls {
Expand Down
Loading