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

LogWriter to only flush after finish generating whole record #5328

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* DBIter::Next() can skip user key checking if previous entry's seqnum is 0.
* Merging iterator to avoid child iterator reseek for some cases
* Reduce iterator key comparision for upper/lower bound check.
* Log Writer will flush after finishing the whole record, rather than a fragment.

### General Improvements
* Added new status code kColumnFamilyDropped to distinguish between Column Family Dropped and DB Shutdown in progress.
Expand Down
12 changes: 7 additions & 5 deletions db/log_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ Status Writer::AddRecord(const Slice& slice) {
left -= fragment_length;
begin = false;
} while (s.ok() && left > 0);

if (s.ok()) {
if (!manual_flush_) {
s = dest_->Flush();
}
}

return s;
}

Expand Down Expand Up @@ -146,11 +153,6 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
Status s = dest_->Append(Slice(buf, header_size));
if (s.ok()) {
s = dest_->Append(Slice(ptr, n));
if (s.ok()) {
if (!manual_flush_) {
s = dest_->Flush();
}
}
}
block_offset_ += header_size + n;
riversand963 marked this conversation as resolved.
Show resolved Hide resolved
return s;
Expand Down