Fix unittest no space issue (#8204)

Summary:
Unittest reports no space from time to time, which can be reproduced on a small memory machine with SHM. It's caused by large WAL files generated during the test, which is preallocated, but didn't truncate during close(). Adding the missing APIs to set preallocation.
It added arm test as nightly build, as the test runs more than 1 hour.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8204

Test Plan: test on small memory arm machine

Reviewed By: mrambacher

Differential Revision: D27873145

Pulled By: jay-zhuang

fbshipit-source-id: f797c429d6bc13cbcc673bc03fcc72adda55f506
main
Jay Zhuang 4 years ago committed by Facebook GitHub Bot
parent a345b4d60d
commit a89740fbc6
  1. 12
      .circleci/config.yml
  2. 12
      db/db_test_util.h
  3. 11
      env/env_encryption.cc
  4. 5
      include/rocksdb/env_encryption.h

@ -572,6 +572,16 @@ jobs:
gtest-parallel $(</tmp/test_list) --output_dir=/tmp | cat # pipe to cat to continuously output status on circleci UI. Otherwise, no status will be printed while the job is running. gtest-parallel $(</tmp/test_list) --output_dir=/tmp | cat # pipe to cat to continuously output status on circleci UI. Otherwise, no status will be printed while the job is running.
- post-steps - post-steps
build-linux-arm-test-full:
machine:
image: ubuntu-2004:202101-01
resource_class: arm.large
steps:
- pre-steps
- install-gflags
- run: make V=1 J=4 -j4 check | .circleci/cat_ignore_eagain
- post-steps
build-linux-arm: build-linux-arm:
machine: machine:
image: ubuntu-2004:202101-01 image: ubuntu-2004:202101-01
@ -612,6 +622,7 @@ jobs:
cd build cd build
cmake -DJNI=1 -DCMAKE_BUILD_TYPE=Release -DWITH_GFLAGS=0 .. cmake -DJNI=1 -DCMAKE_BUILD_TYPE=Release -DWITH_GFLAGS=0 ..
make -j4 rocksdb rocksdbjni make -j4 rocksdb rocksdbjni
- post-steps
build-format-compatible: build-format-compatible:
machine: machine:
@ -746,3 +757,4 @@ workflows:
- master - master
jobs: jobs:
- build-format-compatible - build-format-compatible
- build-linux-arm-test-full

@ -378,14 +378,20 @@ class SpecialEnv : public EnvWrapper {
return Append(data); return Append(data);
} }
Status Truncate(uint64_t size) override { return base_->Truncate(size); } Status Truncate(uint64_t size) override { return base_->Truncate(size); }
void PrepareWrite(size_t offset, size_t len) override {
base_->PrepareWrite(offset, len);
}
void SetPreallocationBlockSize(size_t size) override {
base_->SetPreallocationBlockSize(size);
}
Status Close() override { Status Close() override {
// SyncPoint is not supported in Released Windows Mode. // SyncPoint is not supported in Released Windows Mode.
#if !(defined NDEBUG) || !defined(OS_WIN) #if !(defined NDEBUG) || !defined(OS_WIN)
// Check preallocation size // Check preallocation size
// preallocation size is never passed to base file. size_t block_size, last_allocated_block;
size_t preallocation_size = preallocation_block_size(); base_->GetPreallocationStatus(&block_size, &last_allocated_block);
TEST_SYNC_POINT_CALLBACK("DBTestWalFile.GetPreallocationStatus", TEST_SYNC_POINT_CALLBACK("DBTestWalFile.GetPreallocationStatus",
&preallocation_size); &block_size);
#endif // !(defined NDEBUG) || !defined(OS_WIN) #endif // !(defined NDEBUG) || !defined(OS_WIN)
return base_->Close(); return base_->Close();

@ -362,6 +362,17 @@ void EncryptedWritableFile::PrepareWrite(size_t offset, size_t len,
file_->PrepareWrite(offset + prefixLength_, len, options, dbg); file_->PrepareWrite(offset + prefixLength_, len, options, dbg);
} }
void EncryptedWritableFile::SetPreallocationBlockSize(size_t size) {
// the size here doesn't need to include prefixLength_, as it's a
// configuration will be use for `PrepareWrite()`.
file_->SetPreallocationBlockSize(size);
}
void EncryptedWritableFile::GetPreallocationStatus(
size_t* block_size, size_t* last_allocated_block) {
file_->GetPreallocationStatus(block_size, last_allocated_block);
}
// Pre-allocates space for a file. // Pre-allocates space for a file.
IOStatus EncryptedWritableFile::Allocate(uint64_t offset, uint64_t len, IOStatus EncryptedWritableFile::Allocate(uint64_t offset, uint64_t len,
const IOOptions& options, const IOOptions& options,

@ -366,6 +366,11 @@ class EncryptedWritableFile : public FSWritableFile {
void PrepareWrite(size_t offset, size_t len, const IOOptions& options, void PrepareWrite(size_t offset, size_t len, const IOOptions& options,
IODebugContext* dbg) override; IODebugContext* dbg) override;
void SetPreallocationBlockSize(size_t size) override;
void GetPreallocationStatus(size_t* block_size,
size_t* last_allocated_block) override;
// Pre-allocates space for a file. // Pre-allocates space for a file.
IOStatus Allocate(uint64_t offset, uint64_t len, const IOOptions& options, IOStatus Allocate(uint64_t offset, uint64_t len, const IOOptions& options,
IODebugContext* dbg) override; IODebugContext* dbg) override;

Loading…
Cancel
Save