mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
test(rust): stabilize deferred SQL timeout cancellation (#5305)
The deferred-result timeout regression intermittently fails in the macOS SDK SQL job. The test pauses Tokio while opening a loopback DoGet, so the SDK deadline and the gRPC request timer can compete to finish the read. [Failure on main](https://github.com/lancedb/lancedb/actions/runs/46420851203/job/141855322793) Delay result-request headers so the SDK deadline expires before DoGet starts. The regression checks that the pending reader returns the overall timeout and that the Flight server receives cancellation. The timeout assertion also reports the unexpected result on failure.
This commit is contained in:
@@ -100,7 +100,8 @@ fn assert_overall_timeout<T>(result: Result<T>, operation: &str) {
|
||||
Err(Error::Runtime { message }) => {
|
||||
assert_eq!(message, format!("SQL query {operation} timed out"));
|
||||
}
|
||||
_ => panic!("SQL query {operation} did not honor the overall timeout"),
|
||||
Err(error) => panic!("SQL query {operation} did not honor the overall timeout: {error:?}"),
|
||||
Ok(_) => panic!("SQL query {operation} succeeded when a timeout was expected"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5623,13 +5624,29 @@ async fn a_deferred_result_timeout_sends_cancellation() {
|
||||
..TestSqlService::default()
|
||||
};
|
||||
let cancellations = service.cancel_count.clone();
|
||||
let (client, _shutdown) = start_sql_service(service, ClientConfig::default()).await;
|
||||
let mut request = ExecuteQueryRequest::new("SELECT slow get");
|
||||
let header_provider = Arc::new(DelayedHeaderProvider::default());
|
||||
let client_config = ClientConfig {
|
||||
header_provider: Some(header_provider.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
let (client, _shutdown) = start_sql_service(service, client_config).await;
|
||||
let mut request = ExecuteQueryRequest::new("SELECT 1");
|
||||
request.options.timeout = Some(Duration::from_secs(3));
|
||||
let query = client.execute(request).await.unwrap();
|
||||
|
||||
// Leave less than the header delay in the query budget before the reader starts.
|
||||
// The SDK deadline then expires while preparing headers, before DoGet starts.
|
||||
tokio::time::pause();
|
||||
tokio::time::advance(Duration::from_millis(2_900)).await;
|
||||
let result = query.reader().await;
|
||||
tokio::time::sleep(Duration::from_millis(2_500)).await;
|
||||
header_provider.delay_next.store(true, Ordering::SeqCst);
|
||||
let reader = query.reader();
|
||||
tokio::pin!(reader);
|
||||
assert!(futures::poll!(reader.as_mut()).is_pending());
|
||||
assert!(
|
||||
!header_provider.delay_next.load(Ordering::SeqCst),
|
||||
"the deferred reader must be preparing a result request"
|
||||
);
|
||||
let result = reader.await;
|
||||
tokio::time::resume();
|
||||
assert_overall_timeout(result, "result");
|
||||
wait_for(
|
||||
|
||||
Reference in New Issue
Block a user