diff --git a/dozer-cache/src/cache/lmdb/indexing.rs b/dozer-cache/src/cache/lmdb/indexing.rs index ee49fae7e3..efce5fad10 100644 --- a/dozer-cache/src/cache/lmdb/indexing.rs +++ b/dozer-cache/src/cache/lmdb/indexing.rs @@ -5,11 +5,7 @@ use std::sync::{ use dozer_storage::LmdbEnvironment; use dozer_tracing::Labels; -use dozer_types::{ - log::{debug, error}, - parking_lot::Mutex, - types::IndexDefinition, -}; +use dozer_types::{log::debug, parking_lot::Mutex, types::IndexDefinition}; use metrics::describe_counter; use crate::{cache::lmdb::cache::SecondaryEnvironment, errors::CacheError}; @@ -221,11 +217,13 @@ fn index_and_log_error( Err(e) => { debug!("Error while indexing {}: {e}", main_env.labels()); if e.is_map_full() { - error!( + panic!( "Cache {} has reached its maximum size. Try to increase `cache_max_map_size` in the config.", main_env.labels() ); - break; + } + if e.is_key_size() { + panic!("Secondary index key is too long. This usually happens with `String` fields. Try to [skip](https://getdozer.io/docs/configuration/api-endpoints#indexes) creating secondary index {:?}.", secondary_env.index_definition()); } } } diff --git a/dozer-cache/src/errors.rs b/dozer-cache/src/errors.rs index b02234eaaf..de31bdf9af 100644 --- a/dozer-cache/src/errors.rs +++ b/dozer-cache/src/errors.rs @@ -93,6 +93,13 @@ impl CacheError { CacheError::Storage(StorageError::Lmdb(dozer_storage::lmdb::Error::MapFull)) ) } + + pub fn is_key_size(&self) -> bool { + matches!( + self, + CacheError::Storage(StorageError::Lmdb(dozer_storage::lmdb::Error::BadValSize)) + ) + } } #[derive(Error, Debug)]