From 23d2f81693bca530613dfa45cdef8c15eba92ab9 Mon Sep 17 00:00:00 2001 From: zwang28 <70626450+zwang28@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:34:12 +0800 Subject: [PATCH] chore(storage): issue a warning when key value is too large (#13129) --- src/storage/src/hummock/sstable/builder.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/storage/src/hummock/sstable/builder.rs b/src/storage/src/hummock/sstable/builder.rs index 0cf7c2fd850a7..bb6d190468f8c 100644 --- a/src/storage/src/hummock/sstable/builder.rs +++ b/src/storage/src/hummock/sstable/builder.rs @@ -293,12 +293,22 @@ impl SstableBuilder { const LARGE_KEY_LEN: usize = MAX_KEY_LEN >> 1; let table_key_len = full_key.user_key.table_key.as_ref().len(); - if table_key_len >= LARGE_KEY_LEN { + let table_value_len = match &value { + HummockValue::Put(t) => t.len(), + HummockValue::Delete => 0, + }; + let large_value_len = self.options.max_sst_size as usize / 10; + let large_key_value_len = self.options.max_sst_size as usize / 2; + if table_key_len >= LARGE_KEY_LEN + || table_value_len > large_value_len + || table_key_len + table_value_len > large_key_value_len + { let table_id = full_key.user_key.table_id.table_id(); tracing::warn!( - "A large key (table_id={}, len={}, epoch={}) is added to block", + "A large key/value (table_id={}, key len={}, value len={}, epoch={}) is added to block", table_id, table_key_len, + table_value_len, full_key.epoch ); }