Skip to content

Commit 84d6d69

Browse files
committed
Squashed 'src/leveldb/' changes from ae6c262..a02ddf9
a02ddf9 Added GNU/kFreeBSD kernel name (TARGET_OS) 8487468 CondVar::SignalAll was broken, leading to deadlocks on Windows builds. http://code.google.com/p/leveldb/issues/detail?id=149 f6d84d1 Allow files to be opened for reading multiple times cb8e3f7 Checking whether closing succeeds d5317e8 Print actual Win32 error that occurred on file creation failure. 907f308 Port leveldb to MinGW32 9def2bf Mingw support for Windows LevelDB port 0a7b074 Pre-Vista leveldb::port::InitOnce implementation 31a2b09 Native Windows LevelDB port 058a035 Remove Snappy support 5bd76dc Release leveldb 1.12 7b094f1 Release leveldb 1.11 28dad91 Release leveldb 1.10 514c943 Make DB::Open fail if sst files are missing. d84c825 Fix corruption bug found and analyzed by [email protected] ea2e919 added utility to dump leveldb files REVERT: ae6c262 Merge branch 'leveldb' into ripple-fork REVERT: 28fa222 Looks like a bit more delay is needed to smooth the latency. REVERT: a18f3e6 Tidy up JobQueue, add ripple_core module REVERT: ab82e57 Release leveldb 1.12 REVERT: 02c6259 Release leveldb 1.11 REVERT: 5bbb544 Rate limit compactions with a 25ms pause after each complete file. REVERT: 8c29c47 LevelDB issue 178 fix: cannot resize a level 0 compaction set REVERT: 18b245c Added GNU/kFreeBSD kernel name (TARGET_OS) REVERT: 8be9d12 CondVar::SignalAll was broken, leading to deadlocks on Windows builds. http://code.google.com/p/leveldb/issues/detail?id=149 REVERT: c9fc070 Upgrade LevelDB to 1.10.0, mostly for better write stall logging. REVERT: 8215b15 Tweak to variable name to support unity build REVERT: aca1ffc Allow files to be opened for reading multiple times REVERT: 693a70c Checking whether closing succeeds REVERT: 0144d04 Print actual Win32 error that occurred on file creation failure. REVERT: 43ed517 Fix corruption bug found and analyzed by [email protected] REVERT: 413c74c added utility to dump leveldb files REVERT: 96eda85 Port leveldb to MinGW32 REVERT: 0967260 Mingw support for Windows LevelDB port REVERT: ee3f9bd Pre-Vista leveldb::port::InitOnce implementation REVERT: f5d0a41 Native Windows LevelDB port REVERT: 28b35f1 Remove Snappy support git-subtree-dir: src/leveldb git-subtree-split: a02ddf9b14d145e88185ee209ab8b01d8826663a
1 parent adae78e commit 84d6d69

File tree

6 files changed

+107
-9
lines changed

6 files changed

+107
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build_config.mk
66
*.so.*
77
*_test
88
db_bench
9+
leveldbutil
910
Release
1011
Debug
1112
Benchmark

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
1212
#-----------------------------------------------
1313

1414
# detect what platform we're building on
15-
$(shell CC=$(CC) CXX=$(CXX) TARGET_OS=$(TARGET_OS) \
15+
$(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
1616
./build_detect_platform build_config.mk ./)
1717
# this file is generated by the previous line to set build flags and sources
1818
include build_config.mk

build_detect_platform

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ if test -z "$CXX"; then
4444
CXX=g++
4545
fi
4646

47+
if test -z "$TMPDIR"; then
48+
TMPDIR=/tmp
49+
fi
50+
4751
# Detect OS
4852
if test -z "$TARGET_OS"; then
4953
TARGET_OS=`uname -s`
@@ -169,8 +173,10 @@ if [ "$CROSS_COMPILE" = "true" ]; then
169173
# Cross-compiling; do not try any compilation tests.
170174
true
171175
else
176+
CXXOUTPUT="${TMPDIR}/leveldb_build_detect_platform-cxx.$$"
177+
172178
# If -std=c++0x works, use <cstdatomic>. Otherwise use port_posix.h.
173-
$CXX $CXXFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null <<EOF
179+
$CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null <<EOF
174180
#include <cstdatomic>
175181
int main() {}
176182
EOF
@@ -182,12 +188,14 @@ EOF
182188
fi
183189

184190
# Test whether tcmalloc is available
185-
$CXX $CXXFLAGS -x c++ - -o /dev/null -ltcmalloc 2>/dev/null <<EOF
191+
$CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null <<EOF
186192
int main() {}
187193
EOF
188194
if [ "$?" = 0 ]; then
189195
PLATFORM_LIBS="$PLATFORM_LIBS -ltcmalloc"
190196
fi
197+
198+
rm -f $CXXOUTPUT 2>/dev/null
191199
fi
192200

193201
PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS"

db/db_impl.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ Status DBImpl::Recover(VersionEdit* edit) {
322322
if (ParseFileName(filenames[i], &number, &type)) {
323323
expected.erase(number);
324324
if (type == kLogFile && ((number >= min_log) || (number == prev_log)))
325-
logs.push_back(number);
325+
logs.push_back(number);
326326
}
327327
}
328328
if (!expected.empty()) {
@@ -822,9 +822,6 @@ Status DBImpl::FinishCompactionOutputFile(CompactionState* compact,
822822
(unsigned long long) output_number,
823823
(unsigned long long) current_entries,
824824
(unsigned long long) current_bytes);
825-
826-
// rate-limit compaction file creation with a 100ms pause
827-
env_->SleepForMicroseconds(100000);
828825
}
829826
}
830827
return s;

