mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 17:32:56 +00:00
Introduce a maximum size for values and warn for them
This commit is contained in:
@@ -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::*;
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user