-
Notifications
You must be signed in to change notification settings - Fork 0
Stability & Testing Refinement #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
9860aea
3e8ac2a
62cd6a2
8255d84
b3cc142
5ef2128
349af8e
d69635c
f409e85
5bfe0ae
c6b8eb2
b474388
4f35ce6
355e4ea
878d551
bd6f8df
88872b4
821ffa6
e2388b2
2991320
a1f186a
51b82e4
a5b64a8
17447c9
5f5eb18
b09bdce
a77dc20
5cd90ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <iostream> | ||
| #include <memory> | ||
| #include <mutex> | ||
| #include <string> | ||
|
|
@@ -28,7 +29,19 @@ BufferPoolManager::BufferPoolManager(size_t pool_size, StorageManager& storage_m | |
| } | ||
| } | ||
|
|
||
| BufferPoolManager::~BufferPoolManager() = default; | ||
| BufferPoolManager::~BufferPoolManager() { | ||
| try { | ||
| flush_all_pages(); | ||
| } catch (const std::exception& e) { | ||
| // Log error to stderr; avoid throwing from destructor to prevent std::terminate | ||
| std::cerr << "[Error] Exception in BufferPoolManager destructor during flush_all_pages: " | ||
| << e.what() << std::endl; | ||
| } catch (...) { | ||
| std::cerr | ||
| << "[Error] Unknown exception in BufferPoolManager destructor during flush_all_pages" | ||
| << std::endl; | ||
| } | ||
| } | ||
|
|
||
| Page* BufferPoolManager::fetch_page(const std::string& file_name, uint32_t page_id) { | ||
| const std::scoped_lock<std::mutex> lock(latch_); | ||
|
|
@@ -62,7 +75,11 @@ Page* BufferPoolManager::fetch_page(const std::string& file_name, uint32_t page_ | |
| page->file_name_ = file_name; | ||
| page->pin_count_ = 1; | ||
| page->is_dirty_ = false; | ||
| storage_manager_.read_page(file_name, page_id, page->get_data()); | ||
|
|
||
| if (!storage_manager_.read_page(file_name, page_id, page->get_data())) { | ||
| // If read fails (e.g. file too short), initialize with zeros | ||
| std::memset(page->get_data(), 0, Page::PAGE_SIZE); | ||
| } | ||
|
Comment on lines
+78
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check how storage_manager_.read_page handles EOF vs actual errors
ast-grep --pattern 'bool read_page($_, $_, $_) {
$$$
}'Repository: poyrazK/cloudSQL Length of output: 42 🏁 Script executed: # Find the storage manager files
find . -type f -name "*storage*manager*" | head -20Repository: poyrazK/cloudSQL Length of output: 131 🏁 Script executed: # Look at the file in question to understand the context
head -n 100 src/storage/buffer_pool_manager.cpp | tail -n 30Repository: poyrazK/cloudSQL Length of output: 993 🏁 Script executed: # Search for read_page implementations in storage layer
rg "bool read_page" --type cpp -A 5Repository: poyrazK/cloudSQL Length of output: 1239 🏁 Script executed: # Check the read_page implementation in storage_manager.cpp
cat -n src/storage/storage_manager.cpp | head -150Repository: poyrazK/cloudSQL Length of output: 5020 🏁 Script executed: # Find where HeapTable::read_page and BTreeIndex::read_page are implemented
rg "HeapTable::read_page|BTreeIndex::read_page" --type cpp -B 2 -A 10Repository: poyrazK/cloudSQL Length of output: 1513 🏁 Script executed: # Get the fetch_page function signature and what it returns
rg "fetch_page" include/storage/buffer_pool_manager.hpp -A 3Repository: poyrazK/cloudSQL Length of output: 174 Callers cannot detect I/O failures—both EOF and actual read errors result in zero-filled pages returned as success.
Since This is appropriate for new pages beyond file EOF, but actual I/O errors (disk failures, corruption) are silently masked, potentially causing silent data corruption. The storage layer should propagate read failures so callers can handle them appropriately, or the buffer pool should use an out-parameter or status code to signal failures separately from the page pointer. 🤖 Prompt for AI Agents |
||
|
|
||
| replacer_.pin(frame_id); | ||
| return page; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.