Skip to content

Commit

Permalink
chore(sqlsmith): skip timeout queries (#16160)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel authored Apr 5, 2024
1 parent d0f8e58 commit 436884a
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/tests/sqlsmith/src/test_runners/diff.rs
Original file line number Diff line number Diff line change
@@ -100,13 +100,13 @@ async fn diff_stream_and_batch_with_sqls(

let select = format!("SELECT * FROM {}", &mview_name);
tracing::info!("[RUN SELECT * FROM MVIEW id={}]: {}", i, select);
let (skip_count, stream_result) = run_query_inner(12, client, &select).await?;
let (skip_count, stream_result) = run_query_inner(12, client, &select, true).await?;
if skip_count > 0 {
bail!("SQL should not fail: {:?}", select)
}

tracing::info!("[RUN - BATCH QUERY id={}]: {}", i, &batch);
let (skip_count, batch_result) = run_query_inner(12, client, batch).await?;
let (skip_count, batch_result) = run_query_inner(12, client, batch, true).await?;
if skip_count > 0 {
tracing::info!(
"[DIFF - DROP MVIEW id={}]: {}",
18 changes: 13 additions & 5 deletions src/tests/sqlsmith/src/test_runners/utils.rs
Original file line number Diff line number Diff line change
@@ -283,9 +283,10 @@ pub(super) fn validate_response(
}

pub(super) async fn run_query(timeout_duration: u64, client: &Client, query: &str) -> Result<i64> {
let (skipped_count, _) = run_query_inner(timeout_duration, client, query).await?;
let (skipped_count, _) = run_query_inner(timeout_duration, client, query, true).await?;
Ok(skipped_count)
}

/// Run query, handle permissible errors
/// For recovery error, just do bounded retry.
/// For other errors, validate them accordingly, skipping if they are permitted.
@@ -296,15 +297,22 @@ pub(super) async fn run_query_inner(
timeout_duration: u64,
client: &Client,
query: &str,
skip_timeout: bool,
) -> Result<(i64, Vec<SimpleQueryMessage>)> {
let query_task = client.simple_query(query);
let result = timeout(Duration::from_secs(timeout_duration), query_task).await;
let response = match result {
Ok(r) => r,
Err(_) => bail!(
"[UNEXPECTED ERROR] Query timeout after {timeout_duration}s:\n{:?}",
query
),
Err(_) => {
if skip_timeout {
return Ok((1, vec![]));
} else {
bail!(
"[UNEXPECTED ERROR] Query timeout after {timeout_duration}s:\n{:?}",
query
)
}
}
};
if let Err(e) = &response
&& let Some(e) = e.as_db_error()

0 comments on commit 436884a

Please sign in to comment.