Skip to content

Commit

Permalink
feat: add the system.queries table (#24992)
Browse files Browse the repository at this point in the history
The system.queries table is now accessible, when queries are initiated
in debug mode, which is not currently enabled via the HTTP API, therefore
this is not yet accessible unless via the gRPC interface.

The system.queries table lists all queries in the QueryLog on the
QueryExecutorImpl.
  • Loading branch information
hiltontj committed May 17, 2024
1 parent 1cb3652 commit 0201feb
Show file tree
Hide file tree
Showing 7 changed files with 440 additions and 62 deletions.
89 changes: 51 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions influxdb3/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ pub struct Config {
action
)]
pub segment_duration: SegmentDuration,

// TODO - tune this default:
/// The size of the query log. Up to this many queries will remain in the log before
/// old queries are evicted to make room for new ones.
#[clap(
long = "query-log-size",
env = "INFLUXDB3_QUERY_LOG_SIZE",
default_value = "1000",
action
)]
pub query_log_size: usize,
}

/// If `p` does not exist, try to create it as a directory.
Expand Down Expand Up @@ -275,6 +286,7 @@ pub async fn command(config: Config) -> Result<()> {
Arc::clone(&metrics),
Arc::new(config.datafusion_config),
10,
config.query_log_size,
));

let builder = ServerBuilder::new(common_state)
Expand Down
13 changes: 12 additions & 1 deletion influxdb3/tests/server/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod flight;
mod limits;
mod ping;
mod query;
mod system_tables;
mod write;

/// Configuration for a [`TestServer`]
Expand Down Expand Up @@ -115,14 +116,24 @@ impl TestServer {

/// Get a [`FlightSqlClient`] for making requests to the running service over gRPC
pub async fn flight_sql_client(&self, database: &str) -> FlightSqlClient {
self.flight_sql_client_debug_mode(database, false).await
}

pub async fn flight_sql_client_debug_mode(
&self,
database: &str,
debug_mode: bool,
) -> FlightSqlClient {
let channel = tonic::transport::Channel::from_shared(self.client_addr())
.expect("create tonic channel")
.connect()
.await
.expect("connect to gRPC client");
let mut client = FlightSqlClient::new(channel);
client.add_header("database", database).unwrap();
client.add_header("iox-debug", "true").unwrap();
if debug_mode {
client.add_header("iox-debug", "true").unwrap();
}
client
}

Expand Down
Loading

0 comments on commit 0201feb

Please sign in to comment.