issues/issue178_test.cc

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) 2013 The LevelDB Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file. See the AUTHORS file for names of contributors.
4+
5+
// Test for issue 178: a manual compaction causes deleted data to reappear.
6+
#include <iostream>
7+
#include <sstream>
8+
#include <cstdlib>
9+
10+
#include "leveldb/db.h"
11+
#include "leveldb/write_batch.h"
12+
#include "util/testharness.h"
13+
14+
namespace {
15+
16+
const int kNumKeys = 1100000;
17+
18+
std::string Key1(int i) {
19+
char buf[100];
20+
snprintf(buf, sizeof(buf), "my_key_%d", i);
21+
return buf;
22+
}
23+
24+
std::string Key2(int i) {
25+
return Key1(i) + "_xxx";
26+
}
27+
28+
class Issue178 { };
29+
30+
TEST(Issue178, Test) {
31+
// Get rid of any state from an old run.
32+
std::string dbpath = leveldb::test::TmpDir() + "/leveldb_cbug_test";
33+
DestroyDB(dbpath, leveldb::Options());
34+
35+
// Open database. Disable compression since it affects the creation
36+
// of layers and the code below is trying to test against a very
37+
// specific scenario.
38+
leveldb::DB* db;
39+
leveldb::Options db_options;
40+
db_options.create_if_missing = true;
41+
db_options.compression = leveldb::kNoCompression;
42+
ASSERT_OK(leveldb::DB::Open(db_options, dbpath, &db));
43+
44+
// create first key range
45+
leveldb::WriteBatch batch;
46+
for (size_t i = 0; i < kNumKeys; i++) {
47+
batch.Put(Key1(i), "value for range 1 key");
48+
}
49+
ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch));
50+
51+
// create second key range
52+
batch.Clear();
53+
for (size_t i = 0; i < kNumKeys; i++) {
54+
batch.Put(Key2(i), "value for range 2 key");
55+
}
56+
ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch));
57+
58+
// delete second key range
59+
batch.Clear();
60+
for (size_t i = 0; i < kNumKeys; i++) {
61+
batch.Delete(Key2(i));
62+
}
63+
ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch));
64+
65+
// compact database
66+
std::string start_key = Key1(0);
67+
std::string end_key = Key1(kNumKeys - 1);
68+
leveldb::Slice least(start_key.data(), start_key.size());
69+
leveldb::Slice greatest(end_key.data(), end_key.size());
70+
71+
// commenting out the line below causes the example to work correctly
72+
db->CompactRange(&least, &greatest);
73+
74+
// count the keys
75+
leveldb::Iterator* iter = db->NewIterator(leveldb::ReadOptions());
76+
size_t num_keys = 0;
77+
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
78+
num_keys++;
79+
}
80+
delete iter;
81+
ASSERT_EQ(kNumKeys, num_keys) << "Bad number of keys";
82+
83+
// close database
84+
delete db;
85+
DestroyDB(dbpath, leveldb::Options());
86+
}
87+
88+
} // anonymous namespace
89+
90+
int main(int argc, char** argv) {
91+
return leveldb::test::RunAllTests();
92+
}

util/comparator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ class BytewiseComparatorImpl : public Comparator {
6666
};
6767
} // namespace
6868

69-
static port::OnceType once_comparator = LEVELDB_ONCE_INIT;
69+
static port::OnceType once = LEVELDB_ONCE_INIT;
7070
static const Comparator* bytewise;
7171

7272
static void InitModule() {
7373
bytewise = new BytewiseComparatorImpl;
7474
}
7575

7676
const Comparator* BytewiseComparator() {
77-
port::InitOnce(&once_comparator, InitModule);
77+
port::InitOnce(&once, InitModule);
7878
return bytewise;
7979
}
8080

0 commit comments

Comments
 (0)