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

query add http api /v1/status #4454

Merged
merged 7 commits into from
Mar 15, 2022
Merged

query add http api /v1/status #4454

merged 7 commits into from
Mar 15, 2022

Conversation

youngsofun
Copy link
Member

@youngsofun youngsofun commented Mar 15, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

related issue #4354

add /v1/status which return running_queries_count, last_query_started_at, last_query_finished_at, may add other fields later.

pub struct Status {
    pub running_queries_count: u64,
    // secs since epoch
    pub last_query_started_at: Option<u64>,
    // secs since epoch
    pub last_query_finished_at: Option<u64>,
}

to make it lightweight, maintain the info in sessionManager and update on each query start/finish.

to ignore queries issued by admin api, change session type from string to enum. making it more useful.

Changelog

  • New Feature

Related Issues

Fixes #4354

Test Plan

Unit Tests

Stateless Tests

@vercel
Copy link

vercel bot commented Mar 15, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/databend/databend/Hh7CBw3H5Pqy7JJ55heY4q7G9Skb
✅ Preview: Canceled

[Deployment for b2f5874 canceled]

@mergify
Copy link
Contributor

mergify bot commented Mar 15, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Mar 15, 2022
use crate::sessions::SessionManager;

#[derive(Serialize, Deserialize, Eq, PartialEq, Debug)]
pub struct Status {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we also cover tenant_id and cluster_id? since those things update dynamically

Copy link
Member Author

Choose a reason for hiding this comment

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

ok I will check it

Copy link
Member Author

@youngsofun youngsofun Mar 15, 2022

Choose a reason for hiding this comment

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

@ZhiHanZ

since those things update dynamically

do you mean reload_config, what about get tenant_id and cluster_id through /v1/config?


fn secs_since_epoch(t: SystemTime) -> u64 {
t.duration_since(SystemTime::UNIX_EPOCH)
.expect("Time went backwards")
Copy link
Member

@flaneur2020 flaneur2020 Mar 15, 2022

Choose a reason for hiding this comment

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

i guess if the clock got skewed, this might panic the databend instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

we use this in multi place in data bend. resolve it as another issue?

Copy link
Member

Choose a reason for hiding this comment

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

ok to me, we may replace it with a default value on Err to replace the expect

@flaneur2020
Copy link
Member

/lgtm

Copy link
Collaborator

@ZhiHanZ ZhiHanZ left a comment

Choose a reason for hiding this comment

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

nice work

@mergify mergify bot merged commit c36243d into databendlabs:main Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: add /v1/status uri to show real time tenant, cluster, S3, and latest query endtime status
4 participants