From ea7307f69cd3b2c993ad819c2fb21fa468150cb6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 20 Nov 2026 01:23:32 -0800 Subject: [PATCH] lance worker: a removal sets again what the key's add overwrote first Recovery ran only when an add resumed. A key withdrawn after its add stopped went to the remove job, which dropped the column and its restore mark, losing for good the requests and key states the add overwrote. The remove job now recovers the add before it drops the column; the key stays off. a_removal_keeps_what_the_add_overwrote failed before this change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK --- .../crates/lance/src/jobs/metadata_index.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/seaweed-worker/crates/lance/src/jobs/metadata_index.rs b/seaweed-worker/crates/lance/src/jobs/metadata_index.rs index 3cfdaa134b..a1662271c9 100644 --- a/seaweed-worker/crates/lance/src/jobs/metadata_index.rs +++ b/seaweed-worker/crates/lance/src/jobs/metadata_index.rs @@ -165,6 +165,9 @@ pub async fn run( )) } (Action::Remove, Some(column)) if column.state == Some(State::Off) => { + // Dropping the column drops its restore mark: set again first + // what its add overwrote. + metadata_index::recover_add(dataset, &column).await?; metadata_index::remove_column(dataset, &column.column).await?; Ok(format!("{key} removed with {}", column.column)) } @@ -488,6 +491,38 @@ mod tests { assert_eq!(settings(&values), (SEGMENT_ROWS_FLOOR as u64, 0)); } + /// A removal of a key whose add stopped before setting again what it + /// overwrote sets that first: a key requested meanwhile stays requested. + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] + async fn a_removal_keeps_what_the_add_overwrote() { + use crate::metadata_index::tests::lifecycle::table; + let dir = tempfile::TempDir::new().unwrap(); + let mut dataset = table(&dir, 2).await; + metadata_index::request(&mut dataset, "author") + .await + .unwrap(); + let mut adder = dataset.clone(); + metadata_index::request(&mut dataset, "lang").await.unwrap(); + metadata_index::commit_column(&mut adder, "author") + .await + .unwrap(); + metadata_index::request_removal(&mut adder, "author") + .await + .unwrap(); + run( + &mut adder, + "author", + Action::Remove, + 1_000, + 0, + std::time::Duration::ZERO, + ) + .await + .unwrap(); + assert!(metadata_index::keys_of(&adder).is_empty()); + assert_eq!(metadata_index::requests(&adder), ["lang"]); + } + /// What the table asks for is what a job does, and a job the table no /// longer asks for does nothing. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]