Skip to content

Commit e8ffc1a

Browse files
authored
fix(vane): track Windows distributed mutation artifacts (#56)
Windows drive paths such as `C:\...` and `D:/...` were parsed as non-file URI schemes in mutation workers. They consequently reopened the dataset through Lance's direct local writer, bypassing the object-store wrapper that tracks mutation files. UPDATE replacements and partial-DELETE files could be written and then rejected by transaction artifact validation. Use upstream `uri_to_url()` and OS-aware `to_file_path()` before selecting `file-object-store`. Resolve the C++ error-redaction policy before the mutation FFI call so path normalization cannot erase its Rust error. Keep artifact validation and diagnostic redaction in place. Regression coverage now includes local paths/file URIs with spaces, Unicode and literal percent escapes, plus the existing remote URI behavior. The existing Windows/macOS qualification script now exercises UPDATE, whole-fragment and partial DELETE, and full-table mutations in both local and Ray modes. The failed-UPDATE test requires the underlying nullability error rather than accepting only the generic transaction prefix. ### Validation - `cargo test --locked --offline --lib --features vane-distributed ffi::distributed_mutation::tests`: **5 passed**; compiled the changed Rust source. - C++ syntax compilation of `src/lance_distributed_write.cpp` with the released Vane 0.3.0 SDK headers and `LANCE_VANE_DISTRIBUTED`: **passed**. - `python -m pytest -q python/tests/test_vane_platform_release.py`: **23 passed**. - `uv run make format`, `cargo fmt --all --check`, Black, Python syntax checks and `git diff --check`: **passed**. - Updated qualification script: **local and Ray passed on Linux using the existing signed 0.3.0/0.3.0.1 wheels**. This checks the expanded script, not a newly linked provider. The Ray run used one node/two CPUs; inspection of 38 Ray log files found no mutation error or Python fatal. Windows verification of the rebuilt provider and the end-to-end error-detail regression remain pending. No TestPyPI/PyPI publication is part of this PR. ### Windows verification Use the matched Windows base/provider wheels built for this PR (the `vane-lance-full-windows` CI artifact), in a fresh CPython 3.12 x64 environment. The already published `0.3.0.1` wheel and the old test kit's pinned `install` step still select the old native code. From this PR checkout, after installing those CI wheels: ```powershell $env:VANE_EXPECTED_EXTENSION_TRUST_IDENTITY = "vane-ci-test-key" $env:VANE_DISTRIBUTED_NODE_COUNT = "1" $env:VANE_DISTRIBUTED_WORKER_SLOTS = "2" python scripts/verify_vane_platform.py --runner local --directory C:/vane-pr-test/local python scripts/verify_vane_platform.py --runner ray --directory C:/vane-pr-test/ray ``` Use fresh output directories. The script verifies signed loading, exact mutated rows and the empty result after full DELETE. Inspect actor stderr as well as command exit status. The separate GIL abort is tracked in [AstroVela/vane#1146](AstroVela/vane#1146), with the related upstream [duckdb-python#456](duckdb/duckdb-python#456) and [#462](duckdb/duckdb-python#462). That crash's exact native caller still needs a Windows stack; this mutation fix does not claim to fix it.
1 parent b3efe20 commit e8ffc1a

4 files changed

Lines changed: 98 additions & 22 deletions

File tree

‎python/tests/test_vane_distributed_write.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,8 @@ def test_failed_distributed_lance_update_keeps_the_target_unchanged(
821821
initial_deletion_file_count = _deletion_file_count(connection, target_path)
822822

823823
previous_dispatch_count = write_capture.dispatch_count
824-
with pytest.raises(Exception, match="NULL|NOT NULL|worker mutation"):
824+
# Require the underlying Rust error, not only the generic C++ prefix.
825+
with pytest.raises(Exception, match="NULL|NOT NULL|non-nullable"):
825826
connection.table("lance_mutation.main.mutation_target").update(
826827
{
827828
"value": vane.SQLExpression(

‎rust/ffi/distributed_mutation.rs‎

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use lance::dataset::builder::DatasetBuilder;
1515
use lance::dataset::transaction::{Operation, Transaction, UpdateMode};
1616
use lance::dataset::{CommitBuilder, Dataset, InsertBuilder, WriteMode, WriteParams};
1717
use lance_arrow::RecordBatchExt;
18-
use lance_io::object_store::WrappingObjectStore;
18+
use lance_io::object_store::{uri_to_url, WrappingObjectStore};
1919
use lance_table::format::{Fragment, RowIdMeta};
2020
use lance_table::io::deletion::relative_deletion_file_path;
2121
use lance_table::rowids::{rechunk_sequences, write_row_ids, RowIdSequence};
@@ -700,17 +700,14 @@ async fn open_dataset(
700700
}
701701

702702
fn mutation_worker_uri(path: &str) -> FfiResult<String> {
703-
let parsed = Url::parse(path).ok();
704-
if parsed
705-
.as_ref()
706-
.is_some_and(|url| !matches!(url.scheme(), "file" | "file+uring"))
707-
{
703+
let url = uri_to_url(path)
704+
.map_err(|err| mutation_error(format!("parse distributed mutation target: {err}")))?;
705+
if !matches!(url.scheme(), "file" | "file+uring") {
708706
return Ok(path.to_string());
709707
}
710-
let local_path = match parsed {
711-
Some(url) => std::path::PathBuf::from(url.path()),
712-
None => std::path::PathBuf::from(path),
713-
};
708+
let local_path = url.to_file_path().map_err(|_| {
709+
mutation_error(format!("decode local distributed mutation target '{path}'"))
710+
})?;
714711
let absolute = std::fs::canonicalize(&local_path).map_err(|err| {
715712
mutation_error(format!(
716713
"resolve local distributed mutation target '{}': {err}",
@@ -2297,6 +2294,40 @@ mod tests {
22972294
const QUERY_ID: &str = "query";
22982295
const SCHEMA_FINGERPRINT: &str = "00000000000000000000000000000000";
22992296

2297+
#[test]
2298+
fn local_mutation_worker_paths_use_the_tracked_object_store() {
2299+
let path = std::env::temp_dir().join(format!(
2300+
"lance-mutation-{} space 更新 %20",
2301+
rand::random::<u64>()
2302+
));
2303+
std::fs::create_dir(&path).unwrap();
2304+
let absolute = std::fs::canonicalize(&path).unwrap();
2305+
let file_uri = Url::from_file_path(&absolute).unwrap().to_string();
2306+
let expected = file_uri.replacen("file:", "file-object-store:", 1);
2307+
2308+
// On Windows the raw path includes a drive letter, which Url::parse
2309+
// treats as a scheme. File URIs also need OS-specific percent decoding.
2310+
for target in [
2311+
path.to_str().unwrap().to_string(),
2312+
path.to_str().unwrap().replace('\\', "/"),
2313+
file_uri.clone(),
2314+
file_uri.replacen("file:", "file+uring:", 1),
2315+
] {
2316+
assert_eq!(mutation_worker_uri(&target).unwrap(), expected, "{target}");
2317+
}
2318+
std::fs::remove_dir(&path).unwrap();
2319+
}
2320+
2321+
#[test]
2322+
fn remote_mutation_worker_uris_are_preserved() {
2323+
for uri in [
2324+
"s3://bucket/mutation%20target.lance",
2325+
"memory://mutation-test",
2326+
] {
2327+
assert_eq!(mutation_worker_uri(uri).unwrap(), uri);
2328+
}
2329+
}
2330+
23002331
fn dataset() -> Dataset {
23012332
let schema = Arc::new(Schema::new(vec![Field::new(
23022333
"value",

‎scripts/verify_vane_platform.py‎

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,63 @@ def main():
4444
"extension signature and identity checks must remain enabled"
4545
)
4646
vane.load_installed_extension("lance", connection=connection)
47-
root = args.directory.resolve().as_posix().replace("'", "''")
47+
namespace = args.directory / "mutation path 更新"
48+
namespace.mkdir()
49+
root = namespace.resolve().as_posix().replace("'", "''")
4850
connection.execute(f"ATTACH '{root}' AS lance_platform (TYPE LANCE)")
49-
connection.sql("SELECT i::BIGINT AS id FROM range(8) AS source(i)").create(
50-
"lance_platform.main.records"
51-
)
52-
connection.sql("SELECT 8::BIGINT AS id").insert_into(
53-
"lance_platform.main.records"
54-
)
51+
connection.sql(
52+
"SELECT i::BIGINT AS id, 'original'::VARCHAR AS value "
53+
"FROM range(8) AS source(i)"
54+
).create("lance_platform.main.records")
55+
connection.sql(
56+
"SELECT 8::BIGINT AS id, 'original'::VARCHAR AS value"
57+
).insert_into("lance_platform.main.records")
5558
rows = connection.execute(
5659
"SELECT count(*), sum(id)::BIGINT FROM lance_platform.main.records"
5760
).fetchall()
5861
if rows != [(9, 36)]:
5962
raise RuntimeError(
6063
f"incorrect {args.runner} Lance read/write result: {rows}"
6164
)
65+
connection.table("lance_platform.main.records").update(
66+
{"value": vane.lit("updated")}, condition=vane.col("id") < 3
67+
)
68+
rows = connection.execute(
69+
"SELECT id, value FROM lance_platform.main.records ORDER BY id"
70+
).fetchall()
71+
if rows != [(i, "updated" if i < 3 else "original") for i in range(9)]:
72+
raise RuntimeError(f"incorrect {args.runner} Lance UPDATE result: {rows}")
73+
74+
# The append is a whole fragment; id=1 also exercises a deletion file.
75+
connection.table("lance_platform.main.records").delete(
76+
condition=vane.col("id") == 8
77+
)
78+
connection.table("lance_platform.main.records").delete(
79+
condition=vane.col("id") == 1
80+
)
81+
rows = connection.execute(
82+
"SELECT id, value FROM lance_platform.main.records ORDER BY id"
83+
).fetchall()
84+
if rows != [
85+
(i, "updated" if i < 3 else "original") for i in range(8) if i != 1
86+
]:
87+
raise RuntimeError(f"incorrect {args.runner} Lance DELETE result: {rows}")
88+
89+
connection.table("lance_platform.main.records").update(
90+
{"value": vane.lit("all-updated")}
91+
)
92+
rows = connection.execute(
93+
"SELECT id, value FROM lance_platform.main.records ORDER BY id"
94+
).fetchall()
95+
if rows != [(i, "all-updated") for i in range(8) if i != 1]:
96+
raise RuntimeError(
97+
f"incorrect {args.runner} Lance full UPDATE result: {rows}"
98+
)
99+
connection.table("lance_platform.main.records").delete()
100+
if connection.execute(
101+
"SELECT count(*) FROM lance_platform.main.records"
102+
).fetchone() != (0,):
103+
raise RuntimeError(f"incorrect {args.runner} Lance full DELETE result")
62104
finally:
63105
connection.close()
64106
vane.teardown_runner()

‎src/lance_distributed_write.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,6 +2693,10 @@ LanceDistributedWriteCombine(ExecutionContext &context,
26932693
global.transport.set_expr_irs[index].data()));
26942694
set_expr_lengths.push_back(global.transport.set_expr_irs[index].size());
26952695
}
2696+
// Resolving the redaction policy calls Rust path normalization, which
2697+
// clears the thread-local error on success. Do it before the mutation.
2698+
const auto redact_error = LanceVanePathRequiresRedaction(
2699+
context.client, global.transport.dataset_uri);
26962700
auto *encoded = lance_distributed_create_mutation_transaction(
26972701
global.open_path.c_str(), key_ptrs.empty() ? nullptr : key_ptrs.data(),
26982702
value_ptrs.empty() ? nullptr : value_ptrs.data(),
@@ -2716,10 +2720,8 @@ LanceDistributedWriteCombine(ExecutionContext &context,
27162720
if (!encoded) {
27172721
throw IOException(
27182722
"Failed to create distributed Lance worker mutation transaction" +
2719-
LanceVaneFormatErrorSuffix(
2720-
global.transport.dataset_uri,
2721-
LanceVanePathRequiresRedaction(context.client,
2722-
global.transport.dataset_uri)));
2723+
LanceVaneFormatErrorSuffix(global.transport.dataset_uri,
2724+
redact_error));
27232725
}
27242726
LanceUncommittedMutationTransactionGuard transaction_guard(
27252727
encoded, global.transport, global.open_path, global.option_keys,

0 commit comments

Comments
 (0)