Skip to content

Commit

Permalink
fix: Don't retry indexing if key size is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
chubei committed Dec 5, 2023
1 parent a3c1649 commit 960bb3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 5 additions & 7 deletions dozer-cache/src/cache/lmdb/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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());
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions dozer-cache/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 960bb3d

Please sign in to comment.