Introduce a maximum size for values and warn for them

This commit is contained in:
Arpad Müller
2024-02-06 01:04:52 +01:00
parent 09519c1773
commit 8072dcf5e2
2 changed files with 13 additions and 1 deletions

View File

@@ -33,6 +33,9 @@ impl Value {
}
}
/// The maximum size of a value supported by the pageserver
pub const MAX_VALUE_SIZE: usize = 10_000_000;
#[cfg(test)]
mod test {
use super::*;

View File

@@ -6,7 +6,7 @@
//!
use crate::config::PageServerConf;
use crate::context::{PageContentKind, RequestContext, RequestContextBuilder};
use crate::repository::{Key, Value};
use crate::repository::{Key, Value, MAX_VALUE_SIZE};
use crate::tenant::block_io::BlockReader;
use crate::tenant::ephemeral_file::EphemeralFile;
use crate::tenant::storage_layer::{ValueReconstructResult, ValueReconstructState};
@@ -284,6 +284,15 @@ impl InMemoryLayer {
) -> Result<()> {
trace!("put_value key {} at {}/{}", key, self.timeline_id, lsn);
if let Value::Image(buf) = val {
if buf.len() > MAX_VALUE_SIZE {
tracing::warn!(
"Can't put value of size {} above limit {MAX_VALUE_SIZE} for key {key}",
buf.len()
);
}
}
let off = {
// Avoid doing allocations for "small" values.
// In the regression test suite, the limit of 256 avoided allocations in 95% of cases: