diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 2d2c3d9a..c86de823 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -100,3 +100,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/Cargo.lock b/Cargo.lock index dfaa6003..37ff26df 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", @@ -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" @@ -328,9 +334,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.4" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" dependencies = [ "core-foundation-sys", "libc", @@ -409,7 +415,7 @@ dependencies = [ "lz4_flex", "oauth2", "open", - "rand 0.9.2", + "rand 0.9.4", "reqwest", "serde", "serde_json", @@ -496,15 +502,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" @@ -523,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" @@ -545,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", @@ -559,6 +556,12 @@ 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" @@ -703,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", @@ -745,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" @@ -810,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", @@ -825,7 +856,6 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "pin-utils", "smallvec", "tokio", "want", @@ -833,15 +863,14 @@ 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", @@ -866,14 +895,13 @@ dependencies = [ [[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", @@ -883,18 +911,16 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2", - "system-configuration", "tokio", "tower-service", "tracing", - "windows-registry", ] [[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", @@ -916,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", @@ -929,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", @@ -942,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", @@ -956,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", @@ -976,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", @@ -995,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" @@ -1008,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", @@ -1018,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]] @@ -1037,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" @@ -1072,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", ] @@ -1092,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" @@ -1163,9 +1196,9 @@ 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", ] @@ -1178,9 +1211,9 @@ 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" @@ -1205,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", ] @@ -1223,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" @@ -1236,12 +1269,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" @@ -1254,9 +1281,9 @@ 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", @@ -1265,9 +1292,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.14" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" dependencies = [ "libc", "log", @@ -1347,7 +1374,7 @@ dependencies = [ "chrono", "getrandom 0.2.17", "http", - "rand 0.8.5", + "rand 0.8.6", "reqwest", "serde", "serde_json", @@ -1359,9 +1386,9 @@ 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" @@ -1376,15 +1403,14 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.75" +version = "0.10.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +checksum = "a45fa2aa886c42762255da344f0a0d313e254066c46aad76f300c3d3da62d967" dependencies = [ "bitflags", "cfg-if", "foreign-types", "libc", - "once_cell", "openssl-macros", "openssl-sys", ] @@ -1402,15 +1428,15 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "openssl-sys" -version = "0.9.111" +version = "0.9.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +checksum = "f28a22dc7140cda5f096e5e7724a6962ca81a7f8bfd2979f9b18c11af56318c4" dependencies = [ "cc", "libc", @@ -1461,21 +1487,15 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" - -[[package]] -name = "pin-utils" -version = "0.1.0" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pkg-config" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" [[package]] name = "portable-atomic" @@ -1485,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", ] @@ -1501,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" @@ -1593,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", @@ -1628,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", ] @@ -1641,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", @@ -1654,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", @@ -1722,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", @@ -1734,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", @@ -1745,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" @@ -1757,10 +1793,8 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64", "bytes", - "encoding_rs", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", @@ -1770,7 +1804,6 @@ dependencies = [ "hyper-util", "js-sys", "log", - "mime", "native-tls", "percent-encoding", "pin-project-lite", @@ -1812,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" @@ -1840,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", @@ -1854,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", @@ -1864,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", @@ -1881,15 +1914,15 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "schannel" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" dependencies = [ "windows-sys 0.61.2", ] @@ -1902,9 +1935,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.11.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ "bitflags", "core-foundation", @@ -1915,9 +1948,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.15.0" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -1925,9 +1958,9 @@ dependencies = [ [[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" @@ -1961,9 +1994,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", @@ -2033,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" @@ -2051,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]] @@ -2073,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", @@ -2102,27 +2135,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" @@ -2136,7 +2148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.2", "once_cell", "rustix", "windows-sys 0.61.2", @@ -2202,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", @@ -2212,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", ] @@ -2227,9 +2239,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.50.0" +version = "1.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" dependencies = [ "bytes", "libc", @@ -2244,9 +2256,9 @@ 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", @@ -2303,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", @@ -2315,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]] @@ -2411,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" @@ -2487,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", @@ -2509,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", @@ -2533,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", @@ -2546,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" @@ -2566,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", @@ -2588,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", ] @@ -2636,17 +2693,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" @@ -2915,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", @@ -2935,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", @@ -2947,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", @@ -2967,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", @@ -2994,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", @@ -3005,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", @@ -3016,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", @@ -3027,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 ec3cc267..3236f0b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,19 @@ arrow-select = "57" arrow-ipc = "57" # HTTP client and async runtime -reqwest = { version = "0.12", features = ["json", "gzip", "stream", "native-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 @@ -65,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/) @@ -75,6 +94,43 @@ 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/`) 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). +# +# 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 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"] +tls-rustls = ["reqwest/rustls-tls"] + [lib] name = "databricks_sql_kernel" crate-type = ["lib", "cdylib", "staticlib"] 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/client/sea.rs b/src/client/sea.rs index d22f47d0..0dd732cd 100644 --- a/src/client/sea.rs +++ b/src/client/sea.rs @@ -377,7 +377,9 @@ impl SeaRestTransport { // Arrow shape collapses (VARIANT → Utf8, intervals → Interval, // GEOMETRY/GEOGRAPHY → Utf8). The post-processor also handles // the optional complex-types-as-JSON rewrite in the same pass. - 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 @@ -530,7 +532,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/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/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..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 @@ -98,12 +99,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) } @@ -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)) + 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), - }; - 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)) + 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), - }; - 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)) + 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), - }; - 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)) + 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) + 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) + 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) + 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) + 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) + 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) + 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 46ff0e41..be44237e 100644 --- a/src/reader/mod.rs +++ b/src/reader/mod.rs @@ -34,9 +34,9 @@ use crate::reader::inline::InlineArrowProvider; use crate::reader::post_processor::{PostProcessOptions, ResultPostProcessor}; 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; @@ -94,17 +94,20 @@ 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(ResultPostProcessor::new( - inner, - response.manifest.as_ref(), - self.post_process_options.clone(), - )?)) + Ok(Box::new( + ResultPostProcessor::new( + inner, + response.manifest.as_ref(), + self.post_process_options.clone(), + ) + .await?, + )) } /// Pick the right concrete reader for `response`: CloudFetch, @@ -300,10 +303,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( @@ -331,39 +331,48 @@ 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). +/// +/// **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. - 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 } } @@ -383,14 +392,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() } } @@ -419,12 +429,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()) } } @@ -444,12 +455,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) } } @@ -479,11 +491,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, @@ -564,7 +580,15 @@ 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`. + // `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( @@ -588,22 +612,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); @@ -614,34 +638,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), @@ -649,22 +673,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] @@ -886,15 +910,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), @@ -902,12 +928,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 diff --git a/src/reader/post_processor/mod.rs b/src/reader/post_processor/mod.rs index 93af0e73..8f9af656 100644 --- a/src/reader/post_processor/mod.rs +++ b/src/reader/post_processor/mod.rs @@ -41,6 +41,7 @@ use crate::types::sea::ResultManifest; use arrow_array::builder::StringBuilder; use arrow_array::{ArrayRef, RecordBatch}; use arrow_schema::{DataType, Field, Schema, SchemaRef}; +use async_trait::async_trait; use std::sync::Arc; /// Optional per-batch transforms the post-processor applies. @@ -83,12 +84,12 @@ impl ResultPostProcessor { /// per-column metadata; `None` for upstreams that don't have one /// (e.g. legacy paths). `options` toggles optional transforms /// (today: complex-type JSON stringification). - pub(crate) fn new( + pub(crate) async fn new( inner: Box, manifest: Option<&ResultManifest>, options: PostProcessOptions, ) -> Result { - let inner_schema = inner.schema()?; + let inner_schema = inner.schema().await?; // 1. Compute the output schema after manifest augmentation // (no-op when manifest is None). @@ -169,13 +170,14 @@ impl ResultPostProcessor { } } +#[async_trait] impl ResultReader for ResultPostProcessor { - fn schema(&self) -> Result { + async fn schema(&self) -> Result { Ok(self.schema.clone()) } - fn next_batch(&mut self) -> Result> { - let Some(batch) = self.inner.next_batch()? else { + async fn next_batch(&mut self) -> Result> { + let Some(batch) = self.inner.next_batch().await? else { return Ok(None); }; match &self.transform { @@ -299,8 +301,8 @@ mod tests { } } - #[test] - fn pass_through_when_no_manifest_and_json_off() { + #[tokio::test] + async fn pass_through_when_no_manifest_and_json_off() { let schema = Arc::new(Schema::new(vec![Field::new("name", DataType::Utf8, true)])); let batch = RecordBatch::try_new( schema.clone(), @@ -309,16 +311,18 @@ mod tests { .unwrap(); let inner: Box = Box::new(MockReader::new(vec![batch])); - let mut pp = ResultPostProcessor::new(inner, None, PostProcessOptions::default()).unwrap(); + let mut pp = ResultPostProcessor::new(inner, None, PostProcessOptions::default()) + .await + .unwrap(); // No transform should have been installed. assert!(pp.transform.is_none()); - let out = pp.next_batch().unwrap().unwrap(); + let out = pp.next_batch().await.unwrap().unwrap(); assert_eq!(out.num_rows(), 1); assert_eq!(out.schema().field(0).metadata().len(), 0); } - #[test] - fn manifest_only_attaches_metadata_to_batches() { + #[tokio::test] + async fn manifest_only_attaches_metadata_to_batches() { let schema = Arc::new(Schema::new(vec![Field::new("name", DataType::Utf8, true)])); let batch = RecordBatch::try_new( schema.clone(), @@ -330,10 +334,11 @@ mod tests { let mut pp = ResultPostProcessor::new(inner, Some(&manifest), PostProcessOptions::default()) + .await .unwrap(); assert!(pp.transform.is_some()); - let out = pp.next_batch().unwrap().unwrap(); + let out = pp.next_batch().await.unwrap().unwrap(); assert_eq!( out.schema() .field(0) @@ -343,8 +348,8 @@ mod tests { ); } - #[test] - fn json_path_rewrites_list_column_to_utf8() { + #[tokio::test] + async fn json_path_rewrites_list_column_to_utf8() { // Build a one-row batch with a list column. let mut list_b = ListBuilder::new(arrow_array::builder::Int32Builder::new()); list_b.values().append_value(1); @@ -373,14 +378,14 @@ mod tests { let opts = PostProcessOptions { complex_types_as_json: true, }; - let mut pp = ResultPostProcessor::new(inner, None, opts).unwrap(); + let mut pp = ResultPostProcessor::new(inner, None, opts).await.unwrap(); // Output schema should expose Utf8 for the complex column. - let out_schema = pp.schema().unwrap(); + let out_schema = pp.schema().await.unwrap(); assert_eq!(out_schema.field(0).data_type(), &DataType::Utf8); assert_eq!(out_schema.field(1).data_type(), &DataType::Int32); - let out_batch = pp.next_batch().unwrap().unwrap(); + let out_batch = pp.next_batch().await.unwrap().unwrap(); let arr = out_batch .column(0) .as_any() @@ -396,8 +401,8 @@ mod tests { assert_eq!(other.value(0), 7); } - #[test] - fn json_path_handles_null_list_value() { + #[tokio::test] + async fn json_path_handles_null_list_value() { let mut list_b = ListBuilder::new(arrow_array::builder::Int32Builder::new()); list_b.append(false); // null list_b.values().append_value(1); @@ -416,8 +421,8 @@ mod tests { let opts = PostProcessOptions { complex_types_as_json: true, }; - let mut pp = ResultPostProcessor::new(inner, None, opts).unwrap(); - let out_batch = pp.next_batch().unwrap().unwrap(); + let mut pp = ResultPostProcessor::new(inner, None, opts).await.unwrap(); + let out_batch = pp.next_batch().await.unwrap().unwrap(); let arr = out_batch .column(0) .as_any() @@ -427,8 +432,8 @@ mod tests { assert_eq!(arr.value(1), "[1]"); } - #[test] - fn json_path_struct_renders_fields_in_order() { + #[tokio::test] + async fn json_path_struct_renders_fields_in_order() { let fields: Fields = vec![ Field::new("a", DataType::Utf8, true), Field::new("b", DataType::Int32, true), @@ -453,8 +458,8 @@ mod tests { let opts = PostProcessOptions { complex_types_as_json: true, }; - let mut pp = ResultPostProcessor::new(inner, None, opts).unwrap(); - let out = pp.next_batch().unwrap().unwrap(); + let mut pp = ResultPostProcessor::new(inner, None, opts).await.unwrap(); + let out = pp.next_batch().await.unwrap().unwrap(); let arr = out .column(0) .as_any() @@ -463,8 +468,8 @@ mod tests { assert_eq!(arr.value(0), "{\"a\":\"foo\",\"b\":1}"); } - #[test] - fn json_path_map_renders_object() { + #[tokio::test] + async fn json_path_map_renders_object() { let mut b = MapBuilder::new(None, StringBuilder::new(), StringBuilder::new()); b.keys().append_value("k"); b.values().append_value("v"); @@ -479,8 +484,8 @@ mod tests { let opts = PostProcessOptions { complex_types_as_json: true, }; - let mut pp = ResultPostProcessor::new(inner, None, opts).unwrap(); - let out = pp.next_batch().unwrap().unwrap(); + let mut pp = ResultPostProcessor::new(inner, None, opts).await.unwrap(); + let out = pp.next_batch().await.unwrap().unwrap(); let arr = out .column(0) .as_any() @@ -489,8 +494,8 @@ mod tests { assert_eq!(arr.value(0), "{\"k\":\"v\"}"); } - #[test] - fn json_off_leaves_complex_columns_intact() { + #[tokio::test] + async fn json_off_leaves_complex_columns_intact() { let mut list_b = ListBuilder::new(arrow_array::builder::Int32Builder::new()); list_b.values().append_value(1); list_b.append(true); @@ -501,9 +506,11 @@ mod tests { let batch = RecordBatch::try_new(schema, vec![Arc::new(list_arr) as _]).unwrap(); let inner: Box = Box::new(MockReader::new(vec![batch])); - let mut pp = ResultPostProcessor::new(inner, None, PostProcessOptions::default()).unwrap(); - assert_eq!(pp.schema().unwrap().field(0).data_type(), &list_dt); - let out = pp.next_batch().unwrap().unwrap(); + let mut pp = ResultPostProcessor::new(inner, None, PostProcessOptions::default()) + .await + .unwrap(); + assert_eq!(pp.schema().await.unwrap().field(0).data_type(), &list_dt); + let out = pp.next_batch().await.unwrap().unwrap(); assert_eq!(out.schema().field(0).data_type(), &list_dt); } } 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..4a870c16 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,16 @@ 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 + /// [`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 { @@ -614,7 +627,14 @@ impl Iterator for OwnedBatchIter { if self.done { return None; } - match 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; @@ -645,10 +665,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 +690,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 +717,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 +731,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 +754,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 +776,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 +800,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 +819,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 +840,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 +870,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 +882,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 +895,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 +937,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 +963,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 +971,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 +992,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 +1008,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 +1024,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/session.rs b/src/session.rs index 95aa51da..9cdef68f 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 @@ -325,15 +325,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 5b1fdd9e..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 @@ -260,7 +272,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..5dc3c982 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,57 @@ 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)?; - 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(); + // 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 +198,41 @@ 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(); + // 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 @@ -250,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), + } +} diff --git a/tests/v0_execute_e2e.rs b/tests/v0_execute_e2e.rs index cc213aff..11c10def 100644 --- a/tests/v0_execute_e2e.rs +++ b/tests/v0_execute_e2e.rs @@ -459,33 +459,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)"); @@ -493,7 +501,40 @@ 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"); +} + +/// 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");