1. 24 8月, 2022 2 次提交
  2. 23 8月, 2022 1 次提交
    • H
      Add missing synchronization in TestFSWritableFile (#10544) · b16655a5
      Hui Xiao 提交于
      Summary:
      **Context:**
      ajkr's command revealed an existing TSAN data race between `TestFSWritableFile::Append` and `TestFSWritableFile::Sync` on `TestFSWritableFile::state_`
      
      ```
      $ make clean && COMPILE_WITH_TSAN=1 make -j56 db_stress
      $ python3 tools/db_crashtest.py blackbox --simple --duration=3600 --interval=10 --sync_fault_injection=1 --disable_wal=0 --max_key=10000 --checkpoint_one_in=1000
      ```
      
      The race is due to concurrent access from [checkpoint's WAL sync](https://github.com/facebook/rocksdb/blob/7.4.fb/utilities/fault_injection_fs.cc#L324) and [db put's WAL write when ‘sync_fault_injection=1 ‘](https://github.com/facebook/rocksdb/blob/7.4.fb/utilities/fault_injection_fs.cc#L208) to the `state_` on the same WAL `TestFSWritableFile` under the missing synchronization.
      
      ```
      WARNING: ThreadSanitizer: data race (pid=11275)
      Write of size 8 at 0x7b480003d850 by thread T23 (mutexes: write M69230):
      #0 rocksdb::TestFSWritableFile::Sync(rocksdb::IOOptions const&, rocksdb::IODebugContext*) internal_repo_rocksdb/repo/utilities/fault_injection_fs.cc:297 (db_stress+0x716004)
      https://github.com/facebook/rocksdb/issues/1 rocksdb::(anonymous namespace)::CompositeWritableFileWrapper::Sync() internal_repo_rocksdb/repo/env/composite_env.cc:154 (db_stress+0x4dfa78)
      https://github.com/facebook/rocksdb/issues/2 rocksdb::(anonymous namespace)::LegacyWritableFileWrapper::Sync(rocksdb::IOOptions const&, rocksdb::IODebugContext*) internal_repo_rocksdb/repo/env/env.cc:280 (db_stress+0x6dfd24)
      https://github.com/facebook/rocksdb/issues/3 rocksdb::WritableFileWriter::SyncInternal(bool) internal_repo_rocksdb/repo/file/writable_file_writer.cc:460 (db_stress+0xa1b98c)
      https://github.com/facebook/rocksdb/issues/4 rocksdb::WritableFileWriter::SyncWithoutFlush(bool) internal_repo_rocksdb/repo/file/writable_file_writer.cc:435 (db_stress+0xa1e441)
      https://github.com/facebook/rocksdb/issues/5 rocksdb::DBImpl::SyncWAL() internal_repo_rocksdb/repo/db/db_impl/db_impl.cc:1385 (db_stress+0x529458)
      https://github.com/facebook/rocksdb/issues/6 rocksdb::DBImpl::FlushWAL(bool) internal_repo_rocksdb/repo/db/db_impl/db_impl.cc:1339 (db_stress+0x54f82a)
      https://github.com/facebook/rocksdb/issues/7 rocksdb::DBImpl::GetLiveFilesStorageInfo(rocksdb::LiveFilesStorageInfoOptions const&, std::vector<rocksdb::LiveFileStorageInfo, std::allocator<rocksdb::LiveFileStorageInfo> >*) internal_repo_rocksdb/repo/db/db_filesnapshot.cc:387 (db_stress+0x5c831d)
      https://github.com/facebook/rocksdb/issues/8 rocksdb::CheckpointImpl::CreateCustomCheckpoint(std::function<rocksdb::Status (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::FileType)>, std::function<rocksdb::Status (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, rocksdb::FileType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::Temperature)>, std::function<rocksdb::Status (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::FileType)>, unsigned long*, unsigned long, bool) internal_repo_rocksdb/repo/utilities/checkpoint/checkpoint_impl.cc:214 (db_stress+0x4c0343)
      https://github.com/facebook/rocksdb/issues/9 rocksdb::CheckpointImpl::CreateCheckpoint(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, unsigned long*) internal_repo_rocksdb/repo/utilities/checkpoint/checkpoint_impl.cc:123 (db_stress+0x4c237e)
      https://github.com/facebook/rocksdb/issues/10 rocksdb::StressTest::TestCheckpoint(rocksdb::ThreadState*, std::vector<int, std::allocator<int> > const&, std::vector<long, std::allocator<long> > const&) internal_repo_rocksdb/repo/db_stress_tool/db_stress_test_base.cc:1699 (db_stress+0x328340)
      https://github.com/facebook/rocksdb/issues/11 rocksdb::StressTest::OperateDb(rocksdb::ThreadState*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_test_base.cc:825 (db_stress+0x33921f)
      https://github.com/facebook/rocksdb/issues/12 rocksdb::ThreadBody(void*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_driver.cc:33 (db_stress+0x354857)
      https://github.com/facebook/rocksdb/issues/13 rocksdb::(anonymous namespace)::StartThreadWrapper(void*) internal_repo_rocksdb/repo/env/env_posix.cc:447 (db_stress+0x6eb2ad)
      
      Previous read of size 8 at 0x7b480003d850 by thread T64 (mutexes: write M980798978697532600, write M253744503184415024, write M1262):
      #0 memcpy <null> (db_stress+0xbc9696)
      https://github.com/facebook/rocksdb/issues/1 operator= internal_repo_rocksdb/repo/utilities/fault_injection_fs.h:35 (db_stress+0x70d5f1)
      https://github.com/facebook/rocksdb/issues/2 rocksdb::FaultInjectionTestFS::WritableFileAppended(rocksdb::FSFileState const&) internal_repo_rocksdb/repo/utilities/fault_injection_fs.cc:827 (db_stress+0x70d5f1)
      https://github.com/facebook/rocksdb/issues/3 rocksdb::TestFSWritableFile::Append(rocksdb::Slice const&, rocksdb::IOOptions const&, rocksdb::IODebugContext*) internal_repo_rocksdb/repo/utilities/fault_injection_fs.cc:173 (db_stress+0x7143af)
      https://github.com/facebook/rocksdb/issues/4 rocksdb::(anonymous namespace)::CompositeWritableFileWrapper::Append(rocksdb::Slice const&) internal_repo_rocksdb/repo/env/composite_env.cc:115 (db_stress+0x4de3ab)
      https://github.com/facebook/rocksdb/issues/5 rocksdb::(anonymous namespace)::LegacyWritableFileWrapper::Append(rocksdb::Slice const&, rocksdb::IOOptions const&, rocksdb::IODebugContext*) internal_repo_rocksdb/repo/env/env.cc:248 (db_stress+0x6df44b)
      https://github.com/facebook/rocksdb/issues/6 rocksdb::WritableFileWriter::WriteBuffered(char const*, unsigned long, rocksdb::Env::IOPriority) internal_repo_rocksdb/repo/file/writable_file_writer.cc:551 (db_stress+0xa1a953)
      https://github.com/facebook/rocksdb/issues/7 rocksdb::WritableFileWriter::Flush(rocksdb::Env::IOPriority) internal_repo_rocksdb/repo/file/writable_file_writer.cc:327 (db_stress+0xa16ee8)
      https://github.com/facebook/rocksdb/issues/8 rocksdb::log::Writer::AddRecord(rocksdb::Slice const&, rocksdb::Env::IOPriority) internal_repo_rocksdb/repo/db/log_writer.cc:147 (db_stress+0x7f121f)
      https://github.com/facebook/rocksdb/issues/9 rocksdb::DBImpl::WriteToWAL(rocksdb::WriteBatch const&, rocksdb::log::Writer*, unsigned long*, unsigned long*, rocksdb::Env::IOPriority, rocksdb::DBImpl::LogFileNumberSize&) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:1285 (db_stress+0x695042)
      https://github.com/facebook/rocksdb/issues/10 rocksdb::DBImpl::WriteToWAL(rocksdb::WriteThread::WriteGroup const&, rocksdb::log::Writer*, unsigned long*, bool, bool, unsigned long, rocksdb::DBImpl::LogFileNumberSize&) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:1328 (db_stress+0x6907e8)
      https://github.com/facebook/rocksdb/issues/11 rocksdb::DBImpl::PipelinedWriteImpl(rocksdb::WriteOptions const&, rocksdb::WriteBatch*, rocksdb::WriteCallback*, unsigned long*, unsigned long, bool, unsigned long*) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:731 (db_stress+0x68e8a7)
      https://github.com/facebook/rocksdb/issues/12 rocksdb::DBImpl::WriteImpl(rocksdb::WriteOptions const&, rocksdb::WriteBatch*, rocksdb::WriteCallback*, unsigned long*, unsigned long, bool, unsigned long*, unsigned long, rocksdb::PreReleaseCallback*, rocksdb::PostMemTableCallback*) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:283 (db_stress+0x688370)
      https://github.com/facebook/rocksdb/issues/13 rocksdb::DBImpl::Write(rocksdb::WriteOptions const&, rocksdb::WriteBatch*) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:126 (db_stress+0x69a7b5)
      https://github.com/facebook/rocksdb/issues/14 rocksdb::DB::Put(rocksdb::WriteOptions const&, rocksdb::ColumnFamilyHandle*, rocksdb::Slice const&, rocksdb::Slice const&, rocksdb::Slice const&) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:2247 (db_stress+0x698634)
      https://github.com/facebook/rocksdb/issues/15 rocksdb::DBImpl::Put(rocksdb::WriteOptions const&, rocksdb::ColumnFamilyHandle*, rocksdb::Slice const&, rocksdb::Slice const&, rocksdb::Slice const&) internal_repo_rocksdb/repo/db/db_impl/db_impl_write.cc:37 (db_stress+0x699868)
      https://github.com/facebook/rocksdb/issues/16 rocksdb::NonBatchedOpsStressTest::TestPut(rocksdb::ThreadState*, rocksdb::WriteOptions&, rocksdb::ReadOptions const&, std::vector<int, std::allocator<int> > const&, std::vector<long, std::allocator<long> > const&, char (&) [100], std::unique_ptr<rocksdb::MutexLock, std::default_delete<rocksdb::MutexLock> >&) internal_repo_rocksdb/repo/db_stress_tool/no_batched_ops_stress.cc:681 (db_stress+0x38d20c)
      https://github.com/facebook/rocksdb/issues/17 rocksdb::StressTest::OperateDb(rocksdb::ThreadState*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_test_base.cc:897 (db_stress+0x3399ec)
      https://github.com/facebook/rocksdb/issues/18 rocksdb::ThreadBody(void*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_driver.cc:33 (db_stress+0x354857)
      https://github.com/facebook/rocksdb/issues/19 rocksdb::(anonymous namespace)::StartThreadWrapper(void*) internal_repo_rocksdb/repo/env/env_posix.cc:447 (db_stress+0x6eb2ad)
      
      Location is heap block of size 352 at 0x7b480003d800 allocated by thread T23:
      #0 operator new(unsigned long) <null> (db_stress+0xb685dc)
      https://github.com/facebook/rocksdb/issues/1 rocksdb::FaultInjectionTestFS::NewWritableFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rocksdb::FileOptions const&, std::unique_ptr<rocksdb::FSWritableFile, std::default_delete<rocksdb::FSWritableFile> >*, rocksdb::IODebugContext*) internal_repo_rocksdb/repo/utilities/fault_injection_fs.cc:506 (db_stress+0x711192)
      https://github.com/facebook/rocksdb/issues/2 rocksdb::CompositeEnv::NewWritableFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::unique_ptr<rocksdb::WritableFile, std::default_delete<rocksdb::WritableFile> >*, rocksdb::EnvOptions const&) internal_repo_rocksdb/repo/env/composite_env.cc:329 (db_stress+0x4d33fa)
      https://github.com/facebook/rocksdb/issues/3 rocksdb::EnvWrapper::NewWritableFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::unique_ptr<rocksdb::WritableFile, std::default_delete<rocksdb::WritableFile> >*, rocksdb::EnvOptions const&) internal_repo_rocksdb/repo/include/rocksdb/env.h:1425 (db_stress+0x300662)
      ...
      ```
      
      **Summary:**
      - Added the missing lock in functions mentioned above along with three other functions with a similar need in TestFSWritableFile
      - Added clarification comment
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10544
      
      Test Plan: - Past the above race condition repro
      
      Reviewed By: ajkr
      
      Differential Revision: D38886634
      
      Pulled By: hx235
      
      fbshipit-source-id: 0571bae9615f35b16fbd8168204607e306b1b486
      b16655a5
  3. 22 8月, 2022 1 次提交
    • B
      Post 7.6 branch cut changes (#10546) · b0048b67
      Bo Wang 提交于
      Summary:
      After branch 7.6.fb branch is cut, following release process, upgrade version number to 7.7 and add 7.6.fb to format compatibility check.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10546
      
      Test Plan: Watch CI
      
      Reviewed By: ajkr
      
      Differential Revision: D38892023
      
      Pulled By: gitbw95
      
      fbshipit-source-id: 94e96dedbd973f5f9713e73d3bed336e4678565b
      b0048b67
  4. 21 8月, 2022 1 次提交
  5. 20 8月, 2022 3 次提交
    • A
      MultiGet async IO across multiple levels (#10535) · 35cdd3e7
      anand76 提交于
      Summary:
      This PR exploits parallelism in MultiGet across levels. It applies only to the coroutine version of MultiGet. Previously, MultiGet file reads from SST files in the same level were parallelized. With this PR, MultiGet batches with keys distributed across multiple levels are read in parallel. This is accomplished by splitting the keys not present in a level (determined by bloom filtering) into a separate batch, and processing the new batch in parallel with the original batch.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10535
      
      Test Plan:
      1. Ensure existing MultiGet unit tests pass, updating them as necessary
      2. New unit tests - TODO
      3. Run stress test - TODO
      
      No noticeable regression (<1%) without async IO -
      Without PR: `multireadrandom :       7.261 micros/op 1101724 ops/sec 60.007 seconds 66110936 operations;  571.6 MB/s (8168992 of 8168992 found)`
      With PR: `multireadrandom :       7.305 micros/op 1095167 ops/sec 60.007 seconds 65717936 operations;  568.2 MB/s (8271992 of 8271992 found)`
      
      For a fully cached DB, but with async IO option on, no regression observed (<1%) -
      Without PR: `multireadrandom :       5.201 micros/op 1538027 ops/sec 60.005 seconds 92288936 operations;  797.9 MB/s (11540992 of 11540992 found) `
      With PR: `multireadrandom :       5.249 micros/op 1524097 ops/sec 60.005 seconds 91452936 operations;  790.7 MB/s (11649992 of 11649992 found) `
      
      Reviewed By: akankshamahajan15
      
      Differential Revision: D38774009
      
      Pulled By: anand1976
      
      fbshipit-source-id: c955e259749f1c091590ade73105b3ee46cd0007
      35cdd3e7
    • L
      Add support for wide-column point lookups (#10540) · 81388b36
      Levi Tamasi 提交于
      Summary:
      The patch adds a new API `GetEntity` that can be used to perform
      wide-column point lookups. It also extends the `Get` code path and
      the `MemTable` / `MemTableList` and `Version` / `GetContext` logic
      accordingly so that wide-column entities can be served from both
      memtables and SSTs. If the result of a lookup is a wide-column entity
      (`kTypeWideColumnEntity`), it is passed to the application in deserialized
      form; if it is a plain old key-value (`kTypeValue`), it is presented as a
      wide-column entity with a single default (anonymous) column.
      (In contrast, regular `Get` returns plain old key-values as-is, and
      returns the value of the default column for wide-column entities, see
      https://github.com/facebook/rocksdb/issues/10483 .)
      
      The result of `GetEntity` is a self-contained `PinnableWideColumns` object.
      `PinnableWideColumns` contains a `PinnableSlice`, which either stores the
      underlying data in its own buffer or holds on to a cache handle. It also contains
      a `WideColumns` instance, which indexes the contents of the `PinnableSlice`,
      so applications can access the values of columns efficiently.
      
      There are several pieces of functionality which are currently not supported
      for wide-column entities: there is currently no `MultiGetEntity` or wide-column
      iterator; also, `Merge` and `GetMergeOperands` are not supported, and there
      is no `GetEntity` implementation for read-only and secondary instances.
      We plan to implement these in future PRs.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10540
      
      Test Plan: `make check`
      
      Reviewed By: akankshamahajan15
      
      Differential Revision: D38847474
      
      Pulled By: ltamasi
      
      fbshipit-source-id: 42311a34ccdfe88b3775e847a5e2a5296e002b5b
      81388b36
    • A
      Revert "Avoid dynamic memory allocation on read path (#10453)" (#10541) · 2553d1ef
      anand76 提交于
      Summary:
      This reverts commit 0d885e80. The original commit causes a ASAN stack-use-after-return failure due to the `CreateCallback` being allocated on stack and then used in another thread when a secondary cache object is promoted to the primary cache.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10541
      
      Reviewed By: gitbw95
      
      Differential Revision: D38850039
      
      Pulled By: anand1976
      
      fbshipit-source-id: 810c592b7de2523693f5bb267159b23b0ee9132c
      2553d1ef
  6. 19 8月, 2022 2 次提交
    • B
      Fix the memory leak in db_stress tests that are caused by... · 13cb7a84
      Bo Wang 提交于
      Fix the memory leak in db_stress tests that are caused by `FaultInjectionSecondaryCache` and add `CompressedSecondaryCache` into stress tests. (#10523)
      
      Summary:
      1. Fix the memory leak in db_stress tests that are caused by `FaultInjectionSecondaryCache`. To address the test requirements for both CompressedSecondaryCache and CachlibWrapper, a new class variable `base_is_compressed_sec_cache_` is added to determine the different behaviors in `Lookup()` and `WaitAll()`.
      2. Add `CompressedSecondaryCache` into stress tests.
      
      Before this PR, memory leak is reported during crash tests if  `CompressedSecondaryCache` is in stress tests. One example is shown as follows:
      ```
      ==70722==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 6648240 byte(s) in 83103 object(s) allocated from:
          #0 0x13de9d7 in operator new(unsigned long) (/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dbgo/gen/aab7ed39/internal_repo_rocksdb/repo/db_stress+0x13de9d7)
          https://github.com/facebook/rocksdb/issues/1 0x9084c7 in rocksdb::BlocklikeTraits<rocksdb::Block>::Create(rocksdb::BlockContents&&, unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*) internal_repo_rocksdb/repo/table/block_based/block_like_traits.h:128
          https://github.com/facebook/rocksdb/issues/2 0x9084c7 in std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)::operator()(void const*, unsigned long, void**, unsigned long*) const internal_repo_rocksdb/repo/table/block_based/block_like_traits.h:34
          https://github.com/facebook/rocksdb/issues/3 0x9082c9 in rocksdb::Block std::__invoke_impl<rocksdb::Status, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*, unsigned long, void**, unsigned long*>(std::__invoke_other, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*&&, unsigned long&&, void**&&, unsigned long*&&) third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/invoke.h:61
          https://github.com/facebook/rocksdb/issues/4 0x90825d in std::enable_if<is_invocable_r_v<rocksdb::Block, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*, unsigned long, void**, unsigned long*>, rocksdb::Block>::type std::__invoke_r<rocksdb::Status, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*, unsigned long, void**, unsigned long*>(std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*&&, unsigned long&&, void**&&, unsigned long*&&) third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/invoke.h:114
          https://github.com/facebook/rocksdb/issues/5 0x9081b0 in std::_Function_handler<rocksdb::Status (void const*, unsigned long, void**, unsigned long*), std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)>::_M_invoke(std::_Any_data const&, void const*&&, unsigned long&&, void**&&, unsigned long*&&) third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/std_function.h:291
          https://github.com/facebook/rocksdb/issues/6 0x991f2c in std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)>::operator()(void const*, unsigned long, void**, unsigned long*) const third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/std_function.h:560
          https://github.com/facebook/rocksdb/issues/7 0x990277 in rocksdb::CompressedSecondaryCache::Lookup(rocksdb::Slice const&, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, bool, bool&) internal_repo_rocksdb/repo/cache/compressed_secondary_cache.cc:77
          https://github.com/facebook/rocksdb/issues/8 0xd3aa4d in rocksdb::FaultInjectionSecondaryCache::Lookup(rocksdb::Slice const&, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, bool, bool&) internal_repo_rocksdb/repo/utilities/fault_injection_secondary_cache.cc:92
          https://github.com/facebook/rocksdb/issues/9 0xeadaab in rocksdb::lru_cache::LRUCacheShard::Lookup(rocksdb::Slice const&, unsigned int, rocksdb::Cache::CacheItemHelper const*, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, rocksdb::Cache::Priority, bool, rocksdb::Statistics*) internal_repo_rocksdb/repo/cache/lru_cache.cc:445
          https://github.com/facebook/rocksdb/issues/10 0x1064573 in rocksdb::ShardedCache::Lookup(rocksdb::Slice const&, rocksdb::Cache::CacheItemHelper const*, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, rocksdb::Cache::Priority, bool, rocksdb::Statistics*) internal_repo_rocksdb/repo/cache/sharded_cache.cc:89
          https://github.com/facebook/rocksdb/issues/11 0x8be0df in rocksdb::BlockBasedTable::GetEntryFromCache(rocksdb::CacheTier const&, rocksdb::Cache*, rocksdb::Slice const&, rocksdb::BlockType, bool, rocksdb::GetContext*, rocksdb::Cache::CacheItemHelper const*, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, rocksdb::Cache::Priority) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:389
          https://github.com/facebook/rocksdb/issues/12 0x905790 in rocksdb::Status rocksdb::BlockBasedTable::GetDataBlockFromCache<rocksdb::Block>(rocksdb::Slice const&, rocksdb::Cache*, rocksdb::Cache*, rocksdb::ReadOptions const&, rocksdb::CachableEntry<rocksdb::Block>*, rocksdb::UncompressionDict const&, rocksdb::BlockType, bool, rocksdb::GetContext*) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:1263
          https://github.com/facebook/rocksdb/issues/13 0x8b9259 in rocksdb::Status rocksdb::BlockBasedTable::MaybeReadBlockAndLoadToCache<rocksdb::Block>(rocksdb::FilePrefetchBuffer*, rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::UncompressionDict const&, bool, bool, rocksdb::CachableEntry<rocksdb::Block>*, rocksdb::BlockType, rocksdb::GetContext*, rocksdb::BlockCacheLookupContext*, rocksdb::BlockContents*, bool) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:1559
          https://github.com/facebook/rocksdb/issues/14 0x8b710c in rocksdb::Status rocksdb::BlockBasedTable::RetrieveBlock<rocksdb::Block>(rocksdb::FilePrefetchBuffer*, rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::UncompressionDict const&, rocksdb::CachableEntry<rocksdb::Block>*, rocksdb::BlockType, rocksdb::GetContext*, rocksdb::BlockCacheLookupContext*, bool, bool, bool, bool) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:1726
          https://github.com/facebook/rocksdb/issues/15 0x8c329f in rocksdb::DataBlockIter* rocksdb::BlockBasedTable::NewDataBlockIterator<rocksdb::DataBlockIter>(rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::DataBlockIter*, rocksdb::BlockType, rocksdb::GetContext*, rocksdb::BlockCacheLookupContext*, rocksdb::FilePrefetchBuffer*, bool, bool, rocksdb::Status&) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader_impl.h:58
          https://github.com/facebook/rocksdb/issues/16 0x920117 in rocksdb::BlockBasedTableIterator::InitDataBlock() internal_repo_rocksdb/repo/table/block_based/block_based_table_iterator.cc:262
          https://github.com/facebook/rocksdb/issues/17 0x920d42 in rocksdb::BlockBasedTableIterator::MaterializeCurrentBlock() internal_repo_rocksdb/repo/table/block_based/block_based_table_iterator.cc:332
          https://github.com/facebook/rocksdb/issues/18 0xc6a201 in rocksdb::IteratorWrapperBase<rocksdb::Slice>::PrepareValue() internal_repo_rocksdb/repo/table/iterator_wrapper.h:78
          https://github.com/facebook/rocksdb/issues/19 0xc6a201 in rocksdb::IteratorWrapperBase<rocksdb::Slice>::PrepareValue() internal_repo_rocksdb/repo/table/iterator_wrapper.h:78
          https://github.com/facebook/rocksdb/issues/20 0xef9f6c in rocksdb::MergingIterator::PrepareValue() internal_repo_rocksdb/repo/table/merging_iterator.cc:260
          https://github.com/facebook/rocksdb/issues/21 0xc6a201 in rocksdb::IteratorWrapperBase<rocksdb::Slice>::PrepareValue() internal_repo_rocksdb/repo/table/iterator_wrapper.h:78
          https://github.com/facebook/rocksdb/issues/22 0xc67bcd in rocksdb::DBIter::FindNextUserEntryInternal(bool, rocksdb::Slice const*) internal_repo_rocksdb/repo/db/db_iter.cc:326
          https://github.com/facebook/rocksdb/issues/23 0xc66d36 in rocksdb::DBIter::FindNextUserEntry(bool, rocksdb::Slice const*) internal_repo_rocksdb/repo/db/db_iter.cc:234
          https://github.com/facebook/rocksdb/issues/24 0xc7ab47 in rocksdb::DBIter::Next() internal_repo_rocksdb/repo/db/db_iter.cc:161
          https://github.com/facebook/rocksdb/issues/25 0x70d938 in rocksdb::BatchedOpsStressTest::TestPrefixScan(rocksdb::ThreadState*, rocksdb::ReadOptions const&, std::vector<int, std::allocator<int> > const&, std::vector<long, std::allocator<long> > const&) internal_repo_rocksdb/repo/db_stress_tool/batched_ops_stress.cc:320
          https://github.com/facebook/rocksdb/issues/26 0x6dc6a8 in rocksdb::StressTest::OperateDb(rocksdb::ThreadState*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_test_base.cc:907
          https://github.com/facebook/rocksdb/issues/27 0x6867de in rocksdb::ThreadBody(void*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_driver.cc:33
          https://github.com/facebook/rocksdb/issues/28 0xce4cc2 in rocksdb::(anonymous namespace)::StartThreadWrapper(void*) internal_repo_rocksdb/repo/env/env_posix.cc:461
          https://github.com/facebook/rocksdb/issues/29 0x7f23f9068c0e in start_thread /home/engshare/third-party2/glibc/2.34/src/glibc-2.34/nptl/pthread_create.c:434:8
      ```
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10523
      
      Test Plan:
      ```
      $COMPILE_WITH_ASAN=1  make -j 24
      $db_stress J=40 crash_test_with_txn
      ```
      
      Reviewed By: anand1976
      
      Differential Revision: D38646839
      
      Pulled By: gitbw95
      
      fbshipit-source-id: 9452895c7dc95481a9d7afe83b15193cf5b1c43e
      13cb7a84
    • A
      Add initial_auto_readahead_size and max_auto_readahead_size to db_bench (#10539) · 5956ef00
      Akanksha Mahajan 提交于
      Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/10539
      
      Reviewed By: anand1976
      
      Differential Revision: D38837111
      
      Pulled By: akankshamahajan15
      
      fbshipit-source-id: eb845c6e15a3c823ff6113395817388ff15a20b1
      5956ef00
  7. 18 8月, 2022 2 次提交
    • A
      Prevent a case of WriteBufferManager flush thrashing (#6364) · 91166012
      Andrew Kryczka 提交于
      Summary:
      Previously, the flushes triggered by `WriteBufferManager` could affect
      the same CF repeatedly if it happens to get consecutive writes. Such
      flushes are not particularly useful for reducing memory usage since
      they switch nearly-empty memtables to immutable while they've just begun
      filling their first arena block. In fact they may not even reduce the
      mutable memory count if they involve replacing one mutable memtable containing
      one arena block with a new mutable memtable containing one arena block.
      Further, if such switches happen even a few times before a flush finishes,
      the immutable memtable limit will be reached and writes will stall.
      
      This PR adds a heuristic to not switch memtables to immutable for CFs
      that already have one or more immutable memtables awaiting flush. There
      is a memory usage regression if the user continues writing to the same
      CF, that DB does not have any CFs eligible for switching, flushes
      are not finishing, and the `WriteBufferManager` was constructed with
      `allow_stall=false`. Before, it would grow by switching nearly empty
      memtables until writes stall. Now, it would grow by filling memtables
      until writes stall. This feels like an acceptable behavior change because
      users who prefer to stall over violate the memory limit should be using
      `allow_stall=true`, which is unaffected by this PR.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/6364
      
      Test Plan:
      - Command:
      
      `rm -rf /dev/shm/dbbench/ && TEST_TMPDIR=/dev/shm ./db_bench -benchmarks=fillrandom -num_multi_db=8 -num_column_families=2 -write_buffer_size=4194304 -db_write_buffer_size=16777216 -compression_type=none -statistics=true -target_file_size_base=4194304 -max_bytes_for_level_base=16777216`
      
      - `rocksdb.db.write.stall` count before this PR: 175
      - `rocksdb.db.write.stall` count after this PR: 0
      
      Reviewed By: jay-zhuang
      
      Differential Revision: D20167197
      
      Pulled By: ajkr
      
      fbshipit-source-id: 4a64064e9bc33d57c0a35f15547542d0191d0cb7
      91166012
    • A
      Fix range deletion handling in async MultiGet (#10534) · 65814a4a
      anand76 提交于
      Summary:
      The fix in https://github.com/facebook/rocksdb/issues/10513 was not complete w.r.t range deletion handling. It didn't handle the case where a file with a range tombstone covering a key also overlapped another key in the batch. In that case, ```mget_range``` would be non-empty. However, ```mget_range``` would only have the second key and, therefore, the first key would be skipped when iterating through the range tombstones in ```TableCache::MultiGet```.
      
      Test plan -
      1. Add a unit test
      2. Run stress tests
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10534
      
      Reviewed By: akankshamahajan15
      
      Differential Revision: D38773880
      
      Pulled By: anand1976
      
      fbshipit-source-id: dae491dbe52e18bbce5179b77b63f20771a66c00
      65814a4a
  8. 13 8月, 2022 5 次提交
    • G
      Add a blob-specific cache priority (#10461) · 275cd80c
      Gang Liao 提交于
      Summary:
      RocksDB's `Cache` abstraction currently supports two priority levels for items: high (used for frequently accessed/highly valuable SST metablocks like index/filter blocks) and low (used for SST data blocks). Blobs are typically lower-value targets for caching than data blocks, since 1) with BlobDB, data blocks containing blob references conceptually form an index structure which has to be consulted before we can read the blob value, and 2) cached blobs represent only a single key-value, while cached data blocks generally contain multiple KVs. Since we would like to make it possible to use the same backing cache for the block cache and the blob cache, it would make sense to add a new, lower-than-low cache priority level (bottom level) for blobs so data blocks are prioritized over them.
      
      This task is a part of https://github.com/facebook/rocksdb/issues/10156
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10461
      
      Reviewed By: siying
      
      Differential Revision: D38672823
      
      Pulled By: ltamasi
      
      fbshipit-source-id: 90cf7362036563d79891f47be2cc24b827482743
      275cd80c
    • S
      Fix two extra headers (#10525) · bc575c61
      sdong 提交于
      Summary:
      Fix copyright for two more extra headers to make internal tool happy.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10525
      
      Reviewed By: jay-zhuang
      
      Differential Revision: D38661390
      
      fbshipit-source-id: ab2d055bfd145dfe82b5bae7a6c25cc338c8de94
      bc575c61
    • C
      Add memtable per key-value checksum (#10281) · fd165c86
      Changyu Bi 提交于
      Summary:
      Append per key-value checksum to internal key. These checksums are verified on read paths including Get, Iterator and during Flush. Get and Iterator will return `Corruption` status if there is a checksum verification failure. Flush will make DB become read-only upon memtable entry checksum verification failure.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10281
      
      Test Plan:
      - Added new unit test cases: `make check`
      - Benchmark on memtable insert
      ```
      TEST_TMPDIR=/dev/shm/memtable_write ./db_bench -benchmarks=fillseq -disable_wal=true -max_write_buffer_number=100 -num=10000000 -min_write_buffer_number_to_merge=100
      
      # avg over 10 runs
      Baseline: 1166936 ops/sec
      memtable 2 bytes kv checksum : 1.11674e+06 ops/sec (-4%)
      memtable 2 bytes kv checksum + write batch 8 bytes kv checksum: 1.08579e+06 ops/sec (-6.95%)
      write batch 8 bytes kv checksum: 1.17979e+06 ops/sec (+1.1%)
      ```
      -  Benchmark on only memtable read: ops/sec dropped 31% for `readseq` due to time spend on verifying checksum.
      ops/sec for `readrandom` dropped ~6.8%.
      ```
      # Readseq
      sudo TEST_TMPDIR=/dev/shm/memtable_read ./db_bench -benchmarks=fillseq,readseq"[-X20]" -disable_wal=true -max_write_buffer_number=100 -num=10000000 -min_write_buffer_number_to_merge=100
      
      readseq [AVG    20 runs] : 7432840 (± 212005) ops/sec;  822.3 (± 23.5) MB/sec
      readseq [MEDIAN 20 runs] : 7573878 ops/sec;  837.9 MB/sec
      
      With -memtable_protection_bytes_per_key=2:
      
      readseq [AVG    20 runs] : 5134607 (± 119596) ops/sec;  568.0 (± 13.2) MB/sec
      readseq [MEDIAN 20 runs] : 5232946 ops/sec;  578.9 MB/sec
      
      # Readrandom
      sudo TEST_TMPDIR=/dev/shm/memtable_read ./db_bench -benchmarks=fillrandom,readrandom"[-X10]" -disable_wal=true -max_write_buffer_number=100 -num=1000000 -min_write_buffer_number_to_merge=100
      readrandom [AVG    10 runs] : 140236 (± 3938) ops/sec;    9.8 (± 0.3) MB/sec
      readrandom [MEDIAN 10 runs] : 140545 ops/sec;    9.8 MB/sec
      
      With -memtable_protection_bytes_per_key=2:
      readrandom [AVG    10 runs] : 130632 (± 2738) ops/sec;    9.1 (± 0.2) MB/sec
      readrandom [MEDIAN 10 runs] : 130341 ops/sec;    9.1 MB/sec
      ```
      
      - Stress test: `python3 -u tools/db_crashtest.py whitebox --duration=1800`
      
      Reviewed By: ajkr
      
      Differential Revision: D37607896
      
      Pulled By: cbi42
      
      fbshipit-source-id: fdaefb475629d2471780d4a5f5bf81b44ee56113
      fd165c86
    • P
      Derive cache keys from SST unique IDs (#10394) · 86a1e3e0
      Peter Dillinger 提交于
      Summary:
      ... so that cache keys can be derived from DB manifest data
      before reading the file from storage--so that every part of the file
      can potentially go in a persistent cache.
      
      See updated comments in cache_key.cc for technical details. Importantly,
      the new cache key encoding uses some fancy but efficient math to pack
      data into the cache key without depending on the sizes of the various
      pieces. This simplifies some existing code creating cache keys, like
      cache warming before the file size is known.
      
      This should provide us an essentially permanent mapping between SST
      unique IDs and base cache keys, with the ability to "upgrade" SST
      unique IDs (and thus cache keys) with new SST format_versions.
      
      These cache keys are of similar, perhaps indistinguishable quality to
      the previous generation. Before this change (see "corrected" days
      between collision):
      
      ```
      ./cache_bench -stress_cache_key -sck_keep_bits=43
      18 collisions after 2 x 90 days, est 10 days between (1.15292e+19 corrected)
      ```
      
      After this change (keep 43 bits, up through 50, to validate "trajectory"
      is ok on "corrected" days between collision):
      ```
      19 collisions after 3 x 90 days, est 14.2105 days between (1.63836e+19 corrected)
      16 collisions after 5 x 90 days, est 28.125 days between (1.6213e+19 corrected)
      15 collisions after 7 x 90 days, est 42 days between (1.21057e+19 corrected)
      15 collisions after 17 x 90 days, est 102 days between (1.46997e+19 corrected)
      15 collisions after 49 x 90 days, est 294 days between (2.11849e+19 corrected)
      15 collisions after 62 x 90 days, est 372 days between (1.34027e+19 corrected)
      15 collisions after 53 x 90 days, est 318 days between (5.72858e+18 corrected)
      15 collisions after 309 x 90 days, est 1854 days between (1.66994e+19 corrected)
      ```
      
      However, the change does modify (probably weaken) the "guaranteed unique" promise from this
      
      > SST files generated in a single process are guaranteed to have unique cache keys, unless/until number session ids * max file number = 2**86
      
      to this (see https://github.com/facebook/rocksdb/issues/10388)
      
      > With the DB id limitation, we only have nice guaranteed unique cache keys for files generated in a single process until biggest session_id_counter and offset_in_file reach combined 64 bits
      
      I don't think this is a practical concern, though.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10394
      
      Test Plan: unit tests updated, see simulation results above
      
      Reviewed By: jay-zhuang
      
      Differential Revision: D38667529
      
      Pulled By: pdillinger
      
      fbshipit-source-id: 49af3fe7f47e5b61162809a78b76c769fd519fba
      86a1e3e0
    • P
      LOG more info on oldest snapshot and sequence numbers (#10454) · 9fa5c146
      Peter Dillinger 提交于
      Summary:
      The info LOG file does not currently give any direct
      information about the existence of old, live snapshots, nor how to
      estimate wall time from a sequence number within the scope of LOG
      history. This change addresses both with:
      * Logging smallest and largest seqnos for generated SST files, which can
      help associate sequence numbers with write time (based on flushes).
      * Logging oldest_snapshot_seqno for each compaction, which (along with
      that seqno info) helps us to determine how much old data might be kept
      around for old (leaked?) snapshots. Including the date here I thought might
      be excessive.
      
      I wanted to log the date and seqno of the oldest snapshot with periodic
      stats, but the current structure of the code doesn't really support that
      because `DumpDBStats` doesn't have access to the DB object.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10454
      
      Test Plan:
      manual inspect LOG from
      `KEEP_DB=1 ./db_basic_test --gtest_filter=*CompactBetweenSnapshots*`
      
      Reviewed By: ajkr
      
      Differential Revision: D38326948
      
      Pulled By: pdillinger
      
      fbshipit-source-id: 294918ffc04a419844146cd826045321b4d5c038
      9fa5c146
  9. 12 8月, 2022 5 次提交
  10. 11 8月, 2022 3 次提交
    • J
      Migrate to docker for CI run (#10496) · 5d3aefb6
      Jay Zhuang 提交于
      Summary:
      Moved linux builds to using docker to avoid CI instability caused by dependency installation site down.
      Added the `Dockerfile` which is used to build the image.
      The build time is also significantly reduced, because no dependencies installation and with using 2xlarge+ instance for slow build (like tsan test).
      Also fixed a few issues detected while building this:
      * `DestoryDB()` Status not checked for a few tests
      * nullptr might be used in `inlineskiplist.cc`
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10496
      
      Test Plan: CI
      
      Reviewed By: ajkr
      
      Differential Revision: D38554200
      
      Pulled By: jay-zhuang
      
      fbshipit-source-id: 16e8fb2bf07b9c84bb27fb18421c4d54f2f248fd
      5d3aefb6
    • G
      Enable ClockCache in DB block cache test (#10482) · a0798f6f
      Guido Tagliavini Ponce 提交于
      Summary:
      A test in db_block_cache_test.cc was skipping ClockCache due to the 16-byte key length requirement. We fixed this. Along the way, we fixed a bug in ApplyToSomeEntries, which assumed the function being applied could modify handle metadata, and thus took an exclusive reference. This is incompatible with calls that need to inspect every element (including externally referenced ones) to gather stats.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10482
      
      Test Plan: ``make -j24 check``
      
      Reviewed By: anand1976
      
      Differential Revision: D38553073
      
      Pulled By: guidotag
      
      fbshipit-source-id: 0ed63fed4d3b89e5056b35b7091fce579f5647ae
      a0798f6f
    • S
      WritableFileWriter tries to skip operations after failure (#10489) · 911c0208
      sdong 提交于
      Summary:
      A flag in WritableFileWriter is introduced to remember error has happened. Subsequent operations will fail with an assertion. Those operations, except Close() are not supposed to be called anyway. This change will help catch bug in tests and stress tests and limit damage of a potential bug of continue writing to a file after a failure.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10489
      
      Test Plan: Fix existing unit tests and watch crash tests for a while.
      
      Reviewed By: anand1976
      
      Differential Revision: D38473277
      
      fbshipit-source-id: 09aafb971e56cfd7f9ef92ad15b883f54acf1366
      911c0208
  11. 10 8月, 2022 5 次提交
    • G
      Revert "Add CompressedSecondaryCache into stress test" #10442 (#10509) · b57155a0
      gitbw95 提交于
      Summary:
      Revert https://github.com/facebook/rocksdb/pull/10442 before I find the root cause and fix the memory leak in db_stress tests that are caused by `FaultInjectionSecondaryCache`.
      
      Memory leak is reported during crash tests and one example is shown as follows:
      ```
      ==70722==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 6648240 byte(s) in 83103 object(s) allocated from:
          #0 0x13de9d7 in operator new(unsigned long) (/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dbgo/gen/aab7ed39/internal_repo_rocksdb/repo/db_stress+0x13de9d7)
          https://github.com/facebook/rocksdb/issues/1 0x9084c7 in rocksdb::BlocklikeTraits<rocksdb::Block>::Create(rocksdb::BlockContents&&, unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*) internal_repo_rocksdb/repo/table/block_based/block_like_traits.h:128
          https://github.com/facebook/rocksdb/issues/2 0x9084c7 in std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)::operator()(void const*, unsigned long, void**, unsigned long*) const internal_repo_rocksdb/repo/table/block_based/block_like_traits.h:34
          https://github.com/facebook/rocksdb/issues/3 0x9082c9 in rocksdb::Block std::__invoke_impl<rocksdb::Status, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*, unsigned long, void**, unsigned long*>(std::__invoke_other, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*&&, unsigned long&&, void**&&, unsigned long*&&) third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/invoke.h:61
          https://github.com/facebook/rocksdb/issues/4 0x90825d in std::enable_if<is_invocable_r_v<rocksdb::Block, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*, unsigned long, void**, unsigned long*>, rocksdb::Block>::type std::__invoke_r<rocksdb::Status, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*, unsigned long, void**, unsigned long*>(std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)&, void const*&&, unsigned long&&, void**&&, unsigned long*&&) third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/invoke.h:114
          https://github.com/facebook/rocksdb/issues/5 0x9081b0 in std::_Function_handler<rocksdb::Status (void const*, unsigned long, void**, unsigned long*), std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> rocksdb::GetCreateCallback<rocksdb::Block>(unsigned long, rocksdb::Statistics*, bool, rocksdb::FilterPolicy const*)::'lambda'(void const*, unsigned long, void**, unsigned long*)>::_M_invoke(std::_Any_data const&, void const*&&, unsigned long&&, void**&&, unsigned long*&&) third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/std_function.h:291
          https://github.com/facebook/rocksdb/issues/6 0x991f2c in std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)>::operator()(void const*, unsigned long, void**, unsigned long*) const third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/std_function.h:560
          https://github.com/facebook/rocksdb/issues/7 0x990277 in rocksdb::CompressedSecondaryCache::Lookup(rocksdb::Slice const&, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, bool, bool&) internal_repo_rocksdb/repo/cache/compressed_secondary_cache.cc:77
          https://github.com/facebook/rocksdb/issues/8 0xd3aa4d in rocksdb::FaultInjectionSecondaryCache::Lookup(rocksdb::Slice const&, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, bool, bool&) internal_repo_rocksdb/repo/utilities/fault_injection_secondary_cache.cc:92
          https://github.com/facebook/rocksdb/issues/9 0xeadaab in rocksdb::lru_cache::LRUCacheShard::Lookup(rocksdb::Slice const&, unsigned int, rocksdb::Cache::CacheItemHelper const*, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, rocksdb::Cache::Priority, bool, rocksdb::Statistics*) internal_repo_rocksdb/repo/cache/lru_cache.cc:445
          https://github.com/facebook/rocksdb/issues/10 0x1064573 in rocksdb::ShardedCache::Lookup(rocksdb::Slice const&, rocksdb::Cache::CacheItemHelper const*, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, rocksdb::Cache::Priority, bool, rocksdb::Statistics*) internal_repo_rocksdb/repo/cache/sharded_cache.cc:89
          https://github.com/facebook/rocksdb/issues/11 0x8be0df in rocksdb::BlockBasedTable::GetEntryFromCache(rocksdb::CacheTier const&, rocksdb::Cache*, rocksdb::Slice const&, rocksdb::BlockType, bool, rocksdb::GetContext*, rocksdb::Cache::CacheItemHelper const*, std::function<rocksdb::Status (void const*, unsigned long, void**, unsigned long*)> const&, rocksdb::Cache::Priority) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:389
          https://github.com/facebook/rocksdb/issues/12 0x905790 in rocksdb::Status rocksdb::BlockBasedTable::GetDataBlockFromCache<rocksdb::Block>(rocksdb::Slice const&, rocksdb::Cache*, rocksdb::Cache*, rocksdb::ReadOptions const&, rocksdb::CachableEntry<rocksdb::Block>*, rocksdb::UncompressionDict const&, rocksdb::BlockType, bool, rocksdb::GetContext*) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:1263
          https://github.com/facebook/rocksdb/issues/13 0x8b9259 in rocksdb::Status rocksdb::BlockBasedTable::MaybeReadBlockAndLoadToCache<rocksdb::Block>(rocksdb::FilePrefetchBuffer*, rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::UncompressionDict const&, bool, bool, rocksdb::CachableEntry<rocksdb::Block>*, rocksdb::BlockType, rocksdb::GetContext*, rocksdb::BlockCacheLookupContext*, rocksdb::BlockContents*, bool) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:1559
          https://github.com/facebook/rocksdb/issues/14 0x8b710c in rocksdb::Status rocksdb::BlockBasedTable::RetrieveBlock<rocksdb::Block>(rocksdb::FilePrefetchBuffer*, rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::UncompressionDict const&, rocksdb::CachableEntry<rocksdb::Block>*, rocksdb::BlockType, rocksdb::GetContext*, rocksdb::BlockCacheLookupContext*, bool, bool, bool, bool) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader.cc:1726
          https://github.com/facebook/rocksdb/issues/15 0x8c329f in rocksdb::DataBlockIter* rocksdb::BlockBasedTable::NewDataBlockIterator<rocksdb::DataBlockIter>(rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::DataBlockIter*, rocksdb::BlockType, rocksdb::GetContext*, rocksdb::BlockCacheLookupContext*, rocksdb::FilePrefetchBuffer*, bool, bool, rocksdb::Status&) const internal_repo_rocksdb/repo/table/block_based/block_based_table_reader_impl.h:58
          https://github.com/facebook/rocksdb/issues/16 0x920117 in rocksdb::BlockBasedTableIterator::InitDataBlock() internal_repo_rocksdb/repo/table/block_based/block_based_table_iterator.cc:262
          https://github.com/facebook/rocksdb/issues/17 0x920d42 in rocksdb::BlockBasedTableIterator::MaterializeCurrentBlock() internal_repo_rocksdb/repo/table/block_based/block_based_table_iterator.cc:332
          https://github.com/facebook/rocksdb/issues/18 0xc6a201 in rocksdb::IteratorWrapperBase<rocksdb::Slice>::PrepareValue() internal_repo_rocksdb/repo/table/iterator_wrapper.h:78
          https://github.com/facebook/rocksdb/issues/19 0xc6a201 in rocksdb::IteratorWrapperBase<rocksdb::Slice>::PrepareValue() internal_repo_rocksdb/repo/table/iterator_wrapper.h:78
          https://github.com/facebook/rocksdb/issues/20 0xef9f6c in rocksdb::MergingIterator::PrepareValue() internal_repo_rocksdb/repo/table/merging_iterator.cc:260
          https://github.com/facebook/rocksdb/issues/21 0xc6a201 in rocksdb::IteratorWrapperBase<rocksdb::Slice>::PrepareValue() internal_repo_rocksdb/repo/table/iterator_wrapper.h:78
          https://github.com/facebook/rocksdb/issues/22 0xc67bcd in rocksdb::DBIter::FindNextUserEntryInternal(bool, rocksdb::Slice const*) internal_repo_rocksdb/repo/db/db_iter.cc:326
          https://github.com/facebook/rocksdb/issues/23 0xc66d36 in rocksdb::DBIter::FindNextUserEntry(bool, rocksdb::Slice const*) internal_repo_rocksdb/repo/db/db_iter.cc:234
          https://github.com/facebook/rocksdb/issues/24 0xc7ab47 in rocksdb::DBIter::Next() internal_repo_rocksdb/repo/db/db_iter.cc:161
          https://github.com/facebook/rocksdb/issues/25 0x70d938 in rocksdb::BatchedOpsStressTest::TestPrefixScan(rocksdb::ThreadState*, rocksdb::ReadOptions const&, std::vector<int, std::allocator<int> > const&, std::vector<long, std::allocator<long> > const&) internal_repo_rocksdb/repo/db_stress_tool/batched_ops_stress.cc:320
          https://github.com/facebook/rocksdb/issues/26 0x6dc6a8 in rocksdb::StressTest::OperateDb(rocksdb::ThreadState*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_test_base.cc:907
          https://github.com/facebook/rocksdb/issues/27 0x6867de in rocksdb::ThreadBody(void*) internal_repo_rocksdb/repo/db_stress_tool/db_stress_driver.cc:33
          https://github.com/facebook/rocksdb/issues/28 0xce4cc2 in rocksdb::(anonymous namespace)::StartThreadWrapper(void*) internal_repo_rocksdb/repo/env/env_posix.cc:461
          https://github.com/facebook/rocksdb/issues/29 0x7f23f9068c0e in start_thread /home/engshare/third-party2/glibc/2.34/src/glibc-2.34/nptl/pthread_create.c:434:8
      ```
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10509
      
      Test Plan:
      ```
      $COMPILE_WITH_ASAN=1  make -j 24
      $db_stress J=40 crash_test_with_txn
      ```
      
      Reviewed By: siying
      
      Differential Revision: D38540648
      
      Pulled By: gitbw95
      
      fbshipit-source-id: 703948e3a7ba40828a6445d00f3e73c184e34bf7
      b57155a0
    • Y
      Include minimal contextual information in `CompactionIterator` (#10505) · fee2c472
      Yanqin Jin 提交于
      Summary:
      The main purpose is to make debugging easier without sacrificing performance.
      
      Instead of using a boolean variable for `CompactionIterator::valid_`, we can extend it to an `uint8_t`,
      using the LSB to denote if the compaction iterator is valid and 4 additional bits to denote where
      the iterator is set valid inside `NextFromInput()`. Therefore, when the control flow reaches
      `PrepareOutput()` and hits assertion there, we can have a better idea of what has gone wrong.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10505
      
      Test Plan:
      make check
      ```
      TEST_TMPDIR=/dev/shm/rocksdb time ./db_bench -compression_type=none -write_buffer_size=1073741824 -benchmarks=fillseq,flush
      ```
      The above command has a 'flush' benchmark which uses `CompactionIterator`.  I haven't observed any CPU regression or drop in throughput or latency increase.
      
      Reviewed By: ltamasi
      
      Differential Revision: D38551615
      
      Pulled By: riversand963
      
      fbshipit-source-id: 1250848fc118bb753d71fa9ff8ba840df999f5e0
      fee2c472
    • G
      Fix the segdefault bug in CompressedSecondaryCache and its tests (#10507) · f060b47e
      gitbw95 提交于
      Summary:
      This fix is to replace `AllocateBlock()` with `new`. Once I figure out why `AllocateBlock()` might cause the segfault, I will update the implementation.
      
      Fix the bug that causes ./compressed_secondary_cache_test output following test failures:
      
      ```
      Note: Google Test filter = CompressedSecondaryCacheTest.MergeChunksIntoValueTest
      [==========] Running 1 test from 1 test case.
      [----------] Global test environment set-up.
      [----------] 1 test from CompressedSecondaryCacheTest
      [ RUN      ] CompressedSecondaryCacheTest.MergeChunksIntoValueTest
      [       OK ] CompressedSecondaryCacheTest.MergeChunksIntoValueTest (1 ms)
      [----------] 1 test from CompressedSecondaryCacheTest (1 ms total)
      
      [----------] Global test environment tear-down
      [==========] 1 test from 1 test case ran. (9 ms total)
      [  PASSED  ] 1 test.
      t/run-compressed_secondary_cache_test-CompressedSecondaryCacheTest.MergeChunksIntoValueTest: line 4: 1091086 Segmentation fault      (core dumped) TEST_TMPDIR=$d ./compressed_secondary_cache_test --gtest_filter=CompressedSecondaryCacheTest.MergeChunksIntoValueTest
      Note: Google Test filter = CompressedSecondaryCacheTest.BasicTestWithMemoryAllocatorAndCompression
      [==========] Running 1 test from 1 test case.
      [----------] Global test environment set-up.
      [----------] 1 test from CompressedSecondaryCacheTest
      [ RUN      ] CompressedSecondaryCacheTest.BasicTestWithMemoryAllocatorAndCompression
      [       OK ] CompressedSecondaryCacheTest.BasicTestWithMemoryAllocatorAndCompression (1 ms)
      [----------] 1 test from CompressedSecondaryCacheTest (1 ms total)
      
      [----------] Global test environment tear-down
      [==========] 1 test from 1 test case ran. (2 ms total)
      [  PASSED  ] 1 test.
      t/run-compressed_secondary_cache_test-CompressedSecondaryCacheTest.BasicTestWithMemoryAllocatorAndCompression: line 4: 1090883 Segmentation fault      (core dumped) TEST_TMPDIR=$d ./compressed_secondary_cache_test --gtest_filter=CompressedSecondaryCacheTest.BasicTestWithMemoryAllocatorAndCompression
      
      ```
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10507
      
      Test Plan:
      Test 1:
      ```
      $make -j 24
      $./compressed_secondary_cache_test
      ```
      Test 2:
      ```
      $COMPILE_WITH_ASAN=1  make -j 24
      $./compressed_secondary_cache_test
      ```
      Test 3:
      ```
      $COMPILE_WITH_TSAN=1 make -j 24
      $./compressed_secondary_cache_test
      ```
      
      Reviewed By: anand1976
      
      Differential Revision: D38529885
      
      Pulled By: gitbw95
      
      fbshipit-source-id: d903fa3fadbd4d29f9528728c63a4f61c4396890
      f060b47e
    • A
      Fix MultiGet range deletion handling and a memory leak (#10513) · 0b02960d
      anand76 提交于
      Summary:
      This PR fixes 2 bugs introduced in https://github.com/facebook/rocksdb/issues/10432 -
      1. If the bloom filter returned a negative result for all MultiGet keys in a file, the range tombstones in that file were being ignored, resulting in incorrect results if those tombstones covered a key in a higher level.
      2. If all the keys in a file were filtered out in `TableCache::MultiGetFilter`, the table cache handle was not being released.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10513
      
      Test Plan: Add a new unit test that fails without this fix
      
      Reviewed By: akankshamahajan15
      
      Differential Revision: D38548739
      
      Pulled By: anand1976
      
      fbshipit-source-id: a741a1e25d2e991d63f038100f126c2dc404a87c
      0b02960d
    • L
      Reset blob value as soon as it's not needed in DBIter (#10490) · 06b04127
      Levi Tamasi 提交于
      Summary:
      We have recently added caching support to BlobDB, and separately,
      implemented an optimization where reading blobs from the cache
      results in the cache handle being transferred to the target `PinnableSlice`
      (as opposed to the contents getting copied). With these changes,
      it makes sense to reset the `PinnableSlice` storing the blob value in
      `DBIter` as soon as we move to a different iterator position to prevent
      us from holding on to the cache handle any longer than necessary.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10490
      
      Test Plan: `make check`
      
      Reviewed By: akankshamahajan15
      
      Differential Revision: D38473630
      
      Pulled By: ltamasi
      
      fbshipit-source-id: 84c045ffac76436c6152fd0f5775b007f4051386
      06b04127
  12. 09 8月, 2022 7 次提交
  13. 08 8月, 2022 1 次提交
  14. 06 8月, 2022 2 次提交
    • B
      Remove local static string (#8103) · e446bc65
      Burton Li 提交于
      Summary:
      Local static string is not friendly to Jemalloc arena aware implementation, as it will be allocated on the arena of the first caller, which causes crash if the allocated arena gets refunded earlier.
      
      P.S. A Jemalloc arena aware implementation is each rocksdb instance only use certain Jemalloc arenas, and arena will be refunded after associated DB instance is destroyed.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/8103
      
      Reviewed By: ajkr
      
      Differential Revision: D38477235
      
      Pulled By: ltamasi
      
      fbshipit-source-id: a58d32cb647ed64c144b4736fb2d5db27c2c28f9
      e446bc65
    • A
      Close the Logger before rolling to next one in AutoRollLogger (#10488) · ce370d6b
      Akanksha Mahajan 提交于
      Summary:
      Close the existing logger first to release the existing
      handle before renaming the file using the file system.
      Since `AutoRollLogger::Flush` pinned down the `logger_`, `logger_` can't be closed unless its
      the last reference otherwise it  gives seg fault during Flush on file
      that has been closed.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10488
      
      Test Plan: CircleCI jobs
      
      Reviewed By: ajkr
      
      Differential Revision: D38469249
      
      Pulled By: akankshamahajan15
      
      fbshipit-source-id: dfbdb89b4ac37639aefcc503526f24753445fd3f
      ce370d6b