From 8cd7311d7c13709bec3116784ca8825a1bff608a Mon Sep 17 00:00:00 2001 From: CactiFromDesert Date: Mon, 18 May 2026 13:05:03 +0300 Subject: [PATCH 1/3] fix: correct MAX_PAGE_NUM calculation to account for buffer_pool_id --- deps/3rd/jsoncpp | 2 +- deps/3rd/libevent | 2 +- src/observer/storage/buffer/disk_buffer_pool.h | 3 +-- src/observer/storage/buffer/page.h | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/deps/3rd/jsoncpp b/deps/3rd/jsoncpp index 8190e061b..89e2973c7 160000 --- a/deps/3rd/jsoncpp +++ b/deps/3rd/jsoncpp @@ -1 +1 @@ -Subproject commit 8190e061bc2d95da37479a638aa2c9e483e58ec6 +Subproject commit 89e2973c754a9c02a49974d839779b151e95afd6 diff --git a/deps/3rd/libevent b/deps/3rd/libevent index 5df3037d1..112421c8f 160000 --- a/deps/3rd/libevent +++ b/deps/3rd/libevent @@ -1 +1 @@ -Subproject commit 5df3037d10556bfcb675bc73e516978b75fc7bc7 +Subproject commit 112421c8fa4840acd73502f2ab6a674fc025de37 diff --git a/src/observer/storage/buffer/disk_buffer_pool.h b/src/observer/storage/buffer/disk_buffer_pool.h index d41d1bd0c..3c79888e8 100644 --- a/src/observer/storage/buffer/disk_buffer_pool.h +++ b/src/observer/storage/buffer/disk_buffer_pool.h @@ -72,8 +72,7 @@ struct BPFileHeader * 能够分配的最大的页面个数,即bitmap的字节数 乘以8 */ static const int MAX_PAGE_NUM = - (BP_PAGE_DATA_SIZE - sizeof(buffer_pool_id) - sizeof(page_count) - sizeof(allocated_pages)) * 8; - + (BP_PAGE_DATA_SIZE - sizeof(buffer_pool_id) - sizeof(page_count) - sizeof(allocated_pages)) * 8; string to_string() const; }; diff --git a/src/observer/storage/buffer/page.h b/src/observer/storage/buffer/page.h index cc7b02293..06af4558a 100644 --- a/src/observer/storage/buffer/page.h +++ b/src/observer/storage/buffer/page.h @@ -25,7 +25,6 @@ static constexpr PageNum BP_HEADER_PAGE = 0; static constexpr const int BP_PAGE_SIZE = (1 << 13); static constexpr const int BP_PAGE_DATA_SIZE = (BP_PAGE_SIZE - sizeof(LSN) - sizeof(CheckSum)); - /** * @brief 表示一个页面,可能放在内存或磁盘上 * @ingroup BufferPool From 89dce9690628f0004ec4e81187baecb7cb45dce3 Mon Sep 17 00:00:00 2001 From: CactiFromDesert Date: Mon, 18 May 2026 14:20:26 +0300 Subject: [PATCH 2/3] style: apply clang-format to changed files --- src/observer/storage/buffer/disk_buffer_pool.h | 4 ++-- src/observer/storage/buffer/page.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/observer/storage/buffer/disk_buffer_pool.h b/src/observer/storage/buffer/disk_buffer_pool.h index 3c79888e8..26f1fa523 100644 --- a/src/observer/storage/buffer/disk_buffer_pool.h +++ b/src/observer/storage/buffer/disk_buffer_pool.h @@ -72,7 +72,7 @@ struct BPFileHeader * 能够分配的最大的页面个数,即bitmap的字节数 乘以8 */ static const int MAX_PAGE_NUM = - (BP_PAGE_DATA_SIZE - sizeof(buffer_pool_id) - sizeof(page_count) - sizeof(allocated_pages)) * 8; + (BP_PAGE_DATA_SIZE - sizeof(buffer_pool_id) - sizeof(page_count) - sizeof(allocated_pages)) * 8; string to_string() const; }; @@ -351,5 +351,5 @@ class BufferPoolManager final common::Mutex lock_; unordered_map buffer_pools_; unordered_map id_to_buffer_pools_; - atomic next_buffer_pool_id_{1}; // 系统启动时,会打开所有的表,这样就可以知道当前系统最大的ID是多少了 + atomic next_buffer_pool_id_{1}; // 系统启动时,会打开所有的表,这样就可以知道当前系统最大的ID是多少了 }; diff --git a/src/observer/storage/buffer/page.h b/src/observer/storage/buffer/page.h index 06af4558a..ef06ea12d 100644 --- a/src/observer/storage/buffer/page.h +++ b/src/observer/storage/buffer/page.h @@ -24,8 +24,7 @@ static constexpr PageNum BP_INVALID_PAGE_NUM = -1; static constexpr PageNum BP_HEADER_PAGE = 0; static constexpr const int BP_PAGE_SIZE = (1 << 13); -static constexpr const int BP_PAGE_DATA_SIZE = (BP_PAGE_SIZE - sizeof(LSN) - sizeof(CheckSum)); -/** +static constexpr const int BP_PAGE_DATA_SIZE = (BP_PAGE_SIZE - sizeof(LSN) - sizeof(CheckSum));/** * @brief 表示一个页面,可能放在内存或磁盘上 * @ingroup BufferPool */ From cbd49ad4f37a03cd389fd794cc5ae5263b832a9e Mon Sep 17 00:00:00 2001 From: CactiFromDesert Date: Mon, 18 May 2026 14:54:44 +0300 Subject: [PATCH 3/3] style: apply clang-format formatting --- src/observer/storage/buffer/disk_buffer_pool.h | 3 +-- src/observer/storage/buffer/page.h | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/observer/storage/buffer/disk_buffer_pool.h b/src/observer/storage/buffer/disk_buffer_pool.h index 26f1fa523..070fbd6f1 100644 --- a/src/observer/storage/buffer/disk_buffer_pool.h +++ b/src/observer/storage/buffer/disk_buffer_pool.h @@ -351,5 +351,4 @@ class BufferPoolManager final common::Mutex lock_; unordered_map buffer_pools_; unordered_map id_to_buffer_pools_; - atomic next_buffer_pool_id_{1}; // 系统启动时,会打开所有的表,这样就可以知道当前系统最大的ID是多少了 -}; + atomic next_buffer_pool_id_{1}; // System startup opens all tables to know current max ID}; diff --git a/src/observer/storage/buffer/page.h b/src/observer/storage/buffer/page.h index ef06ea12d..35f463625 100644 --- a/src/observer/storage/buffer/page.h +++ b/src/observer/storage/buffer/page.h @@ -23,11 +23,12 @@ static constexpr PageNum BP_INVALID_PAGE_NUM = -1; static constexpr PageNum BP_HEADER_PAGE = 0; -static constexpr const int BP_PAGE_SIZE = (1 << 13); -static constexpr const int BP_PAGE_DATA_SIZE = (BP_PAGE_SIZE - sizeof(LSN) - sizeof(CheckSum));/** - * @brief 表示一个页面,可能放在内存或磁盘上 - * @ingroup BufferPool - */ +static constexpr const int BP_PAGE_SIZE = (1 << 13); +static constexpr const int BP_PAGE_DATA_SIZE = + (BP_PAGE_SIZE - sizeof(LSN) - sizeof(CheckSum)); /** + * @brief 表示一个页面,可能放在内存或磁盘上 + * @ingroup BufferPool + */ struct Page { LSN lsn;