760dd4750f
Summary: This is initial version. A few ways in which this could be extended in the future are: (a) Killing from more places in source code (b) Hashing stack and using that hash in determining whether to crash. This is to avoid crashing more often at source lines that are executed more often. (c) Raising exceptions or returning errors instead of killing Test Plan: This whole thing is for testing. Here is part of output: python2.7 tools/db_crashtest2.py -d 600 Running db_stress db_stress retncode -15 output LevelDB version : 1.5 Number of threads : 32 Ops per thread : 10000000 Read percentage : 50 Write-buffer-size : 4194304 Delete percentage : 30 Max key : 1000 Ratio #ops/#keys : 320000 Num times DB reopens: 0 Batches/snapshots : 1 Purge redundant % : 50 Num keys per lock : 4 Compression : snappy ------------------------------------------------ No lock creation because test_batches_snapshots set 2013/04/26-17:55:17 Starting database operations Created bg thread 0x7fc1f07ff700 ... finished 60000 ops Running db_stress db_stress retncode -15 output LevelDB version : 1.5 Number of threads : 32 Ops per thread : 10000000 Read percentage : 50 Write-buffer-size : 4194304 Delete percentage : 30 Max key : 1000 Ratio #ops/#keys : 320000 Num times DB reopens: 0 Batches/snapshots : 1 Purge redundant % : 50 Num keys per lock : 4 Compression : snappy ------------------------------------------------ Created bg thread 0x7ff0137ff700 No lock creation because test_batches_snapshots set 2013/04/26-17:56:15 Starting database operations ... finished 90000 ops Revert Plan: OK Task ID: #2252691 Reviewers: dhruba, emayanke Reviewed By: emayanke CC: leveldb, haobo Differential Revision: https://reviews.facebook.net/D10581
73 lines
2.3 KiB
C++
73 lines
2.3 KiB
C++
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
//
|
|
#ifndef STORAGE_LEVELDB_UTIL_STORAGE_OPTIONS_H_
|
|
#define STORAGE_LEVELDB_UTIL_STORAGE_OPTIONS_H_
|
|
|
|
#include <string>
|
|
#include <stdint.h>
|
|
#include "leveldb/env.h"
|
|
#include "leveldb/options.h"
|
|
|
|
namespace leveldb {
|
|
|
|
// Environment Options that are used to read files from storage
|
|
class StorageOptions : public EnvOptions {
|
|
public:
|
|
/* implicit */ StorageOptions(const Options& opt) :
|
|
data_in_os_(opt.allow_os_buffer),
|
|
fs_readahead_(opt.allow_readahead),
|
|
readahead_compactions_(opt.allow_readahead_compactions),
|
|
use_mmap_reads_(opt.allow_mmap_reads),
|
|
use_mmap_writes_(opt.allow_mmap_writes),
|
|
set_fd_cloexec_(opt.is_fd_close_on_exec) {
|
|
}
|
|
|
|
// copy constructor with readaheads set to readahead_compactions_
|
|
StorageOptions(const StorageOptions& opt) {
|
|
data_in_os_ = opt.UseOsBuffer();
|
|
fs_readahead_ = opt.UseReadaheadCompactions();
|
|
readahead_compactions_ = opt.UseReadaheadCompactions();
|
|
use_mmap_reads_ = opt.UseMmapReads();
|
|
use_mmap_writes_ = opt.UseMmapWrites();
|
|
set_fd_cloexec_ = opt.IsFDCloseOnExec();
|
|
}
|
|
|
|
// constructor with default options
|
|
StorageOptions() {
|
|
Options opt;
|
|
data_in_os_ = opt.allow_os_buffer;
|
|
fs_readahead_ = opt.allow_readahead;
|
|
readahead_compactions_ = fs_readahead_;
|
|
use_mmap_reads_ = opt.allow_mmap_reads;
|
|
use_mmap_writes_ = opt.allow_mmap_writes;
|
|
set_fd_cloexec_ = opt.is_fd_close_on_exec;
|
|
}
|
|
|
|
virtual ~StorageOptions() {}
|
|
|
|
bool UseOsBuffer() const { return data_in_os_; };
|
|
bool UseReadahead() const { return fs_readahead_; };
|
|
bool UseMmapReads() const { return use_mmap_reads_; }
|
|
bool UseMmapWrites() const { return use_mmap_writes_; }
|
|
bool UseReadaheadCompactions() const { return readahead_compactions_;}
|
|
bool IsFDCloseOnExec() const { return set_fd_cloexec_;}
|
|
|
|
void DisableMmapWrites() {
|
|
use_mmap_writes_ = false;
|
|
}
|
|
|
|
private:
|
|
bool data_in_os_;
|
|
bool fs_readahead_;
|
|
bool readahead_compactions_;
|
|
bool use_mmap_reads_;
|
|
bool use_mmap_writes_;
|
|
bool set_fd_cloexec_;
|
|
};
|
|
|
|
} // namespace leveldb
|
|
|
|
#endif // STORAGE_LEVELDB_UTIL_STORAGE_OPTIONS_H_
|