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

chore(cubesql): Support extra_id for Session #8612

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

ovr
Copy link
Member

@ovr ovr commented Aug 22, 2024

No description provided.

Copy link

vercel bot commented Aug 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Aug 22, 2024 0:18am

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 75.94937% with 19 lines in your changes missing coverage. Please review.

Project coverage is 82.51%. Comparing base (b67a2f1) to head (1db70dd).
Report is 4 commits behind head on master.

Files Patch % Lines
rust/cubesql/cubesql/src/sql/session_manager.rs 66.66% 11 Missing ⚠️
rust/cubesql/cubesql/src/sql/postgres/service.rs 37.50% 5 Missing ⚠️
rust/cubesql/cubesql/src/sql/session.rs 93.54% 2 Missing ⚠️
rust/cubesql/cubesql/src/compile/test/mod.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8612      +/-   ##
==========================================
- Coverage   82.53%   82.51%   -0.02%     
==========================================
  Files         209      209              
  Lines       76688    76711      +23     
==========================================
+ Hits        63292    63297       +5     
- Misses      13396    13414      +18     
Flag Coverage Δ
cubesql 82.51% <75.94%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ovr ovr marked this pull request as ready for review August 22, 2024 12:42
@ovr ovr requested review from a team as code owners August 22, 2024 12:42
@ovr ovr merged commit 861f13e into master Aug 22, 2024
65 checks passed
@ovr ovr deleted the chore/cubesql-session-extra-id branch August 22, 2024 13:54
Copy link
Member

@mcheshkov mcheshkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, noticed some minor stuff

@@ -62,6 +62,8 @@ pub enum QueryState {
pub struct SessionState {
// connection id, immutable
pub connection_id: u32,
// Can be UUID or anything else. MDX uses UUID
pub extra_id: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to limit extra_id to UTF-8? Maybe Vec<u8>/Bytes would be better. UUID is representable with 16 raw bytes, AFAIK uuid crate does exactly that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -447,17 +412,58 @@ pub struct SessionProcessList {
pub database: Option<String>,
}

impl From<&Arc<Session>> for SessionProcessList {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need Arc here? It feels like impl From<&Session> should be enough here

}

pub async fn process_list(self: &Arc<Self>) -> Vec<SessionProcessList> {
pub async fn map_sessions<T: for<'a> From<&'a Arc<Session>>>(self: &Arc<Self>) -> Vec<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current map_sessions usages don't need Arc part, From<&'a Session> should be enough.
Arc here can be useful (e.g. to be able to clone Arc instance), but as it is now it's bit confusing to me


let mut guard = self.sessions.write().await;

guard.insert(connection_id, session_ref.clone());
if let Some(extra_id) = extra_id {
if guard.uid_to_session.contains_key(&extra_id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU, extra_id is user-controlled, so this place can trigger hashing of strings of arbitrary length.
Do we want to limit it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants