• I
    Add experimental API MarkForCompaction() · 6059bdf8
    Igor Canadi 提交于
    Summary:
    Some Mongo+Rocks datasets in Parse's environment are not doing compactions very frequently. During the quiet period (with no IO), we'd like to schedule compactions so that our reads become faster. Also, aggressively compacting during quiet periods helps when write bursts happen. In addition, we also want to compact files that are containing deleted key ranges (like old oplog keys).
    
    All of this is currently not possible with CompactRange() because it's single-threaded and blocks all other compactions from happening. Running CompactRange() risks an issue of blocking writes because we generate too much Level 0 files before the compaction is over. Stopping writes is very dangerous because they hold transaction locks. We tried running manual compaction once on Mongo+Rocks and everything fell apart.
    
    MarkForCompaction() solves all of those problems. This is very light-weight manual compaction. It is lower priority than automatic compactions, which means it shouldn't interfere with background process keeping the LSM tree clean. However, if no automatic compactions need to be run (or we have extra background threads available), we will start compacting files that are marked for compaction.
    
    Test Plan: added a new unit test
    
    Reviewers: yhchiang, rven, MarkCallaghan, sdong
    
    Reviewed By: sdong
    
    Subscribers: yoshinorim, dhruba, leveldb
    
    Differential Revision: https://reviews.facebook.net/D37083
    6059bdf8
db_impl.h 27.6 KB