Fix ldb segfault and use static libsnappy for all builds

Summary:
Link statically against snappy, using the gvfs one for facebook
environments, and the bundled one otherwise.

In addition, fix a few minor segfaults in ldb when it couldn't open the
database, and update .gitignore to include a few other build artifacts.

Test Plan: make check

Reviewers: dhruba

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D6855
This commit is contained in:
Chip Turner 2012-11-20 16:14:04 -08:00
parent 7632fdb5cb
commit 879e45eb99
5 changed files with 22 additions and 7 deletions

7
.gitignore vendored
View File

@ -6,3 +6,10 @@ build_config.mk
*.so.* *.so.*
*_test *_test
db_bench db_bench
db_stress
ldb
leveldb_server
leveldb_shell
manifest_dump
sst_dump
util/build_version.cc

View File

@ -165,7 +165,7 @@ EOF
EOF EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY" COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lsnappy -L./snappy/libs" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS ${SNAPPY_LDFLAGS:-./snappy/libs/libsnappy.a}"
fi fi
# Test whether zlib library is installed # Test whether zlib library is installed

View File

@ -24,8 +24,8 @@ if test "$USE_HDFS"; then
fi fi
# location of snappy headers and libraries # location of snappy headers and libraries
SNAPPY_INCLUDE=" -I ./snappy" SNAPPY_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/snappy/snappy-1.0.3/7518bbe/include"
SNAPPY_LIBS=" -L./snappy/libs" SNAPPY_LIBS=" $TOOLCHAIN_LIB_BASE/snappy/snappy-1.0.3/7518bbe/lib/libsnappy.a"
# location of boost headers and libraries # location of boost headers and libraries
THRIFT_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/boost/boost-1.48.0/bef9365/include -std=gnu++0x" THRIFT_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/boost/boost-1.48.0/bef9365/include -std=gnu++0x"
@ -37,7 +37,7 @@ if test -z "$USE_SSE"; then
export USE_SSE=" -msse -msse4.2 " export USE_SSE=" -msse -msse4.2 "
fi fi
CC="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/gcc" CC="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/gcc"
CXX="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/g++ $JINCLUDE $SNAPPY_INCLUDE $THRIFT_INCLUDE" CXX="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/g++ $JINCLUDE $SNAPPY_INCLUDE $THRIFT_INCLUDE"
AR=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ar AR=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ar
RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib
@ -49,5 +49,6 @@ EXEC_LDFLAGS=" -Wl,--whole-archive $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/l
EXEC_LDFLAGS+="-Wl,--no-whole-archive $TOOLCHAIN_LIB_BASE/libunwind/libunwind-20100812_experimental/91ddd43/lib/libunwind.a" EXEC_LDFLAGS+="-Wl,--no-whole-archive $TOOLCHAIN_LIB_BASE/libunwind/libunwind-20100812_experimental/91ddd43/lib/libunwind.a"
EXEC_LDFLAGS+="$HDFSLIB $SNAPPY_LIBS $THRIFT_LIBS " EXEC_LDFLAGS+="$HDFSLIB $SNAPPY_LIBS $THRIFT_LIBS "
EXEC_LDFLAGS_SHARED="$SNAPPY_LIBS $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/lib/libjemalloc.so" EXEC_LDFLAGS_SHARED="$SNAPPY_LIBS $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/lib/libjemalloc.so"
SNAPPY_LDFLAGS="$SNAPPY_LIBS"
export CC CXX AR RANLIB CFLAGS EXEC_LDFLAGS EXEC_LDFLAGS_SHARED export CC CXX AR RANLIB CFLAGS EXEC_LDFLAGS EXEC_LDFLAGS_SHARED SNAPPY_LDFLAGS

View File

@ -315,6 +315,9 @@ void ReduceDBLevels::DoCommand() {
old_levels_ = old_level_num; old_levels_ = old_level_num;
OpenDB(); OpenDB();
if (!db_) {
return;
}
// Compact the whole DB to put all files to the highest level. // Compact the whole DB to put all files to the highest level.
fprintf(stdout, "Compacting the db...\n"); fprintf(stdout, "Compacting the db...\n");
db_->CompactRange(NULL, NULL); db_->CompactRange(NULL, NULL);

View File

@ -44,10 +44,10 @@ public:
case EXEC_SUCCEED: case EXEC_SUCCEED:
break; break;
case EXEC_FAILED: case EXEC_FAILED:
ret.append("Failed."); ret.append("Failed: ");
break; break;
case EXEC_NOT_STARTED: case EXEC_NOT_STARTED:
ret.append("Not started."); ret.append("Not started: ");
} }
if (!message_.empty()) { if (!message_.empty()) {
ret.append(message_); ret.append(message_);
@ -134,6 +134,10 @@ public:
OpenDB(); OpenDB();
} }
if (!db_) {
return;
}
DoCommand(); DoCommand();
if (exec_state_.IsNotStarted()) { if (exec_state_.IsNotStarted()) {
exec_state_ = LDBCommandExecuteResult::SUCCEED(""); exec_state_ = LDBCommandExecuteResult::SUCCEED("");