From b2ab8116963f9b1e0cc00e94f57bd1b8bb931a6c Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 00:00:53 +0800 Subject: [PATCH 1/9] feat: Add log_io_latch_ & Change bool type to std::atomic for better concurrency support --- src/include/storage/disk/disk_manager.h | 19 ++++++++++++++----- src/storage/disk/disk_manager.cpp | 13 ++++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index 04e0ee6d6..ba6f74f95 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -37,7 +37,12 @@ class DiskManager { /** FOR TEST / LEADERBOARD ONLY, used by DiskManagerMemory */ DiskManager() = default; - virtual ~DiskManager() = default; + virtual ~DiskManager() { + // If ShutDown() is not manually called, shut it down when DiskManager goes out of scope + if (!has_shut_down_.load()) { + ShutDown(); + } + } /** * Shut down the disk manager and close all the file resources. @@ -94,18 +99,22 @@ class DiskManager { protected: auto GetFileSize(const std::string &file_name) -> int; - // stream to write log file + /** Stream to write log file */ std::fstream log_io_; std::string log_name_; - // stream to write db file + /** Stream to write db file */ std::fstream db_io_; std::string file_name_; int num_flushes_{0}; int num_writes_{0}; - bool flush_log_{false}; + std::atomic flush_log_{false}; + /** Used for Destructor */ + std::atomic has_shut_down_{false}; std::future *flush_log_f_{nullptr}; - // With multiple buffer pool instances, need to protect file access + /** With multiple buffer pool instances, need to protect file access */ std::mutex db_io_latch_; + /** Same as above, the log access also needs to be protected, since std::fstream is NOT thread-safe */ + std::mutex log_io_latch_; }; } // namespace bustub diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index 8faaa1ad4..48b12adc8 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -67,11 +67,15 @@ DiskManager::DiskManager(const std::string &db_file) : file_name_(db_file) { * Close all file streams */ void DiskManager::ShutDown() { + has_shut_down_ = true; { std::scoped_lock scoped_db_io_latch(db_io_latch_); + std::scoped_lock scoped_log_io_latch(log_io_latch_); db_io_.close(); + log_io_.close(); } - log_io_.close(); + // Not for production code, only to check the state under DEBUG mode + assert(!db_io_.is_open() && !log_io_.is_open()); } /** @@ -127,7 +131,8 @@ void DiskManager::ReadPage(page_id_t page_id, char *page_data) { * Only return when sync is done, and only perform sequence write */ void DiskManager::WriteLog(char *log_data, int size) { - // enforce swap log buffer + std::scoped_lock scoped_log_io_latch(log_io_latch_); + // Enforce swap log buffer assert(log_data != buffer_used); buffer_used = log_data; @@ -162,6 +167,8 @@ void DiskManager::WriteLog(char *log_data, int size) { * @return: false means already reach the end */ auto DiskManager::ReadLog(char *log_data, int size, int offset) -> bool { + std::scoped_lock scoped_log_io_latch(log_io_latch_); + // Perform sanity check here if (offset >= GetFileSize(log_name_)) { // LOG_DEBUG("end of log file"); // LOG_DEBUG("file size is %d", GetFileSize(log_name_)); @@ -197,7 +204,7 @@ auto DiskManager::GetNumWrites() const -> int { return num_writes_; } /** * Returns true if the log is currently being flushed */ -auto DiskManager::GetFlushState() const -> bool { return flush_log_; } +auto DiskManager::GetFlushState() const -> bool { return flush_log_.load(); } /** * Private helper function to get disk file size From 8de3745f9888e018545155affc582278a1ae2288 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 00:24:13 +0800 Subject: [PATCH 2/9] feat: Overall format improvement --- src/include/storage/disk/disk_manager.h | 26 +++++++++++++++++++------ src/storage/disk/disk_manager.cpp | 26 +++++++------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index ba6f74f95..6d2ef8648 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -79,14 +79,23 @@ class DiskManager { */ auto ReadLog(char *log_data, int size, int offset) -> bool; - /** @return the number of disk flushes */ - auto GetNumFlushes() const -> int; + /** + * @brief Returns number of flushes made so far + * @return The number of disk flushes + */ + auto GetNumFlushes() const -> int { return num_flushes_; }; - /** @return true iff the in-memory content has not been flushed yet */ - auto GetFlushState() const -> bool; + /** + * @brief Returns true if the log is currently being flushed + * @return true iff the in-memory content has not been flushed yet + */ + auto GetFlushState() const -> bool { return flush_log_.load(); }; - /** @return the number of disk writes */ - auto GetNumWrites() const -> int; + /** + * @brief Returns number of Writes made so far + * @return The number of disk writes + */ + auto GetNumWrites() const -> int { return num_writes_; }; /** * Sets the future which is used to check for non-blocking flushes. @@ -99,20 +108,25 @@ class DiskManager { protected: auto GetFileSize(const std::string &file_name) -> int; + /** Stream to write log file */ std::fstream log_io_; std::string log_name_; + /** Stream to write db file */ std::fstream db_io_; std::string file_name_; + int num_flushes_{0}; int num_writes_{0}; std::atomic flush_log_{false}; /** Used for Destructor */ std::atomic has_shut_down_{false}; std::future *flush_log_f_{nullptr}; + /** With multiple buffer pool instances, need to protect file access */ std::mutex db_io_latch_; + /** Same as above, the log access also needs to be protected, since std::fstream is NOT thread-safe */ std::mutex log_io_latch_; }; diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index 48b12adc8..8a693e24f 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -140,15 +140,18 @@ void DiskManager::WriteLog(char *log_data, int size) { return; } - flush_log_ = true; - - if (flush_log_f_ != nullptr) { + if (HasFlushLogFuture()) { // used for checking non-blocking flushing assert(flush_log_f_->wait_for(std::chrono::seconds(10)) == std::future_status::ready); } + // The older log has been flushed, it's time to write new log + flush_log_ = true; + + // Increase the num of flush by one num_flushes_ += 1; - // sequence write + + // Sequence write log_io_.write(log_data, size); // check for I/O error @@ -191,21 +194,6 @@ auto DiskManager::ReadLog(char *log_data, int size, int offset) -> bool { return true; } -/** - * Returns number of flushes made so far - */ -auto DiskManager::GetNumFlushes() const -> int { return num_flushes_; } - -/** - * Returns number of Writes made so far - */ -auto DiskManager::GetNumWrites() const -> int { return num_writes_; } - -/** - * Returns true if the log is currently being flushed - */ -auto DiskManager::GetFlushState() const -> bool { return flush_log_.load(); } - /** * Private helper function to get disk file size */ From daad0633ad061c0f096ad814adcaf2055648a414 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 00:27:54 +0800 Subject: [PATCH 3/9] feat: Change flush_log_f_ to be wrapped in a std::unique_ptr to prevent potential memory problems --- src/include/storage/disk/disk_manager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index 6d2ef8648..3c8064b8f 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -101,10 +101,10 @@ class DiskManager { * Sets the future which is used to check for non-blocking flushes. * @param f the non-blocking flush check */ - inline void SetFlushLogFuture(std::future *f) { flush_log_f_ = f; } + inline void SetFlushLogFuture(std::unique_ptr> f) { flush_log_f_ = std::move(f); } /** Checks if the non-blocking flush future was set. */ - inline auto HasFlushLogFuture() -> bool { return flush_log_f_ != nullptr; } + inline auto HasFlushLogFuture() -> bool { return flush_log_f_ != nullptr && flush_log_f_->valid(); } protected: auto GetFileSize(const std::string &file_name) -> int; @@ -122,7 +122,7 @@ class DiskManager { std::atomic flush_log_{false}; /** Used for Destructor */ std::atomic has_shut_down_{false}; - std::future *flush_log_f_{nullptr}; + std::unique_ptr> flush_log_f_{nullptr}; /** With multiple buffer pool instances, need to protect file access */ std::mutex db_io_latch_; From e5a6433be49958f8a82d69e580b0c347b517ea97 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 01:18:12 +0800 Subject: [PATCH 4/9] feat: WriteLog() now support asynchronous flushing --- src/include/storage/disk/disk_manager.h | 2 +- src/storage/disk/disk_manager.cpp | 35 ++++++++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index 3c8064b8f..e7240aa32 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -87,7 +87,7 @@ class DiskManager { /** * @brief Returns true if the log is currently being flushed - * @return true iff the in-memory content has not been flushed yet + * @return True iff the in-memory content has currently been flushed */ auto GetFlushState() const -> bool { return flush_log_.load(); }; diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index 8a693e24f..d21fec14d 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include #include // NOLINT #include #include // NOLINT @@ -65,9 +67,11 @@ DiskManager::DiskManager(const std::string &db_file) : file_name_(db_file) { /** * Close all file streams + * Note: ShutDown should now be aware of none-terminated future flush */ void DiskManager::ShutDown() { has_shut_down_ = true; + // Close the fstream, to prevent memory leak { std::scoped_lock scoped_db_io_latch(db_io_latch_); std::scoped_lock scoped_log_io_latch(log_io_latch_); @@ -76,6 +80,12 @@ void DiskManager::ShutDown() { } // Not for production code, only to check the state under DEBUG mode assert(!db_io_.is_open() && !log_io_.is_open()); + + // Wait for the ever existing flushing operation to finish + if (HasFlushLogFuture()) { + // Same problem as in DiskManager::WriteLog(), may crash the program + assert(flush_log_f_->wait_for(std::chrono::seconds(10)) == std::future_status::ready); + } } /** @@ -129,6 +139,7 @@ void DiskManager::ReadPage(page_id_t page_id, char *page_data) { /** * Write the contents of the log into disk file * Only return when sync is done, and only perform sequence write + * Note: The flush operation will be executed asynchronously */ void DiskManager::WriteLog(char *log_data, int size) { std::scoped_lock scoped_log_io_latch(log_io_latch_); @@ -141,26 +152,35 @@ void DiskManager::WriteLog(char *log_data, int size) { } if (HasFlushLogFuture()) { - // used for checking non-blocking flushing + // Used for checking non-blocking flushing, the default (and expected) time for a logging thread is 10s + // TODO(Zihao): Now the program will crash if the flush is still persisting after 10s, + // Should it be handled more softly (e.g, Print a warning and terminate just that thread by resetting the ptr?) assert(flush_log_f_->wait_for(std::chrono::seconds(10)) == std::future_status::ready); + // No need to do anything, since std::unique_ptr will be reset and the previous resource will be released automatically } - // The older log has been flushed, it's time to write new log + // The older log has been flushed, set the flush_log_ to true flush_log_ = true; // Increase the num of flush by one num_flushes_ += 1; - // Sequence write + // Write the log log_io_.write(log_data, size); - // check for I/O error + // Check for I/O error if (log_io_.bad()) { LOG_DEBUG("I/O error while writing log"); return; } - // needs to flush to keep disk file in sync - log_io_.flush(); + + // The flushing here is done asynchronously + flush_log_f_ = std::make_unique>(std::async(std::launch::async, [&] { + // Needs to flush to keep disk file in sync + log_io_.flush(); + })); + + // Set the flush_log_ back to false, since the execution time of this thread is not sure flush_log_ = false; } @@ -171,12 +191,14 @@ void DiskManager::WriteLog(char *log_data, int size) { */ auto DiskManager::ReadLog(char *log_data, int size, int offset) -> bool { std::scoped_lock scoped_log_io_latch(log_io_latch_); + // Perform sanity check here if (offset >= GetFileSize(log_name_)) { // LOG_DEBUG("end of log file"); // LOG_DEBUG("file size is %d", GetFileSize(log_name_)); return false; } + log_io_.seekp(offset); log_io_.read(log_data, size); @@ -184,6 +206,7 @@ auto DiskManager::ReadLog(char *log_data, int size, int offset) -> bool { LOG_DEBUG("I/O error while reading log"); return false; } + // if log file ends before reading "size" int read_count = log_io_.gcount(); if (read_count < size) { From 4353a7481f773d8a0b9ca3615e0253099d96e7a1 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 01:31:07 +0800 Subject: [PATCH 5/9] fix: Ensure format consistency --- src/storage/disk/disk_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index d21fec14d..a6c725bb1 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -156,7 +156,8 @@ void DiskManager::WriteLog(char *log_data, int size) { // TODO(Zihao): Now the program will crash if the flush is still persisting after 10s, // Should it be handled more softly (e.g, Print a warning and terminate just that thread by resetting the ptr?) assert(flush_log_f_->wait_for(std::chrono::seconds(10)) == std::future_status::ready); - // No need to do anything, since std::unique_ptr will be reset and the previous resource will be released automatically + // No need to do anything, since std::unique_ptr will be reset and the previous resource will be released + // automatically } // The older log has been flushed, set the flush_log_ to true From cdbf804600474acfa4f4b6241120efb601727638 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 15:30:00 +0800 Subject: [PATCH 6/9] fix: Ensure format consistency --- src/include/storage/disk/disk_manager.h | 4 +++- src/storage/disk/disk_manager.cpp | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index e7240aa32..368b19b44 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -15,8 +15,10 @@ #include #include #include // NOLINT -#include // NOLINT +#include +#include // NOLINT #include +#include #include "common/config.h" diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index a6c725bb1..381833ddd 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -13,11 +13,7 @@ #include #include #include -#include #include -#include -#include // NOLINT -#include #include // NOLINT #include "common/exception.h" From a3ccb5aad13bfa14d87f0edc08e75b7a770fe66c Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 19:32:54 +0800 Subject: [PATCH 7/9] feat: Redesign the log related functions, add WriteLogAsync() --- src/include/storage/disk/disk_manager.h | 48 +++++++++++--- src/storage/disk/disk_manager.cpp | 85 +++++++++++++++++++------ 2 files changed, 107 insertions(+), 26 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index 368b19b44..0596bf2ec 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -72,6 +72,13 @@ class DiskManager { */ void WriteLog(char *log_data, int size); + /** + * The non-blocking, asynchronous version of WriteLog() + * @param log_data + * @param size + */ + void WriteLogAsync(char *log_data, int size); + /** * Read a log entry from the log file. * @param[out] log_data output buffer @@ -85,7 +92,7 @@ class DiskManager { * @brief Returns number of flushes made so far * @return The number of disk flushes */ - auto GetNumFlushes() const -> int { return num_flushes_; }; + auto GetNumFlushes() const -> int { return num_flushes_.load(); }; /** * @brief Returns true if the log is currently being flushed @@ -100,13 +107,35 @@ class DiskManager { auto GetNumWrites() const -> int { return num_writes_; }; /** - * Sets the future which is used to check for non-blocking flushes. - * @param f the non-blocking flush check + * Sets the future which is used to check for non-blocking writes. + * @param f the non-blocking write check */ - inline void SetFlushLogFuture(std::unique_ptr> f) { flush_log_f_ = std::move(f); } + inline void PushWriteLogFuture(std::unique_ptr> f) { + std::scoped_lock write_log_f_deque_latch(write_log_f_deque_latch_); + write_log_f_deque_.push_back(std::move(f)); + } - /** Checks if the non-blocking flush future was set. */ - inline auto HasFlushLogFuture() -> bool { return flush_log_f_ != nullptr && flush_log_f_->valid(); } + inline void PopWriteLogFuture() { + std::scoped_lock write_log_f_deque_latch(write_log_f_deque_latch_); + write_log_f_deque_.pop_front(); + } + + /** Checks if the non-blocking write future exists. */ + inline auto HasWriteLogFuture() -> bool { + std::scoped_lock lock(write_log_f_deque_latch_); + return !write_log_f_deque_.empty(); + } + + inline void WaitForAsyncToComplete() { + std::scoped_lock lock(write_log_f_deque_latch_); + while (!write_log_f_deque_.empty()) { + if (write_log_f_deque_.front()->valid()) { + // Be consistent with previous solution + assert(write_log_f_deque_.front()->wait_for(std::chrono::seconds(10)) == std::future_status::ready); + } + write_log_f_deque_.pop_front(); + } + } protected: auto GetFileSize(const std::string &file_name) -> int; @@ -119,12 +148,15 @@ class DiskManager { std::fstream db_io_; std::string file_name_; - int num_flushes_{0}; + std::atomic num_flushes_{0}; int num_writes_{0}; std::atomic flush_log_{false}; /** Used for Destructor */ std::atomic has_shut_down_{false}; - std::unique_ptr> flush_log_f_{nullptr}; + + /** For asynchronous functions */ + std::deque>> write_log_f_deque_; + std::mutex write_log_f_deque_latch_; /** With multiple buffer pool instances, need to protect file access */ std::mutex db_io_latch_; diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index 381833ddd..b2cef63ae 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -78,10 +78,12 @@ void DiskManager::ShutDown() { assert(!db_io_.is_open() && !log_io_.is_open()); // Wait for the ever existing flushing operation to finish - if (HasFlushLogFuture()) { + if (HasWriteLogFuture()) { // Same problem as in DiskManager::WriteLog(), may crash the program - assert(flush_log_f_->wait_for(std::chrono::seconds(10)) == std::future_status::ready); + WaitForAsyncToComplete(); } + // Sanity Check + assert(!HasWriteLogFuture()); } /** @@ -135,7 +137,7 @@ void DiskManager::ReadPage(page_id_t page_id, char *page_data) { /** * Write the contents of the log into disk file * Only return when sync is done, and only perform sequence write - * Note: The flush operation will be executed asynchronously + * Note: This version of WriteLog() will block until all asynchronous tasks are finished */ void DiskManager::WriteLog(char *log_data, int size) { std::scoped_lock scoped_log_io_latch(log_io_latch_); @@ -143,25 +145,17 @@ void DiskManager::WriteLog(char *log_data, int size) { assert(log_data != buffer_used); buffer_used = log_data; - if (size == 0) { // no effect on num_flushes_ if log buffer is empty + if (size == 0) { // no effect on num_flushes_ if log buffer is empty return; } - if (HasFlushLogFuture()) { + if (HasWriteLogFuture()) { // Used for checking non-blocking flushing, the default (and expected) time for a logging thread is 10s // TODO(Zihao): Now the program will crash if the flush is still persisting after 10s, // Should it be handled more softly (e.g, Print a warning and terminate just that thread by resetting the ptr?) - assert(flush_log_f_->wait_for(std::chrono::seconds(10)) == std::future_status::ready); - // No need to do anything, since std::unique_ptr will be reset and the previous resource will be released - // automatically + WaitForAsyncToComplete(); } - // The older log has been flushed, set the flush_log_ to true - flush_log_ = true; - - // Increase the num of flush by one - num_flushes_ += 1; - // Write the log log_io_.write(log_data, size); @@ -171,24 +165,79 @@ void DiskManager::WriteLog(char *log_data, int size) { return; } - // The flushing here is done asynchronously - flush_log_f_ = std::make_unique>(std::async(std::launch::async, [&] { - // Needs to flush to keep disk file in sync + // Flush the log + log_io_.flush(); + + // Update flush status + flush_log_ = true; + + // Increase number of flushing by one + num_flushes_ += 1; +} + +/** + * @brief A non-blocking, asynchronous version of WriteLog + * + * @param log_data + * @param size + */ +void DiskManager::WriteLogAsync(char *log_data, int size) { + auto curr_write_f = std::make_unique>(std::async(std::launch::async, [&] { + // First acquire the lock, the underlying threads will sequentially acquire the log_io_latch_ + std::scoped_lock scoped_log_io_latch(log_io_latch_); + + // Ensure swap log buffer + if (log_data != buffer_used) { + // Directly return + // TODO(Zihao): Warning the user? + return; + } + // Otherwise set the buffer_used to the incoming new log_data + buffer_used = log_data; + + // No effect on num_flushes_ if log buffer is empty + if (size == 0) { + return; + } + + // Write the log + log_io_.write(log_data, size); + + // Check for I/O error + if (log_io_.bad()) { + // Directly return, may be changed in the future + return; + } + + // Flush the log to disk log_io_.flush(); + // The current flushing is done + flush_log_ = true; + // Increase the num of flush by one + num_flushes_ += 1; })); - // Set the flush_log_ back to false, since the execution time of this thread is not sure + // Set flush status to false, since the execution of this task is unknown flush_log_ = false; + + // Push the new future handle in to the deque + PushWriteLogFuture(std::move(curr_write_f)); } /** * Read the contents of the log into the given memory area * Always read from the beginning and perform sequence read * @return: false means already reach the end + * Note: This function will read the log AFTER all write operations (including asynchronous) are finished */ auto DiskManager::ReadLog(char *log_data, int size, int offset) -> bool { std::scoped_lock scoped_log_io_latch(log_io_latch_); + // Wait for potential async write operations + if (HasWriteLogFuture()) { + WaitForAsyncToComplete(); + } + // Perform sanity check here if (offset >= GetFileSize(log_name_)) { // LOG_DEBUG("end of log file"); From 81ff2a4211d18626eee2e2cef06b3a2b20fd0995 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 19:33:56 +0800 Subject: [PATCH 8/9] fix: Ensure format consistency --- src/include/storage/disk/disk_manager.h | 5 +++-- src/storage/disk/disk_manager.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index 0596bf2ec..403480b3d 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include #include // NOLINT #include @@ -74,8 +75,8 @@ class DiskManager { /** * The non-blocking, asynchronous version of WriteLog() - * @param log_data - * @param size + * @param log_data + * @param size */ void WriteLogAsync(char *log_data, int size); diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index b2cef63ae..cdab03238 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -145,7 +145,7 @@ void DiskManager::WriteLog(char *log_data, int size) { assert(log_data != buffer_used); buffer_used = log_data; - if (size == 0) { // no effect on num_flushes_ if log buffer is empty + if (size == 0) { // no effect on num_flushes_ if log buffer is empty return; } @@ -177,9 +177,9 @@ void DiskManager::WriteLog(char *log_data, int size) { /** * @brief A non-blocking, asynchronous version of WriteLog - * - * @param log_data - * @param size + * + * @param log_data + * @param size */ void DiskManager::WriteLogAsync(char *log_data, int size) { auto curr_write_f = std::make_unique>(std::async(std::launch::async, [&] { From 6db727bb880721635ca4a84581cd52a1f7835cbf Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Thu, 22 Jun 2023 19:38:17 +0800 Subject: [PATCH 9/9] fix: Ensure format consistency --- src/include/storage/disk/disk_manager.h | 1 + src/storage/disk/disk_manager.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/storage/disk/disk_manager.h b/src/include/storage/disk/disk_manager.h index 403480b3d..7711b7b82 100644 --- a/src/include/storage/disk/disk_manager.h +++ b/src/include/storage/disk/disk_manager.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include #include #include // NOLINT diff --git a/src/storage/disk/disk_manager.cpp b/src/storage/disk/disk_manager.cpp index cdab03238..6a6b33789 100644 --- a/src/storage/disk/disk_manager.cpp +++ b/src/storage/disk/disk_manager.cpp @@ -11,7 +11,6 @@ //===----------------------------------------------------------------------===// #include -#include #include #include #include // NOLINT