Skip to content

Commit 2ab8bd0

Browse files
authored
Merge pull request #94 from rockset/DbStress
Fix DB Bench tool for AwsEnv
2 parents 22ac45f + 6488202 commit 2ab8bd0

File tree

16 files changed

+99
-103
lines changed

16 files changed

+99
-103
lines changed

cloud/aws/aws_env.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include <unordered_map>
2222

2323
namespace ROCKSDB_NAMESPACE {
24-
2524
class S3ReadableFile;
25+
2626
//
2727
// The S3 environment for rocksdb. This class overrides all the
2828
// file/dir access methods and delegates all other methods to the

cloud/aws/aws_file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#ifdef USE_AWS
55

66
#include <aws/core/Aws.h>
7+
78
#include "rocksdb/rocksdb_namespace.h"
89

910
namespace ROCKSDB_NAMESPACE {

cloud/examples/clone_example.cc

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ Status CloneDB(const std::string& clone_name, const std::string& src_bucket,
4444

4545
// Create new AWS env
4646
CloudEnv* cenv;
47-
Status st = CloudEnv::NewAwsEnv(Env::Default(),
48-
src_bucket, src_object_path, kRegion,
49-
dest_bucket, dest_object_path, kRegion,
50-
cloud_env_options, nullptr, &cenv);
47+
Status st = CloudEnv::NewAwsEnv(Env::Default(), src_bucket, src_object_path,
48+
kRegion, dest_bucket, dest_object_path,
49+
kRegion, cloud_env_options, nullptr, &cenv);
5150
if (!st.ok()) {
5251
fprintf(stderr,
5352
"Unable to create an AWS environment with "
@@ -107,16 +106,14 @@ int main() {
107106
const std::string bucketName = bucketPrefix + kBucketSuffix;
108107

109108
// Needed if using bucket prefix other than the default "rockset."
110-
cloud_env_options.src_bucket.SetBucketName(kBucketSuffix,bucketPrefix);
111-
cloud_env_options.dest_bucket.SetBucketName(kBucketSuffix,bucketPrefix);
112-
109+
cloud_env_options.src_bucket.SetBucketName(kBucketSuffix, bucketPrefix);
110+
cloud_env_options.dest_bucket.SetBucketName(kBucketSuffix, bucketPrefix);
111+
113112
// Create a new AWS cloud env Status
114113
CloudEnv* cenv;
115-
Status s =
116-
CloudEnv::NewAwsEnv(Env::Default(),
117-
kBucketSuffix, kDBPath, kRegion,
118-
kBucketSuffix, kDBPath, kRegion,
119-
cloud_env_options, nullptr, &cenv);
114+
Status s = CloudEnv::NewAwsEnv(Env::Default(), kBucketSuffix, kDBPath,
115+
kRegion, kBucketSuffix, kDBPath, kRegion,
116+
cloud_env_options, nullptr, &cenv);
120117
if (!s.ok()) {
121118
fprintf(stderr, "Unable to create cloud env in bucket %s. %s\n",
122119
bucketName.c_str(), s.ToString().c_str());

cloud/examples/cloud_dump.cc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,17 @@ int main() {
4444

4545
// "rockset." is the default bucket prefix
4646
const std::string bucketPrefix = "rockset.";
47-
cloud_env_options.src_bucket.SetBucketName(kBucketSuffix,bucketPrefix);
48-
cloud_env_options.dest_bucket.SetBucketName(kBucketSuffix,bucketPrefix);
49-
47+
cloud_env_options.src_bucket.SetBucketName(kBucketSuffix, bucketPrefix);
48+
cloud_env_options.dest_bucket.SetBucketName(kBucketSuffix, bucketPrefix);
49+
5050
// create a bucket name for debugging purposes
5151
const std::string bucketName = bucketPrefix + kBucketSuffix;
5252

5353
// Create a new AWS cloud env Status
5454
CloudEnv* cenv;
55-
Status s =
56-
CloudEnv::NewAwsEnv(Env::Default(),
57-
kBucketSuffix, kDBPath, kRegion,
58-
kBucketSuffix, kDBPath, kRegion,
59-
cloud_env_options, nullptr, &cenv);
55+
Status s = CloudEnv::NewAwsEnv(Env::Default(), kBucketSuffix, kDBPath,
56+
kRegion, kBucketSuffix, kDBPath, kRegion,
57+
cloud_env_options, nullptr, &cenv);
6058
if (!s.ok()) {
6159
fprintf(stderr, "Unable to create cloud env in bucket %s. %s\n",
6260
bucketName.c_str(), s.ToString().c_str());
@@ -95,7 +93,7 @@ int main() {
9593
// verify that the data is somewhat sane by manaully scanning for cfs
9694
std::vector<std::string> cf_names;
9795
s = ROCKSDB_NAMESPACE::DB::ListColumnFamilies(options, kDBPath, &cf_names);
98-
for (std::string cf: cf_names) {
96+
for (const std::string & cf : cf_names) {
9997
std::cout << " Found Column Family " << cf;
10098
}
10199
std::cout << " \n";

cloud/examples/cloud_durable_example.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,17 @@ int main() {
4747

4848
// "rockset." is the default bucket prefix
4949
const std::string bucketPrefix = "rockset.";
50-
cloud_env_options.src_bucket.SetBucketName(kBucketSuffix,bucketPrefix);
51-
cloud_env_options.dest_bucket.SetBucketName(kBucketSuffix,bucketPrefix);
50+
cloud_env_options.src_bucket.SetBucketName(kBucketSuffix, bucketPrefix);
51+
cloud_env_options.dest_bucket.SetBucketName(kBucketSuffix, bucketPrefix);
5252

5353
// create a bucket name for debugging purposes
5454
const std::string bucketName = bucketPrefix + kBucketSuffix;
55-
55+
5656
// Create a new AWS cloud env Status
5757
CloudEnv* cenv;
58-
Status s =
59-
CloudEnv::NewAwsEnv(Env::Default(),
60-
kBucketSuffix, kDBPath, kRegion,
61-
kBucketSuffix, kDBPath, kRegion,
62-
cloud_env_options, nullptr, &cenv);
58+
Status s = CloudEnv::NewAwsEnv(Env::Default(), kBucketSuffix, kDBPath,
59+
kRegion, kBucketSuffix, kDBPath, kRegion,
60+
cloud_env_options, nullptr, &cenv);
6361
if (!s.ok()) {
6462
fprintf(stderr, "Unable to create cloud env in bucket %s. %s\n",
6563
bucketName.c_str(), s.ToString().c_str());

cloud/remote_compaction_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
#ifdef USE_AWS
66

7-
#include <cinttypes>
8-
97
#include <algorithm>
108
#include <chrono>
9+
#include <cinttypes>
1110

1211
#include "cloud/aws/aws_env.h"
1312
#include "cloud/aws/aws_file.h"

db/db_impl/db_impl.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,7 @@ class DBImpl : public DB {
838838
// Allow compaction with a set of explicitly specified snapshots
839839
virtual Status ExecuteRemoteCompactionRequest(
840840
const PluggableCompactionParam& inputParams,
841-
PluggableCompactionResult* result,
842-
bool sanitize) override;
841+
PluggableCompactionResult* result, bool sanitize) override;
843842

844843
// This registered service will be called to do a remote compaction
845844
virtual Status RegisterPluggableCompactionService(
@@ -2094,15 +2093,12 @@ class DBImpl : public DB {
20942093
std::shared_ptr<PluggableCompactionService> remote_compaction_service_;
20952094

20962095
Status doCompact(const CompactionOptions& compact_options,
2097-
ColumnFamilyData* cfd,
2098-
Version* version,
2099-
const std::vector<FilesInOneLevel>& input_file_names,
2100-
int output_level,
2101-
const std::vector<SequenceNumber>& existing_snapshots,
2102-
bool unitTests,
2103-
JobContext* job_context,
2104-
LogBuffer* log_buffer,
2105-
PluggableCompactionResult* result);
2096+
ColumnFamilyData* cfd, Version* version,
2097+
const std::vector<FilesInOneLevel>& input_file_names,
2098+
int output_level,
2099+
const std::vector<SequenceNumber>& existing_snapshots,
2100+
bool unitTests, JobContext* job_context,
2101+
LogBuffer* log_buffer, PluggableCompactionResult* result);
21062102

21072103
bool wal_in_db_path_;
21082104
};

db/db_test_util.cc

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
// found in the LICENSE file. See the AUTHORS file for names of contributors.
99

1010
#include "db/db_test_util.h"
11+
1112
#include "db/forward_iterator.h"
12-
#include "util/stderr_logger.h"
1313
#include "rocksdb/env_encryption.h"
14+
#include "util/stderr_logger.h"
1415
#ifdef USE_AWS
1516
#include "cloud/cloud_env_impl.h"
1617
#include "rocksdb/cloud/cloud_storage_provider.h"
@@ -85,7 +86,7 @@ DBTestBase::DBTestBase(const std::string path)
8586
// Randomize the test path so that multiple tests can run in parallel
8687
srand(static_cast<unsigned int>(time(nullptr)));
8788
std::string mypath = path + "_" + std::to_string(rand());
88-
89+
8990
env_->NewLogger(test::TmpDir(env_) + "/rocksdb-cloud.log", &info_log_);
9091
info_log_->SetInfoLogLevel(InfoLogLevel::DEBUG_LEVEL);
9192
s3_env_ = CreateNewAwsEnv(mypath, env_);
@@ -187,45 +188,45 @@ bool DBTestBase::ShouldSkipOptions(int option_config, int skip_mask) {
187188
}
188189

189190
bool DBTestBase::ShouldSkipAwsOptions(int option_config) {
190-
// AWS Env doesn't work with DirectIO
191-
return option_config == kDirectIO;
191+
// AWS Env doesn't work with DirectIO
192+
return option_config == kDirectIO;
192193
}
193194

194195
// Switch to a fresh database with the next option configuration to
195196
// test. Return false if there are no more configurations to test.
196197
bool DBTestBase::ChangeOptions(int skip_mask) {
197198
while (true) {
198-
for (option_config_++; option_config_ < kEnd; option_config_++) {
199-
if (ShouldSkipOptions(option_config_, skip_mask)) {
200-
continue;
201-
}
202-
if (option_env_ == kAwsEnv && ShouldSkipAwsOptions(option_config_)) {
203-
continue;
204-
}
205-
break;
206-
}
207-
if (option_config_ >= kEnd) {
199+
for (option_config_++; option_config_ < kEnd; option_config_++) {
200+
if (ShouldSkipOptions(option_config_, skip_mask)) {
201+
continue;
202+
}
203+
if (option_env_ == kAwsEnv && ShouldSkipAwsOptions(option_config_)) {
204+
continue;
205+
}
206+
break;
207+
}
208+
if (option_config_ >= kEnd) {
208209
#ifndef USE_AWS
209-
// If not built for AWS, skip it
210-
if (option_env_ + 1 == kAwsEnv) {
211-
option_env_++;
212-
}
210+
// If not built for AWS, skip it
211+
if (option_env_ + 1 == kAwsEnv) {
212+
option_env_++;
213+
}
213214
#endif
214-
if (option_env_ + 1 >= kEndEnv) {
215-
Destroy(last_options_);
216-
return false;
217-
} else {
218-
option_env_++;
219-
option_config_ = kDefault;
220-
continue;
221-
}
222-
} else {
223-
auto options = CurrentOptions();
224-
options.create_if_missing = true;
225-
DestroyAndReopen(options);
226-
return true;
227-
}
228-
}
215+
if (option_env_ + 1 >= kEndEnv) {
216+
Destroy(last_options_);
217+
return false;
218+
} else {
219+
option_env_++;
220+
option_config_ = kDefault;
221+
continue;
222+
}
223+
} else {
224+
auto options = CurrentOptions();
225+
options.create_if_missing = true;
226+
DestroyAndReopen(options);
227+
return true;
228+
}
229+
}
229230
}
230231

231232
// Switch between different compaction styles.
@@ -620,8 +621,8 @@ Options DBTestBase::GetOptions(
620621
case kAwsEnv: {
621622
assert(s3_env_);
622623
options.env = s3_env_;
623-
options.recycle_log_file_num = 0; // do not reuse log files
624-
options.allow_mmap_reads = false; // mmap is incompatible with S3
624+
options.recycle_log_file_num = 0; // do not reuse log files
625+
options.allow_mmap_reads = false; // mmap is incompatible with S3
625626
break;
626627
}
627628
#endif /* USE_AWS */
@@ -644,7 +645,7 @@ Options DBTestBase::GetOptions(
644645
}
645646

646647
#ifdef USE_AWS
647-
Env* DBTestBase::CreateNewAwsEnv(const std::string& prefix, Env *parent) {
648+
Env* DBTestBase::CreateNewAwsEnv(const std::string& prefix, Env* parent) {
648649
if (!prefix.empty()) {
649650
fprintf(stderr, "Creating new AWS env with prefix %s\n", prefix.c_str());
650651
}
@@ -747,7 +748,7 @@ void DBTestBase::Destroy(const Options& options, bool delete_cf_paths) {
747748
ASSERT_OK(DestroyDB(dbname_, options, column_families));
748749
#ifdef USE_AWS
749750
if (s3_env_) {
750-
AwsEnv* aenv = static_cast<AwsEnv *>(s3_env_);
751+
AwsEnv* aenv = static_cast<AwsEnv*>(s3_env_);
751752
Status st = aenv->GetCloudEnvOptions().storage_provider->EmptyBucket(
752753
aenv->GetSrcBucketName(), dbname_);
753754
ASSERT_TRUE(st.ok() || st.IsNotFound());

db/db_test_util.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#pragma once
1111

1212
#include <fcntl.h>
13-
#include <cinttypes>
1413

1514
#include <algorithm>
15+
#include <cinttypes>
1616
#include <map>
1717
#include <set>
1818
#include <string>
@@ -21,6 +21,7 @@
2121
#include <utility>
2222
#include <vector>
2323

24+
#include "cloud/aws/aws_env.h"
2425
#include "db/db_impl/db_impl.h"
2526
#include "db/dbformat.h"
2627
#include "env/mock_env.h"
@@ -43,17 +44,14 @@
4344
#include "table/plain/plain_table_factory.h"
4445
#include "table/scoped_arena_iterator.h"
4546
#include "test_util/mock_time_env.h"
46-
#include "util/compression.h"
47-
#include "util/mutexlock.h"
48-
4947
#include "test_util/sync_point.h"
5048
#include "test_util/testharness.h"
5149
#include "test_util/testutil.h"
50+
#include "util/compression.h"
51+
#include "util/mutexlock.h"
5252
#include "util/string_util.h"
5353
#include "utilities/merge_operators.h"
5454

55-
#include "cloud/aws/aws_env.h"
56-
5755
namespace ROCKSDB_NAMESPACE {
5856

5957
namespace anon {
@@ -736,7 +734,7 @@ class DBTestBase : public testing::Test {
736734
};
737735

738736
#ifdef USE_AWS
739-
Env* CreateNewAwsEnv(const std::string& pathPrefix, Env *env);
737+
Env* CreateNewAwsEnv(const std::string& pathPrefix, Env* env);
740738
std::shared_ptr<Logger> info_log_;
741739
#endif
742740

db/flush_job.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ Status FlushJob::WriteLevel0Table() {
387387
cfd_->ioptions()->compression_opts,
388388
mutable_cf_options_.paranoid_file_checks, cfd_->internal_stats(),
389389
TableFileCreationReason::kFlush, event_logger_, job_context_->job_id,
390-
Env::IO_HIGH, &table_properties_, 0 /* level */,
391-
creation_time, oldest_key_time, write_hint, current_time);
390+
Env::IO_HIGH, &table_properties_, 0 /* level */, creation_time,
391+
oldest_key_time, write_hint, current_time);
392392
LogFlush(db_options_.info_log);
393393
}
394394
ROCKS_LOG_INFO(db_options_.info_log,

0 commit comments

Comments
 (0)