From 5b48ef2c7ae53095d4d38aa31be75e3961bdecc9 Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Fri, 15 May 2026 00:27:12 +0000 Subject: [PATCH 1/7] fix(kernel): remove block_on from ResultStream async public surface krn-async-public-api: remove block_on from ResultStream and async public surface. ResultStream::next_batch and ResultReaderAdapter / OwnedBatchIter were declared async but the wrapped ResultReader trait was sync, forcing CloudFetchResultReader to call self.runtime_handle.block_on on its async StreamingCloudFetchProvider. When ResultStream::next_batch().await ran from napi-rs's tokio runtime this triggered tokio's nested-runtime safety check and panicked. Made the kernel-internal ResultReader trait async (via async_trait, already a dependency). CloudFetchResultReader now awaits its provider directly. ResultStream::from_reader becomes pub(crate) async fn (schema is pulled asynchronously); ResultStream::next_batch awaits the reader without block_on; in-memory readers (InMemoryReader, EmptyReader, InlineArrowReader, the four test mocks) gain async impls that resolve immediately. OwnedBatchIter and ResultReaderAdapter keep their sync Iterator surfaces via futures::executor::block_on (executor-agnostic, not tokio), with doc-comments noting that CloudFetch consumers must drive them from inside a tokio context. No new dependencies. Sync C ABI in src/ffi/ unchanged (still unimplemented!()). Files: src/reader/mod.rs, src/reader/test_utils.rs, src/result_stream.rs, src/statement/mutable.rs, src/statement/executed_async.rs, src/metadata_v0.rs, src/metadata/static_data.rs Tests: cargo check pass, cargo test --lib pass (366 passed) Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- src/client/sea.rs | 6 +- src/metadata/static_data.rs | 22 ++-- src/metadata/thrift_shape.rs | 7 +- src/metadata_v0.rs | 30 +++--- src/reader/mod.rs | 173 +++++++++++++++++--------------- src/reader/test_utils.rs | 21 ++-- src/result_stream.rs | 110 +++++++++++--------- src/statement/executed_async.rs | 2 +- src/statement/mutable.rs | 2 +- 9 files changed, 207 insertions(+), 166 deletions(-) diff --git a/src/client/sea.rs b/src/client/sea.rs index a47ecd3e..a9f3f425 100644 --- a/src/client/sea.rs +++ b/src/client/sea.rs @@ -376,7 +376,9 @@ impl SeaRestTransport { // attributes to recover the precise type for columns whose // Arrow shape collapses (VARIANT → Utf8, intervals → Interval, // GEOMETRY/GEOGRAPHY → Utf8). - let reader = reader_factory.create_reader(&response.statement_id, &response)?; + let reader = reader_factory + .create_reader(&response.statement_id, &response) + .await?; // `server_state` carries the terminal state forward so the // executed handle can skip a redundant CloseStatement when @@ -518,7 +520,7 @@ impl Transport for SeaRestTransport { match Self::terminal_outcome(response) { StatementOutcome::Done(r) => { let reader_factory = self.reader_factory()?; - let reader = reader_factory.create_reader(&r.statement_id, &r)?; + let reader = reader_factory.create_reader(&r.statement_id, &r).await?; let server_state = r.status.state; Ok(Some(ExecuteResult { statement_id: r.statement_id, diff --git a/src/metadata/static_data.rs b/src/metadata/static_data.rs index ec23b5ac..763f1909 100644 --- a/src/metadata/static_data.rs +++ b/src/metadata/static_data.rs @@ -692,20 +692,20 @@ mod tests { use super::*; use arrow_array::Array; - #[test] - fn type_info_reader_yields_expected_shape() { + #[tokio::test] + async fn type_info_reader_yields_expected_shape() { let mut r = type_info_reader(); - let rb = r.next_batch().unwrap().expect("one batch"); + let rb = r.next_batch().await.unwrap().expect("one batch"); assert_eq!(rb.schema(), *TYPE_INFO_SCHEMA); assert!(rb.num_rows() >= 19, "{} rows", rb.num_rows()); // Stream is exhausted after the first batch. - assert!(r.next_batch().unwrap().is_none()); + assert!(r.next_batch().await.unwrap().is_none()); } - #[test] - fn type_info_includes_required_databricks_types() { + #[tokio::test] + async fn type_info_includes_required_databricks_types() { let mut r = type_info_reader(); - let rb = r.next_batch().unwrap().unwrap(); + let rb = r.next_batch().await.unwrap().unwrap(); let names = rb .column_by_name("TYPE_NAME") .unwrap() @@ -734,15 +734,15 @@ mod tests { } } - #[test] - fn table_types_reader_yields_provided_types() { + #[tokio::test] + async fn table_types_reader_yields_provided_types() { let types = vec!["TABLE".to_string(), "VIEW".to_string()]; let mut r = table_types_reader(&types); - let rb = r.next_batch().unwrap().expect("one batch"); + let rb = r.next_batch().await.unwrap().expect("one batch"); assert_eq!(rb.num_rows(), 2); let arr = rb.column(0).as_any().downcast_ref::().unwrap(); assert_eq!(arr.value(0), "TABLE"); assert_eq!(arr.value(1), "VIEW"); - assert!(r.next_batch().unwrap().is_none()); + assert!(r.next_batch().await.unwrap().is_none()); } } diff --git a/src/metadata/thrift_shape.rs b/src/metadata/thrift_shape.rs index 7723ee36..7f7ab3ff 100644 --- a/src/metadata/thrift_shape.rs +++ b/src/metadata/thrift_shape.rs @@ -633,13 +633,14 @@ impl ThriftReshapingReader { } } +#[async_trait::async_trait] impl ResultReader for ThriftReshapingReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { - match self.upstream.next_batch()? { + async fn next_batch(&mut self) -> Result> { + match self.upstream.next_batch().await? { Some(b) => Ok(Some((self.reshape)(&b)?)), None => Ok(None), } diff --git a/src/metadata_v0.rs b/src/metadata_v0.rs index 4ece48e8..0002be2b 100644 --- a/src/metadata_v0.rs +++ b/src/metadata_v0.rs @@ -98,12 +98,12 @@ use std::sync::Arc; /// an empty stream typed to the operation's JDBC schema; pass other /// errors through. Matches the JDBC driver's /// `isObjectNotFoundException → empty getXResult` pattern. -fn not_found_or(err: Error, schema: SchemaRef, otherwise: F) -> Result +async fn not_found_or(err: Error, schema: SchemaRef, otherwise: F) -> Result where F: FnOnce(Error) -> Result, { if is_object_not_found(&err) { - ResultStream::from_reader(Box::new(EmptyReader::new(schema))) + ResultStream::from_reader(Box::new(EmptyReader::new(schema))).await } else { otherwise(err) } @@ -254,7 +254,7 @@ impl Metadata { GET_CATALOGS_SCHEMA.clone(), Box::new(thrift_shape::reshape_catalogs), ); - ResultStream::from_reader(Box::new(reshaped)) + ResultStream::from_reader(Box::new(reshaped)).await } /// Schemas filtered by catalog (exact) and schema name pattern. @@ -281,14 +281,14 @@ impl Metadata { .await { Ok(r) => r, - Err(e) => return not_found_or(e, GET_SCHEMAS_SCHEMA.clone(), Err), + Err(e) => return not_found_or(e, GET_SCHEMAS_SCHEMA.clone(), Err).await, }; let reshaped = ThriftReshapingReader::new( raw.reader, GET_SCHEMAS_SCHEMA.clone(), Box::new(move |b| thrift_shape::reshape_schemas(b, catalog_str.as_deref())), ); - ResultStream::from_reader(Box::new(reshaped)) + ResultStream::from_reader(Box::new(reshaped)).await } /// Tables filtered by catalog (exact), schema (pattern), table @@ -329,7 +329,7 @@ impl Metadata { .await { Ok(r) => r, - Err(e) => return not_found_or(e, GET_TABLES_SCHEMA.clone(), Err), + Err(e) => return not_found_or(e, GET_TABLES_SCHEMA.clone(), Err).await, }; let reshaped = ThriftReshapingReader::new( raw.reader, @@ -341,7 +341,7 @@ impl Metadata { thrift_shape::reshape_tables(b, catalog_str.as_deref(), types_ref.as_deref()) }), ); - ResultStream::from_reader(Box::new(reshaped)) + ResultStream::from_reader(Box::new(reshaped)).await } /// Columns of tables matching the filter. Catalog is optional and @@ -390,14 +390,14 @@ impl Metadata { .await { Ok(r) => r, - Err(e) => return not_found_or(e, GET_COLUMNS_SCHEMA.clone(), Err), + Err(e) => return not_found_or(e, GET_COLUMNS_SCHEMA.clone(), Err).await, }; let reshaped = ThriftReshapingReader::new( raw.reader, GET_COLUMNS_SCHEMA.clone(), Box::new(move |b| thrift_shape::reshape_columns(b, catalog_str.as_deref())), ); - ResultStream::from_reader(Box::new(reshaped)) + ResultStream::from_reader(Box::new(reshaped)).await } /// Primary keys for the given table. All three identifiers are @@ -438,7 +438,7 @@ impl Metadata { table.as_str(), ) .await?; - ResultStream::from_reader(raw.reader) + ResultStream::from_reader(raw.reader).await } /// Foreign-key relationships. Both parent and foreign sides are @@ -484,7 +484,7 @@ impl Metadata { foreign_table.as_str(), ) .await?; - ResultStream::from_reader(raw.reader) + ResultStream::from_reader(raw.reader).await } /// Functions visible to the session. Catalog is exact; schema / @@ -510,7 +510,7 @@ impl Metadata { name_pattern.as_ref().map(|p| p.as_str()), ) .await?; - ResultStream::from_reader(raw.reader) + ResultStream::from_reader(raw.reader).await } /// Procedures visible to the session. Catalog is exact; schema / @@ -535,7 +535,7 @@ impl Metadata { name_pattern.as_ref().map(|p| p.as_str()), ) .await?; - ResultStream::from_reader(raw.reader) + ResultStream::from_reader(raw.reader).await } /// SQL data types supported by the workspace. No filters. No wire @@ -543,7 +543,7 @@ impl Metadata { pub async fn type_info(&self) -> Result { let _g = self.session.log_span().clone().entered(); let reader = static_data::type_info_reader(); - ResultStream::from_reader(reader) + ResultStream::from_reader(reader).await } /// All table types (`TABLE`, `VIEW`, `SYSTEM TABLE`, …). No @@ -554,7 +554,7 @@ impl Metadata { let _g = self.session.log_span().clone().entered(); let types = self.session.transport().list_table_types(); let reader = static_data::table_types_reader(&types); - ResultStream::from_reader(reader) + ResultStream::from_reader(reader).await } } diff --git a/src/reader/mod.rs b/src/reader/mod.rs index 4abac058..8981dd58 100644 --- a/src/reader/mod.rs +++ b/src/reader/mod.rs @@ -32,9 +32,9 @@ use crate::reader::cloudfetch::streaming_provider::StreamingCloudFetchProvider; use crate::reader::inline::InlineArrowProvider; use crate::types::cloudfetch::{CloudFetchConfig, CloudFetchLink}; use crate::types::sea::{CompressionCodec, ResultManifest, StatementState}; -use crate::util::runtime::block_on_in_runtime; use arrow_array::RecordBatch; use arrow_schema::{ArrowError, DataType, Field, Schema, SchemaRef}; +use async_trait::async_trait; use std::sync::Arc; pub use cloudfetch::StreamingCloudFetchProvider as CloudFetchReader; @@ -85,16 +85,15 @@ impl ResultReaderFactory { /// to the wrapped reader's schema. Both sites share the same helper, /// so the metadata-attachment behaviour is consistent across the /// two surfaces. - pub(crate) fn create_reader( + pub(crate) async fn create_reader( &self, statement_id: &str, response: &ExecuteResponse, ) -> Result> { let inner = self.create_inner_reader(statement_id, response)?; - Ok(Box::new(ManifestAugmentingReader::new( - inner, - response.manifest.as_ref(), - )?)) + Ok(Box::new( + ManifestAugmentingReader::new(inner, response.manifest.as_ref()).await?, + )) } /// Pick the right concrete reader for `response`: CloudFetch, @@ -290,10 +289,7 @@ impl ResultReaderFactory { self.runtime_handle.clone(), ); - Ok(Box::new(CloudFetchResultReader::new( - provider, - self.runtime_handle.clone(), - ))) + Ok(Box::new(CloudFetchResultReader::new(provider))) } fn create_inline_reader( @@ -321,39 +317,39 @@ impl ResultReaderFactory { /// expectation of `async_trait` methods on the surrounding /// `ExecutedStatementHandle`. Practically every existing impl is /// already Sync (their state is `Arc`s or owned `Vec`s). +/// +/// Both methods are `async` so the CloudFetch implementation can +/// `.await` its underlying async provider directly — no internal +/// `block_on`. This is what makes the public `ResultStream::next_batch` +/// truly async and safe to call from a tokio runtime (e.g. napi-rs). +#[async_trait] pub trait ResultReader: Send + Sync { /// Get the schema of the result. - fn schema(&self) -> Result; + async fn schema(&self) -> Result; /// Get the next record batch, or None if end of results. - fn next_batch(&mut self) -> Result>; + async fn next_batch(&mut self) -> Result>; } /// Wrapper for StreamingCloudFetchProvider that implements ResultReader. struct CloudFetchResultReader { provider: Arc, - runtime_handle: tokio::runtime::Handle, } impl CloudFetchResultReader { - fn new( - provider: Arc, - runtime_handle: tokio::runtime::Handle, - ) -> Self { - Self { - provider, - runtime_handle, - } + fn new(provider: Arc) -> Self { + Self { provider } } } +#[async_trait] impl ResultReader for CloudFetchResultReader { - fn schema(&self) -> Result { - block_on_in_runtime(&self.runtime_handle, self.provider.get_schema()) + async fn schema(&self) -> Result { + self.provider.get_schema().await } - fn next_batch(&mut self) -> Result> { - block_on_in_runtime(&self.runtime_handle, self.provider.next_batch()) + async fn next_batch(&mut self) -> Result> { + self.provider.next_batch().await } } @@ -373,14 +369,15 @@ impl InlineArrowReader { } } +#[async_trait] impl ResultReader for InlineArrowReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { self.schema .clone() .ok_or_else(|| Error::invalid_state().message("Schema not available for inline result")) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { self.provider.next_batch() } } @@ -409,12 +406,13 @@ impl InMemoryReader { } } +#[async_trait] impl ResultReader for InMemoryReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { Ok(self.batches.next()) } } @@ -434,12 +432,13 @@ impl EmptyReader { } } +#[async_trait] impl ResultReader for EmptyReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { Ok(None) } } @@ -483,11 +482,11 @@ impl ManifestAugmentingReader { /// `databricks.*` keys. When it's `None`, the wrapper is a /// pass-through (so callers don't need to special-case the /// metadata-less path). - pub(crate) fn new( + pub(crate) async fn new( inner: Box, manifest: Option<&ResultManifest>, ) -> Result { - let schema = inner.schema()?; + let schema = inner.schema().await?; let schema = match manifest { Some(m) => ResultReaderAdapter::augment_schema_with_manifest(&schema, m), None => schema, @@ -496,13 +495,14 @@ impl ManifestAugmentingReader { } } +#[async_trait] impl ResultReader for ManifestAugmentingReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { - match self.inner.next_batch()? { + async fn next_batch(&mut self) -> Result> { + match self.inner.next_batch().await? { None => Ok(None), Some(batch) => { // Re-project the batch's columns onto our augmented @@ -539,11 +539,15 @@ pub struct ResultReaderAdapter { impl ResultReaderAdapter { /// Create a new adapter wrapping a ResultReader, optionally augmenting the /// schema with Databricks column metadata from the SEA manifest. - pub fn new( + /// + /// `async` because [`ResultReader::schema`] is async (the CloudFetch + /// reader forces the first chunk to download to extract the schema). + /// In-memory readers resolve their schema synchronously. + pub async fn new( inner: Box, manifest: Option<&ResultManifest>, ) -> Result { - let schema = inner.schema()?; + let schema = inner.schema().await?; let schema = match manifest { Some(m) => Self::augment_schema_with_manifest(&schema, m), None => schema, @@ -624,7 +628,14 @@ impl Iterator for ResultReaderAdapter { type Item = std::result::Result; fn next(&mut self) -> Option { - match self.inner.next_batch() { + // Sync `Iterator` adapter for arrow's `RecordBatchReader`. + // Uses the executor-agnostic `futures::executor::block_on` so + // this works in non-tokio contexts (e.g. unit tests) for + // in-memory readers whose futures are immediately ready. For + // CloudFetch readers (which use tokio primitives internally), + // callers must drive iteration from inside a tokio runtime + // context — use the async `ResultStream::next_batch` instead. + match futures::executor::block_on(self.inner.next_batch()) { Ok(Some(batch)) => Some(Ok(batch)), Ok(None) => None, Err(e) => Some(Err(ArrowError::ExternalError(Box::new( @@ -648,22 +659,22 @@ mod tests { // --- ResultReaderAdapter tests --- - #[test] - fn test_adapter_schema() { + #[tokio::test] + async fn test_adapter_schema() { let batch = make_test_batch(vec!["a"]); let reader: Box = Box::new(MockReader::new(vec![batch])); - let adapter = ResultReaderAdapter::new(reader, None).unwrap(); + let adapter = ResultReaderAdapter::new(reader, None).await.unwrap(); let schema = arrow_array::RecordBatchReader::schema(&adapter); assert_eq!(schema.fields().len(), 1); assert_eq!(schema.field(0).name(), "name"); } - #[test] - fn test_adapter_iterates_batches() { + #[tokio::test] + async fn test_adapter_iterates_batches() { let batch1 = make_test_batch(vec!["a", "b"]); let batch2 = make_test_batch(vec!["c"]); let reader: Box = Box::new(MockReader::new(vec![batch1, batch2])); - let mut adapter = ResultReaderAdapter::new(reader, None).unwrap(); + let mut adapter = ResultReaderAdapter::new(reader, None).await.unwrap(); let first = adapter.next().unwrap().unwrap(); assert_eq!(first.num_rows(), 2); @@ -674,34 +685,34 @@ mod tests { assert!(adapter.next().is_none()); } - #[test] - fn test_adapter_empty_reader() { + #[tokio::test] + async fn test_adapter_empty_reader() { let reader: Box = Box::new(MockReader::new(vec![])); - let mut adapter = ResultReaderAdapter::new(reader, None).unwrap(); + let mut adapter = ResultReaderAdapter::new(reader, None).await.unwrap(); assert!(adapter.next().is_none()); } - #[test] - fn test_adapter_propagates_error() { + #[tokio::test] + async fn test_adapter_propagates_error() { let schema = Arc::new(Schema::new(vec![Field::new("x", DataType::Utf8, false)])); let reader: Box = Box::new(ErrorReader { schema }); - let mut adapter = ResultReaderAdapter::new(reader, None).unwrap(); + let mut adapter = ResultReaderAdapter::new(reader, None).await.unwrap(); let result = adapter.next().unwrap(); assert!(result.is_err()); } - #[test] - fn test_adapter_schema_error() { + #[tokio::test] + async fn test_adapter_schema_error() { let reader: Box = Box::new(SchemaErrorReader); - let result = ResultReaderAdapter::new(reader, None); + let result = ResultReaderAdapter::new(reader, None).await; assert!(result.is_err()); } // --- EmptyReader tests --- - #[test] - fn test_empty_reader_with_schema() { + #[tokio::test] + async fn test_empty_reader_with_schema() { let schema = Arc::new(Schema::new(vec![ Field::new("id", DataType::Int64, false), Field::new("name", DataType::Utf8, true), @@ -709,22 +720,22 @@ mod tests { let mut reader = EmptyReader::new(schema.clone()); // Schema should be preserved - let result_schema = reader.schema().unwrap(); + let result_schema = reader.schema().await.unwrap(); assert_eq!(result_schema.fields().len(), 2); assert_eq!(result_schema.field(0).name(), "id"); assert_eq!(result_schema.field(1).name(), "name"); // Should return no batches - assert!(reader.next_batch().unwrap().is_none()); + assert!(reader.next_batch().await.unwrap().is_none()); } - #[test] - fn test_empty_reader_with_empty_schema() { + #[tokio::test] + async fn test_empty_reader_with_empty_schema() { let schema = Arc::new(Schema::empty()); let mut reader = EmptyReader::new(schema); - assert_eq!(reader.schema().unwrap().fields().len(), 0); - assert!(reader.next_batch().unwrap().is_none()); + assert_eq!(reader.schema().await.unwrap().fields().len(), 0); + assert!(reader.next_batch().await.unwrap().is_none()); } #[test] @@ -946,15 +957,17 @@ mod tests { ); } - #[test] - fn test_adapter_with_manifest() { + #[tokio::test] + async fn test_adapter_with_manifest() { let batch = make_test_batch(vec!["hello"]); let reader: Box = Box::new(MockReader::new(vec![batch])); let manifest = make_manifest(vec![make_column_info( "name", "STRING", "STRING", 0, None, None, None, )]); - let adapter = ResultReaderAdapter::new(reader, Some(&manifest)).unwrap(); + let adapter = ResultReaderAdapter::new(reader, Some(&manifest)) + .await + .unwrap(); let schema = arrow_array::RecordBatchReader::schema(&adapter); assert_eq!( schema.field(0).metadata().get(metadata_keys::TYPE_NAME), @@ -962,12 +975,12 @@ mod tests { ); } - #[test] - fn test_adapter_without_manifest() { + #[tokio::test] + async fn test_adapter_without_manifest() { let batch = make_test_batch(vec!["hello"]); let reader: Box = Box::new(MockReader::new(vec![batch])); - let adapter = ResultReaderAdapter::new(reader, None).unwrap(); + let adapter = ResultReaderAdapter::new(reader, None).await.unwrap(); let schema = arrow_array::RecordBatchReader::schema(&adapter); // No databricks metadata when manifest is None assert!(!schema @@ -978,8 +991,8 @@ mod tests { // --- ManifestAugmentingReader tests --- - #[test] - fn test_manifest_augmenting_reader_attaches_metadata_to_schema_and_batches() { + #[tokio::test] + async fn test_manifest_augmenting_reader_attaches_metadata_to_schema_and_batches() { // Server-shape: Utf8 column the kernel doesn't otherwise know // is a VARIANT. The manifest carries the precise type. let batch = make_test_batch(vec!["{\"a\":1}"]); @@ -988,10 +1001,12 @@ mod tests { "name", "VARIANT", "VARIANT", 0, None, None, None, )]); - let mut wrapper = ManifestAugmentingReader::new(reader, Some(&manifest)).unwrap(); + let mut wrapper = ManifestAugmentingReader::new(reader, Some(&manifest)) + .await + .unwrap(); // Stream-level schema carries the metadata. - let schema = wrapper.schema().unwrap(); + let schema = wrapper.schema().await.unwrap(); assert_eq!( schema.field(0).metadata().get(metadata_keys::TYPE_NAME), Some(&"VARIANT".to_string()) @@ -1000,7 +1015,7 @@ mod tests { // Batches emitted by `next_batch` are re-projected onto the // augmented schema, so consumers reading `batch.schema()` // also see the metadata. - let batch = wrapper.next_batch().unwrap().expect("one batch"); + let batch = wrapper.next_batch().await.unwrap().expect("one batch"); assert_eq!( batch .schema() @@ -1009,16 +1024,16 @@ mod tests { .get(metadata_keys::TYPE_NAME), Some(&"VARIANT".to_string()) ); - assert!(wrapper.next_batch().unwrap().is_none()); + assert!(wrapper.next_batch().await.unwrap().is_none()); } - #[test] - fn test_manifest_augmenting_reader_passes_through_when_manifest_absent() { + #[tokio::test] + async fn test_manifest_augmenting_reader_passes_through_when_manifest_absent() { let batch = make_test_batch(vec!["plain"]); let reader: Box = Box::new(MockReader::new(vec![batch])); - let mut wrapper = ManifestAugmentingReader::new(reader, None).unwrap(); - let schema = wrapper.schema().unwrap(); + let mut wrapper = ManifestAugmentingReader::new(reader, None).await.unwrap(); + let schema = wrapper.schema().await.unwrap(); assert!( !schema .field(0) @@ -1027,7 +1042,7 @@ mod tests { "no manifest → no databricks.* metadata" ); - let batch = wrapper.next_batch().unwrap().expect("one batch"); + let batch = wrapper.next_batch().await.unwrap().expect("one batch"); assert!( !batch .schema() diff --git a/src/reader/test_utils.rs b/src/reader/test_utils.rs index fab63499..0e4e3ffb 100644 --- a/src/reader/test_utils.rs +++ b/src/reader/test_utils.rs @@ -18,6 +18,7 @@ use crate::kernel_error::{Error, Result}; use crate::reader::ResultReader; use arrow_array::RecordBatch; use arrow_schema::{Schema, SchemaRef}; +use async_trait::async_trait; use std::sync::Arc; /// A simple mock reader that returns predefined batches. @@ -42,12 +43,13 @@ impl MockReader { } } +#[async_trait] impl ResultReader for MockReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { if self.index >= self.batches.len() { Ok(None) } else { @@ -63,12 +65,13 @@ pub struct ErrorReader { pub schema: SchemaRef, } +#[async_trait] impl ResultReader for ErrorReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { Err(Error::io().message("simulated read error")) } } @@ -83,12 +86,13 @@ pub struct BatchThenErrorReader { pub batch: Option, } +#[async_trait] impl ResultReader for BatchThenErrorReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { match self.batch.take() { Some(b) => Ok(Some(b)), None => Err(Error::io().message("simulated read error after first batch")), @@ -99,12 +103,13 @@ impl ResultReader for BatchThenErrorReader { /// A reader that returns an error on `schema()`. pub struct SchemaErrorReader; +#[async_trait] impl ResultReader for SchemaErrorReader { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Err(Error::io().message("schema unavailable")) } - fn next_batch(&mut self) -> Result> { + async fn next_batch(&mut self) -> Result> { Ok(None) } } diff --git a/src/result_stream.rs b/src/result_stream.rs index a498972d..8dc4eb20 100644 --- a/src/result_stream.rs +++ b/src/result_stream.rs @@ -432,15 +432,19 @@ fn type_mismatch(col: usize, expected: &str, actual: &DataType) -> Error { /// the polymorphism is hidden. #[non_exhaustive] pub struct ResultStream { - /// Wrapped synchronous reader. The reader's `next_batch` is - /// already sync and does no I/O for in-memory readers; for - /// CloudFetch / inline readers it `block_on`s the runtime - /// internally. PR 5 generalises this to drive truly-async - /// fetches without `block_on`. + /// Wrapped async reader. The reader's `next_batch` is `async fn` + /// — for in-memory readers the future is immediately ready; for + /// CloudFetch it drives the underlying `StreamingCloudFetchProvider` + /// directly. No `block_on` is performed anywhere on this path, so + /// `ResultStream::next_batch` is safe to `.await` from any tokio + /// runtime (including napi-rs's). reader: Box, - /// Cached schema. Filled in eagerly by [`ResultStream::from_reader`] - /// so [`ResultStream::schema`] is non-fallible. + /// Cached schema. Filled in eagerly by + /// [`ResultStream::from_reader`] (which is `async` because pulling + /// the schema from a CloudFetch reader forces the first chunk to + /// download) so [`ResultStream::schema`] is non-fallible and + /// synchronous. schema: SchemaRef, /// The most recent batch returned by [`ResultStream::next_batch`]. @@ -470,10 +474,13 @@ impl ResultStream { /// /// Pulls the reader's schema eagerly so `ResultStream::schema` /// is non-fallible and available before any batches are - /// requested. v0 only ever wraps Arrow-producing readers, so - /// every batch is wrapped in [`ResultBatch::Arrow`]. - pub(crate) fn from_reader(reader: Box) -> Result { - let schema = reader.schema()?; + /// requested. `async` because the CloudFetch reader resolves its + /// schema by forcing the first chunk to download; in-memory and + /// inline readers resolve immediately. v0 only ever wraps + /// Arrow-producing readers, so every batch is wrapped in + /// [`ResultBatch::Arrow`]. + pub(crate) async fn from_reader(reader: Box) -> Result { + let schema = reader.schema().await?; Ok(Self { reader, schema, @@ -506,15 +513,15 @@ impl ResultStream { /// are non-breaking). /// /// **v0 implementation note.** The wrapped `ResultReader` is - /// synchronous (it `block_on`s internally for the - /// network-driving variants). The `async fn` signature is the - /// **forward-compatible** API the spec mandates; PR 5 swaps the - /// body for a real async path without breaking callers. + /// async-native — `next_batch` awaits the underlying provider + /// (CloudFetch / inline / in-memory) directly. No `block_on` is + /// performed on this path, so calling from a tokio runtime + /// (napi-rs, PyO3 async) is safe. pub async fn next_batch(&mut self) -> Result> { if self.exhausted { return Ok(None); } - match self.reader.next_batch()? { + match self.reader.next_batch().await? { Some(rb) => { self.current = Some(ResultBatch::Arrow(rb)); self.current_row_idx = 0; @@ -583,10 +590,13 @@ impl ResultStream { /// where carrying a borrow across a host-language boundary /// isn't expressible. /// - /// The wrapped reader is synchronous (it `block_on`s the - /// runtime internally for CloudFetch), so this iterator does - /// not need a separate tokio handle — `next()` is a plain - /// blocking call. Errors are surfaced once; subsequent calls + /// The wrapped reader is async; `next()` drives it via + /// `futures::executor::block_on`, which is executor-agnostic and + /// works in non-tokio contexts for in-memory readers. For + /// CloudFetch readers (which use tokio primitives internally), + /// `next()` must be called from inside a tokio runtime context + /// — see the `tokio::task::block_in_place` pattern in + /// `docs/spec-v0.md`. Errors are surfaced once; subsequent calls /// after an `Err` keep returning `None`. pub fn into_owned_batches(self) -> OwnedBatchIter { OwnedBatchIter { @@ -614,7 +624,11 @@ impl Iterator for OwnedBatchIter { if self.done { return None; } - match self.reader.next_batch() { + // Executor-agnostic blocking poll. Safe for in-memory readers + // (immediately-ready futures). CloudFetch readers must be + // driven from inside a tokio runtime context — the underlying + // provider uses tokio primitives. + match futures::executor::block_on(self.reader.next_batch()) { Ok(Some(batch)) => Some(Ok(batch)), Ok(None) => { self.done = true; @@ -645,10 +659,12 @@ mod tests { Arc::new(ArrowSchema::new(fields)) } - fn stream_with(batch: RecordBatch) -> ResultStream { + async fn stream_with(batch: RecordBatch) -> ResultStream { let schema = batch.schema(); let reader = InMemoryReader::new(schema, vec![batch]); - ResultStream::from_reader(Box::new(reader)).expect("from_reader") + ResultStream::from_reader(Box::new(reader)) + .await + .expect("from_reader") } async fn advance_to_first_row(stream: &mut ResultStream) { @@ -668,7 +684,7 @@ mod tests { let schema = schema_for(vec![Field::new("s", DataType::Utf8, true)]); let arr: ArrayRef = Arc::new(StringArray::from(vec![Some("hi"), None])); let batch = RecordBatch::try_new(schema, vec![arr]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); @@ -695,7 +711,7 @@ mod tests { ], ) .unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert_eq!(r.get_i64(0).unwrap(), Some(1)); @@ -709,7 +725,7 @@ mod tests { let schema = schema_for(vec![Field::new("a", DataType::Int64, false)]); let batch = RecordBatch::try_new(schema, vec![Arc::new(Int64Array::from(vec![1_i64]))]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); let err = r.get_i32(0).unwrap_err(); @@ -732,7 +748,7 @@ mod tests { ], ) .unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert_eq!(r.get_u8(0).unwrap(), Some(7)); @@ -754,7 +770,7 @@ mod tests { ], ) .unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert!((r.get_f64(0).unwrap().unwrap() - 1.5).abs() < f64::EPSILON); @@ -778,7 +794,7 @@ mod tests { ], ) .unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert_eq!(r.get_bool(0).unwrap(), Some(true)); @@ -797,7 +813,7 @@ mod tests { .unwrap(), ); let batch = RecordBatch::try_new(schema, vec![arr]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert_eq!(r.get_decimal(0).unwrap().as_deref(), Some("-123.45")); @@ -818,7 +834,7 @@ mod tests { .unwrap(), ); let batch = RecordBatch::try_new(schema, vec![arr]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert_eq!(r.get_decimal(0).unwrap().as_deref(), Some("-123.456")); @@ -848,7 +864,7 @@ mod tests { ], ) .unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); assert_eq!(r.get_date(0).unwrap(), Some(date)); @@ -860,7 +876,7 @@ mod tests { let schema = schema_for(vec![Field::new("s", DataType::Utf8, false)]); let batch = RecordBatch::try_new(schema, vec![Arc::new(StringArray::from(vec!["x"]))]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; let r = first_row(&mut stream); let err = r.get_i64(0).unwrap_err(); @@ -873,7 +889,7 @@ mod tests { let schema = schema_for(vec![Field::new("a", DataType::Int32, false)]); let batch = RecordBatch::try_new(schema, vec![Arc::new(Int32Array::from(vec![1, 2, 3]))]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; advance_to_first_row(&mut stream).await; assert_eq!( stream @@ -915,7 +931,7 @@ mod tests { .unwrap(); let b2 = RecordBatch::try_new(schema, vec![Arc::new(Int32Array::from(vec![30]))]).unwrap(); let reader = InMemoryReader::new(b1.schema(), vec![b1, b2]); - let mut stream = ResultStream::from_reader(Box::new(reader)).unwrap(); + let mut stream = ResultStream::from_reader(Box::new(reader)).await.unwrap(); stream.next_batch().await.unwrap().unwrap(); assert!(stream.next_row_in_batch().is_some()); @@ -941,7 +957,7 @@ mod tests { let schema = schema_for(vec![Field::new("a", DataType::Int32, false)]); let batch = RecordBatch::try_new(schema, vec![Arc::new(Int32Array::from(vec![1]))]).unwrap(); - let mut stream = stream_with(batch); + let mut stream = stream_with(batch).await; // Pull and exhaust. stream.next_batch().await.unwrap(); assert!(stream.next_batch().await.unwrap().is_none()); @@ -949,15 +965,17 @@ mod tests { assert!(stream.next_batch().await.unwrap().is_none()); } - #[test] - fn into_owned_batches_yields_then_terminates() { - // Pure-sync iterator path — no tokio needed. + #[tokio::test] + async fn into_owned_batches_yields_then_terminates() { + // Stream construction is async (schema pulled via async fn); + // the iterator itself is sync and drives in-memory readers via + // `futures::executor::block_on`. let schema = schema_for(vec![Field::new("a", DataType::Int32, false)]); let b1 = RecordBatch::try_new(schema.clone(), vec![Arc::new(Int32Array::from(vec![1, 2]))]) .unwrap(); let b2 = RecordBatch::try_new(schema, vec![Arc::new(Int32Array::from(vec![3]))]).unwrap(); let reader = InMemoryReader::new(b1.schema(), vec![b1.clone(), b2.clone()]); - let stream = ResultStream::from_reader(Box::new(reader)).unwrap(); + let stream = ResultStream::from_reader(Box::new(reader)).await.unwrap(); let mut iter = stream.into_owned_batches(); let first = iter.next().unwrap().unwrap(); @@ -968,14 +986,14 @@ mod tests { assert!(iter.next().is_none(), "still None on subsequent calls"); } - #[test] - fn into_owned_batches_stops_after_error() { + #[tokio::test] + async fn into_owned_batches_stops_after_error() { // ErrorReader yields one Err then would yield None; iterator // surfaces the error once and terminates. use crate::reader::test_utils::ErrorReader; let schema = schema_for(vec![Field::new("a", DataType::Int32, false)]); let reader = ErrorReader { schema }; - let stream = ResultStream::from_reader(Box::new(reader)).unwrap(); + let stream = ResultStream::from_reader(Box::new(reader)).await.unwrap(); let mut iter = stream.into_owned_batches(); let first = iter.next().unwrap(); @@ -984,8 +1002,8 @@ mod tests { assert!(iter.next().is_none()); } - #[test] - fn into_owned_batches_yields_batch_then_error_then_none() { + #[tokio::test] + async fn into_owned_batches_yields_batch_then_error_then_none() { // BatchThenErrorReader: one Ok(Some(batch)), then Err. // Iterator must yield the batch, surface the error, then // fuse to None forever. @@ -1000,7 +1018,7 @@ mod tests { schema: batch.schema(), batch: Some(batch), }; - let stream = ResultStream::from_reader(Box::new(reader)).unwrap(); + let stream = ResultStream::from_reader(Box::new(reader)).await.unwrap(); let mut iter = stream.into_owned_batches(); let first = iter.next().expect("first yields a batch"); diff --git a/src/statement/executed_async.rs b/src/statement/executed_async.rs index 5b1fdd9e..10ec7e43 100644 --- a/src/statement/executed_async.rs +++ b/src/statement/executed_async.rs @@ -260,7 +260,7 @@ impl ExecutedAsyncStatement { .fetch_completed_result(&self.statement_id) .await? { - Some(result) => ResultStream::from_reader(result.reader), + Some(result) => ResultStream::from_reader(result.reader).await, None => { // Re-read the status so the error message names the // observed state (Pending vs Running). Best-effort — diff --git a/src/statement/mutable.rs b/src/statement/mutable.rs index 46b8bb13..57278a6e 100644 --- a/src/statement/mutable.rs +++ b/src/statement/mutable.rs @@ -170,7 +170,7 @@ impl Statement { self.last_valid = Some(valid.clone()); self.last_closed = Some(Arc::clone(&closed)); - let result_stream = ResultStream::from_reader(result.reader)?; + let result_stream = ResultStream::from_reader(result.reader).await?; Ok(ExecutedStatement::new( Arc::clone(&self.session), result.statement_id, From 23b83026f9933278571100982872f891930069b4 Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Fri, 15 May 2026 01:21:20 +0000 Subject: [PATCH 2/7] krn-async-public-api: make Statement::execute/submit Send and switch to rustls-tls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two coupled changes that unblock the napi-rs binding for Round 2: 1. Statement::execute / Statement::submit are now Send. Both methods held a tracing::EnteredSpan (!Send) across .await boundaries via `let _g = self.session.log_span().clone().entered();`. napi-rs's execute_tokio_future requires Send, so calling Statement::execute().await from a #[napi] async fn failed to compile. Switch the per-method span entry from .entered() to wrapping the body in `async { … }.instrument(span)`. Identical observable behaviour; resulting future is Send because tracing::Span is Send (only EnteredSpan is !Send). 2. reqwest features: native-tls → rustls-tls. When loaded into Node 24 (openssl 3.x statically linked), the binding crashes with SIGSEGV at require() time because the kernel's native-tls dynamic-links openssl 1.1, which collides with Node's symbols. rustls is pure Rust + ring and has no system openssl dep. One pre-existing test, test_http_client_with_invalid_pem, regresses because rustls's Certificate::from_pem doesn't error on syntactic garbage the way native-tls does. Tracked as a follow-up to update the test to use a structurally-valid PEM. 365/366 lib tests pass. Session::close still holds EnteredSpan across .await — out of scope for Round 2; the binding works around it with fire-and-forget drop. Same .entered() → .instrument() fix applies. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- Cargo.lock | 211 --------------------------------------- Cargo.toml | 9 +- src/statement/mutable.rs | 169 +++++++++++++++++-------------- 3 files changed, 102 insertions(+), 287 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5dc876c..502f2610 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,16 +326,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -496,15 +486,6 @@ dependencies = [ "syn", ] -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -559,21 +540,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.2" @@ -849,22 +815,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.19" @@ -884,11 +834,9 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2", - "system-configuration", "tokio", "tower-service", "tracing", - "windows-registry", ] [[package]] @@ -1237,12 +1185,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -1264,23 +1206,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "native-tls" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -1375,50 +1300,6 @@ dependencies = [ "pathdiff", ] -[[package]] -name = "openssl" -version = "0.10.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" - -[[package]] -name = "openssl-sys" -version = "0.9.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -1472,12 +1353,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - [[package]] name = "portable-atomic" version = "1.13.1" @@ -1758,21 +1633,16 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64", "bytes", - "encoding_rs", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", - "hyper-tls", "hyper-util", "js-sys", "log", - "mime", - "native-tls", "percent-encoding", "pin-project-lite", "quinn", @@ -1783,7 +1653,6 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-native-tls", "tokio-rustls", "tokio-util", "tower", @@ -1886,44 +1755,12 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" -[[package]] -name = "schannel" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.27" @@ -2103,27 +1940,6 @@ dependencies = [ "syn", ] -[[package]] -name = "system-configuration" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" -dependencies = [ - "bitflags", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "target-lexicon" version = "0.13.5" @@ -2254,16 +2070,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.4" @@ -2459,12 +2265,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.5" @@ -2637,17 +2437,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" -dependencies = [ - "windows-link", - "windows-result", - "windows-strings", -] - [[package]] name = "windows-result" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index ec3cc267..b5285d2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,14 @@ arrow-select = "57" arrow-ipc = "57" # HTTP client and async runtime -reqwest = { version = "0.12", features = ["json", "gzip", "stream", "native-tls"] } +# +# `rustls-tls` (not `native-tls`) because the napi-rs binding is loaded +# into Node.js processes that statically link OpenSSL 3.x. Dynamically +# linking against the system's OpenSSL 1.1 (which is what `native-tls` +# pulls in on Linux today) collides with Node's symbols at module load +# time and segfaults the process before any Rust code runs. `rustls` is +# pure Rust + ring and avoids the conflict entirely. +reqwest = { version = "0.12", default-features = false, features = ["json", "gzip", "stream", "rustls-tls"] } tokio = { version = "1", features = ["full", "sync"] } # Serialization diff --git a/src/statement/mutable.rs b/src/statement/mutable.rs index 57278a6e..75b493d6 100644 --- a/src/statement/mutable.rs +++ b/src/statement/mutable.rs @@ -64,7 +64,7 @@ use crate::statement::validity::ValidityFlag; use crate::types::sea::{ExecuteParams, StatementState}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use tracing::warn; +use tracing::{warn, Instrument}; /// Lifecycle owner for a single statement spec. /// @@ -136,48 +136,61 @@ impl Statement { /// short-circuit to `InvalidStatementHandle` without hitting the /// wire. pub async fn execute(&mut self) -> Result { - let _g = self.session.log_span().clone().entered(); - - self.invalidate_prior().await; - let (sql, exec_params) = self.prepare_for_dispatch(None)?; - - let cancel_state = MidExecuteCancelState::new(Arc::clone(&self.session)); - let guard = cancel_state.guard(); - - // SeaRestTransport::execute_statement polls to completion - // (server's default ~10s wait, then GetStatementStatus loop - // until terminal). - let result = self - .session - .transport() - .execute_statement(self.session.session_id(), &sql, &exec_params) - .await?; - - cancel_state.observe(&result.statement_id); - guard.defuse(); - - let valid = ValidityFlag::new(); - // Only `Closed` triggers the short-circuit. `Succeeded` means - // the server still owns the statement and we must issue - // CloseStatement. `Failed` / `Canceled` are terminal but still - // server-side-tracked — also fall through to the standard close - // path. See `prepare_for_dispatch` for why omitting - // `wait_timeout` typically yields `Closed` on the inline-result - // fast path. - let already_closed = result.server_state == StatementState::Closed; - let closed = Arc::new(AtomicBool::new(already_closed)); - self.last_statement_id = Some(result.statement_id.clone()); - self.last_valid = Some(valid.clone()); - self.last_closed = Some(Arc::clone(&closed)); - - let result_stream = ResultStream::from_reader(result.reader).await?; - Ok(ExecutedStatement::new( - Arc::clone(&self.session), - result.statement_id, - valid, - result_stream, - closed, - )) + // `instrument` (rather than `.entered()`) so the resulting + // future stays `Send` — napi-rs's `execute_tokio_future` and + // `tokio::spawn` both require `Send`, and `EnteredSpan` is + // `!Send`. Clone the span up-front to avoid double-borrowing + // `self.session` (once in the async body, once on the + // `.instrument()` argument). + let span = self.session.log_span().clone(); + async { + self.invalidate_prior().await; + let (sql, exec_params) = self.prepare_for_dispatch(None)?; + + let cancel_state = MidExecuteCancelState::new(Arc::clone(&self.session)); + let guard = cancel_state.guard(); + + // SeaRestTransport::execute_statement polls to completion + // (10s server-side wait_timeout, then GetStatementStatus + // loop until terminal). + let result = self + .session + .transport() + .execute_statement(self.session.session_id(), &sql, &exec_params) + .await?; + + cancel_state.observe(&result.statement_id); + guard.defuse(); + + let valid = ValidityFlag::new(); + self.last_statement_id = Some(result.statement_id.clone()); + self.last_valid = Some(valid.clone()); + + let valid = ValidityFlag::new(); + // Only `Closed` triggers the short-circuit. `Succeeded` means + // the server still owns the statement and we must issue + // CloseStatement. `Failed` / `Canceled` are terminal but still + // server-side-tracked — also fall through to the standard close + // path. See `prepare_for_dispatch` for why omitting + // `wait_timeout` typically yields `Closed` on the inline-result + // fast path. + let already_closed = result.server_state == StatementState::Closed; + let closed = Arc::new(AtomicBool::new(already_closed)); + self.last_statement_id = Some(result.statement_id.clone()); + self.last_valid = Some(valid.clone()); + self.last_closed = Some(Arc::clone(&closed)); + + let result_stream = ResultStream::from_reader(result.reader).await?; + Ok(ExecutedStatement::new( + Arc::clone(&self.session), + result.statement_id, + valid, + result_stream, + closed, + )) + } + .instrument(span) + .await } /// Submit-and-return. `wait_timeout=0s`; no direct results. Same @@ -189,38 +202,44 @@ impl Statement { /// `fetch_result`. Long-running queries that would blow past /// `execute()`'s sync polling budget belong on this path. pub async fn submit(&mut self) -> Result { - let _g = self.session.log_span().clone().entered(); - - self.invalidate_prior().await; - let (sql, exec_params) = self.prepare_for_dispatch(Some("0s"))?; - - let cancel_state = MidExecuteCancelState::new(Arc::clone(&self.session)); - let guard = cancel_state.guard(); - - let response = self - .session - .transport() - .submit_statement(self.session.session_id(), &sql, &exec_params) - .await?; - - cancel_state.observe(&response.statement_id); - guard.defuse(); - - let valid = ValidityFlag::new(); - // submit path always uses wait_timeout=0s, so the server can't - // return CLOSED yet; start the flag false and let later close() - // calls flip it. - let closed = Arc::new(AtomicBool::new(false)); - self.last_statement_id = Some(response.statement_id.clone()); - self.last_valid = Some(valid.clone()); - self.last_closed = Some(Arc::clone(&closed)); - - Ok(ExecutedAsyncStatement::new( - Arc::clone(&self.session), - response.statement_id, - valid, - closed, - )) + let span = self.session.log_span().clone(); + async { + self.invalidate_prior().await; + let (sql, exec_params) = self.prepare_for_dispatch(Some("0s"))?; + + let cancel_state = MidExecuteCancelState::new(Arc::clone(&self.session)); + let guard = cancel_state.guard(); + + let response = self + .session + .transport() + .submit_statement(self.session.session_id(), &sql, &exec_params) + .await?; + + cancel_state.observe(&response.statement_id); + guard.defuse(); + + let valid = ValidityFlag::new(); + self.last_statement_id = Some(response.statement_id.clone()); + self.last_valid = Some(valid.clone()); + + // submit path always uses wait_timeout=0s, so the server can't + // return CLOSED yet; start the flag false and let later close() + // calls flip it. + let closed = Arc::new(AtomicBool::new(false)); + self.last_statement_id = Some(response.statement_id.clone()); + self.last_valid = Some(valid.clone()); + self.last_closed = Some(Arc::clone(&closed)); + + Ok(ExecutedAsyncStatement::new( + Arc::clone(&self.session), + response.statement_id, + valid, + closed, + )) + } + .instrument(span) + .await } /// Explicit close. Cancels and closes any executed handle this From 54630ce5b9f19aafac433543f4c9149eafe6277a Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Sat, 16 May 2026 15:22:42 +0000 Subject: [PATCH 3/7] test(reader): port cloudfetch_drain_does_not_nest_block_on from PR #20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an e2e regression guard for issue #19 — drains 1M rows from inside a #[tokio::test(flavor = "multi_thread")] to verify that the Option-1 async-trait fix in this branch doesn't regress into a nested-block_on panic. Adapted from PR #20 (author @vikrantpuppala) which proposed Option 2 (block_in_place + Handle::current().block_on as a stopgap). Our branch picks Option 1 (make ResultReader trait async) per issue #19's own "right answer" recommendation. The test is independent of the fix mechanism — it just asserts the panic doesn't return. e2e tests; run via: DATABRICKS_HOST=... DATABRICKS_HTTP_PATH=... DATABRICKS_TOKEN=... \ cargo test --test v0_execute_e2e cloudfetch_drain_does_not_nest_block_on -- --ignored Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- tests/v0_execute_e2e.rs | 49 ++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/tests/v0_execute_e2e.rs b/tests/v0_execute_e2e.rs index 6982923d..f031f2cd 100644 --- a/tests/v0_execute_e2e.rs +++ b/tests/v0_execute_e2e.rs @@ -403,33 +403,41 @@ async fn bind_binary_typed_value_is_rejected_at_execute_time() { session.close().await.expect("session close"); } -/// Repro for issue #19: `CloudFetchResultReader::next_batch` calls -/// `runtime_handle.block_on` from a sync trait method. When the -/// kernel is driven from inside an enclosing tokio runtime (e.g. -/// the PyO3 wrapper's `runtime.block_on`, or a `#[tokio::test]` -/// here), the inner `block_on` is nested under the same runtime -/// and tokio panics with "Cannot start a runtime from within a +/// Regression guard for issue #19 (kernel `block_on` removal). +/// +/// History: the original `CloudFetchResultReader::next_batch` was a +/// sync trait method that called `runtime_handle.block_on(...)` on +/// an inner async future. When the kernel ran under an enclosing +/// tokio runtime (e.g. the PyO3 wrapper's `runtime.block_on`, the +/// napi-rs `execute_tokio_future`, or a `#[tokio::test]` like this +/// one), the inner `block_on` would nest under the same runtime and +/// tokio would panic with "Cannot start a runtime from within a /// runtime." /// -/// `range(100000)` is too small to flip the server to CloudFetch -/// disposition (it inlines the Arrow stream), so the existing -/// `multi_batch_range_succeeds` test never reaches the -/// `block_on` path. `range(1000000)` reliably triggers external -/// links on Dogfood. +/// This commit fixed it by making the `ResultReader` trait itself +/// `async` (Option 1 in issue #19), so `next_batch().await` is now +/// genuinely async end-to-end — no inner `block_on`, no nested- +/// runtime hazard, and no caller-side multi-thread-runtime +/// requirement. This test exists to keep that property pinned: if +/// a future refactor reintroduces a sync→async bridge inside a +/// reader, draining 1M rows from inside a tokio test will repro +/// the original panic. +/// +/// `range(100_000)` is too small to flip the server to CloudFetch +/// disposition (inline Arrow), so we use `range(1_000_000)` to +/// reliably hit external-link results on pecotesting. /// -/// Gated to `flavor = "multi_thread"` because the eventual fix -/// uses `tokio::task::block_in_place`, which is a no-op on -/// current-thread runtimes. The PyO3 wrapper is multi-thread, so -/// matching that here is the realistic shape. +/// Adapted from PR #20's regression test (author: @vikrantpuppala) +/// — see the kernel-async-public-api PR description for the +/// Option 1 vs Option 2 framing. #[tokio::test(flavor = "multi_thread")] #[ignore] async fn cloudfetch_drain_does_not_nest_block_on() { let session = live_session().await; let mut stmt = session.statement(); - // Large enough to force external-links disposition (the - // CloudFetchResultReader path) on Dogfood. If a future - // server-side change moves the inline/external threshold, - // bump this. + // Large enough to force external-links (CloudFetch) disposition + // on the test warehouse. If a future server-side change moves + // the inline/external threshold, bump this. stmt.spec().sql("SELECT * FROM range(1000000)"); let mut exec = stmt.execute().await.expect("execute range(1000000)"); @@ -437,7 +445,8 @@ async fn cloudfetch_drain_does_not_nest_block_on() { assert_eq!( rows, 1_000_000, "expected 1M rows; if this drain panicked with \ - 'Cannot start a runtime from within a runtime' the fix has regressed" + 'Cannot start a runtime from within a runtime' the Option-1 \ + async-trait fix has regressed" ); exec.close().await.expect("close"); session.close().await.expect("session close"); From af5894a1587d9bd53064b8b1dbfa36bdc245d579 Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Wed, 20 May 2026 10:28:31 +0000 Subject: [PATCH 4/7] feat(config): make TLS backend selectable via Cargo features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit (8657251) hardcoded reqwest's rustls-tls backend to unblock the napi-rs binding (Node statically links OpenSSL 3.x; native-tls's dynamic link against system OpenSSL 1.1 segfaults at module load). That choice is correct for napi but pre-empts the decision for other consumers — notably the C ABI / ODBC path (currently skeleton in src/ffi/), which historically uses native-tls. This commit makes the TLS backend a Cargo feature so each consumer picks its own: [features] default = ["tls-native"] tls-native = ["reqwest/native-tls"] tls-rustls = ["reqwest/rustls-tls"] Direct-Rust users + the C-ABI path + pyo3 use the default tls-native and get the historical native-tls behavior. The napi binding crate (added in the follow-up commit / next PR in this stack) explicitly opts INTO tls-rustls. Exactly one TLS feature MUST be enabled per consumer. Cargo feature unification would activate both reqwest TLS backends simultaneously, which is a build error — isolated by each consumer setting default-features = false where appropriate. Verified locally: - cargo check -p databricks-sql-kernel (default tls-native) PASS - cargo test --lib --workspace 376 passed / 0 failed Side benefit: the pre-existing PEM flake test (D-016 test_http_client_with_invalid_pem) which failed on the rustls-tls build passes on native-tls. CI default is back to a green state. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- Cargo.lock | 812 ++++++++++++++++++++++++++++++++++++++--------------- Cargo.toml | 35 ++- 2 files changed, 606 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 502f2610..c04b372c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,11 +40,17 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + [[package]] name = "arrow-array" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ca404ea6191e06bf30956394173337fa9c35f445bd447fe6c21ab944e1a23c" +checksum = "c8a4ab47b3f3eac60f7fd31b81e9028fda018607bcc63451aca4f2b755269862" dependencies = [ "ahash", "arrow-buffer", @@ -60,9 +66,9 @@ dependencies = [ [[package]] name = "arrow-buffer" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36356383099be0151dacc4245309895f16ba7917d79bdb71a7148659c9206c56" +checksum = "0d18b89b4c4f4811d0858175e79541fe98e33e18db3b011708bc287b1240593f" dependencies = [ "bytes", "half", @@ -72,9 +78,9 @@ dependencies = [ [[package]] name = "arrow-cast" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8e372ed52bd4ee88cc1e6c3859aa7ecea204158ac640b10e187936e7e87074" +checksum = "722b5c41dd1d14d0a879a1bce92c6fe33f546101bb2acce57a209825edd075b3" dependencies = [ "arrow-array", "arrow-buffer", @@ -93,9 +99,9 @@ dependencies = [ [[package]] name = "arrow-data" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf87f4ff5fc13290aa47e499a8b669a82c5977c6a1fedce22c7f542c1fd5a597" +checksum = "c1683705c63dcf0d18972759eda48489028cbbff67af7d6bef2c6b7b74ab778a" dependencies = [ "arrow-buffer", "arrow-schema", @@ -106,9 +112,9 @@ dependencies = [ [[package]] name = "arrow-ipc" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3ca63edd2073fcb42ba112f8ae165df1de935627ead6e203d07c99445f2081" +checksum = "8cf72d04c07229fbf4dbebe7145cac37d7cf7ec582fe705c6b92cb314af096ab" dependencies = [ "arrow-array", "arrow-buffer", @@ -120,9 +126,9 @@ dependencies = [ [[package]] name = "arrow-ord" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c4e0530272ca755d6814218dffd04425c5b7854b87fa741d5ff848bf50aa39" +checksum = "082342947d4e5a2bcccf029a0a0397e21cb3bb8421edd9571d34fb5dd2670256" dependencies = [ "arrow-array", "arrow-buffer", @@ -133,9 +139,9 @@ dependencies = [ [[package]] name = "arrow-pyarrow" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f45c7989cb70214b2f362eaa10266d15e1a433692f2ea1514018be3aace679f4" +checksum = "699e04d51e2ac87efc52faa0a1bb9742b11b7f75c2abd2842de50c41cc630a47" dependencies = [ "arrow-array", "arrow-data", @@ -145,18 +151,18 @@ dependencies = [ [[package]] name = "arrow-schema" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb63203e8e0e54b288d0d8043ca8fa1013820822a27692ef1b78a977d879f2c" +checksum = "e4cf0d4a6609679e03002167a61074a21d7b1ad9ea65e462b2c0a97f8a3b2bc6" dependencies = [ "bitflags", ] [[package]] name = "arrow-select" -version = "57.2.0" +version = "57.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96d8a1c180b44ecf2e66c9a2f2bbcb8b1b6f14e165ce46ac8bde211a363411b" +checksum = "0b320d86a9806923663bb0fd9baa65ecaba81cb0cd77ff8c1768b9716b4ef891" dependencies = [ "ahash", "arrow-array", @@ -178,9 +184,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.37" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d10e4f991a553474232bc0a31799f6d24b034a84c0971d80d2e2f78b2e576e40" +checksum = "e79b3f8a79cccc2898f31920fc69f304859b3bd567490f75ebf51ae1c792a9ac" dependencies = [ "compression-codecs", "compression-core", @@ -228,9 +234,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" [[package]] name = "block-buffer" @@ -243,21 +249,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.1" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "bytes" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" -version = "1.2.54" +version = "1.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6354c81bbfd62d9cfa9cb3c773c2b7b2a3a482d569de977fd0e961f6e7c00583" +checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" dependencies = [ "find-msvc-tools", "shlex", @@ -277,9 +283,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.43" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" dependencies = [ "iana-time-zone", "js-sys", @@ -291,9 +297,9 @@ dependencies = [ [[package]] name = "compression-codecs" -version = "0.4.36" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00828ba6fd27b45a448e57dbfe84f1029d4c9f26b368157e9a448a5f49a2ec2a" +checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf" dependencies = [ "compression-core", "flate2", @@ -302,9 +308,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.31" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75984efb6ed102a0d42db99afb6c1948f0380d1d91808d5529916e6c08b49d8d" +checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" [[package]] name = "const-random" @@ -326,6 +332,16 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -399,7 +415,7 @@ dependencies = [ "lz4_flex", "oauth2", "open", - "rand 0.9.2", + "rand 0.9.4", "reqwest", "serde", "serde_json", @@ -504,15 +520,15 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.3.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" [[package]] name = "find-msvc-tools" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "flatbuffers" @@ -526,9 +542,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" dependencies = [ "crc32fast", "miniz_oxide", @@ -540,6 +556,27 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -551,9 +588,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" dependencies = [ "futures-channel", "futures-core", @@ -566,9 +603,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", "futures-sink", @@ -576,15 +613,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" [[package]] name = "futures-executor" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" dependencies = [ "futures-core", "futures-task", @@ -593,15 +630,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", @@ -610,21 +647,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ "futures-channel", "futures-core", @@ -634,7 +671,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -670,16 +706,29 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi", + "r-efi 5.3.0", "wasip2", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "wasip2", + "wasip3", +] + [[package]] name = "h2" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733" dependencies = [ "atomic-waker", "bytes", @@ -712,12 +761,27 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + [[package]] name = "heck" version = "0.5.0" @@ -777,9 +841,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" dependencies = [ "atomic-waker", "bytes", @@ -792,7 +856,6 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "pin-utils", "smallvec", "tokio", "want", @@ -800,31 +863,45 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.7" +version = "0.27.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" dependencies = [ "http", "hyper", "hyper-util", "rustls", - "rustls-pki-types", "tokio", "tokio-rustls", "tower-service", "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "base64", "bytes", "futures-channel", - "futures-core", "futures-util", "http", "http-body", @@ -841,9 +918,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.64" +version = "0.1.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -865,12 +942,13 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" dependencies = [ "displaydoc", "potential_utf", + "utf8_iter", "yoke", "zerofrom", "zerovec", @@ -878,9 +956,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" dependencies = [ "displaydoc", "litemap", @@ -891,9 +969,9 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" dependencies = [ "icu_collections", "icu_normalizer_data", @@ -905,15 +983,15 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" [[package]] name = "icu_properties" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" dependencies = [ "icu_collections", "icu_locale_core", @@ -925,15 +1003,15 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" [[package]] name = "icu_provider" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" dependencies = [ "displaydoc", "icu_locale_core", @@ -944,6 +1022,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "idna" version = "1.1.0" @@ -957,9 +1041,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" dependencies = [ "icu_normalizer", "icu_properties", @@ -967,12 +1051,14 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.16.1", + "hashbrown 0.17.1", + "serde", + "serde_core", ] [[package]] @@ -986,19 +1072,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" - -[[package]] -name = "iri-string" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" -dependencies = [ - "memchr", - "serde", -] +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" [[package]] name = "is-docker" @@ -1021,16 +1097,18 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.85" +version = "0.3.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08" dependencies = [ + "cfg-if", + "futures-util", "once_cell", "wasm-bindgen", ] @@ -1041,6 +1119,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "lexical-core" version = "1.0.6" @@ -1100,9 +1184,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.180" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libm" @@ -1112,24 +1196,24 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" +checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" dependencies = [ "libc", ] [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" [[package]] name = "lock_api" @@ -1154,9 +1238,9 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "lz4_flex" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08ab2867e3eeeca90e844d1940eab391c9dc5228783db2ed999acbc0a9ed375a" +checksum = "373f5eceeeab7925e0c1098212f2fbc4d416adec9d35051a6ab251e824c1854a" dependencies = [ "twox-hash", ] @@ -1172,9 +1256,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "memoffset" @@ -1197,15 +1281,32 @@ dependencies = [ [[package]] name = "mio" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" dependencies = [ "libc", "wasi", "windows-sys 0.61.2", ] +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -1273,7 +1374,7 @@ dependencies = [ "chrono", "getrandom 0.2.17", "http", - "rand 0.8.5", + "rand 0.8.6", "reqwest", "serde", "serde_json", @@ -1285,21 +1386,64 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "open" -version = "5.3.3" +version = "5.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43bb73a7fa3799b198970490a51174027ba0d4ec504b03cd08caf513d40024bc" +checksum = "2fbaa89d2ddc8473c78a3adf69eea8cffa28c483b8e02a971ef31527cd0fc92c" dependencies = [ "is-wsl", "libc", "pathdiff", ] +[[package]] +name = "openssl" +version = "0.10.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf0b434746ee2832f4f0baf10137e1cabb18cbe6912c69e2e33263c45250f542" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "158fe5b292746440aa6e7a7e690e55aeb72d41505e2804c23c6973ad0e9c9781" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -1343,15 +1487,15 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] -name = "pin-utils" -version = "0.1.0" +name = "pkg-config" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" [[package]] name = "portable-atomic" @@ -1361,9 +1505,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "potential_utf" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" dependencies = [ "zerovec", ] @@ -1377,6 +1521,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" version = "1.0.106" @@ -1469,14 +1623,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.13" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" dependencies = [ "bytes", "getrandom 0.3.4", "lru-slab", - "rand 0.9.2", + "rand 0.9.4", "ring", "rustc-hash", "rustls", @@ -1504,9 +1658,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.44" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -1517,11 +1671,17 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "rand" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", "rand_chacha 0.3.1", @@ -1530,9 +1690,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.5", @@ -1598,9 +1758,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -1610,9 +1770,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -1621,9 +1781,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "reqwest" @@ -1640,9 +1800,11 @@ dependencies = [ "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "js-sys", "log", + "native-tls", "percent-encoding", "pin-project-lite", "quinn", @@ -1653,6 +1815,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", + "tokio-native-tls", "tokio-rustls", "tokio-util", "tower", @@ -1682,9 +1845,9 @@ dependencies = [ [[package]] name = "rustc-hash" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" [[package]] name = "rustc_version" @@ -1697,9 +1860,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ "bitflags", "errno", @@ -1710,9 +1873,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.36" +version = "0.23.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" +checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" dependencies = [ "once_cell", "ring", @@ -1724,9 +1887,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.14.0" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" dependencies = [ "web-time", "zeroize", @@ -1734,9 +1897,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.9" +version = "0.103.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" dependencies = [ "ring", "rustls-pki-types", @@ -1751,9 +1914,18 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.22" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] [[package]] name = "scopeguard" @@ -1761,11 +1933,34 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "serde" @@ -1871,9 +2066,9 @@ dependencies = [ [[package]] name = "simd-adler32" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" [[package]] name = "slab" @@ -1889,12 +2084,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -1911,9 +2106,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.114" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -1948,12 +2143,12 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" [[package]] name = "tempfile" -version = "3.24.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.2", "once_cell", "rustix", "windows-sys 0.61.2", @@ -2019,9 +2214,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" dependencies = [ "displaydoc", "zerovec", @@ -2029,9 +2224,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" dependencies = [ "tinyvec_macros", ] @@ -2044,9 +2239,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.49.0" +version = "1.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" dependencies = [ "bytes", "libc", @@ -2061,15 +2256,25 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.4" @@ -2110,9 +2315,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51" dependencies = [ "async-compression", "bitflags", @@ -2122,13 +2327,13 @@ dependencies = [ "http", "http-body", "http-body-util", - "iri-string", "pin-project-lite", "tokio", "tokio-util", "tower", "tower-layer", "tower-service", + "url", ] [[package]] @@ -2188,9 +2393,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" dependencies = [ "matchers", "nu-ansi-term", @@ -2218,15 +2423,21 @@ checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" [[package]] name = "typenum" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unindent" @@ -2265,6 +2476,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" @@ -2288,18 +2505,27 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.2+wasi-0.2.9" +version = "1.0.3+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", ] [[package]] name = "wasm-bindgen" -version = "0.2.108" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790" dependencies = [ "cfg-if", "once_cell", @@ -2310,23 +2536,19 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.58" +version = "0.4.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f" +checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8" dependencies = [ - "cfg-if", - "futures-util", "js-sys", - "once_cell", "wasm-bindgen", - "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.108" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2334,9 +2556,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.108" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2" dependencies = [ "bumpalo", "proc-macro2", @@ -2347,13 +2569,35 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.108" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441" dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + [[package]] name = "wasm-streams" version = "0.4.2" @@ -2367,11 +2611,23 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + [[package]] name = "web-sys" -version = "0.3.85" +version = "0.3.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598" +checksum = "4b572dff8bcf38bad0fa19729c89bb5748b2b9b1d8be70cf90df697e3a8f32aa" dependencies = [ "js-sys", "wasm-bindgen", @@ -2389,9 +2645,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" +checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" dependencies = [ "rustls-pki-types", ] @@ -2705,18 +2961,106 @@ name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] [[package]] name = "writeable" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" [[package]] name = "yoke" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -2725,9 +3069,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", @@ -2737,18 +3081,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.34" +version = "0.8.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71ddd76bcebeed25db614f82bf31a9f4222d3fbba300e6fb6c00afa26cbd4d9d" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.34" +version = "0.8.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8187381b52e32220d50b255276aa16a084ec0a9017a0ca2152a1f55c539758d" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" dependencies = [ "proc-macro2", "quote", @@ -2757,18 +3101,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", @@ -2784,9 +3128,9 @@ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" [[package]] name = "zerotrie" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" dependencies = [ "displaydoc", "yoke", @@ -2795,9 +3139,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" dependencies = [ "yoke", "zerofrom", @@ -2806,9 +3150,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", @@ -2817,6 +3161,6 @@ dependencies = [ [[package]] name = "zmij" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1966f8ac2c1f76987d69a74d0e0f929241c10e78136434e3be70ff7f58f64214" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index b5285d2b..e462abe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,13 +37,18 @@ arrow-ipc = "57" # HTTP client and async runtime # -# `rustls-tls` (not `native-tls`) because the napi-rs binding is loaded -# into Node.js processes that statically link OpenSSL 3.x. Dynamically -# linking against the system's OpenSSL 1.1 (which is what `native-tls` -# pulls in on Linux today) collides with Node's symbols at module load -# time and segfaults the process before any Rust code runs. `rustls` is -# pure Rust + ring and avoids the conflict entirely. -reqwest = { version = "0.12", default-features = false, features = ["json", "gzip", "stream", "rustls-tls"] } +# TLS backend is selected by Cargo features (see `[features]` below). +# Default = `tls-native` to preserve compatibility for direct-Rust and +# C-ABI consumers (e.g. future ODBC), which historically use the system +# OpenSSL via `native-tls`. +# +# The napi-rs binding crate (`napi/`) opts INTO `tls-rustls` instead: +# napi modules are loaded into Node.js processes that statically link +# OpenSSL 3.x, and dynamically linking against the system's OpenSSL 1.1 +# (which `native-tls` pulls in on Linux) collides with Node's symbols at +# module load time and segfaults the process before any Rust code runs. +# `rustls` is pure Rust + ring and avoids the conflict entirely. +reqwest = { version = "0.12", default-features = false, features = ["json", "gzip", "stream"] } tokio = { version = "1", features = ["full", "sync"] } # Serialization @@ -82,6 +87,22 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros"] } wiremock = "0.6" tempfile = "3" +# TLS backend selection. +# +# Default is `tls-native` (reqwest's `native-tls` backend) to preserve +# compatibility for direct-Rust use and the C-ABI / ODBC path. The napi +# binding crate (`napi/`) explicitly enables `tls-rustls` instead (and +# disables defaults) to avoid the OpenSSL-symbol clash with the host +# Node.js process at module load time. +# +# Exactly one TLS feature MUST be enabled. Don't enable both — Cargo +# feature unification would activate both reqwest backends, which is a +# build error. +[features] +default = ["tls-native"] +tls-native = ["reqwest/native-tls"] +tls-rustls = ["reqwest/rustls-tls"] + [lib] name = "databricks_sql_kernel" crate-type = ["lib", "cdylib", "staticlib"] From ab34b868d7d1660b9dcb8efc58a8d11d9316d83b Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Wed, 20 May 2026 20:17:03 +0000 Subject: [PATCH 5/7] docs(config): correct TLS feature mutual-exclusivity rationale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `tls-native` / `tls-rustls` features are mutually exclusive in intent, not in compile. The prior comment claimed enabling both would be "a build error" — reqwest 0.12 actually accepts both features together and silently links both TLS stacks. In a napi cdylib that defeats the reason for switching to rustls: system OpenSSL still gets linked, and on Node process load it clashes with Node's statically linked OpenSSL. The structural enforcement lives in the napi crate (which is its own workspace, not a kernel-workspace member), introduced in the follow-up napi-skeleton PR. This commit updates the comment so the invariant is described accurately for anyone reading the kernel features in isolation. Signed-off-by: Madhavendra Rathore --- Cargo.toml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e462abe8..76505120 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,9 +95,20 @@ tempfile = "3" # disables defaults) to avoid the OpenSSL-symbol clash with the host # Node.js process at module load time. # -# Exactly one TLS feature MUST be enabled. Don't enable both — Cargo -# feature unification would activate both reqwest backends, which is a -# build error. +# These features are MUTUALLY EXCLUSIVE in intent (not in compile): a +# binary that ends up with both `reqwest/native-tls` AND +# `reqwest/rustls-tls` active will link both TLS stacks. That is not a +# compile error — reqwest 0.12 accepts both features simultaneously and +# silently picks one at runtime — but in a napi cdylib it defeats the +# whole reason for the rustls switch: system OpenSSL gets linked in +# anyway, and on process load that clashes with Node.js's statically +# linked OpenSSL. +# +# The napi crate enforces the intent structurally by being its own +# workspace (not a member of this kernel workspace), so +# `cargo build --workspace` here only sees `tls-native` via pyo3 and +# never unifies the two. Don't add napi to `[workspace] members` — +# build it from `napi/` instead. See `napi/Cargo.toml`. [features] default = ["tls-native"] tls-native = ["reqwest/native-tls"] From dcc4d151ee76a899502cd23f2fcce8fd3c829c73 Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Fri, 22 May 2026 10:43:30 +0000 Subject: [PATCH 6/7] =?UTF-8?q?fix(kernel):=20address=20PR=20#26=20review?= =?UTF-8?q?=20=E2=80=94=20sweep=20.instrument(span),=20restore=20runtime-a?= =?UTF-8?q?ware=20sync=20iterators,=20harden=20TLS=20feature=20wiring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses HIGH-severity findings from PR #26 review: F1 + F1b — `src/statement/mutable.rs:execute/submit`. Both methods wrote `self.last_statement_id` / `self.last_valid` twice; `execute()` also re-allocated `ValidityFlag` via shadowing. A future `.await` inserted between the two write blocks would have raced on `self.last_valid`. Dropped the first write trio in each method. F2 + companion — `src/result_stream.rs:OwnedBatchIter::next` and `src/reader/mod.rs:ResultReaderAdapter::next`. Both called `futures::executor::block_on(self.reader.next_batch())`. For CloudFetch readers (which `.await` tokio primitives inside `StreamingCloudFetchProvider`) this either self-deadlocks under a current-thread runtime or parks the worker without telling tokio under multi-thread — a milder reprise of the issue-#19 hazard this PR was supposed to fix, on the sync iterator path. Added `util::runtime::block_on_current_runtime` which inspects `Handle::try_current().runtime_flavor()` and routes to `block_in_place + handle.block_on` under multi-thread, falls back to `futures::executor::block_on` for current-thread + no-runtime cases. F3 — Send-safety sweep. PR title claimed "Send-safety on Statement" but only `Statement::execute`/`submit` had been migrated to `.instrument(span)`. 15 sites still wrote `let _g = ...entered();` which makes the surrounding `async fn` future `!Send` (`EnteredSpan` carries a `PhantomData<*mut ()>`). Migrated all of them: `Metadata::{list_catalogs, list_schemas, list_tables, list_columns, primary_keys, foreign_keys, functions, procedures, type_info, table_types}`, `ExecutedAsyncStatement::{status, await_result, fetch_result}`, `Session::close`, `Statement::close`. F4a — TLS feature compile-time guard. Added two `compile_error!`s in `src/lib.rs`: one for zero TLS features (a `default-features = false` consumer who forgets to opt back in), one for both features (which would link both TLS stacks and defeat the napi crate's rustls switch). Verified both fire under `cargo check --no-default-features` and `cargo check --features tls-rustls` respectively. F4b — `oauth2 5.x` enables `default = ["reqwest", "rustls-tls"]`, silently unifying both TLS stacks in the kernel workspace before this commit. Pinned `oauth2 = { version = "5", default-features = false, features = ["reqwest"] }` so the kernel's own `tls-native` / `tls-rustls` feature is the only thing controlling the reqwest backend. Corrected the misleading Cargo.toml comment that claimed the napi crate's separate workspace was the load-bearing structural guarantee — it isn't anymore; the compile_error guards plus the oauth2 default-features strip are. F5 — added compile-time `assert_send` on the futures returned by `Statement::{execute, submit, close}`, `ExecutedAsyncStatement::{status, await_result, fetch_result}`, `Session::close`, and the eight `Metadata::*` methods. A maintainer reverting `.instrument(span)` back to `let _g = span.entered();` would silently regress Send-ness while all in-tree tests still passed; this catches it at the build that introduces it. F4c docstring — refuted the reviewer's claim that `danger_accept_invalid_hostnames` panics under rustls (verified locally that reqwest 0.12.28 installs `IgnoreHostname` under rustls). The kernel's own TlsConfig docstring at line 88 said "Requires the `native-tls` backend" — also incorrect. Updated to reflect that the knob works under both backends. F12 (partial) — kept `pub trait ResultReader` public but added a rustdoc paragraph documenting the `#[async_trait::async_trait]` requirement for external implementors. Downgrading the trait to `pub(crate)` was the alternative but would have broken the RecordBatchReader-shaped `ResultReaderAdapter` surface that the ADBC / FFI paths will eventually consume. Verification: - `cargo +stable fmt --all -- --check` - `cargo clippy --all-targets -- -D warnings` clean - `cargo test --workspace`: 382 passed / 0 failed (up from 376) - `cargo check --no-default-features --features tls-rustls` clean - `cargo check --features tls-rustls` correctly fires the both-features compile_error - `cargo check --no-default-features` correctly fires the zero-features compile_error Signed-off-by: Madhavendra Rathore --- Cargo.toml | 51 +++-- src/client/http.rs | 19 +- src/lib.rs | 59 ++++++ src/metadata_v0.rs | 359 ++++++++++++++++++-------------- src/reader/mod.rs | 24 ++- src/result_stream.rs | 28 ++- src/session.rs | 24 ++- src/statement/executed_async.rs | 132 ++++++------ src/statement/mutable.rs | 17 +- src/util/runtime.rs | 55 +++++ 10 files changed, 493 insertions(+), 275 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 76505120..3236f0b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,14 @@ async-trait = "0.1" thiserror = "2" # OAuth dependencies -oauth2 = "5" # OAuth 2.0 protocol operations (PKCE, token exchange, client credentials) +# +# oauth2 5.x enables `default = ["reqwest", "rustls-tls"]`, which would +# silently pull `reqwest/rustls-tls` into the kernel build and unify +# both TLS stacks even when the consumer asked for only `tls-native`. +# Strip defaults and re-enable just the `reqwest` integration here; the +# kernel's own `tls-native` / `tls-rustls` feature controls the TLS +# backend for reqwest, and oauth2 inherits whichever the consumer picks. +oauth2 = { version = "5", default-features = false, features = ["reqwest"] } # OAuth 2.0 protocol operations (PKCE, token exchange, client credentials) sha2 = "0.10" # SHA-256 for token cache key generation open = "5" # Browser launch for interactive OAuth flows dirs = "5" # Cross-platform config directory (~/.config/) @@ -91,24 +98,34 @@ tempfile = "3" # # Default is `tls-native` (reqwest's `native-tls` backend) to preserve # compatibility for direct-Rust use and the C-ABI / ODBC path. The napi -# binding crate (`napi/`) explicitly enables `tls-rustls` instead (and -# disables defaults) to avoid the OpenSSL-symbol clash with the host -# Node.js process at module load time. +# binding crate (`napi/`) sets `default-features = false` on the kernel +# dependency and explicitly enables `tls-rustls` instead, to avoid the +# OpenSSL-symbol clash with the host Node.js process at module load +# time. +# +# These features are MUTUALLY EXCLUSIVE in intent: a binary that ends +# up with both `reqwest/native-tls` AND `reqwest/rustls-tls` active +# links both TLS stacks. In a napi cdylib that defeats the whole reason +# for the rustls switch — system OpenSSL gets linked in anyway and +# clashes with Node.js's statically linked OpenSSL at module load. +# +# Mutual exclusivity is enforced two ways: +# +# 1. `src/lib.rs` has `compile_error!` guards that fail the build if +# both features are active OR if neither is (a consumer who set +# `default-features = false` and forgot to opt back in). # -# These features are MUTUALLY EXCLUSIVE in intent (not in compile): a -# binary that ends up with both `reqwest/native-tls` AND -# `reqwest/rustls-tls` active will link both TLS stacks. That is not a -# compile error — reqwest 0.12 accepts both features simultaneously and -# silently picks one at runtime — but in a napi cdylib it defeats the -# whole reason for the rustls switch: system OpenSSL gets linked in -# anyway, and on process load that clashes with Node.js's statically -# linked OpenSSL. +# 2. The kernel's own oauth2 dep uses `default-features = false` so +# that the kernel workspace doesn't transitively enable rustls via +# oauth2's own default features. Without this, `cargo tree -i +# reqwest -f "{p} {f}"` showed rustls-tls active even in the pure +# `tls-native` build (oauth2 5.x defaults are +# `["reqwest", "rustls-tls"]`). # -# The napi crate enforces the intent structurally by being its own -# workspace (not a member of this kernel workspace), so -# `cargo build --workspace` here only sees `tls-native` via pyo3 and -# never unifies the two. Don't add napi to `[workspace] members` — -# build it from `napi/` instead. See `napi/Cargo.toml`. +# The napi crate also lives in its own workspace (not a member of this +# kernel workspace) so it can pin different transitive feature choices, +# but that separation is no longer load-bearing for the TLS feature +# guarantee — items 1 and 2 above are. [features] default = ["tls-native"] tls-native = ["reqwest/native-tls"] diff --git a/src/client/http.rs b/src/client/http.rs index 31896495..3bc4a8bb 100644 --- a/src/client/http.rs +++ b/src/client/http.rs @@ -85,7 +85,10 @@ pub struct TlsConfig { /// Default: false. pub allow_self_signed: Option, /// Don't verify that the certificate hostname matches the server. - /// Requires the `native-tls` backend. + /// Works under both the `tls-native` (delegates to native-tls's + /// `danger_accept_invalid_hostnames`) and `tls-rustls` (installs + /// reqwest's `IgnoreHostname` verifier) backends. **Insecure** — + /// for dev/test only. /// Default: false. pub allow_hostname_mismatch: Option, /// Path to a PEM-encoded CA certificate file to add to the trust store. @@ -270,6 +273,20 @@ impl DatabricksHttpClient { Error::invalid_argument().message(format!("Failed to create HTTP client: {e}")) })?; + // Surface which TLS backend was compiled in so oncall debugging + // a handshake / unknown-CA report can tell at a glance whether + // this binary is on native-tls (system CA store) or rustls + // (Mozilla webpki-roots). The two stacks differ on cert + // validation behavior, OCSP, and TLS 1.3 quirks. + debug!( + tls_backend = if cfg!(feature = "tls-rustls") { + "rustls" + } else { + "native-tls" + }, + "DatabricksHttpClient initialised" + ); + Ok(Self { client, config, diff --git a/src/lib.rs b/src/lib.rs index 3e109e70..013b7bb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,6 +70,26 @@ //! exec.close().await?; //! ``` +// === TLS feature wiring guard === +// +// Exactly one of `tls-native` / `tls-rustls` must be active. Zero +// would compile but every HTTPS call would fail at runtime (reqwest +// can't pick a backend); both would link two TLS stacks into the +// binary and defeat the napi crate's reason for choosing rustls. +// Catch both cases at the build that introduces them. +#[cfg(not(any(feature = "tls-native", feature = "tls-rustls")))] +compile_error!( + "databricks-sql-kernel requires one of `tls-native` (default) or `tls-rustls`. \ + If you set `default-features = false`, opt back into one explicitly." +); + +#[cfg(all(feature = "tls-native", feature = "tls-rustls"))] +compile_error!( + "`tls-native` and `tls-rustls` are mutually exclusive — enabling both links two \ + TLS stacks and defeats the napi crate's rustls switch. The napi binding must \ + disable defaults (`default-features = false`) before enabling `tls-rustls`." +); + pub mod auth; pub mod client; pub(crate) mod logging; @@ -138,3 +158,42 @@ const _: fn() = || { assert_send_sync::>(); assert_send_sync::>(); }; + +// Futures returned by the async public surface MUST stay `Send` so +// napi-rs's `execute_tokio_future` and `tokio::spawn` accept them. +// `tracing::span::EnteredSpan` is `!Send` (it carries a +// `PhantomData<*mut ()>`), so any maintainer reverting an +// `async {}.instrument(span)` pattern back to a `let _g = span.entered();` +// guard inside an async fn would silently regress this invariant — +// all in-tree tests would still pass. These per-method asserts catch +// it at the build that introduces it. +const _: fn() = || { + fn assert_send(_: &T) {} + // The bindings on these are only used for type-checking; the + // closure is never invoked at runtime. + let _: fn(&mut Statement) = |stmt| { + assert_send(&stmt.execute()); + assert_send(&stmt.submit()); + }; + let _: fn(Statement) = |stmt| { + assert_send(&stmt.close()); + }; + let _: fn(&ExecutedAsyncStatement) = |exec| { + assert_send(&exec.status()); + assert_send(&exec.await_result()); + assert_send(&exec.fetch_result()); + }; + let _: fn(Session) = |session| { + assert_send(&session.close()); + }; + let _: fn(&Metadata) = |md| { + assert_send(&md.list_catalogs()); + assert_send(&md.list_schemas(None, None)); + assert_send(&md.list_tables(None, None, None, None)); + assert_send(&md.list_columns(None, None, None, None)); + assert_send(&md.functions(None, None, None)); + assert_send(&md.procedures(None, None, None)); + assert_send(&md.type_info()); + assert_send(&md.table_types()); + }; +}; diff --git a/src/metadata_v0.rs b/src/metadata_v0.rs index 0002be2b..cca8ea02 100644 --- a/src/metadata_v0.rs +++ b/src/metadata_v0.rs @@ -91,6 +91,7 @@ use crate::result_stream::ResultStream; use crate::session::SessionInner; use arrow_schema::SchemaRef; use std::sync::Arc; +use tracing::Instrument; /// JDBC's `DatabaseMetaData` contract: metadata methods return an /// empty result set for non-existent catalogs / schemas / tables @@ -243,18 +244,22 @@ impl Metadata { /// /// JDBC `getCatalogs` shape: `TABLE_CAT: Utf8`. pub async fn list_catalogs(&self) -> Result { - let _g = self.session.log_span().clone().entered(); - let raw = self - .session - .transport() - .list_catalogs(self.session.session_id()) - .await?; - let reshaped = ThriftReshapingReader::new( - raw.reader, - GET_CATALOGS_SCHEMA.clone(), - Box::new(thrift_shape::reshape_catalogs), - ); - ResultStream::from_reader(Box::new(reshaped)).await + let span = self.session.log_span().clone(); + async { + let raw = self + .session + .transport() + .list_catalogs(self.session.session_id()) + .await?; + let reshaped = ThriftReshapingReader::new( + raw.reader, + GET_CATALOGS_SCHEMA.clone(), + Box::new(thrift_shape::reshape_catalogs), + ); + ResultStream::from_reader(Box::new(reshaped)).await + } + .instrument(span) + .await } /// Schemas filtered by catalog (exact) and schema name pattern. @@ -268,27 +273,31 @@ impl Metadata { catalog: Option>, schema_pattern: Option>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let catalog_str = catalog.as_ref().map(|i| i.as_str().to_owned()); - let raw = match self - .session - .transport() - .list_schemas( - self.session.session_id(), - catalog.as_ref().map(|i| i.as_str()), - schema_pattern.as_ref().map(|p| p.as_str()), - ) - .await - { - Ok(r) => r, - Err(e) => return not_found_or(e, GET_SCHEMAS_SCHEMA.clone(), Err).await, - }; - let reshaped = ThriftReshapingReader::new( - raw.reader, - GET_SCHEMAS_SCHEMA.clone(), - Box::new(move |b| thrift_shape::reshape_schemas(b, catalog_str.as_deref())), - ); - ResultStream::from_reader(Box::new(reshaped)).await + let span = self.session.log_span().clone(); + async { + let catalog_str = catalog.as_ref().map(|i| i.as_str().to_owned()); + let raw = match self + .session + .transport() + .list_schemas( + self.session.session_id(), + catalog.as_ref().map(|i| i.as_str()), + schema_pattern.as_ref().map(|p| p.as_str()), + ) + .await + { + Ok(r) => r, + Err(e) => return not_found_or(e, GET_SCHEMAS_SCHEMA.clone(), Err).await, + }; + let reshaped = ThriftReshapingReader::new( + raw.reader, + GET_SCHEMAS_SCHEMA.clone(), + Box::new(move |b| thrift_shape::reshape_schemas(b, catalog_str.as_deref())), + ); + ResultStream::from_reader(Box::new(reshaped)).await + } + .instrument(span) + .await } /// Tables filtered by catalog (exact), schema (pattern), table @@ -312,36 +321,40 @@ impl Metadata { table_pattern: Option>, table_types: Option<&[&str]>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let catalog_str = catalog.as_ref().map(|i| i.as_str().to_owned()); - let types_owned: Option> = - table_types.map(|s| s.iter().map(|t| (*t).to_owned()).collect()); - let raw = match self - .session - .transport() - .list_tables( - self.session.session_id(), - catalog.as_ref().map(|i| i.as_str()), - schema_pattern.as_ref().map(|p| p.as_str()), - table_pattern.as_ref().map(|p| p.as_str()), - table_types, - ) - .await - { - Ok(r) => r, - Err(e) => return not_found_or(e, GET_TABLES_SCHEMA.clone(), Err).await, - }; - let reshaped = ThriftReshapingReader::new( - raw.reader, - GET_TABLES_SCHEMA.clone(), - Box::new(move |b| { - let types_ref: Option> = types_owned - .as_ref() - .map(|v| v.iter().map(|s| s.as_str()).collect()); - thrift_shape::reshape_tables(b, catalog_str.as_deref(), types_ref.as_deref()) - }), - ); - ResultStream::from_reader(Box::new(reshaped)).await + let span = self.session.log_span().clone(); + async { + let catalog_str = catalog.as_ref().map(|i| i.as_str().to_owned()); + let types_owned: Option> = + table_types.map(|s| s.iter().map(|t| (*t).to_owned()).collect()); + let raw = match self + .session + .transport() + .list_tables( + self.session.session_id(), + catalog.as_ref().map(|i| i.as_str()), + schema_pattern.as_ref().map(|p| p.as_str()), + table_pattern.as_ref().map(|p| p.as_str()), + table_types, + ) + .await + { + Ok(r) => r, + Err(e) => return not_found_or(e, GET_TABLES_SCHEMA.clone(), Err).await, + }; + let reshaped = ThriftReshapingReader::new( + raw.reader, + GET_TABLES_SCHEMA.clone(), + Box::new(move |b| { + let types_ref: Option> = types_owned + .as_ref() + .map(|v| v.iter().map(|s| s.as_str()).collect()); + thrift_shape::reshape_tables(b, catalog_str.as_deref(), types_ref.as_deref()) + }), + ); + ResultStream::from_reader(Box::new(reshaped)).await + } + .instrument(span) + .await } /// Columns of tables matching the filter. Catalog is optional and @@ -375,29 +388,33 @@ impl Metadata { table_pattern: Option>, column_pattern: Option>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let catalog_str = catalog.as_ref().map(|i| i.as_str().to_owned()); - let raw = match self - .session - .transport() - .list_columns( - self.session.session_id(), - catalog.as_ref().map(|i| i.as_str()), - schema_pattern.as_ref().map(|p| p.as_str()), - table_pattern.as_ref().map(|p| p.as_str()), - column_pattern.as_ref().map(|p| p.as_str()), - ) - .await - { - Ok(r) => r, - Err(e) => return not_found_or(e, GET_COLUMNS_SCHEMA.clone(), Err).await, - }; - let reshaped = ThriftReshapingReader::new( - raw.reader, - GET_COLUMNS_SCHEMA.clone(), - Box::new(move |b| thrift_shape::reshape_columns(b, catalog_str.as_deref())), - ); - ResultStream::from_reader(Box::new(reshaped)).await + let span = self.session.log_span().clone(); + async { + let catalog_str = catalog.as_ref().map(|i| i.as_str().to_owned()); + let raw = match self + .session + .transport() + .list_columns( + self.session.session_id(), + catalog.as_ref().map(|i| i.as_str()), + schema_pattern.as_ref().map(|p| p.as_str()), + table_pattern.as_ref().map(|p| p.as_str()), + column_pattern.as_ref().map(|p| p.as_str()), + ) + .await + { + Ok(r) => r, + Err(e) => return not_found_or(e, GET_COLUMNS_SCHEMA.clone(), Err).await, + }; + let reshaped = ThriftReshapingReader::new( + raw.reader, + GET_COLUMNS_SCHEMA.clone(), + Box::new(move |b| thrift_shape::reshape_columns(b, catalog_str.as_deref())), + ); + ResultStream::from_reader(Box::new(reshaped)).await + } + .instrument(span) + .await } /// Primary keys for the given table. All three identifiers are @@ -421,24 +438,28 @@ impl Metadata { schema: Option>, table: Identifier<'_>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let catalog = catalog.ok_or_else(|| { - Error::invalid_argument().message("primary_keys requires a catalog identifier") - })?; - let schema = schema.ok_or_else(|| { - Error::invalid_argument().message("primary_keys requires a schema identifier") - })?; - let raw = self - .session - .transport() - .list_primary_keys( - self.session.session_id(), - catalog.as_str(), - schema.as_str(), - table.as_str(), - ) - .await?; - ResultStream::from_reader(raw.reader).await + let span = self.session.log_span().clone(); + async { + let catalog = catalog.ok_or_else(|| { + Error::invalid_argument().message("primary_keys requires a catalog identifier") + })?; + let schema = schema.ok_or_else(|| { + Error::invalid_argument().message("primary_keys requires a schema identifier") + })?; + let raw = self + .session + .transport() + .list_primary_keys( + self.session.session_id(), + catalog.as_str(), + schema.as_str(), + table.as_str(), + ) + .await?; + ResultStream::from_reader(raw.reader).await + } + .instrument(span) + .await } /// Foreign-key relationships. Both parent and foreign sides are @@ -461,30 +482,34 @@ impl Metadata { foreign_schema: Option>, foreign_table: Option>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let foreign_catalog = foreign_catalog.ok_or_else(|| { - Error::invalid_argument().message("foreign_keys requires foreign_catalog") - })?; - let foreign_schema = foreign_schema.ok_or_else(|| { - Error::invalid_argument().message("foreign_keys requires foreign_schema") - })?; - let foreign_table = foreign_table.ok_or_else(|| { - Error::invalid_argument().message("foreign_keys requires foreign_table") - })?; - let raw = self - .session - .transport() - .list_foreign_keys( - self.session.session_id(), - parent_catalog.as_ref().map(|i| i.as_str()), - parent_schema.as_ref().map(|i| i.as_str()), - parent_table.as_ref().map(|i| i.as_str()), - foreign_catalog.as_str(), - foreign_schema.as_str(), - foreign_table.as_str(), - ) - .await?; - ResultStream::from_reader(raw.reader).await + let span = self.session.log_span().clone(); + async { + let foreign_catalog = foreign_catalog.ok_or_else(|| { + Error::invalid_argument().message("foreign_keys requires foreign_catalog") + })?; + let foreign_schema = foreign_schema.ok_or_else(|| { + Error::invalid_argument().message("foreign_keys requires foreign_schema") + })?; + let foreign_table = foreign_table.ok_or_else(|| { + Error::invalid_argument().message("foreign_keys requires foreign_table") + })?; + let raw = self + .session + .transport() + .list_foreign_keys( + self.session.session_id(), + parent_catalog.as_ref().map(|i| i.as_str()), + parent_schema.as_ref().map(|i| i.as_str()), + parent_table.as_ref().map(|i| i.as_str()), + foreign_catalog.as_str(), + foreign_schema.as_str(), + foreign_table.as_str(), + ) + .await?; + ResultStream::from_reader(raw.reader).await + } + .instrument(span) + .await } /// Functions visible to the session. Catalog is exact; schema / @@ -499,18 +524,22 @@ impl Metadata { schema_pattern: Option>, name_pattern: Option>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let raw = self - .session - .transport() - .list_functions( - self.session.session_id(), - catalog.as_ref().map(|i| i.as_str()), - schema_pattern.as_ref().map(|p| p.as_str()), - name_pattern.as_ref().map(|p| p.as_str()), - ) - .await?; - ResultStream::from_reader(raw.reader).await + let span = self.session.log_span().clone(); + async { + let raw = self + .session + .transport() + .list_functions( + self.session.session_id(), + catalog.as_ref().map(|i| i.as_str()), + schema_pattern.as_ref().map(|p| p.as_str()), + name_pattern.as_ref().map(|p| p.as_str()), + ) + .await?; + ResultStream::from_reader(raw.reader).await + } + .instrument(span) + .await } /// Procedures visible to the session. Catalog is exact; schema / @@ -524,26 +553,34 @@ impl Metadata { schema_pattern: Option>, name_pattern: Option>, ) -> Result { - let _g = self.session.log_span().clone().entered(); - let raw = self - .session - .transport() - .list_procedures( - self.session.session_id(), - catalog.as_ref().map(|i| i.as_str()), - schema_pattern.as_ref().map(|p| p.as_str()), - name_pattern.as_ref().map(|p| p.as_str()), - ) - .await?; - ResultStream::from_reader(raw.reader).await + let span = self.session.log_span().clone(); + async { + let raw = self + .session + .transport() + .list_procedures( + self.session.session_id(), + catalog.as_ref().map(|i| i.as_str()), + schema_pattern.as_ref().map(|p| p.as_str()), + name_pattern.as_ref().map(|p| p.as_str()), + ) + .await?; + ResultStream::from_reader(raw.reader).await + } + .instrument(span) + .await } /// SQL data types supported by the workspace. No filters. No wire /// call — returns a static in-memory result. pub async fn type_info(&self) -> Result { - let _g = self.session.log_span().clone().entered(); - let reader = static_data::type_info_reader(); - ResultStream::from_reader(reader).await + let span = self.session.log_span().clone(); + async { + let reader = static_data::type_info_reader(); + ResultStream::from_reader(reader).await + } + .instrument(span) + .await } /// All table types (`TABLE`, `VIEW`, `SYSTEM TABLE`, …). No @@ -551,10 +588,14 @@ impl Metadata { /// driven by the session's transport list (see /// [`Transport::list_table_types`](crate::client::Transport::list_table_types)). pub async fn table_types(&self) -> Result { - let _g = self.session.log_span().clone().entered(); - let types = self.session.transport().list_table_types(); - let reader = static_data::table_types_reader(&types); - ResultStream::from_reader(reader).await + let span = self.session.log_span().clone(); + async { + let types = self.session.transport().list_table_types(); + let reader = static_data::table_types_reader(&types); + ResultStream::from_reader(reader).await + } + .instrument(span) + .await } } diff --git a/src/reader/mod.rs b/src/reader/mod.rs index 8981dd58..d305f4aa 100644 --- a/src/reader/mod.rs +++ b/src/reader/mod.rs @@ -322,6 +322,15 @@ impl ResultReaderFactory { /// `.await` its underlying async provider directly — no internal /// `block_on`. This is what makes the public `ResultStream::next_batch` /// truly async and safe to call from a tokio runtime (e.g. napi-rs). +/// +/// **External implementors**: this trait is rewritten by `async_trait` +/// into a `Pin>` return shape. Any external +/// `impl ResultReader for MyType { async fn schema(&self) -> ... }` +/// must be annotated with `#[async_trait::async_trait]`, otherwise the +/// compiler will emit an opaque type-mismatch error. The same goes for +/// the bound on `Box` containers — readers +/// constructed outside the kernel need to thread `async_trait` through +/// their definitions. #[async_trait] pub trait ResultReader: Send + Sync { /// Get the schema of the result. @@ -629,13 +638,14 @@ impl Iterator for ResultReaderAdapter { fn next(&mut self) -> Option { // Sync `Iterator` adapter for arrow's `RecordBatchReader`. - // Uses the executor-agnostic `futures::executor::block_on` so - // this works in non-tokio contexts (e.g. unit tests) for - // in-memory readers whose futures are immediately ready. For - // CloudFetch readers (which use tokio primitives internally), - // callers must drive iteration from inside a tokio runtime - // context — use the async `ResultStream::next_batch` instead. - match futures::executor::block_on(self.inner.next_batch()) { + // `block_on_current_runtime` uses block_in_place + the + // current runtime Handle when one exists (the case for + // CloudFetch readers), and falls back to + // `futures::executor::block_on` when there is no runtime + // (in-memory readers in plain-thread tests / non-tokio + // callers). Prevents the issue-#19 nested-block_on panic + // on this sync iterator path. + match crate::util::runtime::block_on_current_runtime(self.inner.next_batch()) { Ok(Some(batch)) => Some(Ok(batch)), Ok(None) => None, Err(e) => Some(Err(ArrowError::ExternalError(Box::new( diff --git a/src/result_stream.rs b/src/result_stream.rs index 8dc4eb20..4a870c16 100644 --- a/src/result_stream.rs +++ b/src/result_stream.rs @@ -591,12 +591,15 @@ impl ResultStream { /// isn't expressible. /// /// The wrapped reader is async; `next()` drives it via - /// `futures::executor::block_on`, which is executor-agnostic and - /// works in non-tokio contexts for in-memory readers. For - /// CloudFetch readers (which use tokio primitives internally), - /// `next()` must be called from inside a tokio runtime context - /// — see the `tokio::task::block_in_place` pattern in - /// `docs/spec-v0.md`. Errors are surfaced once; subsequent calls + /// [`crate::util::runtime::block_on_current_runtime`], which uses + /// `tokio::task::block_in_place` + the current runtime handle when + /// called from inside a multi-thread tokio runtime, and falls back + /// to `futures::executor::block_on` when no runtime is on the + /// thread (e.g. plain Rust callers, the C ABI shim). This keeps + /// CloudFetch readers (which await tokio primitives internally) + /// safe from the nested-`block_on` panic that motivated issue #19, + /// while still letting in-memory readers iterate without a tokio + /// runtime at all. Errors are surfaced once; subsequent calls /// after an `Err` keep returning `None`. pub fn into_owned_batches(self) -> OwnedBatchIter { OwnedBatchIter { @@ -624,11 +627,14 @@ impl Iterator for OwnedBatchIter { if self.done { return None; } - // Executor-agnostic blocking poll. Safe for in-memory readers - // (immediately-ready futures). CloudFetch readers must be - // driven from inside a tokio runtime context — the underlying - // provider uses tokio primitives. - match futures::executor::block_on(self.reader.next_batch()) { + // Runtime-aware blocking poll: uses block_in_place + the + // current Handle when there's a tokio runtime on this thread + // (the case for CloudFetch readers, which await tokio + // primitives); falls back to futures::executor::block_on for + // plain-thread callers driving in-memory readers. Prevents + // the nested-block_on panic from issue #19 on the sync + // iterator path. + match crate::util::runtime::block_on_current_runtime(self.reader.next_batch()) { Ok(Some(batch)) => Some(Ok(batch)), Ok(None) => { self.done = true; diff --git a/src/session.rs b/src/session.rs index 255ce05f..69367cfa 100644 --- a/src/session.rs +++ b/src/session.rs @@ -66,7 +66,7 @@ use crate::statement::mutable::Statement; use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; -use tracing::{debug, info_span, Span}; +use tracing::{debug, info_span, Instrument, Span}; /// Crate-internal session state. Wrapped in `Arc` and shared with /// every child handle (`Statement`, `ExecutedStatement`, …) so the @@ -324,15 +324,19 @@ impl Session { if self.inner.closed.load(std::sync::atomic::Ordering::Acquire) { return Ok(()); } - let _g = self.inner.log_span.clone().entered(); - self.inner - .transport - .delete_session(&self.inner.session_id) - .await?; - self.inner - .closed - .store(true, std::sync::atomic::Ordering::Release); - Ok(()) + let span = self.inner.log_span.clone(); + async { + self.inner + .transport + .delete_session(&self.inner.session_id) + .await?; + self.inner + .closed + .store(true, std::sync::atomic::Ordering::Release); + Ok(()) + } + .instrument(span) + .await } } diff --git a/src/statement/executed_async.rs b/src/statement/executed_async.rs index 10ec7e43..019335f7 100644 --- a/src/statement/executed_async.rs +++ b/src/statement/executed_async.rs @@ -148,14 +148,18 @@ impl ExecutedAsyncStatement { /// locally — without hitting the wire — if the parent `Statement` /// has already invalidated this handle. pub async fn status(&self) -> Result { - let _g = self.session.log_span().clone().entered(); - self.valid.check()?; - let response = self - .session - .transport() - .statement_status(&self.statement_id) - .await?; - Ok(StatementStatus::from_sea_response(&response)) + let span = self.session.log_span().clone(); + async { + self.valid.check()?; + let response = self + .session + .transport() + .statement_status(&self.statement_id) + .await?; + Ok(StatementStatus::from_sea_response(&response)) + } + .instrument(span) + .await } /// Block until the server reaches a terminal state, then return @@ -178,62 +182,66 @@ impl ExecutedAsyncStatement { /// sync polling path produces). The caller may issue a fresh /// `status()` or `await_result()` to resume. pub async fn await_result(&self) -> Result { - let _g = self.session.log_span().clone().entered(); - self.valid.check()?; + let span = self.session.log_span().clone(); + async { + self.valid.check()?; - // Poll cadence + ceiling come from the transport's config — - // same source the sync `wait_for_completion` path uses, so - // a caller's `SessionBuilder` tuning applies to both modes. - let cfg = self.session.transport().poll_config(); - let start = std::time::Instant::now(); + // Poll cadence + ceiling come from the transport's config — + // same source the sync `wait_for_completion` path uses, so + // a caller's `SessionBuilder` tuning applies to both modes. + let cfg = self.session.transport().poll_config(); + let start = std::time::Instant::now(); - // RAII guard: if the future is dropped mid-poll (timeout, - // tokio::select! loser, task cancellation), spawn a - // best-effort `cancel_statement` so the server stops - // charging DBUs on a now-orphaned query. Defused once we - // reach a terminal state on the success or error path. - let cancel_guard = - AwaitResultCancelGuard::new(Arc::clone(&self.session), self.statement_id.clone()); + // RAII guard: if the future is dropped mid-poll (timeout, + // tokio::select! loser, task cancellation), spawn a + // best-effort `cancel_statement` so the server stops + // charging DBUs on a now-orphaned query. Defused once we + // reach a terminal state on the success or error path. + let cancel_guard = + AwaitResultCancelGuard::new(Arc::clone(&self.session), self.statement_id.clone()); - loop { - self.valid.check()?; - let response = self - .session - .transport() - .statement_status(&self.statement_id) - .await?; - match StatementStatus::from_sea_response(&response) { - StatementStatus::Succeeded | StatementStatus::Closed => { - cancel_guard.defuse(); - return self.materialise_result().await; - } - StatementStatus::Failed(e) => { - // Server already decided this is terminal — no - // need to fire a redundant cancel. - cancel_guard.defuse(); - return Err(e); - } - StatementStatus::Cancelled => { - cancel_guard.defuse(); - return Err(Error::invalid_state() - .message(format!("Statement {} was cancelled", self.statement_id))); - } - StatementStatus::Pending | StatementStatus::Running => { - if start.elapsed() > cfg.poll_timeout { - // Internal poll-timeout: we asked to wait, - // we gave up. Leave the cancel guard armed - // so the server stops charging DBUs on the - // now-orphaned query when we return — same - // policy as a caller-initiated future drop. - return Err(Error::timeout().message(format!( - "Statement {} did not reach a terminal state within {:?}", - self.statement_id, cfg.poll_timeout - ))); + loop { + self.valid.check()?; + let response = self + .session + .transport() + .statement_status(&self.statement_id) + .await?; + match StatementStatus::from_sea_response(&response) { + StatementStatus::Succeeded | StatementStatus::Closed => { + cancel_guard.defuse(); + return self.materialise_result().await; + } + StatementStatus::Failed(e) => { + // Server already decided this is terminal — no + // need to fire a redundant cancel. + cancel_guard.defuse(); + return Err(e); + } + StatementStatus::Cancelled => { + cancel_guard.defuse(); + return Err(Error::invalid_state() + .message(format!("Statement {} was cancelled", self.statement_id))); + } + StatementStatus::Pending | StatementStatus::Running => { + if start.elapsed() > cfg.poll_timeout { + // Internal poll-timeout: we asked to wait, + // we gave up. Leave the cancel guard armed + // so the server stops charging DBUs on the + // now-orphaned query when we return — same + // policy as a caller-initiated future drop. + return Err(Error::timeout().message(format!( + "Statement {} did not reach a terminal state within {:?}", + self.statement_id, cfg.poll_timeout + ))); + } + tokio::time::sleep(cfg.poll_interval).await; } - tokio::time::sleep(cfg.poll_interval).await; } } } + .instrument(span) + .await } /// Fetch the result without polling. Errors if the statement has @@ -243,9 +251,13 @@ impl ExecutedAsyncStatement { /// message pointing callers at [`status`](Self::status). Useful /// when the caller has already confirmed completion themselves. pub async fn fetch_result(&self) -> Result { - let _g = self.session.log_span().clone().entered(); - self.valid.check()?; - self.materialise_result().await + let span = self.session.log_span().clone(); + async { + self.valid.check()?; + self.materialise_result().await + } + .instrument(span) + .await } /// Internal: resolve the reader for an (expected to be) terminal diff --git a/src/statement/mutable.rs b/src/statement/mutable.rs index 75b493d6..5dc3c982 100644 --- a/src/statement/mutable.rs +++ b/src/statement/mutable.rs @@ -162,10 +162,6 @@ impl Statement { cancel_state.observe(&result.statement_id); guard.defuse(); - let valid = ValidityFlag::new(); - self.last_statement_id = Some(result.statement_id.clone()); - self.last_valid = Some(valid.clone()); - let valid = ValidityFlag::new(); // Only `Closed` triggers the short-circuit. `Succeeded` means // the server still owns the statement and we must issue @@ -220,9 +216,6 @@ impl Statement { guard.defuse(); let valid = ValidityFlag::new(); - self.last_statement_id = Some(response.statement_id.clone()); - self.last_valid = Some(valid.clone()); - // submit path always uses wait_timeout=0s, so the server can't // return CLOSED yet; start the flag false and let later close() // calls flip it. @@ -269,9 +262,13 @@ impl Statement { /// for callers that forget to call `close()` explicitly, but /// the explicit path is the supported one. pub async fn close(mut self) -> Result<()> { - let _g = self.session.log_span().clone().entered(); - self.invalidate_prior().await; - Ok(()) + let span = self.session.log_span().clone(); + async { + self.invalidate_prior().await; + Ok(()) + } + .instrument(span) + .await } /// Shared spec-validation + `ExecuteParams` builder used by both diff --git a/src/util/runtime.rs b/src/util/runtime.rs index 28523b94..88f5487e 100644 --- a/src/util/runtime.rs +++ b/src/util/runtime.rs @@ -57,3 +57,58 @@ where runtime_handle.block_on(fut) } } + +/// Bridge from a sync iterator to an async kernel future when no +/// runtime handle has been threaded through. +/// +/// Three cases: +/// +/// - **No tokio runtime on this thread** (plain Rust use, the C ABI +/// shim's sync entry points): falls back to +/// `futures::executor::block_on`. Sufficient for readers whose +/// futures are immediately ready (in-memory data); the only safe +/// option when nobody set up a reactor. +/// +/// - **Multi-thread tokio runtime**: escapes via `block_in_place` + +/// the discovered handle (same shape as +/// [`block_on_in_runtime`]). Tells the runtime "I'm about to do +/// something blocking" so other tasks can migrate to a different +/// worker, then drives the future to completion. This is the +/// primary CloudFetch path under napi-rs. +/// +/// - **Current-thread tokio runtime**: `block_in_place` panics here +/// ("can call blocking only when running on the multi-threaded +/// runtime"). For in-memory readers (immediately-ready futures) +/// `futures::executor::block_on` still works because the future +/// never yields, so we fall back to it. For futures that genuinely +/// await tokio primitives (CloudFetch / timer / Notify), this path +/// cannot bridge safely — sync iteration over CloudFetch from a +/// current-thread runtime is a logically impossible request. The +/// fallback at least doesn't crash unit tests that iterate +/// in-memory mock readers from inside `#[tokio::test]`. +/// +/// Used by [`crate::result_stream::OwnedBatchIter`] and +/// [`crate::reader::ResultReaderAdapter`] — sync iterator adapters +/// over `Box` where the caller couldn't thread a +/// handle through at construction time (e.g. arrow's +/// `RecordBatchReader` impl). Async-aware kernel callers should +/// drive the reader via `next_batch().await` instead. +pub(crate) fn block_on_current_runtime(fut: F) -> F::Output +where + F: std::future::Future, +{ + match tokio::runtime::Handle::try_current() { + Ok(handle) => match handle.runtime_flavor() { + tokio::runtime::RuntimeFlavor::MultiThread => { + tokio::task::block_in_place(|| handle.block_on(fut)) + } + // CurrentThread (or any future single-worker flavor): + // block_in_place panics. Fall back to executor::block_on + // — works for immediately-ready futures (in-memory + // readers), and there's no safe option for futures that + // need this runtime's reactor anyway. + _ => futures::executor::block_on(fut), + }, + Err(_) => futures::executor::block_on(fut), + } +} From f782035361ca692ab705739c56c7e1533363082d Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Fri, 22 May 2026 10:43:45 +0000 Subject: [PATCH 7/7] ci+test: cover tls-rustls feature build + add current_thread regression for CloudFetch drain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses MEDIUM-severity findings F7 and F8 from the PR #26 review. F7 — CI was running only `cargo clippy --all-targets -- -D warnings` and `cargo test --workspace`, both with default features (which resolves to `tls-native`). The downstream napi binding opts INTO `tls-rustls`. Without a CI job for that build, a feature-gated cfg typo or a dep update that breaks rustls compilation would only surface when the napi crate's CI broke — long after the kernel PR landed. Added `check-tls-rustls` job: `cargo check --no-default-features --features tls-rustls` plus a clippy run with the same flags, so warnings caught under tls-native stay honest under tls-rustls and vice versa. F8 — the existing `cloudfetch_drain_does_not_nest_block_on` test uses `#[tokio::test(flavor = "multi_thread")]`. That flavor was required under PR #20's Option-2 (`block_in_place` stopgap); under Option-1 (this PR's async trait), the fix is supposed to be runtime-flavor-independent. A future refactor that reintroduced a sync→async `block_on` bridge protected by `block_in_place` would still pass `multi_thread` but `current_thread` is the worst case (`block_in_place` panics there). Added a sibling `cloudfetch_drain_works_on_current_thread_runtime` test annotated `flavor = "current_thread"` as the discriminating regression guard. Both tests stay `#[ignore]` — they require a live workspace and CloudFetch-disposition results, same as before. Signed-off-by: Madhavendra Rathore --- .github/workflows/pr-checks.yml | 26 ++++++++++++++++++++++++++ tests/v0_execute_e2e.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 87e2b3f8..3a4e9235 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -88,3 +88,29 @@ jobs: # run the v0_*_e2e suites — those are #[ignore]'d and require # a live workspace; `rust-e2e.yml` runs them separately. run: cargo test --workspace + + check-tls-rustls: + name: Build (tls-rustls feature) + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + with: + toolchain: stable + components: clippy + + - name: cargo check (tls-rustls) + # Default features pull in `tls-native`; the napi binding crate + # opts INTO `tls-rustls` instead. Without this job, a feature- + # gated cfg typo or a dep update that breaks rustls compilation + # would only surface when the downstream napi build breaks. + run: cargo check --no-default-features --features tls-rustls + + - name: cargo clippy (tls-rustls) + # Keep clippy honest under both backends so warnings caught + # under tls-native don't disappear under tls-rustls and vice + # versa. + run: cargo clippy --no-default-features --features tls-rustls --all-targets -- -D warnings diff --git a/tests/v0_execute_e2e.rs b/tests/v0_execute_e2e.rs index f031f2cd..51deec23 100644 --- a/tests/v0_execute_e2e.rs +++ b/tests/v0_execute_e2e.rs @@ -451,3 +451,35 @@ async fn cloudfetch_drain_does_not_nest_block_on() { exec.close().await.expect("close"); session.close().await.expect("session close"); } + +/// Current-thread sibling of `cloudfetch_drain_does_not_nest_block_on`. +/// +/// Under Option-1 (this PR's async trait), the fix is supposed to be +/// runtime-flavor-independent. The `multi_thread` test above could +/// still pass even if a future refactor reintroduced a sync→async +/// `block_on` bridge protected by `tokio::task::block_in_place` (the +/// Option-2 stopgap PR #20 used). `current_thread` is the worst case: +/// `block_in_place` panics on a current-thread runtime, so a nested +/// `block_on` here would surface immediately. This is the +/// discriminating regression guard. +#[tokio::test(flavor = "current_thread")] +#[ignore] +async fn cloudfetch_drain_works_on_current_thread_runtime() { + let session = live_session().await; + let mut stmt = session.statement(); + stmt.spec().sql("SELECT * FROM range(1000000)"); + let mut exec = stmt + .execute() + .await + .expect("execute range(1000000) on current_thread runtime"); + + let rows = drain_rows(exec.result_stream_mut()).await; + assert_eq!( + rows, 1_000_000, + "expected 1M rows on current_thread runtime; if this drain \ + panicked or block_in_place was reintroduced, the Option-1 \ + async-trait fix has regressed" + ); + exec.close().await.expect("close"); + session.close().await.expect("session close"); +}