Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

feat: append mlog in fixed-size blocks using log_appender #418

Merged
merged 3 commits into from
Apr 16, 2020

Conversation

neverchanje
Copy link
Contributor

@neverchanje neverchanje commented Mar 17, 2020

The current mutation_log implementation is unfriendly with such case:

There're some writes being flushed into the disk, in the meantime, new incoming writes are pending in the log_block waiting to be flushed.

As the pending log_block grows, it could be considerably large (like tens of MB) which is unfriendly for both replica recovery and duplication. I've met a bug while testing duplication that reading a large log block may cause tcmalloc to allocate an inaccessible memory.

This PR limits the log block to 1MB using log_appender, reduces the possibility of large block related bug.

log_appender is a buffer for multiple log blocks. This PR doesn't change the behavior that all the pending writes will be flushed to disk (mutation_log::commit_pending_mutations), no matter how large the size is. What changed is only the size of the log-block, so that reading the log block can be more smooth, without allocating large memory buffer.

While the buffered writes went flushed (which blocks another flush), the incoming writes will be buffered in a new log_appender. The old log_appender will be removed.

@neverchanje neverchanje changed the title refactor: append mlog in fixed-size blocks feat: append mlog in fixed-size blocks Mar 28, 2020
@neverchanje neverchanje changed the title feat: append mlog in fixed-size blocks feat: append mlog in fixed-size blocks using log_appender Mar 28, 2020
@acelyc111

This comment has been minimized.

src/dist/replication/lib/log_block.cpp Outdated Show resolved Hide resolved
src/dist/replication/lib/log_block.h Outdated Show resolved Hide resolved
src/dist/replication/lib/log_block.h Show resolved Hide resolved
src/dist/replication/lib/mutation_log.cpp Outdated Show resolved Hide resolved
src/dist/replication/lib/mutation_log.h Outdated Show resolved Hide resolved
src/dist/replication/lib/log_block.h Outdated Show resolved Hide resolved
src/dist/replication/lib/log_block.h Outdated Show resolved Hide resolved
src/dist/replication/lib/log_block.cpp Outdated Show resolved Hide resolved
src/dist/replication/lib/log_block.cpp Outdated Show resolved Hide resolved
@neverchanje neverchanje force-pushed the mlog_block branch 3 times, most recently from ccc68a9 to 7771797 Compare April 15, 2020 10:37
neverchanje added 2 commits April 15, 2020 20:04
feat: append mlog in fixed-size blocks using log_appender
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants