• Levi Tamasi's avatar
    Revisit the handling of the case when a file is re-added to the same level (#6939) · d854abad
    Levi Tamasi 创作于
    Summary:
    https://github.com/facebook/rocksdb/pull/6901 subtly changed the handling of the corner case
    when a table file is deleted from a level, then re-added to the same level. (Note: this
    should be extremely rare; one scenario that comes to mind is a trivial move followed by
    a call to `ReFitLevel` that moves the file back to the original level.) Before that change,
    a new `FileMetaData` object was created as a result of this sequence; after the change,
    the original `FileMetaData` was essentially resurrected (since the deletion and the addition
    simply cancel each other out with the change). This patch restores the original behavior,
    which is more intuitive considering the interface, and in sync with how trivial moves are handled.
    (Also note that `FileMetaData` contains some mutable data members, the values of which
    might be different in the resurrected object and the freshly created one.)
    The PR also fixes a bug in this area: with the original pre-6901 code, `VersionBuilder`
    would add the same file twice to the same level in the scenario described above.
    Pull Request resolved: https://github.com/facebook/rocksdb/pull/6939
    
    Test Plan: `make check`
    
    Reviewed By: ajkr
    
    Differential Revision: D21905580
    
    Pulled By: ltamasi
    
    fbshipit-source-id: da07ae45384ecf3c6c53506d106432d88a7ec9df
    d854abad