diff --git a/crates/admin/src/migrate_store_v2.rs b/crates/admin/src/migrate_store_v2.rs index 3881676..dd2c00a 100644 --- a/crates/admin/src/migrate_store_v2.rs +++ b/crates/admin/src/migrate_store_v2.rs @@ -469,15 +469,35 @@ impl NewIndexWriterV2 { self.email_buf.dedup_by(|a, b| a.0 == b.0); let count = self.email_buf.len(); + let mut skipped = 0usize; for (key, data) in &self.email_buf { - self.engine.put(*key, data, Codec::Zstd).map_err(|e| { - raise_error!( + if let Err(e) = self.engine.put(*key, data, Codec::Zstd) { + if matches!(e, bichon_blob::Error::ValueTooLarge { .. }) { + eprintln!( + "{}", + console::style(format!( + "WARN: skipping oversized email blob key={} ({} bytes)", + hex::encode(*key), + data.len() + )) + .yellow() + ); + skipped += 1; + continue; + } + return Err(raise_error!( format!("blob engine put error: {e:#?}"), ErrorCode::InternalError - ) - })?; + )); + } + } + println!("flushed {} email blobs to engine", count - skipped); + if skipped > 0 { + eprintln!( + "{}", + console::style(format!("skipped {} oversized email blobs", skipped)).yellow() + ); } - println!("flushed {} email blobs to engine", count); self.email_buf.clear(); } @@ -486,15 +506,35 @@ impl NewIndexWriterV2 { self.attachment_buf.dedup_by(|a, b| a.0 == b.0); let count = self.attachment_buf.len(); + let mut skipped = 0usize; for (key, data) in &self.attachment_buf { - self.engine.put(*key, data, Codec::Zstd).map_err(|e| { - raise_error!( + if let Err(e) = self.engine.put(*key, data, Codec::Zstd) { + if matches!(e, bichon_blob::Error::ValueTooLarge { .. }) { + eprintln!( + "{}", + console::style(format!( + "WARN: skipping oversized attachment blob key={} ({} bytes)", + hex::encode(*key), + data.len() + )) + .yellow() + ); + skipped += 1; + continue; + } + return Err(raise_error!( format!("blob engine put error: {e:#?}"), ErrorCode::InternalError - ) - })?; + )); + } + } + println!("flushed {} attachment blobs to engine", count - skipped); + if skipped > 0 { + eprintln!( + "{}", + console::style(format!("skipped {} oversized attachment blobs", skipped)).yellow() + ); } - println!("flushed {} attachment blobs to engine", count); self.attachment_buf.clear(); } diff --git a/crates/admin/src/migrate_v1.rs b/crates/admin/src/migrate_v1.rs index acc474e..555996b 100644 --- a/crates/admin/src/migrate_v1.rs +++ b/crates/admin/src/migrate_v1.rs @@ -65,12 +65,24 @@ fn migrate_keyspace( continue; } let raw_key = hex_key_to_raw(&key_bytes)?; - engine.put(raw_key, &value, Codec::Zstd).map_err(|e| { - raise_error!( + if let Err(e) = engine.put(raw_key, &value, Codec::Zstd) { + if matches!(e, bichon_blob::Error::ValueTooLarge { .. }) { + eprintln!( + "{}", + console::style(format!( + "WARN: skipping oversized blob key={} ({} bytes)", + hex::encode(raw_key), + value.len() + )) + .yellow() + ); + continue; + } + return Err(raise_error!( format!("bichon-blob put error: {e:#?}"), ErrorCode::InternalError - ) - })?; + )); + } count += 1; if count % 1000 == 0 { pb.set_message(format!("{label}: {} blobs migrated...", count));