1. 26 10月, 2017 3 次提交
    • A
      single-file bottom-level compaction when snapshot released · 9b18cc23
      Andrew Kryczka 提交于
      Summary:
      When snapshots are held for a long time, files may reach the bottom level containing overwritten/deleted keys. We previously had no mechanism to trigger compaction on such files. This particularly impacted DBs that write to different parts of the keyspace over time, as such files would never be naturally compacted due to second-last level files moving down. This PR introduces a mechanism for bottommost files to be recompacted upon releasing all snapshots that prevent them from dropping their deleted/overwritten keys.
      
      - Changed `CompactionPicker` to compact files in `BottommostFilesMarkedForCompaction()`. These are the last choice when picking. Each file will be compacted alone and output to the same level in which it originated. The goal of this type of compaction is to rewrite the data excluding deleted/overwritten keys.
      - Changed `ReleaseSnapshot()` to recompute the bottom files marked for compaction when the oldest existing snapshot changes, and schedule a compaction if needed. We cache the value that oldest existing snapshot needs to exceed in order for another file to be marked in `bottommost_files_mark_threshold_`, which allows us to avoid recomputing marked files for most snapshot releases.
      - Changed `VersionStorageInfo` to track the list of bottommost files, which is recomputed every time the version changes by `UpdateBottommostFiles()`. The list of marked bottommost files is first computed in `ComputeBottommostFilesMarkedForCompaction()` when the version changes, but may also be recomputed when `ReleaseSnapshot()` is called.
      - Extracted core logic of `Compaction::IsBottommostLevel()` into `VersionStorageInfo::RangeMightExistAfterSortedRun()` since logic to check whether a file is bottommost is now necessary outside of compaction.
      Closes https://github.com/facebook/rocksdb/pull/3009
      
      Differential Revision: D6062044
      
      Pulled By: ajkr
      
      fbshipit-source-id: 123d201cf140715a7d5928e8b3cb4f9cd9f7ad21
      9b18cc23
    • S
      Return write error on reaching blob dir size limit · 96e3a600
      Sagar Vemuri 提交于
      Summary:
      I found that we continue accepting writes even when the blob db goes beyond the configured blob directory size limit. Now, we return an error for writes on reaching `blob_dir_size` limit and if `is_fifo` is set to false. (We cannot just drop any file when `is_fifo` is true.)
      
      Deleting the oldest file when `is_fifo` is true will be handled in a later PR.
      Closes https://github.com/facebook/rocksdb/pull/3060
      
      Differential Revision: D6136156
      
      Pulled By: sagar0
      
      fbshipit-source-id: 2f11cb3f2eedfa94524fbfa2613dd64bfad7a23c
      96e3a600
    • I
      Fix tombstone scans in SeekForPrev outside prefix · addfe1ef
      Islam AbdelRahman 提交于
      Summary:
      When doing a Seek() or SeekForPrev() we should stop the moment we see a key with a different prefix as start if ReadOptions:: prefix_same_as_start was set to true
      
      Right now we don't stop if we encounter a tombstone outside the prefix while executing SeekForPrev()
      Closes https://github.com/facebook/rocksdb/pull/3067
      
      Differential Revision: D6149638
      
      Pulled By: IslamAbdelRahman
      
      fbshipit-source-id: 7f659862d2bf552d3c9104a360c79439ceba2f18
      addfe1ef
  2. 25 10月, 2017 1 次提交
  3. 24 10月, 2017 4 次提交
    • Z
      added missing subcodes and improved error message for missing enum values · 57fcdc26
      zawlazaw 提交于
      Summary:
      Java's `Status.SubCode` was out of sync with `include/rocksdb/status.h:SubCode`.
      
      When running out of disc space this led to an `IllegalArgumentException` because of an invalid status code, rather than just returning the corresponding status code without an exception.
      
      I added the missing status codes.
      
      By this, we keep the behaviour of throwing an `IllegalArgumentException` in case of newly added status codes that are defined in C but not in Java.
      
      We could think of an alternative strategy: add in Java another code "UnknownCode" which acts as a catch-all for all those status codes that are not yet mirrored from C to Java. This approach would never throw an exception but simply return a non-OK status-code.
      
      I think the current approach of throwing an Exception in case of a C/Java inconsistency is fine, but if you have some opinion on the alternative strategy, then feel free to comment here.
      Closes https://github.com/facebook/rocksdb/pull/3050
      
      Differential Revision: D6129682
      
      Pulled By: sagar0
      
      fbshipit-source-id: f2bf44caad650837cffdcb1f93eb793b43580c66
      57fcdc26
    • Y
      Add DB::Properties::kEstimateOldestKeyTime · 66a2c44e
      Yi Wu 提交于
      Summary:
      With FIFO compaction we would like to get the oldest data time for monitoring. The problem is we don't have timestamp for each key in the DB. As an approximation, we expose the earliest of sst file "creation_time" property.
      
      My plan is to override the property with a more accurate value with blob db, where we actually have timestamp.
      Closes https://github.com/facebook/rocksdb/pull/2842
      
      Differential Revision: D5770600
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 03833c8f10bbfbee62f8ea5c0d03c0cafb5d853a
      66a2c44e
    • D
      Fix unused var warnings in Release mode · d2a65c59
      Dmitri Smirnov 提交于
      Summary:
      MSVC does not support unused attribute at this time. A separate assignment line fixes the issue probably by being counted as usage for MSVC and it no longer complains about unused var.
      Closes https://github.com/facebook/rocksdb/pull/3048
      
      Differential Revision: D6126272
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: 4907865db45fd75a39a15725c0695aaa17509c1f
      d2a65c59
    • M
      Enable two write queues for transactions · 63822eb7
      Maysam Yabandeh 提交于
      Summary:
      Enable concurrent_prepare flag for WritePrepared transactions and extend the existing transaction tests with this config.
      Closes https://github.com/facebook/rocksdb/pull/3046
      
      Differential Revision: D6106534
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: 88c8d21d45bc492beb0a131caea84a2ac5e7d38c
      63822eb7
  4. 21 10月, 2017 6 次提交
  5. 20 10月, 2017 2 次提交
    • S
      Make FIFO compaction options dynamically configurable · f0804db7
      Sagar Vemuri 提交于
      Summary:
      ColumnFamilyOptions::compaction_options_fifo and all its sub-fields can be set dynamically now.
      
      Some of the ways in which the fifo compaction options can be set are:
      - `SetOptions({{"compaction_options_fifo", "{max_table_files_size=1024}"}})`
      - `SetOptions({{"compaction_options_fifo", "{ttl=600;}"}})`
      - `SetOptions({{"compaction_options_fifo", "{max_table_files_size=1024;ttl=600;}"}})`
      - `SetOptions({{"compaction_options_fifo", "{max_table_files_size=51;ttl=49;allow_compaction=true;}"}})`
      
      Most of the code has been made generic enough so that it could be reused later to make universal options (and other such nested defined-types) dynamic with very few lines of parsing/serializing code changes.
      Introduced a few new functions like `ParseStruct`, `SerializeStruct` and `GetStringFromStruct`.
      The duplicate code in `GetStringFromDBOptions` and `GetStringFromColumnFamilyOptions` has been moved into `GetStringFromStruct`. So they become just simple wrappers now.
      Closes https://github.com/facebook/rocksdb/pull/3006
      
      Differential Revision: D6058619
      
      Pulled By: sagar0
      
      fbshipit-source-id: 1e8f78b3374ca5249bb4f3be8a6d3bb4cbc52f92
      f0804db7
    • D
      Enable MSVC W4 with a few exceptions. Fix warnings and bugs · ebab2e2d
      Dmitri Smirnov 提交于
      Summary: Closes https://github.com/facebook/rocksdb/pull/3018
      
      Differential Revision: D6079011
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 988a721e7e7617967859dba71d660fc69f4dff57
      ebab2e2d
  6. 19 10月, 2017 3 次提交
  7. 18 10月, 2017 7 次提交
    • N
      expose a hook to skip tables during iteration · 7891af8b
      Nikhil Benesch 提交于
      Summary:
      As discussed on the mailing list (["Skipping entire SSTs while iterating"](https://groups.google.com/forum/#!topic/rocksdb/ujHCJVLrHlU)), this patch adds a `table_filter` to `ReadOptions` that allows specifying a callback to be executed during iteration before each table in the database is scanned. The callback is passed the table's properties; the table is scanned iff the callback returns true.
      
      This can be used in conjunction with a `TablePropertiesCollector` to dramatically speed up scans by skipping tables that are known to contain irrelevant data for the scan at hand.
      
      We're using this [downstream in CockroachDB](https://github.com/cockroachdb/cockroach/blob/master/pkg/storage/engine/db.cc#L2009-L2022) already. With this feature, under ideal conditions, we can reduce the time of an incremental backup in  from hours to seconds.
      
      FYI, the first commit in this PR fixes a segfault that I unfortunately have not figured out how to reproduce outside of CockroachDB. I'm hoping you accept it on the grounds that it is not correct to return 8-byte aligned memory from a call to `malloc` on some 64-bit platforms; one correct approach is to infer the necessary alignment from `std::max_align_t`, as done here. As noted in the first commit message, the bug is tickled by having a`std::function` in `struct ReadOptions`. That is, the following patch alone is enough to cause RocksDB to segfault when run from CockroachDB on Darwin.
      
      ```diff
       --- a/include/rocksdb/options.h
      +++ b/include/rocksdb/options.h
      @@ -1546,6 +1546,13 @@ struct ReadOptions {
         // Default: false
         bool ignore_range_deletions;
      
      +  // A callback to determine whether relevant keys for this scan exist in a
      +  // given table based on the table's properties. The callback is passed the
      +  // properties of each table during iteration. If the callback returns false,
      +  // the table will not be scanned.
      +  // Default: empty (every table will be scanned)
      +  std::function<bool(const TableProperties&)> table_filter;
      +
         ReadOptions();
         ReadOptions(bool cksum, bool cache);
       };
      ```
      
      /cc danhhz
      Closes https://github.com/facebook/rocksdb/pull/2265
      
      Differential Revision: D5054262
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: dd6b28f2bba6cb8466250d8c5c542d3c92785476
      7891af8b
    • Y
      Blob DB: Store blob index as kTypeBlobIndex in base db · eaaef911
      Yi Wu 提交于
      Summary:
      Blob db insert blob index to base db as kTypeBlobIndex type, to tell apart values written by plain rocksdb or blob db. This is to make it possible to migrate from existing rocksdb to blob db.
      
      Also with the patch blob db garbage collection get away from OptimisticTransaction. Instead it use a custom write callback to achieve similar behavior as OptimisticTransaction. This is because we need to pass the is_blob_index flag to DBImpl::Get but OptimisticTransaction don't support it.
      Closes https://github.com/facebook/rocksdb/pull/3000
      
      Differential Revision: D6050044
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 61dc72ab9977625e75f78cd968e7d8a3976e3632
      eaaef911
    • Y
      Blob DB: not writing sequence number as blob record footer · 0552029b
      Yi Wu 提交于
      Summary:
      Previously each time we write a blob we write blog_record_header + key + value + blob_record_footer to blob log. The footer only contains a sequence and a crc for the sequence number. The sequence number was used in garbage collection to verify the value is recent. After #2703 we moved to use optimistic transaction and no longer use sequence number from the footer. Remove the footer altogether.
      
      There's another usage of sequence number and we are keeping it: Each blob log file keep track of sequence number range of keys in it, and use it to check if it is reference by a snapshot, before being deleted.
      Closes https://github.com/facebook/rocksdb/pull/3005
      
      Differential Revision: D6057585
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: d6da53c457a316e9723f359a1b47facfc3ffe090
      0552029b
    • Z
      fix delete range bug · 966b32b5
      zhangjinpeng1987 提交于
      Summary:
      Fix this [issue](https://github.com/facebook/rocksdb/issues/2989).
      ajkr PTAL
      
      Close #2989
      Closes https://github.com/facebook/rocksdb/pull/3017
      
      Differential Revision: D6078541
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: ef3db87b37b9156f83ca468aa39dea1f6dbde49d
      966b32b5
    • N
      arena: derive alignment unit from std::max_align_t · c0208dff
      Nikhil Benesch 提交于
      Summary:
      As raised in #2265, the arena allocator will return memory that is improperly aligned to store a `std::function` on macOS. Oddly, I'm unable to tickle this bug without adding a `std::function` field to `struct ReadOptions`—but my proposal in #2265 does exactly that.
      
      In any case, here's a simple reproduction. Apply this bogus patch to get a `std::function` into `struct ReadOptions`
      
      ```
       --- a/include/rocksdb/options.h
      +++ b/include/rocksdb/options.h
      @@ -1035,6 +1035,8 @@ struct ReadOptions {
         // Default: 0
         uint64_t max_skippable_internal_keys;
      
      +  std::function<void()> foo;
      +
         ReadOptions();
         ReadOptions(bool cksum, bool cache);
       };
      ```
      
      then compile `db_properties_test` *with ubsan* and run `ReadLatencyHistogramByLevel`:
      
      ```
      $ make COMPILE_WITH_UBSAN=1 db_properties_test
      $ ./db_properties_test --gtest_filter=DBPropertiesTest.ReadLatencyHistogramByLevel
      ```
      
      ubsan will complain about several misaligned accesses:
      
      ```
      Note: Google Test filter = DBPropertiesTest.ReadLatencyHistogramByLevel
      [==========] Running 1 test from 1 test case.
      [----------] Global test environment set-up.
      [----------] 1 test from DBPropertiesTest
      [ RUN      ] DBPropertiesTest.ReadLatencyHistogramByLevel
      util/coding.h:372:12: runtime error: load of misaligned address 0x00010d85516c for type 'const unsigned long', which requires 8 byte alignment
      0x00010d85516c: note: pointer points here
        01 00 34 57 00 00 00 00  02 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  78 24 82 0a 01 00 00 00
                    ^
      util/coding.h:362:3: runtime error: store to misaligned address 0x7fff5733fac4 for type 'unsigned long', which requires 8 byte alignment
      0x7fff5733fac4: note: pointer points here
        01 00 00 00 00 00 00 00  02 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  80 1d 96 0d 01 00 00 00
                    ^
      util/coding.h:372:12: runtime error: load of misaligned address 0x00010d85516c for type 'const unsigned long', which requires 8 byte alignment
      0x00010d85516c: note: pointer points here
        01 00 34 57 00 00 00 00  02 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  78 24 82 0a 01 00 00 00
                    ^
      version_set.cc:854: runtime error: constructor call on misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      version_set.cc:512: runtime error: constructor call on misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      version_set.cc:505: runtime error: constructor call on misaligned address 0x00010dbfa5e8 for type 'rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      options.h:931: runtime error: constructor call on misaligned address 0x00010dbfa5e8 for type 'rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      options.h:931: runtime error: constructor call on misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      functional:1583: runtime error: constructor call on misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1585:9: runtime error: member access within misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1585:9: runtime error: store to misaligned address 0x00010dbfa648 for type '__base *' (aka '__base<void ()> *'), which requires 16 byte alignment
      0x00010dbfa648: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:864:29: runtime error: upcast of misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:521:12: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:521:12: runtime error: load of misaligned address 0x00010dbfa5d8 for type 'rocksdb::TableCache *', which requires 16 byte alignment
      0x00010dbfa5d8: note: pointer points here
       00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00 00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00
                    ^
      db/version_set.cc:522:9: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:522:9: runtime error: reference binding to misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:522:24: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:522:38: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:522:57: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:522:57: runtime error: load of misaligned address 0x00010dbfa678 for type 'rocksdb::RangeDelAggregator *', which requires 16 byte alignment
      0x00010dbfa678: note: pointer points here
       01 00 00 00  d0 a1 bf 0d 01 00 00 00  00 00 00 00 00 00 00 00  f8 db 70 0a 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:523:54: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:523:54: runtime error: load of misaligned address 0x00010dbfa668 for type 'rocksdb::HistogramImpl *', which requires 16 byte alignment
      0x00010dbfa668: note: pointer points here
       01 00 00 00  c8 88 a5 0d 01 00 00 00  00 00 00 00 01 00 00 00  d0 a1 bf 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:524:9: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:524:47: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:524:62: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/table_cache.cc:228:33: runtime error: reference binding to misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      table/block_based_table_reader.cc:1554:41: runtime error: reference binding to misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      table/block_based_table_reader.cc:1396:21: runtime error: reference binding to misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      include/rocksdb/options.h:931:8: runtime error: reference binding to misaligned address 0x00010dbfa628 for type 'const std::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1584:13: runtime error: load of misaligned address 0x00010dbfa648 for type '__base *const' (aka '__base<void ()> *const'), which requires 16 byte alignment
      0x00010dbfa648: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  c8 a5 97 0d 01 00 00 00  38 36 9b 0d
                    ^
      table/block_based_table_reader.cc:1555:24: runtime error: reference binding to misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      db/table_cache.cc:244:54: runtime error: load of misaligned address 0x00010dbfa618 for type 'const bool', which requires 16 byte alignment
      0x00010dbfa618: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      db/table_cache.cc:246:49: runtime error: reference binding to misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:532:12: runtime error: member access within misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:532:12: runtime error: member access within misaligned address 0x00010dbfa5e8 for type 'const rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      db/version_set.cc:532:26: runtime error: load of misaligned address 0x00010dbfa5f8 for type 'const rocksdb::Slice *const', which requires 16 byte alignment
      0x00010dbfa5f8: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      version_set.cc:493: runtime error: member call on misaligned address 0x00010dbfa5c8 for type 'rocksdb::(anonymous namespace)::LevelFileIteratorState', which requires 16 byte alignment
      0x00010dbfa5c8: note: pointer points here
       00 00 00 00  a0 db 70 0a 01 00 00 00  00 00 00 00 00 00 00 00  90 14 98 0d 01 00 00 00  00 00 00 00
                    ^
      version_set.cc:493: runtime error: member call on misaligned address 0x00010dbfa5e8 for type 'rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      options.h:931: runtime error: member call on misaligned address 0x00010dbfa5e8 for type 'rocksdb::ReadOptions', which requires 16 byte alignment
      0x00010dbfa5e8: note: pointer points here
       00 00 00 00  01 01 ff ff ff ff ff ff  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      options.h:931: runtime error: member call on misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      functional:1765: runtime error: member call on misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1766:9: runtime error: member access within misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1766:9: runtime error: load of misaligned address 0x00010dbfa648 for type '__base *' (aka '__base<void ()> *'), which requires 16 byte alignment
      0x00010dbfa648: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  c8 a5 97 0d 01 00 00 00  38 36 9b 0d
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1766:27: runtime error: member access within misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1768:14: runtime error: member access within misaligned address 0x00010dbfa628 for type 'std::__1::function<void ()>', which requires 16 byte alignment
      0x00010dbfa628: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1768:14: runtime error: load of misaligned address 0x00010dbfa648 for type '__base *' (aka '__base<void ()> *'), which requires 16 byte alignment
      0x00010dbfa648: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  c8 a5 97 0d 01 00 00 00  38 36 9b 0d
                    ^
      [       OK ] DBPropertiesTest.ReadLatencyHistogramByLevel (1599 ms)
      [----------] 1 test from DBPropertiesTest (1599 ms total)
      
      [----------] Global test environment tear-down
      [==========] 1 test from 1 test case ran. (1599 ms total)
      [  PASSED  ] 1 test.
      ```
      
      So it seems the root cause is that the internal implementation of `std::function` on macOS (and perhaps with libc++ generally?) requires 16-byte aligned memory, but the arena allocator only guarantees that the returned memory will be `sizeof(void*)` aligned, which is only 8-byte alignment on my machine. This patch solves the problem by adjusting the allocator to derive the necessary alignment from `alignof(std::max_align_t)`, which is properly 16 bytes on my machine.
      
      As I mentioned in #2265, none of RocksDB's tests will cause this unaligned access to actually abort the process, but, on macOS, linking CockroachDB against a version of RocksDB with the above patch and letting it run for just a few seconds will cause a SIGABRT.
      
      ```
      Process 19792 stopped
      * thread #2, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
          frame #0: 0x0000000004f5e78f cockroach`DBNewIter + 95
      cockroach`DBNewIter:
      ->  0x4f5e78f <+95>:  callq  *0x28(%rax)
          0x4f5e792 <+98>:  jmp    0x4f5e79e                 ; <+110>
          0x4f5e794 <+100>: movq   -0x50(%rbp), %rcx
          0x4f5e798 <+104>: movq   %rax, %rdi
      (lldb) bt
      * thread #2, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
        * frame #0: 0x0000000004f5e78f cockroach`DBNewIter + 95
      ```
      
      I'd get you a backtrace, but [Go doesn't include cgo debug information on macOS](https://github.com/golang/go/issues/6942). I've also tried building against libc++ on Linux, where debug information would be available, but I can't seem to trigger the bug there.
      
      In any case, this PR both fixes the segfault in CockroachDB and fixes the warnings reported by ubsan.
      Closes https://github.com/facebook/rocksdb/pull/2347
      
      Differential Revision: D5108596
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: bd5e4323b2ce915ed4fe78e123cb8996aec75a00
      c0208dff
    • C
      VersionBuilder: Erase with iterators for better performance · b8cea7cc
      Changli Gao 提交于
      Summary: Closes https://github.com/facebook/rocksdb/pull/3007
      
      Differential Revision: D6077701
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: a6fd5b8a23f4feb1660b9ce027f651a7e90352b3
      b8cea7cc
    • C
      Move ~Comparator define to comparator.h · f7843f30
      codeeply 提交于
      Summary:
      When I impl my own comparator, and build in release mode.
      The following compile error occurs.
      undefined reference to `typeinfo for rocksdb::Comparator'
      
      This fix allows users build with RTTI off when has their own comparator.
      Closes https://github.com/facebook/rocksdb/pull/3008
      
      Differential Revision: D6077354
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 914c26dbab72f0ad1f0e15f8666a3fb2f10bfed8
      f7843f30
  8. 17 10月, 2017 2 次提交
  9. 14 10月, 2017 2 次提交
  10. 13 10月, 2017 3 次提交
  11. 12 10月, 2017 3 次提交
  12. 11 10月, 2017 3 次提交
  13. 10 10月, 2017 1 次提交
    • J
      compaction picker to use max_bytes_for_level_multiplier_additional · 1a61ba17
      Jay Patel 提交于
      Summary:
      Hi,
      As part of some optimization, we're using multiple DB locations (tmpfs and spindle) to store data and configured max_bytes_for_level_multiplier_additional. But, max_bytes_for_level_multiplier_additional is not used to compute the actual size for the level while picking the DB location. So, even if DB location does not have space, RocksDB mistakenly puts the level at that location.
      
      Can someone pls. verify the fix? Let me know any other changes required.
      
      Thanks,
      Jay
      Closes https://github.com/facebook/rocksdb/pull/2704
      
      Differential Revision: D5992515
      
      Pulled By: ajkr
      
      fbshipit-source-id: cbbc6c0e0a7dbdca91c72e0f37b218c4cec57e28
      1a61ba17