1. 18 10月, 2017 3 次提交
    • 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
  2. 17 10月, 2017 2 次提交
  3. 14 10月, 2017 2 次提交
  4. 13 10月, 2017 3 次提交
  5. 12 10月, 2017 3 次提交
  6. 11 10月, 2017 3 次提交
  7. 10 10月, 2017 4 次提交
  8. 07 10月, 2017 4 次提交
    • Y
      WritePrepare Txn: Cancel flush/compaction before destruction · 17c6325e
      Yi Wu 提交于
      Summary:
      On WritePreparedTxnDB destruct there could be running compaction/flush holding a SnapshotChecker, which holds a pointer back to WritePreparedTxnDB. Make sure those jobs finished before destructing WritePreparedTxnDB.
      
      This is caught by TransactionTest::SeqAdvanceTest.
      Closes https://github.com/facebook/rocksdb/pull/2982
      
      Differential Revision: D6002957
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: f1e70390c9798d1bd7959f5c8e2a1c14100773c3
      17c6325e
    • M
      WritePrepared Txn: end-to-end tests · ec6c5383
      Maysam Yabandeh 提交于
      Summary:
      Enable WritePrepared policy for existing transaction tests.
      Closes https://github.com/facebook/rocksdb/pull/2972
      
      Differential Revision: D5993614
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: d1eb53e2920c4e2a56434bb001231c98426f3509
      ec6c5383
    • S
      Enable WAL for blob index · da29eba4
      Sagar Vemuri 提交于
      Summary:
      Enabled WAL, during GC, for blob index which is stored on regular RocksDB.
      Closes https://github.com/facebook/rocksdb/pull/2975
      
      Differential Revision: D5997384
      
      Pulled By: sagar0
      
      fbshipit-source-id: b76c1487d8b5be0e36c55e8d77ffe3d37d63d85b
      da29eba4
    • Y
      WritePrepared Txn: Compaction/Flush · d1b74b0c
      Yi Wu 提交于
      Summary:
      Update Compaction/Flush to support WritePreparedTxnDB: Add SnapshotChecker which is a proxy to query WritePreparedTxnDB::IsInSnapshot. Pass SnapshotChecker to DBImpl on WritePreparedTxnDB open. CompactionIterator use it to check if a key has been committed and if it is visible to a snapshot. In CompactionIterator:
      * check if key has been committed. If not, output uncommitted keys AS-IS.
      * use SnapshotChecker to check if key is visible to a snapshot when in need.
      * do not output key with seq = 0 if the key is not committed.
      Closes https://github.com/facebook/rocksdb/pull/2926
      
      Differential Revision: D5902907
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 945e037fdf0aa652dc5ba0ad879461040baa0320
      d1b74b0c
  9. 06 10月, 2017 3 次提交
  10. 05 10月, 2017 4 次提交
    • M
      WritePrepared Txn: duplicate keys · 4e3c3d8c
      Maysam Yabandeh 提交于
      Summary:
      With WriteCommitted, when the write batch has duplicate keys, the txn db simply inserts them to the db with different seq numbers and let the db ignore/merge the duplicate values at the read time. With WritePrepared all the entries of the batch are inserted with the same seq number which prevents us from benefiting from this simple solution.
      
      This patch applies a hackish solution to unblock the end-to-end testing. The hack is to be replaced with a proper solution soon. The patch simply detects the duplicate key insertions, and mark the previous one as obsolete. Then before writing to the db it rewrites the batch eliminating the obsolete keys. This would incur a memcpy cost. Furthermore handing duplicate merge would require to do FullMerge instead of simply ignoring the previous value, which is not handled by this patch.
      Closes https://github.com/facebook/rocksdb/pull/2969
      
      Differential Revision: D5976337
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: 114e65b66f137d8454ff2d1d782b8c05da95f989
      4e3c3d8c
    • A
      rate limit auto-tuning · 1026e794
      Andrew Kryczka 提交于
      Summary:
      Dynamic adjustment of rate limit according to demand for background I/O. It increases by a factor when limiter is drained too frequently, and decreases by the same factor when limiter is not drained frequently enough. The parameters for this behavior are fixed in `GenericRateLimiter::Tune`. Other changes:
      
      - make rate limiter's `Env*` configurable for testing
      - track num drain intervals in RateLimiter so we don't have to rely on stats, which may be shared across different DB instances from the ones that share the RateLimiter.
      Closes https://github.com/facebook/rocksdb/pull/2899
      
      Differential Revision: D5858704
      
      Pulled By: ajkr
      
      fbshipit-source-id: cc2bac30f85e7f6fd63655d0a6732ef9ed7403b1
      1026e794
    • A
      Added CPU prefetch for skiplist · 75f7f42d
      Adam Kupczyk 提交于
      Summary:
      This change causes following changes result of test:
      ./db_bench --writes 10000000 --benchmarks="fillrandom" --compression_type none
      from
      fillrandom   :       3.177 micros/op 314804 ops/sec;   34.8 MB/s
      to
      fillrandom   :       2.777 micros/op 360087 ops/sec;   39.8 MB/s
      Closes https://github.com/facebook/rocksdb/pull/2961
      
      Differential Revision: D5977822
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 1ea77707bffa978b1592b0c5d0fe76bfa1930f8d
      75f7f42d
    • M
      Allow upgrades from nullptr to some merge operator · 88ed1f6e
      Manuel Ung 提交于
      Summary:
      Currently, RocksDB does not allow reopening a preexisting DB with no merge operator defined, with a merge operator defined. This means that if a DB ever want to add a merge operator, there's no way to do so currently.
      
      Fix this by adding a new verification type `kByNameAllowFromNull` which will allow old values to be nullptr, and new values to be non-nullptr.
      Closes https://github.com/facebook/rocksdb/pull/2958
      
      Differential Revision: D5961131
      
      Pulled By: lth
      
      fbshipit-source-id: 06179bebd0d90db3d43690b5eb7345e2d5bab1eb
      88ed1f6e
  11. 04 10月, 2017 6 次提交
    • A
      Prevent threads from respawning during joining · 5b2cb64b
      Andrew Kryczka 提交于
      Summary:
      Previously the thread pool might be non-empty after joining since concurrent submissions could spawn new threads. This problem didn't affect our background flush/compaction thread pools because the `shutting_down_` flag prevented new jobs from being submitted during/after joining. But I wanted to be able to reuse the `ThreadPool` without such external synchronization.
      Closes https://github.com/facebook/rocksdb/pull/2953
      
      Differential Revision: D5951920
      
      Pulled By: ajkr
      
      fbshipit-source-id: 0efec7d0056d36d1338367da75e8b0c089bbc973
      5b2cb64b
    • A
      pin L0 filters/indexes for compaction outputs · 82188703
      Andrew Kryczka 提交于
      Summary:
      We need to tell the iterator the compaction output file's level so it can apply proper optimizations, like pinning filter and index blocks when user enables `pin_l0_filter_and_index_blocks_in_cache` and the output file's level is zero.
      Closes https://github.com/facebook/rocksdb/pull/2949
      
      Differential Revision: D5945597
      
      Pulled By: ajkr
      
      fbshipit-source-id: 2389decf9026ffaa32d45801a77d002529f64a62
      82188703
    • M
      fix valgrind leak report in unit test · 283d6076
      Maysam Yabandeh 提交于
      Summary:
      I cannot locally reproduce the valgrind leak report but based on my code inspection not deleting txn1 might be the reason.
      ```
      ==197848== 2,990 (544 direct, 2,446 indirect) bytes in 1 blocks are definitely lost in loss record 15 of 16
      ==197848==    at 0x4C2D06F: operator new(unsigned long) (in /usr/local/fbcode/gcc-5-glibc-2.23/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==197848==    by 0x7D5B31: rocksdb::WritePreparedTxnDB::BeginTransaction(rocksdb::WriteOptions const&, rocksdb::TransactionOptions const&, rocksdb::Transaction*) (pessimistic_transaction_db.cc:173)
      ==197848==    by 0x7D80C1: rocksdb::PessimisticTransactionDB::Initialize(std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<rocksdb::ColumnFamilyHandle*, std::allocator<rocksdb::ColumnFamilyHandle*> > const&) (pessimistic_transaction_db.cc:115)
      ==197848==    by 0x7DC42F: rocksdb::WritePreparedTxnDB::Initialize(std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<rocksdb::ColumnFamilyHandle*, std::allocator<rocksdb::ColumnFamilyHandle*> > const&) (pessimistic_transaction_db.cc:151)
      ==197848==    by 0x7D8CA0: rocksdb::TransactionDB::WrapDB(rocksdb::DB*, rocksdb::TransactionDBOptions const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<rocksdb::ColumnFamilyHandle*, std::allocator<rocksdb::ColumnFamilyHandle*> > const&, rocksdb::TransactionDB**) (pessimistic_transaction_db.cc:275)
      ==197848==    by 0x7D9F26: rocksdb::TransactionDB::Open(rocksdb::DBOptions const&, rocksdb::TransactionDBOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<rocksdb::ColumnFamilyDescriptor, std::allocator<rocksdb::ColumnFamilyDescriptor> > const&, std::vector<rocksdb::ColumnFamilyHandle*, std::allocator<rocksdb::ColumnFamilyHandle*> >*, rocksdb::TransactionDB**) (pessimistic_transaction_db.cc:227)
      ==197848==    by 0x7DB349: rocksdb::TransactionDB::Open(rocksdb::Options const&, rocksdb::TransactionDBOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::TransactionDB**) (pessimistic_transaction_db.cc:198)
      ==197848==    by 0x52ABD2: rocksdb::TransactionTest::ReOpenNoDelete() (transaction_test.h:87)
      ==197848==    by 0x51F7B8: rocksdb::WritePreparedTransactionTest_BasicRecoveryTest_Test::TestBody() (write_prepared_transaction_test.cc:843)
      ==197848==    by 0x857557: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest-all.cc:3824)
      ==197848==    by 0x857557: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest-all.cc:3860)
      ==197848==    by 0x84E7EB: testing::Test::Run() [clone .part.485] (gtest-all.cc:3897)
      ==197848==    by 0x84E9BC: Run (gtest-all.cc:3888)
      ==197848==    by 0x84E9BC: testing::TestInfo::Run() [clone .part.486] (gtest-all.cc:4072)
      ```
      Closes https://github.com/facebook/rocksdb/pull/2963
      
      Differential Revision: D5968856
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: 2ac512bbcad37dc8eeeffe4f363978913354180c
      283d6076
    • S
      Fix DBOptionsTest.SetBytesPerSync test when run with no compression · 377e0040
      Sagar Vemuri 提交于
      Summary:
      Also made the test more easier to understand:
      - changed the value size to ~1MB.
      - switched to NoCompression. We don't anyway need compression in this test for dynamic options.
      
      The test failures started happening starting from: #2893 .
      Closes https://github.com/facebook/rocksdb/pull/2957
      
      Differential Revision: D5959392
      
      Pulled By: sagar0
      
      fbshipit-source-id: 2d55641e429246328bc6d10fcb9ef540d6ce07da
      377e0040
    • Y
      speedup 'make check' · 92ccae71
      Yi Wu 提交于
      Summary:
      Make SnapshotConcurrentAccessTest run in the beginning of the queue.
      
      Test Plan
      `make all check -j64` on devserver
      Closes https://github.com/facebook/rocksdb/pull/2962
      
      Differential Revision: D5965871
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 8cb5a47c2468be0fbbb929226a143ec5848bfaa9
      92ccae71
    • Y
      Add ValueType::kTypeBlobIndex · d1cab2b6
      Yi Wu 提交于
      Summary:
      Add kTypeBlobIndex value type, which will be used by blob db only, to insert a (key, blob_offset) KV pair. The purpose is to
      1. Make it possible to open existing rocksdb instance as blob db. Existing value will be of kTypeIndex type, while value inserted by blob db will be of kTypeBlobIndex.
      2. Make rocksdb able to detect if the db contains value written by blob db, if so return error.
      3. Make it possible to have blob db optionally store value in SST file (with kTypeValue type) or as a blob value (with kTypeBlobIndex type).
      
      The root db (DBImpl) basically pretended kTypeBlobIndex are normal value on write. On Get if is_blob is provided, return whether the value read is of kTypeBlobIndex type, or return Status::NotSupported() status if is_blob is not provided. On scan allow_blob flag is pass and if the flag is true, return wether the value is of kTypeBlobIndex type via iter->IsBlob().
      
      Changes on blob db side will be in a separate patch.
      Closes https://github.com/facebook/rocksdb/pull/2886
      
      Differential Revision: D5838431
      
      Pulled By: yiwu-arbug
      
      fbshipit-source-id: 3c5306c62bc13bb11abc03422ec5cbcea1203cca
      d1cab2b6
  12. 03 10月, 2017 3 次提交
    • A
      disable populating block cache for in-place updates · 880411f5
      Andrew Kryczka 提交于
      Summary:
      There's no point populating the block cache during this read. The key we read is guaranteed to be overwritten with a new `kValueType` key immediately afterwards, so can't be accessed again. A user was seeing high turnover of data blocks, at least partially due to this.
      Closes https://github.com/facebook/rocksdb/pull/2959
      
      Differential Revision: D5961672
      
      Pulled By: ajkr
      
      fbshipit-source-id: e7cb27c156c5db3b32af355c780efb99dbdf087c
      880411f5
    • M
      WritePrepared Txn: Rollback · d27258d3
      Maysam Yabandeh 提交于
      Summary:
      Implement the rollback of WritePrepared txns. For each modified value, it reads the value before the txn and write it back. This would cancel out the effect of transaction. It also remove the rolled back txn from prepared heap.
      Closes https://github.com/facebook/rocksdb/pull/2946
      
      Differential Revision: D5937575
      
      Pulled By: maysamyabandeh
      
      fbshipit-source-id: a6d3c47f44db3729f44b287a80f97d08dc4e888d
      d27258d3
    • S
      Limit number of merge operands in Cassandra merge operator · bb38cd03
      Sagar Vemuri 提交于
      Summary:
      Now that RocksDB supports conditional merging during point lookups (introduced in #2923), Cassandra value merge operator can be updated to pass in a limit. The limit needs to be passed in from the Cassandra code.
      Closes https://github.com/facebook/rocksdb/pull/2947
      
      Differential Revision: D5938454
      
      Pulled By: sagar0
      
      fbshipit-source-id: d64a72d53170d8cf202b53bd648475c3952f7d7f
      bb38cd03