Skip to content
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

Make sure we have at least kHeaderSize immutable pages in log #284

Merged
merged 1 commit into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cc/src/core/faster.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class FasterKv {
double log_mutable_fraction = 0.9, bool pre_allocate_log = false)
: min_table_size_{ table_size }
, disk{ filename, epoch_ }
, hlog{ log_size, epoch_, disk, disk.log(), log_mutable_fraction, pre_allocate_log }
, hlog{ filename.empty() /*hasNoBackingStorage*/, log_size, epoch_, disk, disk.log(), log_mutable_fraction, pre_allocate_log }
, system_state_{ Action::None, Phase::REST, 1 }
, num_pending_ios{ 0 } {
if(!Utility::IsPowerOfTwo(table_size)) {
Expand Down
13 changes: 10 additions & 3 deletions cc/src/core/persistent_memory_malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class PersistentMemoryMalloc {
/// The first 4 HLOG pages should be below the head (i.e., being flushed to disk).
static constexpr uint32_t kNumHeadPages = 4;

PersistentMemoryMalloc(uint64_t log_size, LightEpoch& epoch, disk_t& disk_, log_file_t& file_,
PersistentMemoryMalloc(bool has_no_backing_storage, uint64_t log_size, LightEpoch& epoch, disk_t& disk_, log_file_t& file_,
Address start_address, double log_mutable_fraction, bool pre_allocate_log)
: sector_size{ static_cast<uint32_t>(file_.alignment()) }
, epoch_{ &epoch }
Expand Down Expand Up @@ -282,6 +282,13 @@ class PersistentMemoryMalloc {
// mutable page is full.
throw std::invalid_argument{ "Must have at least 2 mutable pages" };
}
// Make sure we have at least 'kNumHeadPages' immutable pages.
// Otherwise, we will not be able to dump log to disk when our in-memory log is full.
// If the user is certain that we will never need to dump anything to disk
// (this is the case in compaction), skip this check.
if(!has_no_backing_storage && buffer_size_ - num_mutable_pages_ < kNumHeadPages) {
throw std::invalid_argument{ "Must have at least 'kNumHeadPages' immutable pages" };
}

page_status_ = new FullPageStatus[buffer_size_];

Expand All @@ -302,9 +309,9 @@ class PersistentMemoryMalloc {
AllocatePage(tail_page_offset.page() + 1);
}

PersistentMemoryMalloc(uint64_t log_size, LightEpoch& epoch, disk_t& disk_, log_file_t& file_,
PersistentMemoryMalloc(bool has_no_backing_storage, uint64_t log_size, LightEpoch& epoch, disk_t& disk_, log_file_t& file_,
double log_mutable_fraction, bool pre_allocate_log)
: PersistentMemoryMalloc(log_size, epoch, disk_, file_, Address{ 0 }, log_mutable_fraction, pre_allocate_log) {
: PersistentMemoryMalloc(has_no_backing_storage, log_size, epoch, disk_, file_, Address{ 0 }, log_mutable_fraction, pre_allocate_log) {
/// Allocate the invalid page. Supports allocations aligned up to kCacheLineBytes.
uint32_t discard;
Allocate(Constants::kCacheLineBytes, discard);
Expand Down