Skip to content

Commit

Permalink
Make any query on system.local go with WHERE clause
Browse files Browse the repository at this point in the history
Full scan requests are slower even if there is only one record.
  • Loading branch information
dkropachev committed Feb 14, 2025
1 parent 44b5159 commit 3ce6643
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scylla/src/cluster/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ async fn query_peers(
.and_then(|row_result| future::ok((NodeInfoSource::Peer, row_result)));

let mut local_query =
Query::new("select host_id, rpc_address, data_center, rack, tokens from system.local");
Query::new("select host_id, rpc_address, data_center, rack, tokens from system.local WHERE key='local'");
local_query.set_page_size(METADATA_QUERY_PAGE_SIZE);
let local_query_stream = conn
.clone()
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/network/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ mod tests {
// As everything is normal, these queries should succeed.
for _ in 0..3 {
tokio::time::sleep(Duration::from_millis(500)).await;
conn.query_unpaged("SELECT host_id FROM system.local")
conn.query_unpaged("SELECT host_id FROM system.local WHERE key='local'")
.await
.unwrap();
}
Expand All @@ -2610,7 +2610,7 @@ mod tests {

// As the router is invalidated, all further queries should immediately
// return error.
conn.query_unpaged("SELECT host_id FROM system.local")
conn.query_unpaged("SELECT host_id FROM system.local WHERE key='local'")
.await
.unwrap_err();

Expand Down
2 changes: 1 addition & 1 deletion scylla/src/utils/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) async fn supports_feature(session: &Session, feature: &str) -> bool {
}

let result = session
.query_unpaged("SELECT supported_features FROM system.local", ())
.query_unpaged("SELECT supported_features FROM system.local WHERE key='local'", ())
.await
.unwrap()
.into_rows_result()
Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async fn successful_query_history() {
setup_tracing();
let session = create_new_session_builder().build().await.unwrap();

let mut query = Query::new("SELECT * FROM system.local");
let mut query = Query::new("SELECT * FROM system.local WHERE key='local'");
let history_collector = Arc::new(HistoryCollector::new());
query.set_history_listener(history_collector.clone());

Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/new_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn proceed_if_only_some_hostnames_are_invalid() {
.await
.unwrap();
session
.query_unpaged("SELECT host_id FROM system.local", &[])
.query_unpaged("SELECT host_id FROM system.local WHERE key='local'", &[])
.await
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub(crate) async fn supports_feature(session: &Session, feature: &str) -> bool {
}

let result = session
.query_unpaged("SELECT supported_features FROM system.local", ())
.query_unpaged("SELECT supported_features FROM system.local WHERE key='local'", ())
.await
.unwrap()
.into_rows_result()
Expand Down
2 changes: 1 addition & 1 deletion test/cluster/docker-compose-passauth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
ports:
- "9042:9042"
healthcheck:
test: [ "CMD", "cqlsh", "scylla", "-e", "select * from system.local" ]
test: [ "CMD", "cqlsh", "scylla", "-e", "select * from system.local WHERE key='local'" ]
interval: 5s
timeout: 5s
retries: 60
6 changes: 3 additions & 3 deletions test/cluster/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
--smp 2
--memory 1G
healthcheck:
test: [ "CMD", "cqlsh", "scylla1", "-e", "select * from system.local" ]
test: [ "CMD", "cqlsh", "scylla1", "-e", "select * from system.local WHERE key='local'" ]
interval: 5s
timeout: 5s
retries: 60
Expand All @@ -41,7 +41,7 @@ services:
--smp 2
--memory 1G
healthcheck:
test: [ "CMD", "cqlsh", "scylla2", "-e", "select * from system.local" ]
test: [ "CMD", "cqlsh", "scylla2", "-e", "select * from system.local WHERE key='local'" ]
interval: 5s
timeout: 5s
retries: 60
Expand All @@ -62,7 +62,7 @@ services:
--smp 2
--memory 1G
healthcheck:
test: [ "CMD", "cqlsh", "scylla3", "-e", "select * from system.local" ]
test: [ "CMD", "cqlsh", "scylla3", "-e", "select * from system.local WHERE key='local'" ]
interval: 5s
timeout: 5s
retries: 60
Expand Down
2 changes: 1 addition & 1 deletion test/tls/docker-compose-tls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
- "9042:9042"
- "9142:9142"
healthcheck:
test: [ "CMD", "cqlsh", "scylla", "-e", "select * from system.local" ]
test: [ "CMD", "cqlsh", "scylla", "-e", "select * from system.local WHERE key='local'" ]
interval: 5s
timeout: 5s
retries: 60

0 comments on commit 3ce6643

Please sign in to comment.