Skip to content

Commit

Permalink
Warn/error if the created file exceeds limits
Browse files Browse the repository at this point in the history
* if the created layer file is above the target size, warn
* if it is also above the S3 upload limit, don't error when
  uploading, but already error when writing the file.
  • Loading branch information
arpad-m committed Aug 7, 2023
1 parent f2ce04a commit b9c755e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pageserver/src/tenant/storage_layer/delta_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,17 @@ impl DeltaLayerWriterInner {
.metadata()
.context("get file metadata to determine size")?;

// 5GB limit for objects without multipart upload (which we don't want to use)
// Make it a little bit below to account for differing GB units
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html
const S3_UPLOAD_LIMIT: u64 = 4_500_000_000;
ensure!(
metadata.len() <= S3_UPLOAD_LIMIT,
"Created delta layer file at {} of size {} above limit {S3_UPLOAD_LIMIT}!",
file.path.display(),
metadata.len()
);

// Note: Because we opened the file in write-only mode, we cannot
// reuse the same VirtualFile for reading later. That's why we don't
// set inner.file here. The first read will have to re-open it.
Expand Down
10 changes: 10 additions & 0 deletions pageserver/src/tenant/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3740,6 +3740,16 @@ impl Timeline {

// Sync layers
if !new_layers.is_empty() {
// Print a warning if the created layer is larger than double the target size
let warn_limit = target_file_size * 2;
for layer in new_layers.iter() {
if layer.desc.file_size > warn_limit {
warn!(
%layer,
"created delta file of size {} larger than double of target of {target_file_size}", layer.desc.file_size
);
}
}
let mut layer_paths: Vec<PathBuf> = new_layers.iter().map(|l| l.path()).collect();

// Fsync all the layer files and directory using multiple threads to
Expand Down

0 comments on commit b9c755e

Please sign in to comment.