Improve the error message by categorizing NoSpaceLeftOnDevice

This commit is contained in:
Kerollmops 2025-03-31 16:34:58 +02:00
parent 5607802fe1
commit 72c506d8f6
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F
3 changed files with 15 additions and 7 deletions

View File

@ -411,7 +411,7 @@ impl ErrorCode for milli::Error {
| UserError::DocumentLimitReached
| UserError::UnknownInternalDocumentId { .. } => Code::Internal,
UserError::InvalidStoreFile => Code::InvalidStoreFile,
UserError::NoSpaceLeftOnDevice => Code::NoSpaceLeftOnDevice,
UserError::NoSpaceLeftOnDevice { .. } => Code::NoSpaceLeftOnDevice,
UserError::MaxDatabaseSizeReached => Code::DatabaseSizeLimitReached,
UserError::AttributeLimitReached => Code::MaxFieldsLimitExceeded,
UserError::InvalidFilter(_) => Code::InvalidSearchFilter,

View File

@ -259,8 +259,8 @@ and can not be more than 511 bytes.", .document_id.to_string()
NoPrimaryKeyCandidateFound,
#[error("The primary key inference failed as the engine found {} fields ending with `id` in their names: '{}' and '{}'. Please specify the primary key manually using the `primaryKey` query parameter.", .candidates.len(), .candidates.first().unwrap(), .candidates.get(1).unwrap())]
MultiplePrimaryKeyCandidatesFound { candidates: Vec<String> },
#[error("There is no more space left on the device. Consider increasing the size of the disk/partition.")]
NoSpaceLeftOnDevice,
#[error("There is no more space left on the device ({source_}). Consider increasing the size of the disk/partition.")]
NoSpaceLeftOnDevice { source_: &'static str },
#[error("Index already has a primary key: `{0}`.")]
PrimaryKeyCannotBeChanged(String),
#[error(transparent)]

View File

@ -417,25 +417,33 @@ fn spill_entry_to_sorter(
deladd_buffer.clear();
let mut value_writer = KvWriterDelAdd::new(deladd_buffer);
fn convert_io_to_user_error(error: io::Error) -> crate::Error {
if error.kind() == io::ErrorKind::StorageFull {
crate::Error::UserError(crate::UserError::NoSpaceLeftOnDevice { source_: "grenad" })
} else {
crate::Error::IoError(error)
}
}
match deladd {
DelAddRoaringBitmap { del: Some(del), add: None } => {
cbo_buffer.clear();
CboRoaringBitmapCodec::serialize_into_vec(&del, cbo_buffer);
value_writer.insert(DelAdd::Deletion, &cbo_buffer)?;
value_writer.insert(DelAdd::Deletion, &cbo_buffer).map_err(convert_io_to_user_error)?;
}
DelAddRoaringBitmap { del: None, add: Some(add) } => {
cbo_buffer.clear();
CboRoaringBitmapCodec::serialize_into_vec(&add, cbo_buffer);
value_writer.insert(DelAdd::Addition, &cbo_buffer)?;
value_writer.insert(DelAdd::Addition, &cbo_buffer).map_err(convert_io_to_user_error)?;
}
DelAddRoaringBitmap { del: Some(del), add: Some(add) } => {
cbo_buffer.clear();
CboRoaringBitmapCodec::serialize_into_vec(&del, cbo_buffer);
value_writer.insert(DelAdd::Deletion, &cbo_buffer)?;
value_writer.insert(DelAdd::Deletion, &cbo_buffer).map_err(convert_io_to_user_error)?;
cbo_buffer.clear();
CboRoaringBitmapCodec::serialize_into_vec(&add, cbo_buffer);
value_writer.insert(DelAdd::Addition, &cbo_buffer)?;
value_writer.insert(DelAdd::Addition, &cbo_buffer).map_err(convert_io_to_user_error)?;
}
DelAddRoaringBitmap { del: None, add: None } => return Ok(()),
}