Commit 09213cbf authored by John Esmet's avatar John Esmet

fixes #199 Remove BDB-related cmake logic, ydb tests (some code, mostly conditional

compilations).
parent 8c97dbcf
......@@ -631,7 +631,6 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
//printf("#include <inttypes.h>\n");
printf("#if defined(__cplusplus) || defined(__cilkplusplus)\nextern \"C\" {\n#endif\n");
printf("#define TOKUDB 1\n");
printf("#define DB_VERSION_MAJOR %d\n", DB_VERSION_MAJOR);
printf("#define DB_VERSION_MINOR %d\n", DB_VERSION_MINOR);
printf("/* As of r40364 (post TokuDB 5.2.7), the patch version number is 100+ the BDB header patch version number.*/\n");
......
......@@ -93,8 +93,6 @@ if (BUILD_TESTING OR BUILD_FT_TESTS OR BUILD_SRC_TESTS)
## set up full valgrind suppressions file (concatenate the suppressions files)
file(READ ft/valgrind.suppressions valgrind_suppressions)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${valgrind_suppressions}")
file(READ src/tests/bdb.suppressions bdb_suppressions)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${bdb_suppressions}")
file(READ bash.suppressions bash_suppressions)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${bash_suppressions}")
......
......@@ -20,9 +20,6 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
file(GLOB transparent_upgrade_srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" upgrade*.cc)
file(GLOB tdb_dontrun_srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" bdb-simple-deadlock*.cc)
string(REGEX REPLACE "\\.cc(;|$)" "\\1" tdb_dontrun_tests "${tdb_dontrun_srcs}")
file(GLOB srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.cc)
list(REMOVE_ITEM srcs ${transparent_upgrade_srcs})
......@@ -36,330 +33,10 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
string(REGEX REPLACE "\\.cc(;|$)" ".tdb\\1" stress_tests "${stress_test_srcs}")
set(tdb_srcs ${srcs})
list(REMOVE_ITEM tdb_srcs ${tdb_dontrun_srcs})
string(REGEX REPLACE "\\.cc(;|$)" ".tdb\\1" tdb_bins "${tdb_srcs}")
list(REMOVE_ITEM tdb_srcs ${abortrecover_srcs} ${loader_srcs})
string(REGEX REPLACE "\\.cc(;|$)" ".tdb\\1" tdb_tests "${tdb_srcs}")
if(BDB_FOUND)
set(bdb_dontrun_srcs
backwards_10_each_le_and_msg
bigtxn27
blackhole
blocking-prelock-range
blocking-set-range-reverse-0
blocking-table-lock
bug1381
bug627
cachetable-race
checkpoint_callback
checkpoint_stress
cursor-isolation
cursor-set-del-rmw
cursor-set-range-rmw
db-put-simple-deadlock
del-simple
del-multiple
del-multiple-huge-primary-row
del-multiple-srcdb
directory_lock
diskfull
dump-env
env_loader_memory
env-put-multiple
env_nproc
env_startup
execute-updates
filesize
get_key_after_bytes_unit
get_last_key
helgrind1
helgrind2
helgrind3
hotindexer-bw
hotindexer-error-callback
hotindexer-insert-committed-optimized
hotindexer-insert-committed
hotindexer-insert-provisional
hotindexer-lock-test
hotindexer-multiclient
hotindexer-nested-insert-committed
hotindexer-put-abort
hotindexer-put-commit
hotindexer-put-multiple
hotindexer-simple-abort
hotindexer-simple-abort-put
hotindexer-undo-do-test
hotindexer-with-queries
hot-optimize-table-tests
insert-dup-prelock
isolation
isolation-read-committed
keyrange
keyrange-merge
last-verify-time
loader-cleanup-test
loader-create-abort
loader-create-close
loader-dup-test
loader-no-puts
loader-reference-test
loader-stress-del
loader-stress-test
loader-tpch-load
locktree_escalation_stalls
lock-pressure
manyfiles
maxsize-for-loader
multiprocess
mvcc-create-table
mvcc-many-committed
mvcc-read-committed
openlimit17
openlimit17-locktree
openlimit17-metafiles
perf_checkpoint_var
perf_child_txn
perf_cursor_nop
perf_iibench
perf_insert
perf_insert_multiple
perf_malloc_free
perf_nop
perf_ptquery
perf_ptquery2
perf_rangequery
perf_read_txn
perf_read_txn_single_thread
perf_read_write
perf_txn_single_thread
perf_xmalloc_free
prelock-read-read
prelock-read-write
prelock-write-read
prelock-write-write
print_engine_status
powerfail
preload-db
preload-db-nested
progress
put-del-multiple-array-indexing
put-multiple
queries_with_deletes
recover-2483
recover-3113
recover-5146
recover-child-rollback
recover-compare-db
recover-compare-db-descriptor
recover-del-multiple
recover-del-multiple-abort
recover-del-multiple-srcdb-fdelete-all
recover-delboth-after-checkpoint
recover-delboth-checkpoint
recover-descriptor
recover-descriptor2
recover-descriptor3
recover-descriptor4
recover-descriptor5
recover-descriptor6
recover-descriptor7
recover-descriptor8
recover-descriptor9
recover-descriptor10
recover-descriptor11
recover-descriptor12
recover-fclose-in-checkpoint
recover-fcreate-basementnodesize
recover-flt1
recover-flt2
recover-flt3
recover-flt4
recover-flt5
recover-flt6
recover-flt7
recover-flt8
recover-flt9
recover-flt10
recover-hotindexer-simple-abort-put
recover-loader-test
recover-lsn-filter-multiple
recover-put-multiple
recover-put-multiple-abort
recover-put-multiple-fdelete-all
recover-put-multiple-fdelete-some
recover-put-multiple-srcdb-fdelete-all
recover-split-checkpoint
recover-tablelock
recover-test-logsuppress
recover-test-logsuppress-put
recover-test_stress1
recover-test_stress2
recover-test_stress3
recover-test_stress_openclose
recover-upgrade-db-descriptor-multihandle
recover-upgrade-db-descriptor
recover-update-multiple
recover-update-multiple-abort
recover-update_aborts
recover-update_aborts_before_checkpoint
recover-update_aborts_before_close
recover-update_changes_values
recover-update_changes_values_before_checkpoint
recover-update_changes_values_before_close
recover-update_broadcast_aborts
recover-update_broadcast_aborts2
recover-update_broadcast_aborts3
recover-update_broadcast_aborts_before_checkpoint
recover-update_broadcast_aborts_before_close
recover-update_broadcast_changes_values
recover-update_broadcast_changes_values2
recover-update_broadcast_changes_values3
recover-update_broadcast_changes_values_before_checkpoint
recover-update_broadcast_changes_values_before_close
recover-update_changes_values_before_close
recovery_fileops_stress
recovery_fileops_unit
recovery_stress
redirect
replace-into-write-lock
root_fifo_2
root_fifo_32
root_fifo_41
seqinsert
shutdown-3344
stat64
stat64-create-modify-times
stat64_flatten
stat64-null-txn
stat64-root-changes
stress-gc
stress-gc2
test-xa-prepare
test1324
test1572
test3219
test3522
test3522b
test3529
test_3645
test_3529_insert_2
test_3529_table_lock
test_3755
test_4015
test_4368
test_4657
test_5015
test_5469
test-5138
test938c
test_abort1
test_abort4
test_abort5
test_bad_implicit_promotion
test_blobs_leaf_split
test_bulk_fetch
test_compression_methods
test_cmp_descriptor
test_cursor_interrupt
test_cursor_with_read_txn
test_db_change_pagesize
test_db_change_xxx
test_cursor_delete_2119
test_db_descriptor
test_db_descriptor_named_db
test_db_txn_locks_read_uncommitted
test_equal_keys_with_different_bytes
test_get_max_row_size
test_insert_many_gc
test_iterate_live_transactions
test_iterate_pending_lock_requests
test_large_update_broadcast_small_cachetable
test_lock_timeout_callback
test_locking_with_read_txn
test_locktree_close
test_logflush
test_multiple_checkpoints_block_commit
test_query
test_read_txn_invalid_ops
test_redirect_func
test_restrict
test_row_size_supported
test_simple_read_txn
test_stress0
test_stress1
test_stress2
test_stress3
test_stress4
test_stress5
test_stress6
test_stress7
test_stress_openclose
test_stress_with_verify
test_stress_hot_indexing
test_transactional_descriptor
test_trans_desc_during_chkpt
test_trans_desc_during_chkpt2
test_trans_desc_during_chkpt3
test_trans_desc_during_chkpt4
test_txn_abort6
test_txn_abort8
test_txn_abort9
test_txn_close_open_commit
test_txn_commit8
test_txn_nested1
test_txn_nested2
test_txn_nested3
test_txn_nested4
test_txn_nested5
test_update_abort_works
test_update_calls_back
test_update_can_delete_elements
test_update_changes_values
test_update_nonexistent_keys
test_update_previously_deleted
test_update_stress
test_update_txn_snapshot_works_concurrently
test_update_txn_snapshot_works_correctly_with_deletes
test_update_broadcast_abort_works
test_update_broadcast_calls_back
test_update_broadcast_can_delete_elements
test_update_broadcast_changes_values
test_update_broadcast_previously_deleted
test_update_broadcast_stress
test_update_broadcast_update_fun_has_choices
test_update_broadcast_with_empty_table
test_update_broadcast_indexer
test_update_broadcast_loader
test_update_broadcast_nested_updates
test_update_nested_updates
test_update_with_empty_table
test_updates_single_key
txn-ignore
transactional_fileops
update-multiple-data-diagonal
update-multiple-key0
update-multiple-nochange
update-multiple-with-indexer
update-multiple-with-indexer-array
update
upgrade_simple
upgrade-test-1
upgrade-test-2
upgrade-test-3
upgrade-test-4
upgrade-test-5
upgrade-test-6
upgrade-test-7
zombie_db
)
set(bdb_srcs ${srcs})
string(REGEX REPLACE "\\.cc(;|$)" "\\1" bdb_testbases "${bdb_srcs}")
list(REMOVE_ITEM bdb_testbases ${bdb_dontrun_srcs})
string(REGEX REPLACE "(.)(;|$)" "\\1.bdb\\2" bdb_tests "${bdb_testbases}")
set(bdb_bins ${bdb_tests})
endif()
set(tdb_tests_that_should_fail
test_db_no_env.tdb
test_log8.recover
......@@ -374,8 +51,6 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
list(REMOVE_ITEM tdb_bins test-5138.tdb)
add_executable(test-5138.tdb test-5138)
target_link_libraries(test-5138.tdb ${LIBTOKUDB}_static z ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
set_property(TARGET test-5138.tdb APPEND PROPERTY
COMPILE_DEFINITIONS "USE_TDB;IS_TDB=1;TOKUDB=1")
add_space_separated_property(TARGET test-5138.tdb COMPILE_FLAGS -fvisibility=hidden)
add_ydb_test(test-5138.tdb)
......@@ -388,25 +63,9 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
# We link the test with util directly so that the test code itself can use
# some of those things (i.e. kibbutz in the threaded tests).
target_link_libraries(${base}.tdb util ${LIBTOKUDB} ${LIBTOKUPORTABILITY})
set_property(TARGET ${base}.tdb APPEND PROPERTY
COMPILE_DEFINITIONS "USE_TDB;IS_TDB=1;TOKUDB=1")
add_space_separated_property(TARGET ${base}.tdb COMPILE_FLAGS -fvisibility=hidden)
endforeach(bin)
if(BDB_FOUND)
foreach(bin ${bdb_bins})
get_filename_component(base ${bin} NAME_WE)
add_executable(${base}.bdb ${base})
set_property(TARGET ${base}.bdb APPEND PROPERTY
COMPILE_DEFINITIONS "USE_BDB;IS_TDB=0;TOKU_ALLOW_DEPRECATED")
set_target_properties(${base}.bdb PROPERTIES
INCLUDE_DIRECTORIES "${BDB_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/../../portability;${CMAKE_CURRENT_SOURCE_DIR}/../..")
target_link_libraries(${base}.bdb ${LIBTOKUPORTABILITY} ${BDB_LIBRARIES})
add_space_separated_property(TARGET ${base}.bdb COMPILE_FLAGS -fvisibility=hidden)
endforeach(bin)
endif()
foreach(bin loader-cleanup-test.tdb diskfull.tdb)
set_property(TARGET ${bin} APPEND PROPERTY
COMPILE_DEFINITIONS DONT_DEPRECATE_WRITES)
......@@ -419,22 +78,6 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
endmacro(declare_custom_tests)
declare_custom_tests(test1426.tdb)
if(BDB_FOUND)
macro(declare_custom_bdb_tests)
foreach(test ${ARGN})
list(REMOVE_ITEM bdb_tests ${test})
endforeach(test)
endmacro(declare_custom_bdb_tests)
declare_custom_bdb_tests(test1426.bdb)
configure_file(run_test1426.sh . COPYONLY)
add_test(NAME ydb/test1426.tdb
COMMAND run_test1426.sh
$<TARGET_FILE:test1426.tdb> $<TARGET_FILE:test1426.bdb>
"test1426.tdb.ctest-data" "test1426.bdb.ctest-data"
$<TARGET_FILE:tokudb_dump> "${BDB_INCLUDE_DIR}/../bin/db_dump")
add_dependencies(test1426.tdb tokudb_dump)
endif()
string(REGEX REPLACE "\\.cc(;|$)" ".tdb\\1" recover_would_be_tdb_tests "${recover_srcs}")
declare_custom_tests(${recover_would_be_tdb_tests})
......@@ -741,7 +384,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
setup_toku_test_properties(ydb/${test} ${test})
endforeach()
foreach(test ${tdb_tests} ${bdb_tests})
foreach(test ${tdb_tests})
add_ydb_test(${test})
endforeach(test)
......@@ -823,16 +466,6 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
ydb/test_txn_nested5.tdb
ydb/test_update_broadcast_stress.tdb
)
if (BDB_FOUND)
list(APPEND long_tests
ydb/root_fifo_1.bdb
ydb/root_fifo_31.bdb
ydb/rowsize.bdb
ydb/test_log10.bdb
ydb/test_log7.bdb
ydb/test_logmax.bdb
)
endif (BDB_FOUND)
set_tests_properties(${long_tests} PROPERTIES TIMEOUT 3600)
## some take even longer, with valgrind
set(extra_long_tests
......@@ -848,11 +481,6 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
ydb/test3039.tdb
ydb/test_update_stress.tdb
)
if (BDB_FOUND)
list(APPEND extra_long_tests
ydb/test_groupcommit_count.bdb
)
endif (BDB_FOUND)
set_tests_properties(${extra_long_tests} PROPERTIES TIMEOUT 7200)
## these really take a long time with valgrind
set(phenomenally_long_tests
......@@ -862,10 +490,5 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
ydb/recover_stress.tdb
ydb/test3529.tdb
)
if (BDB_FOUND)
list(APPEND phenomenally_long_tests
ydb/test1426.tdb
)
endif (BDB_FOUND)
set_tests_properties(${phenomenally_long_tests} PROPERTIES TIMEOUT 14400)
endif(BUILD_TESTING OR BUILD_SRC_TESTS)
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
// verify that the BDB locker can detect deadlocks on the fly and allow
// the deadlock to be unwound by the deadlocked threads. the main thread
// polls for deadlocks with the lock_detect function.
//
// A write locks L
// B write locks M
// A tries to write lock M && B tries to write lock L
// One of A or B gets the DEADLOCK error, the other waits
// A and B release their locks
#include "test.h"
#include "toku_pthread.h"
#include <portability/toku_atomic.h>
struct test_seq {
int state;
toku_mutex_t lock;
toku_cond_t cv;
};
static void test_seq_init(struct test_seq *seq) {
seq->state = 0;
toku_mutex_init(&seq->lock, NULL);
toku_cond_init(&seq->cv, NULL);
}
static void test_seq_destroy(struct test_seq *seq) {
toku_mutex_destroy(&seq->lock);
toku_cond_destroy(&seq->cv);
}
static void test_seq_sleep(struct test_seq *seq, int new_state) {
toku_mutex_lock(&seq->lock);
while (seq->state != new_state) {
toku_cond_wait(&seq->cv, &seq->lock);
}
toku_mutex_unlock(&seq->lock);
}
static void test_seq_next_state(struct test_seq *seq) {
toku_mutex_lock(&seq->lock);
seq->state++;
toku_cond_broadcast(&seq->cv);
toku_mutex_unlock(&seq->lock);
}
struct locker_args {
DB_ENV *db_env;
struct test_seq *test_seq;
int *deadlock_count;
};
static void *run_locker_a(void *arg) {
struct locker_args *locker_args = (struct locker_args *) arg;
DB_ENV *db_env = locker_args->db_env;
struct test_seq *test_seq = locker_args->test_seq;
int r;
uint32_t locker_a;
r = db_env->lock_id(db_env, &locker_a); assert(r == 0);
DBT object_l = { .data = (char *) "L", .size = 1 };
DBT object_m = { .data = (char *) "M", .size = 1 };
test_seq_sleep(test_seq, 0);
DB_LOCK lock_a_l;
r = db_env->lock_get(db_env, locker_a, DB_LOCK_NOWAIT, &object_l, DB_LOCK_WRITE, &lock_a_l); assert(r == 0);
test_seq_next_state(test_seq);
test_seq_sleep(test_seq, 2);
DB_LOCK lock_a_m;
bool m_locked = false;
r = db_env->lock_get(db_env, locker_a, 0, &object_m, DB_LOCK_WRITE, &lock_a_m);
assert(r == 0 || r == DB_LOCK_DEADLOCK);
if (r == 0)
m_locked = true;
r = db_env->lock_put(db_env, &lock_a_l); assert(r == 0);
if (m_locked) {
r = db_env->lock_put(db_env, &lock_a_m); assert(r == 0);
} else {
(void) toku_sync_fetch_and_add(locker_args->deadlock_count, 1);
if (verbose) printf("%s:%u m deadlock\n", __FUNCTION__, __LINE__);
}
r = db_env->lock_id_free(db_env, locker_a); assert(r == 0);
return arg;
}
static void *run_locker_b(void *arg) {
struct locker_args *locker_args = (struct locker_args *) arg;
DB_ENV *db_env = locker_args->db_env;
struct test_seq *test_seq = locker_args->test_seq;
int r;
uint32_t locker_b;
r = db_env->lock_id(db_env, &locker_b); assert(r == 0);
DBT object_l = { .data = (char *) "L", .size = 1 };
DBT object_m = { .data = (char *) "M", .size = 1 };
test_seq_sleep(test_seq, 1);
DB_LOCK lock_b_m;
r = db_env->lock_get(db_env, locker_b, DB_LOCK_NOWAIT, &object_m, DB_LOCK_WRITE, &lock_b_m); assert(r == 0);
test_seq_next_state(test_seq);
test_seq_sleep(test_seq, 2);
DB_LOCK lock_b_l;
bool l_locked = false;
r = db_env->lock_get(db_env, locker_b, 0, &object_l, DB_LOCK_WRITE, &lock_b_l);
assert(r == 0 || r == DB_LOCK_DEADLOCK);
if (r == 0)
l_locked = true;
r = db_env->lock_put(db_env, &lock_b_m); assert(r == 0);
if (l_locked) {
r = db_env->lock_put(db_env, &lock_b_l); assert(r == 0);
} else {
(void) toku_sync_fetch_and_add(locker_args->deadlock_count, 1);
if (verbose) printf("%s:%u l deadlock\n", __FUNCTION__, __LINE__);
}
r = db_env->lock_id_free(db_env, locker_b); assert(r == 0);
return arg;
}
static void simple_deadlock(DB_ENV *db_env) {
int r;
struct test_seq test_seq; ZERO_STRUCT(test_seq); test_seq_init(&test_seq);
int deadlock_count = 0 ;
toku_pthread_t tid_a;
struct locker_args args_a = { db_env, &test_seq, &deadlock_count };
r = toku_pthread_create(&tid_a, NULL, run_locker_a, &args_a); assert(r == 0);
toku_pthread_t tid_b;
struct locker_args args_b = { db_env, &test_seq, &deadlock_count };
r = toku_pthread_create(&tid_b, NULL, run_locker_b, &args_b); assert(r == 0);
while (1) {
sleep(10);
int rejected = 0;
r = db_env->lock_detect(db_env, 0, DB_LOCK_YOUNGEST, &rejected); assert(r == 0);
if (verbose)
printf("%s %d\n", __FUNCTION__, rejected);
if (rejected == 0)
break;
}
void *ret = NULL;
r = toku_pthread_join(tid_a, &ret); assert(r == 0);
r = toku_pthread_join(tid_b, &ret); assert(r == 0);
assert(deadlock_count == 1);
test_seq_destroy(&test_seq);
}
int test_main(int argc, char * const argv[]) {
uint64_t cachesize = 0;
int do_txn = 1;
const char *db_env_dir = TOKU_TEST_FILENAME;
int db_env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_THREAD;
// parse_args(argc, argv);
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
verbose++;
continue;
}
if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) {
if (verbose > 0)
verbose--;
continue;
}
assert(0);
}
// setup env
int r;
char rm_cmd[strlen(db_env_dir) + strlen("rm -rf ") + 1];
snprintf(rm_cmd, sizeof(rm_cmd), "rm -rf %s", db_env_dir);
r = system(rm_cmd); assert(r == 0);
r = toku_os_mkdir(db_env_dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); assert(r == 0);
DB_ENV *db_env = NULL;
r = db_env_create(&db_env, 0); assert(r == 0);
if (cachesize) {
const uint64_t gig = 1 << 30;
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
// run test
simple_deadlock(db_env);
// close env
r = db_env->close(db_env, 0); assert(r == 0); db_env = NULL;
return 0;
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
// verify that a simle write lock deadlock is detected by the BDB locker
// A write locks L
// B write locks M
// A tries to write lock M, gets DB_LOCK_NOTGRANTED
// B tries to write lock L, gets DB_LOCK_NOTGRANTED
#include "test.h"
static void simple_deadlock(DB_ENV *db_env) {
int r;
uint32_t locker_a;
r = db_env->lock_id(db_env, &locker_a); assert(r == 0);
uint32_t locker_b;
r = db_env->lock_id(db_env, &locker_b); assert(r == 0);
DBT object_l = { .data = (char *) "L", .size = 1 };
DBT object_m = { .data = (char *) "M", .size = 1 };
DB_LOCK lock_a_l;
r = db_env->lock_get(db_env, locker_a, DB_LOCK_NOWAIT, &object_l, DB_LOCK_WRITE, &lock_a_l); assert(r == 0);
DB_LOCK lock_b_m;
r = db_env->lock_get(db_env, locker_b, DB_LOCK_NOWAIT, &object_m, DB_LOCK_WRITE, &lock_b_m); assert(r == 0);
DB_LOCK lock_a_m;
r = db_env->lock_get(db_env, locker_a, DB_LOCK_NOWAIT, &object_m, DB_LOCK_WRITE, &lock_a_m); assert(r == DB_LOCK_NOTGRANTED);
DB_LOCK lock_b_l;
r = db_env->lock_get(db_env, locker_b, DB_LOCK_NOWAIT, &object_l, DB_LOCK_WRITE, &lock_b_l); assert(r == DB_LOCK_NOTGRANTED);
r = db_env->lock_put(db_env, &lock_a_l); assert(r == 0);
r = db_env->lock_put(db_env, &lock_b_m); assert(r == 0);
r = db_env->lock_id_free(db_env, locker_a); assert(r == 0);
r = db_env->lock_id_free(db_env, locker_b); assert(r == 0);
}
int test_main(int argc, char * const argv[]) {
uint64_t cachesize = 0;
int do_txn = 1;
const char *db_env_dir = TOKU_TEST_FILENAME;
int db_env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_THREAD;
// parse_args(argc, argv);
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
verbose++;
continue;
}
if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) {
if (verbose > 0)
verbose--;
continue;
}
assert(0);
}
// setup env
int r;
char rm_cmd[strlen(db_env_dir) + strlen("rm -rf ") + 1];
snprintf(rm_cmd, sizeof(rm_cmd), "rm -rf %s", db_env_dir);
r = system(rm_cmd); assert(r == 0);
r = toku_os_mkdir(db_env_dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); assert(r == 0);
DB_ENV *db_env = NULL;
r = db_env_create(&db_env, 0); assert(r == 0);
if (cachesize) {
const uint64_t gig = 1 << 30;
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if 0 && defined(USE_BDB)
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
#endif
// run test
simple_deadlock(db_env);
// close env
r = db_env->close(db_env, 0); assert(r == 0); db_env = NULL;
return 0;
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
// verify that the BDB locker can detect deadlocks on the fly and allow
// the deadlock to be unwound by the deadlocked threads. we use the
// set_lk_detect function to force the locker to check for deadlocks.
//
// A write locks L
// B write locks M
// A tries to write lock M && B tries to write lock L
// One of A or B should get the DEADLOCK error, the other waits
// A and B release their locks
#include "test.h"
#include "toku_pthread.h"
#include <portability/toku_atomic.h>
struct test_seq {
int state;
toku_mutex_t lock;
toku_cond_t cv;
};
static void test_seq_init(struct test_seq *seq) {
seq->state = 0;
toku_mutex_init(&seq->lock, NULL);
toku_cond_init(&seq->cv, NULL);
}
static void test_seq_destroy(struct test_seq *seq) {
toku_mutex_destroy(&seq->lock);
toku_cond_destroy(&seq->cv);
}
static void test_seq_sleep(struct test_seq *seq, int new_state) {
toku_mutex_lock(&seq->lock);
while (seq->state != new_state) {
toku_cond_wait(&seq->cv, &seq->lock);
}
toku_mutex_unlock(&seq->lock);
}
static void test_seq_next_state(struct test_seq *seq) {
toku_mutex_lock(&seq->lock);
seq->state++;
toku_cond_broadcast(&seq->cv);
toku_mutex_unlock(&seq->lock);
}
struct locker_args {
DB_ENV *db_env;
struct test_seq *test_seq;
int *deadlock_count;
};
static void *run_locker_a(void *arg) {
struct locker_args *locker_args = (struct locker_args *) arg;
DB_ENV *db_env = locker_args->db_env;
struct test_seq *test_seq = locker_args->test_seq;
int r;
uint32_t locker_a;
r = db_env->lock_id(db_env, &locker_a); assert(r == 0);
DBT object_l = { .data = (char *) "L", .size = 1 };
DBT object_m = { .data = (char *) "M", .size = 1 };
test_seq_sleep(test_seq, 0);
DB_LOCK lock_a_l;
r = db_env->lock_get(db_env, locker_a, DB_LOCK_NOWAIT, &object_l, DB_LOCK_WRITE, &lock_a_l); assert(r == 0);
test_seq_next_state(test_seq);
test_seq_sleep(test_seq, 2);
DB_LOCK lock_a_m;
bool m_locked = false;
r = db_env->lock_get(db_env, locker_a, 0, &object_m, DB_LOCK_WRITE, &lock_a_m);
assert(r == 0 || r == DB_LOCK_DEADLOCK);
if (r == 0)
m_locked = true;
r = db_env->lock_put(db_env, &lock_a_l); assert(r == 0);
if (m_locked) {
r = db_env->lock_put(db_env, &lock_a_m); assert(r == 0);
} else {
(void) toku_sync_fetch_and_add(locker_args->deadlock_count, 1);
if (verbose) printf("%s:%u m deadlock\n", __FUNCTION__, __LINE__);
}
r = db_env->lock_id_free(db_env, locker_a); assert(r == 0);
return arg;
}
static void *run_locker_b(void *arg) {
struct locker_args *locker_args = (struct locker_args *) arg;
DB_ENV *db_env = locker_args->db_env;
struct test_seq *test_seq = locker_args->test_seq;
int r;
uint32_t locker_b;
r = db_env->lock_id(db_env, &locker_b); assert(r == 0);
DBT object_l = { .data = (char *) "L", .size = 1 };
DBT object_m = { .data = (char *) "M", .size = 1 };
test_seq_sleep(test_seq, 1);
DB_LOCK lock_b_m;
r = db_env->lock_get(db_env, locker_b, DB_LOCK_NOWAIT, &object_m, DB_LOCK_WRITE, &lock_b_m); assert(r == 0);
test_seq_next_state(test_seq);
test_seq_sleep(test_seq, 2);
DB_LOCK lock_b_l;
bool l_locked = false;
r = db_env->lock_get(db_env, locker_b, 0, &object_l, DB_LOCK_WRITE, &lock_b_l);
assert(r == 0 || r == DB_LOCK_DEADLOCK);
if (r == 0)
l_locked = true;
r = db_env->lock_put(db_env, &lock_b_m); assert(r == 0);
if (l_locked) {
r = db_env->lock_put(db_env, &lock_b_l); assert(r == 0);
} else {
(void) toku_sync_fetch_and_add(locker_args->deadlock_count, 1);
if (verbose) printf("%s:%u l deadlock\n", __FUNCTION__, __LINE__);
}
r = db_env->lock_id_free(db_env, locker_b); assert(r == 0);
return arg;
}
static void simple_deadlock(DB_ENV *db_env) {
int r;
int deadlock_count = 0;
struct test_seq test_seq; ZERO_STRUCT(test_seq); test_seq_init(&test_seq);
toku_pthread_t tid_a;
struct locker_args args_a = { db_env, &test_seq, &deadlock_count };
r = toku_pthread_create(&tid_a, NULL, run_locker_a, &args_a); assert(r == 0);
toku_pthread_t tid_b;
struct locker_args args_b = { db_env, &test_seq, &deadlock_count };
r = toku_pthread_create(&tid_b, NULL, run_locker_b, &args_b); assert(r == 0);
void *ret = NULL;
r = toku_pthread_join(tid_a, &ret); assert(r == 0);
r = toku_pthread_join(tid_b, &ret); assert(r == 0);
assert(deadlock_count == 1);
test_seq_destroy(&test_seq);
}
int test_main(int argc, char * const argv[]) {
uint64_t cachesize = 0;
int do_txn = 1;
const char *db_env_dir = TOKU_TEST_FILENAME;
int db_env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_THREAD;
// parse_args(argc, argv);
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
verbose++;
continue;
}
if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) {
if (verbose > 0)
verbose--;
continue;
}
assert(0);
}
// setup env
int r;
char rm_cmd[strlen(db_env_dir) + strlen("rm -rf ") + 1];
snprintf(rm_cmd, sizeof(rm_cmd), "rm -rf %s", db_env_dir);
r = system(rm_cmd); assert(r == 0);
r = toku_os_mkdir(db_env_dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); assert(r == 0);
DB_ENV *db_env = NULL;
r = db_env_create(&db_env, 0); assert(r == 0);
if (cachesize) {
const uint64_t gig = 1 << 30;
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if defined(USE_BDB)
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
#endif
// run test
simple_deadlock(db_env);
// close env
r = db_env->close(db_env, 0); assert(r == 0); db_env = NULL;
return 0;
}
{
bdb_writes_undefined_data_to_disk
Memcheck:Param
pwrite64(buf)
fun:pwrite64
fun:__os_io
obj:/lib/libdb-4.3.so
fun:__memp_bhwrite
fun:__memp_sync_int
fun:__memp_fsync
fun:__db_sync
fun:__db_refresh
fun:__db_close
fun:__fop_subdb_setup
fun:__db_open
fun:__db_open_pp
}
{
bdb_leaks_db_home_strdup
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_strdup
fun:__db_open_pp
fun:main
}
{
bdb_leaks_in_db_create
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_calloc
fun:__bam_db_create
fun:db_create
fun:main
}
{
bdb_leaks_if_you_open_twice
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_strdup
fun:__db_open_pp
}
{
bdb_leaks_again
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_strdup
fun:__db_home
obj:/lib/libdb-4.3.so
fun:__dbenv_open
}
{
<bdb_leaks>
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_calloc
fun:__bam_db_create
fun:db_create
}
{
<bdb_leaks>
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_calloc
fun:__bam_db_create
fun:db_create
}
{
<bdb_leaks>
Memcheck:Leak
fun:_vgrZU_libcZdsoZa_malloc
fun:__os_malloc
fun:__os_calloc
fun:db_create
}
......@@ -175,11 +175,7 @@ setup (void) {
r=db_env_create(&env, 0); CKERR(r);
#ifndef TOKUDB
r=env->set_lk_max_objects(env, N); CKERR(r);
#else
r=env->set_redzone(env, 0); CKERR(r);
#endif
env->set_errfile(env, stderr);
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -174,9 +174,6 @@ setup (void) {
r=db_env_create(&env, 0); CKERR(r);
#ifndef TOKUDB
r=env->set_lk_max_objects(env, N); CKERR(r);
#endif
env->set_errfile(env, stderr);
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -169,9 +169,6 @@ setup (void) {
r=db_env_create(&env, 0); CKERR(r);
#ifndef TOKUDB
r=env->set_lk_max_objects(env, N); CKERR(r);
#endif
env->set_errfile(env, stderr);
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -168,13 +168,8 @@ setup (void) {
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r=env->set_redzone(env, 0); CKERR(r);
#endif
#ifndef TOKUDB
r=env->set_lk_max_objects(env, N); CKERR(r);
#endif
env->set_errfile(env, stderr);
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -98,7 +98,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_first_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -107,7 +106,6 @@ static int blocking_first_callback(DBT const *a UU(), DBT const *b UU(), void *e
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_first(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime) {
int r;
......@@ -122,11 +120,7 @@ static void blocking_first(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptim
DBC *cursor = NULL;
r = db->cursor(db, txn, &cursor, 0); assert(r == 0); // get a write lock on -inf +inf
#if TOKUDB
r = cursor->c_getf_first(cursor, DB_RMW, blocking_first_callback, &context); assert(r == DB_NOTFOUND);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_FIRST + DB_RMW); assert(r == DB_NOTFOUND);
#endif
usleep(sleeptime);
......@@ -219,9 +213,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -116,7 +116,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_first_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -125,7 +124,6 @@ static int blocking_first_callback(DBT const *a UU(), DBT const *b UU(), void *e
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_first(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime) {
int r;
......@@ -140,11 +138,7 @@ static void blocking_first(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptim
DBC *cursor = NULL;
r = db->cursor(db, txn, &cursor, 0); assert(r == 0); // get a write lock on -inf ... 0
#if TOKUDB
r = cursor->c_getf_first(cursor, DB_RMW, blocking_first_callback, &context); assert(r == 0);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_FIRST + DB_RMW); assert(r == 0);
#endif
usleep(sleeptime);
r = cursor->c_close(cursor); assert(r == 0);
......@@ -236,9 +230,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -116,7 +116,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_last_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -125,7 +124,6 @@ static int blocking_last_callback(DBT const *a UU(), DBT const *b UU(), void *e
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_last(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime) {
int r;
......@@ -140,11 +138,7 @@ static void blocking_last(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime
DBC *cursor = NULL;
r = db->cursor(db, txn, &cursor, 0); assert(r == 0); // get a write lock on -inf ... 0
#if TOKUDB
r = cursor->c_getf_last(cursor, DB_RMW, blocking_last_callback, &context); assert(r == 0);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_LAST + DB_RMW); assert(r == 0);
#endif
usleep(sleeptime);
r = cursor->c_close(cursor); assert(r == 0);
......@@ -236,9 +230,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -124,7 +124,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_next_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -133,7 +132,6 @@ static int blocking_next_callback(DBT const *a UU(), DBT const *b UU(), void *e
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_next(DB_ENV *db_env, DB *db, uint64_t nrows UU(), long sleeptime) {
int r;
......@@ -150,11 +148,7 @@ static void blocking_next(DB_ENV *db_env, DB *db, uint64_t nrows UU(), long slee
uint64_t i;
for (i = 0; ; i++) {
#if TOKUDB
r = cursor->c_getf_next(cursor, DB_RMW, blocking_next_callback, &context);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_NEXT + DB_RMW);
#endif
if (r != 0)
break;
if (verbose)
......@@ -196,11 +190,7 @@ static void blocking_prev(DB_ENV *db_env, DB *db, uint64_t nrows UU(), long slee
uint64_t i;
for (i = 0; ; i++) {
#if TOKUDB
r = cursor->c_getf_prev(cursor, DB_RMW, blocking_next_callback, &context);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_PREV + DB_RMW);
#endif
if (r != 0)
break;
if (verbose)
......@@ -305,11 +295,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#else
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -123,7 +123,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_next_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -132,7 +131,6 @@ static int blocking_next_callback(DBT const *a UU(), DBT const *b UU(), void *e
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_next(DB_ENV *db_env, DB *db, uint64_t nrows UU(), long sleeptime) {
int r;
......@@ -149,11 +147,7 @@ static void blocking_next(DB_ENV *db_env, DB *db, uint64_t nrows UU(), long slee
uint64_t i;
for (i = 0; ; i++) {
#if TOKUDB
r = cursor->c_getf_next(cursor, 0, blocking_next_callback, &context);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_NEXT);
#endif
if (r != 0)
break;
if (verbose)
......@@ -199,11 +193,7 @@ static void blocking_prev(DB_ENV *db_env, DB *db, uint64_t nrows UU(), long slee
uint64_t i;
for (i = 0; ; i++) {
#if TOKUDB
r = cursor->c_getf_prev(cursor, 0, blocking_next_callback, &context);
#else
r = cursor->c_get(cursor, &context.key, &context.val, DB_PREV);
#endif
if (r != 0)
break;
if (verbose)
......
......@@ -181,9 +181,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -156,11 +156,7 @@ static void t_b(DB_ENV *db_env, DB *db, struct test_seq *seq) {
DBT key = { .data = &k, .size = sizeof k };
DBT val = { .data = &k, .size = sizeof k };
r = db->put(db, txn_b, &key, &val, 0);
#if USE_BDB
assert(r == DB_LOCK_DEADLOCK);
#else
assert(r == DB_LOCK_NOTGRANTED);
#endif
r = txn_b->abort(txn_b); assert(r == 0);
}
......@@ -212,31 +208,12 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if USE_BDB
db_timeout_t t;
r = db_env->get_timeout(db_env, &t, DB_SET_LOCK_TIMEOUT); assert(r == 0);
if (verbose) printf("lock %d\n", t);
r = db_env->get_timeout(db_env, &t, DB_SET_TXN_TIMEOUT); assert(r == 0);
if (verbose) printf("txn %d\n", t);
r = db_env->set_timeout(db_env, 5000000, DB_SET_LOCK_TIMEOUT); assert(r == 0);
r = db_env->set_timeout(db_env, 5000000, DB_SET_TXN_TIMEOUT); assert(r == 0);
r = db_env->get_timeout(db_env, &t, DB_SET_LOCK_TIMEOUT); assert(r == 0);
if (verbose) printf("lock %d\n", t);
r = db_env->get_timeout(db_env, &t, DB_SET_TXN_TIMEOUT); assert(r == 0);
if (verbose) printf("txn %d\n", t);
r = db_env->set_lk_detect(db_env, DB_LOCK_EXPIRE); assert(r == 0);
#endif
#if USE_TDB
uint64_t lock_timeout_msec;
r = db_env->get_lock_timeout(db_env, &lock_timeout_msec); assert(r == 0);
if (verbose) printf("lock timeout: %" PRIu64 "\n", lock_timeout_msec);
r = db_env->set_lock_timeout(db_env, 5000, nullptr); assert(r == 0);
r = db_env->get_lock_timeout(db_env, &lock_timeout_msec); assert(r == 0);
if (verbose) printf("lock timeout: %" PRIu64 "\n", lock_timeout_msec);
#endif
// create the db
DB *db = NULL;
......
......@@ -208,9 +208,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -180,9 +180,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -117,7 +117,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_set_range_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -126,7 +125,6 @@ static int blocking_set_range_callback(DBT const *a UU(), DBT const *b UU(), voi
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_set_range(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime, uint64_t the_key) {
int r;
......@@ -144,11 +142,7 @@ static void blocking_set_range(DB_ENV *db_env, DB *db, uint64_t nrows, long slee
uint64_t k = htonl(the_key);
DBT key = { .data = &k, .size = sizeof k };
#if TOKUDB
r = cursor->c_getf_set_range(cursor, DB_RMW, &key, blocking_set_range_callback, &context); assert(r == 0);
#else
r = cursor->c_get(cursor, &key, &context.val, DB_SET_RANGE + DB_RMW); assert(r == 0);
#endif
uint64_t v;
assert(context.val.size == sizeof v);
memcpy(&v, context.val.data, context.val.size);
......@@ -246,9 +240,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -117,7 +117,6 @@ struct my_callback_context {
DBT val;
};
#if TOKUDB
static int blocking_set_range_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
DBT const *found_key = a;
DBT const *found_val = b;
......@@ -126,7 +125,6 @@ static int blocking_set_range_callback(DBT const *a UU(), DBT const *b UU(), voi
copy_dbt(&context->val, found_val);
return 0;
}
#endif
static void blocking_set_range(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime, uint64_t the_key) {
int r;
......@@ -144,11 +142,7 @@ static void blocking_set_range(DB_ENV *db_env, DB *db, uint64_t nrows, long slee
uint64_t k = htonl(the_key);
DBT key = { .data = &k, .size = sizeof k };
#if TOKUDB
r = cursor->c_getf_set_range(cursor, DB_RMW, &key, blocking_set_range_callback, &context); assert(r == DB_NOTFOUND);
#else
r = cursor->c_get(cursor, &key, &context.val, DB_SET_RANGE + DB_RMW); assert(r == DB_NOTFOUND);
#endif
usleep(sleeptime);
r = cursor->c_close(cursor); assert(r == 0);
......@@ -241,9 +235,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -142,11 +142,7 @@ static void blocking_set_range(DB_ENV *db_env, DB *db, uint64_t nrows, long slee
uint64_t k = htonl(the_key);
DBT key = { .data = &k, .size = sizeof k };
#if TOKUDB
r = cursor->c_getf_set_range_reverse(cursor, 0, &key, blocking_set_range_callback, &context); assert(r == 0);
#else
r = cursor->c_get(cursor, &key, &context.val, DB_SET_RANGE_REVERSE); assert(r == 0);
#endif
uint64_t v;
assert(context.val.size == sizeof v);
memcpy(&v, context.val.data, context.val.size);
......@@ -244,9 +240,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -112,7 +112,6 @@ static void populate(DB_ENV *db_env, DB *db, uint64_t nrows) {
r = txn->commit(txn, 0); assert(r == 0);
}
#if TOKUDB
static int blocking_set_callback(DBT const *a UU(), DBT const *b UU(), void *e UU()) {
// DBT const *found_key = a;
DBT const *found_val = b;
......@@ -123,7 +122,6 @@ static int blocking_set_callback(DBT const *a UU(), DBT const *b UU(), void *e U
memcpy(my_val->data, found_val->data, found_val->size);
return 0;
}
#endif
static void blocking_set(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime) {
int r;
......@@ -140,11 +138,7 @@ static void blocking_set(DB_ENV *db_env, DB *db, uint64_t nrows, long sleeptime)
uint64_t k = htonl(0); // set to key 0
DBT key = { .data = &k, .size = sizeof k };
#if TOKUDB
r = cursor->c_getf_set(cursor, DB_RMW, &key, blocking_set_callback, &val); assert(r == 0);
#else
r = cursor->c_get(cursor, &key, &val, DB_SET + DB_RMW); assert(r == 0);
#endif
uint64_t v;
assert(val.size == sizeof v);
memcpy(&v, val.data, val.size);
......@@ -226,9 +220,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -174,9 +174,7 @@ int test_main(int argc, char * const argv[]) {
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert(r == 0);
}
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -118,9 +118,7 @@ checkpoint1 (void)
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_redzone(env, 0); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
......
......@@ -147,9 +147,7 @@ int test_main(int argc, char * const argv[]) {
// try to starve the checkpoint
{ int chk_r = db_env_create(&env, 0); CKERR(chk_r); }
#ifdef USE_TDB
{ int chk_r = env->set_redzone(env, 0); CKERR(chk_r); }
#endif
{
const int size = 10+strlen(env_dir);
char cmd[size];
......
......@@ -272,10 +272,7 @@ random_acts(void * d) {
}
}
#if IS_TDB && !TOKU_WINDOWS
return intothevoid;
#endif
}
uint64_t max_windows_cachesize = 256 << 20;
......
......@@ -114,13 +114,9 @@ static void run_test (void) {
r = db_create(&db, env, 0); CKERR(r);
r = db->open(db, NULL, "bdir/b.db", NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666);
#if USE_TDB
CKERR(r); //Success, so need a new handle
r = db->close(db, 0); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
#else
assert(r != 0);
#endif
char path[TOKU_PATH_MAX+1];
r = toku_os_mkdir(toku_path_join(path, 2, TOKU_TEST_FILENAME, "bdir"), 0777); assert(r == 0);
r = db->open(db, NULL, "bdir/b.db", NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......@@ -137,13 +133,6 @@ static void run_test (void) {
r = db->open(db, NULL, "c.db", NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r);
#if 0
// test fname with absolute path
r = db_create(&db, env, 0); CKERR(r);
r = db->open(db, NULL, "/tmp/d.db", NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r);
#endif
r = env->close(env, 0); CKERR(r);
}
......
......@@ -104,22 +104,14 @@ setup (void) {
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r=env->set_redzone(env, 0); CKERR(r);
r=env->set_default_bt_compare(env, int_dbt_cmp); CKERR(r);
#endif
env->set_errfile(env, stderr);
#ifdef USE_BDB
r=env->set_lk_max_objects(env, 2*num_insert); CKERR(r);
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &txn, 0); assert(r==0);
#ifdef USE_BDB
r=db->set_bt_compare(db, int_dbt_cmp); CKERR(r);
#endif
r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=txn->commit(txn, 0); assert(r==0);
}
......
......@@ -184,9 +184,6 @@ static void simple_deadlock(DB_ENV *db_env, DB *db, int do_txn, int n) {
}
uint32_t txn_flags = 0;
#if USE_BDB
txn_flags = DB_TXN_NOWAIT; // force no wait for BDB to avoid a bug described below
#endif
DB_TXN *txn_a = NULL;
if (do_txn) {
......@@ -209,7 +206,6 @@ static void simple_deadlock(DB_ENV *db_env, DB *db, int do_txn, int n) {
test_seq_next_state(&test_seq);
test_seq_sleep(&test_seq, 2);
// BDB does not time out this lock request, so the test hangs. it looks like a bug in bdb's __lock_get_internal.
insert_row(db, txn_a, htonl(n-1), n-1, DB_LOCK_NOTGRANTED);
test_seq_next_state(&test_seq);
......@@ -268,16 +264,8 @@ int test_main(int argc, char * const argv[]) {
}
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
#if USE_BDB
r = db_env->set_flags(db_env, DB_TIME_NOTGRANTED, 1); assert(r == 0); // force DB_LOCK_DEADLOCK to DB_LOCK_NOTGRANTED
#endif
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if defined(USE_TDB)
r = db_env->set_lock_timeout(db_env, 0, nullptr); assert(r == 0); // no wait
#elif defined(USE_BDB)
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
r = db_env->set_timeout(db_env, 10000, DB_SET_LOCK_TIMEOUT); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -88,7 +88,7 @@ PATENT RIGHTS GRANT:
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
// this test demonstrates that a simple deadlock with 2 transactions on a single thread works with tokudb, hangs with bdb
// this test demonstrates that a simple deadlock with 2 transactions on a single thread works with tokudb
#include "test.h"
......@@ -115,9 +115,6 @@ static void simple_deadlock(DB_ENV *db_env, DB *db, int do_txn, int n) {
}
uint32_t txn_flags = 0;
#if USE_BDB
txn_flags = DB_TXN_NOWAIT; // force no wait for BDB to avoid a bug described below
#endif
DB_TXN *txn_a = NULL;
if (do_txn) {
......@@ -133,7 +130,6 @@ static void simple_deadlock(DB_ENV *db_env, DB *db, int do_txn, int n) {
insert_row(db, txn_b, htonl(n-1), n-1, 0);
// if the txn_flags is 0, then BDB does not time out this lock request, so the test hangs. it looks like a bug in bdb's __lock_get_internal.
insert_row(db, txn_a, htonl(n-1), n-1, DB_LOCK_NOTGRANTED);
insert_row(db, txn_b, htonl(0), 0, DB_LOCK_NOTGRANTED);
......@@ -148,7 +144,7 @@ int test_main(int argc, char * const argv[]) {
uint64_t cachesize = 0;
uint32_t pagesize = 0;
int do_txn = 1;
int nrows = 1000; // for BDB, insert enough rows to create a tree with more than one page in it. this avoids a page locking conflict.
int nrows = 1000;
const char *db_env_dir = TOKU_TEST_FILENAME;
const char *db_filename = "simple_deadlock";
int db_env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_THREAD;
......@@ -187,14 +183,7 @@ int test_main(int argc, char * const argv[]) {
}
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
#if USE_BDB
r = db_env->set_flags(db_env, DB_TIME_NOTGRANTED, 1); assert(r == 0); // force DB_LOCK_DEADLOCK to DB_LOCK_NOTGRANTED
#endif
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if defined(USE_BDB)
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
r = db_env->set_timeout(db_env, 1000, DB_SET_LOCK_TIMEOUT); assert(r == 0);
#endif
// create the db
DB *db = NULL;
r = db_create(&db, db_env, 0); assert(r == 0);
......
......@@ -213,11 +213,7 @@ int test_main(int argc, char * const argv[]) {
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if TOKUDB
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#else
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
#endif
// create the db
DB *db = NULL;
......
......@@ -91,7 +91,6 @@ PATENT RIGHTS GRANT:
// for all i: T(i) reads 0, gets a read lock on 0
// for all i: T(i) writes 0, enters a deadlock
// tokudb detects deadlock on the fly
// bdb detects deadlock on the fly or uses a deadlock detector
// --poll runs the deadlock detector until all the txns are resolved
#include "test.h"
......@@ -201,18 +200,6 @@ static void update_deadlock(DB_ENV *db_env, DB *db, int do_txn, int nrows, int n
}
#endif
#if defined(USE_BDB)
// check for deadlocks
if (poll_deadlock) {
while (n_txns > 0) {
sleep(10);
int rejected = 0;
r = db_env->lock_detect(db_env, 0, DB_LOCK_YOUNGEST, &rejected); assert(r == 0);
printf("%s rejected %d\n", __FUNCTION__, rejected);
}
}
#endif
// cleanup
for (int i = 0; i < ntxns; i++) {
void *ret = NULL;
......@@ -274,14 +261,7 @@ int test_main(int argc, char * const argv[]) {
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert(r == 0);
#if defined(TOKUDB)
r = db_env->set_lock_timeout(db_env, 30 * 1000, nullptr); assert(r == 0);
#endif
#if defined(USE_BDB)
if (!poll_deadlock) {
r = db_env->set_lk_detect(db_env, DB_LOCK_YOUNGEST); assert(r == 0);
}
#endif
// create the db
DB *db = NULL;
......
......@@ -106,22 +106,14 @@ setup (void) {
}
r=db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r=env->set_redzone(env, 0); CKERR(r);
r=env->set_default_bt_compare(env, int_dbt_cmp); CKERR(r);
#endif
env->set_errfile(env, stderr);
#ifdef USE_BDB
r=env->set_lk_max_objects(env, 2*num_insert); CKERR(r);
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &txn, 0); assert(r==0);
#ifdef USE_BDB
r=db->set_bt_compare(db, int_dbt_cmp); CKERR(r);
#endif
r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=txn->commit(txn, 0); assert(r==0);
}
......
......@@ -196,11 +196,7 @@ delete_n (uint32_t ah)
ndelete_notfound++;
else
ndelete_failed++;
#ifdef USE_BDB
assert(r==0 || r==DB_NOTFOUND);
#else
CKERR(r);
#endif
}
static void
......
......@@ -165,11 +165,7 @@ delete_n (uint32_t ah)
DBT key;
dbt_init(&key, &an, 4);
int r = db->del(db, NULL, &key, DB_DELETE_ANY);
#ifdef USE_BDB
assert(r==0 || r==DB_NOTFOUND);
#else
CKERR(r);
#endif
}
static void
......
......@@ -179,11 +179,7 @@ delete_n_now (uint32_t ah)
DBT key;
dbt_init(&key, &an, 4);
int r = db->del(db, NULL, &key, DB_DELETE_ANY);
#ifdef USE_BDB
assert(r==0 || r==DB_NOTFOUND);
#else
CKERR(r);
#endif
get_n(ah, DB_NOTFOUND);
}
......
// verify that the loader can deal with blobs larger than the node size
#include "test.h"
static int my_bt_compare(DB *db, const DBT *a, const DBT *b) {
db = db;
assert(a->size == 8 && b->size == 8);
return memcmp(a->data, b->data, 8);
}
static int my_row_generate(DB *dest_db, DB *src_db, DBT *dest_key, DBT *dest_val, const DBT *src_key, const DBT *src_val) {
dest_db = dest_db; src_db = src_db; dest_key = dest_key; dest_val = dest_val; src_key = src_key; src_val = src_val;
assert(dest_key->flags == DB_DBT_REALLOC);
dest_key->data = toku_realloc(dest_key->data, src_key->size);
memcpy(dest_key->data, src_key->data, src_key->size);
dest_key->size = src_key->size;
assert(dest_val->flags == DB_DBT_REALLOC);
dest_val->data = toku_realloc(dest_val->data, src_val->size);
memcpy(dest_val->data, src_val->data, src_val->size);
dest_val->size = src_val->size;
return 0;
}
static void insert(DB_LOADER *loader, int k, int val_size) {
int r;
// generate the key
char key_buffer[8];
memset(key_buffer, 0, sizeof key_buffer);
int newa = htonl(k);
memcpy(key_buffer, &newa, sizeof newa);
// generate the value
char *val_buffer = toku_malloc(val_size); assert(val_buffer);
memset(val_buffer, 0, val_size);
DBT key = { .data = key_buffer, .size = sizeof key_buffer };
DBT value = { .data = val_buffer, .size = val_size };
r = loader->put(loader, &key, &value);
if (DISALLOW_PUTS) {
assert(r == EINVAL);
}
else {
assert_zero(r);
}
toku_free(val_buffer);
}
int test_main(int argc, char * const argv[]) {
uint32_t loader_flags = 0;
#if defined(TOKUDB)
char *db_env_dir = "blobs.leafsplit.env.tokudb";
#else
char *db_env_dir = "blobs.leafsplit.env.bdb";
#endif
int db_env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG;
char *db_filename = "blobs.db";
int do_txn = 1;
u_int64_t cachesize = 0;
u_int32_t pagesize = 0;
int i;
for (i = 1; i < argc; i++) {
char *arg = argv[i];
if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0) {
verbose++;
continue;
}
if (strcmp(arg, "-q") == 0) {
if (verbose > 0) verbose--;
continue;
}
if (strcmp(arg, "-z") == 0) {
loader_flags |= LOADER_COMPRESS_INTERMEDIATES;
continue;
}
if (strcmp(arg, "-p") == 0) {
loader_flags |= LOADER_DISALLOW_PUTS;
continue;
}
if (strcmp(arg, "--txn") == 0 && i+1 < argc) {
do_txn = atoi(argv[++i]);
continue;
}
if (strcmp(arg, "--pagesize") == 0 && i+1 < argc) {
pagesize = atoi(argv[++i]);
continue;
}
if (strcmp(arg, "--cachesize") == 0 && i+1 < argc) {
cachesize = atol(argv[++i]);
continue;
}
assert(0);
}
int r;
char rm_cmd[strlen(db_env_dir) + strlen("rm -rf ") + 1];
snprintf(rm_cmd, sizeof(rm_cmd), "rm -rf %s", db_env_dir);
r = system(rm_cmd); assert_zero(r);
r = toku_os_mkdir(db_env_dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); assert_zero(r);
// create and open the env
DB_ENV *db_env = NULL;
r = db_env_create(&db_env, 0); assert_zero(r);
if (cachesize) {
const u_int64_t gig = 1 << 30;
r = db_env->set_cachesize(db_env, cachesize / gig, cachesize % gig, 1); assert_zero(r);
}
r = db_env->set_generate_row_callback_for_put(db_env, my_row_generate); assert_zero(r);
r = db_env->set_default_bt_compare(db_env, my_bt_compare); assert_zero(r);
if (!do_txn)
db_env_open_flags &= ~(DB_INIT_TXN | DB_INIT_LOG);
r = db_env->open(db_env, db_env_dir, db_env_open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert_zero(r);
// create the db
DB *db = NULL;
r = db_create(&db, db_env, 0); assert_zero(r);
DB_TXN *create_txn = NULL;
if (do_txn) {
r = db_env->txn_begin(db_env, NULL, &create_txn, 0); assert_zero(r);
}
if (pagesize) {
r = db->set_pagesize(db, pagesize); assert_zero(r);
}
r = db->open(db, create_txn, db_filename, NULL, DB_BTREE, DB_CREATE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); assert_zero(r);
DB_LOADER *loader = NULL;
uint32_t db_flags = 0;
uint32_t dbt_flags = 0;
r = db_env->create_loader(db_env, create_txn, &loader, db, 1, &db, &db_flags, &dbt_flags, loader_flags); assert_zero(r);
insert(loader, 1, 8000000);
insert(loader, 2, 1);
r = loader->close(loader); assert_zero(r);
if (do_txn) {
r = create_txn->commit(create_txn, 0); assert_zero(r);
}
// shutdown
r = db->close(db, 0); assert_zero(r); db = NULL;
r = db_env->close(db_env, 0); assert_zero(r); db_env = NULL;
return 0;
}
......@@ -177,9 +177,6 @@ test_setup (void) {
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_env_create(&env, 0); CKERR(r);
#ifndef TOKUDB
r=env->set_lk_max_objects(env, N); CKERR(r);
#endif
env->set_errfile(env, stderr);
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -100,8 +100,6 @@ const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG
const char *namea="a.db";
const char *nameb="b.db";
#if USE_TDB
static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
assert(db);
assert(db->cmp_descriptor);
......@@ -112,17 +110,13 @@ static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
return memcmp(a->data, b->data, a->size);
}
#endif
static void
change_descriptor(DB_ENV* env, DB* db) {
#if USE_TDB
DBT descriptor;
dbt_init(&descriptor, descriptor_contents, sizeof(descriptor_contents));
IN_TXN_COMMIT(env, NULL, txn_desc, 0, {
{ int chk_r = db->change_descriptor(db, txn_desc, &descriptor, DB_UPDATE_CMP_DESCRIPTOR); CKERR(chk_r); }
});
#endif
}
static void
......@@ -136,9 +130,7 @@ do_x1_shutdown (bool do_commit, bool do_abort) {
DB *dba, *dbb;
r = db_env_create(&env, 0); CKERR(r);
r = env->set_data_dir(env, "data"); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......@@ -181,9 +173,7 @@ do_x1_recover (bool did_commit) {
r = toku_os_mkdir(datadir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
r = env->set_data_dir(env, "data"); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......
......@@ -98,16 +98,12 @@ const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG
const char *namea="a.db";
const char *nameb="b.db";
#if USE_TDB
static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
assert(db);
assert(a->size == b->size);
return memcmp(a->data, b->data, a->size);
}
#endif
static void
do_x1_shutdown (bool do_commit, bool do_abort) {
int r;
......@@ -116,9 +112,7 @@ do_x1_shutdown (bool do_commit, bool do_abort) {
DB_ENV *env;
DB *dba, *dbb;
r = db_env_create(&env, 0); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......@@ -155,9 +149,7 @@ do_x1_recover (bool did_commit) {
DB *dba, *dbb;
int r;
r = db_env_create(&env, 0); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......
......@@ -99,7 +99,6 @@ static const char *namea="a.db"; uint32_t nodesizea = 0;
static const char *nameb="b.db"; uint32_t nodesizeb = 32*1024;
static void do_remove(DB_ENV *env, const char *filename) {
#if TOKUDB
int r;
DBT dname;
DBT iname;
......@@ -112,12 +111,6 @@ static void do_remove(DB_ENV *env, const char *filename) {
toku_path_join(rmpath, 2, TOKU_TEST_FILENAME, iname.data);
toku_os_recursive_delete(rmpath);
toku_free(iname.data);
#else
(void) env;
char rmpath[TOKU_PATH_MAX+1];
toku_path_join(rmpath, 2, TOKU_TEST_FILENAME, filename);
toku_os_recursive_delete(rmpath);
#endif
}
static void run_test (void) {
......
......@@ -100,7 +100,6 @@ static const char *namea="a.db"; uint32_t nodesizea = 0;
static const char *nameb="b.db"; uint32_t nodesizeb = 64*1024;
static void do_remove(DB_ENV *env, const char *filename) {
#if TOKUDB
int r;
DBT dname;
DBT iname;
......@@ -113,12 +112,6 @@ static void do_remove(DB_ENV *env, const char *filename) {
toku_path_join(rmpath, 2, TOKU_TEST_FILENAME, iname.data);
toku_os_recursive_delete(rmpath);
toku_free(iname.data);
#else
(void) env;
char rmpath[TOKU_PATH_MAX+1];
toku_path_join(rmpath, 2, TOKU_TEST_FILENAME, filename);
toku_os_recursive_delete(rmpath);
#endif
}
static void run_test (void) {
......
......@@ -109,9 +109,7 @@ static void run_test (void) {
DB_ENV *env;
r = db_env_create(&env, 0); CKERR(r);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
DB *dba;
......@@ -160,9 +158,7 @@ static void run_recover (void) {
CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags + DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO);
assert(r == DB_RUNRECOVERY);
......@@ -184,9 +180,7 @@ static void run_no_recover (void) {
int r;
r = db_env_create(&env, 0); CKERR(r);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags & ~DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = env->close(env, 0); CKERR(r);
exit(0);
......
......@@ -109,9 +109,7 @@ static void run_test (void) {
DB *dba;
r = db_env_create(&env, 0); CKERR(r);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
......@@ -151,9 +149,7 @@ static void run_recover (void) {
CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags + DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR2(r, DB_RUNRECOVERY);
......@@ -175,9 +171,7 @@ static void run_no_recover (void) {
int r;
r = db_env_create(&env, 0); CKERR(r);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags & ~DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = env->close(env, 0); CKERR(r);
exit(0);
......
......@@ -105,8 +105,6 @@ const char *namea="a.db";
int verified = 0;
uint32_t forced_version = 2;
#if USE_TDB
static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
assert(db);
assert(db->cmp_descriptor);
......@@ -121,18 +119,14 @@ static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
return memcmp(a->data, b->data, a->size);
}
#endif
static void
change_descriptor(DB* db, int which, DB_ENV* env) {
#if USE_TDB
DBT descriptor;
size_t len = strlen(descriptor_contents[which])+1;
dbt_init(&descriptor, descriptor_contents[which], len);
IN_TXN_COMMIT(env, NULL, txn_desc, 0, {
{ int chk_r = db->change_descriptor(db, txn_desc, &descriptor, DB_UPDATE_CMP_DESCRIPTOR); CKERR(chk_r); }
});
#endif
}
static void
......@@ -146,9 +140,7 @@ do_x1_shutdown (bool do_commit, bool do_abort) {
DB *dba, *dbb;
r = db_env_create(&env, 0); CKERR(r);
r = env->set_data_dir(env, "data"); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
......@@ -194,9 +186,7 @@ do_x1_recover (bool did_commit) {
r = toku_os_mkdir(datadir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
r = env->set_data_dir(env, "data"); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......
......@@ -105,8 +105,6 @@ const char *namea="a.db";
int verified = 0;
uint32_t forced_version = 2;
#if USE_TDB
static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
assert(db);
assert(db->cmp_descriptor);
......@@ -121,18 +119,14 @@ static int my_compare(DB *UU(db), const DBT *a, const DBT *b) {
return memcmp(a->data, b->data, a->size);
}
#endif
static void
change_descriptor(DB* db, int which, DB_ENV* env) {
#if USE_TDB
DBT descriptor;
size_t len = strlen(descriptor_contents[which])+1;
dbt_init(&descriptor, descriptor_contents[which], len);
IN_TXN_COMMIT(env, NULL, txn_desc, 0, {
{ int chk_r = db->change_descriptor(db, txn_desc, &descriptor, DB_UPDATE_CMP_DESCRIPTOR); CKERR(chk_r); }
});
#endif
}
static void
......@@ -146,9 +140,7 @@ do_x1_shutdown (bool do_commit, bool do_abort) {
DB *dba;
r = db_env_create(&env, 0); CKERR(r);
r = env->set_data_dir(env, "data"); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
......@@ -197,9 +189,7 @@ do_x1_recover (bool did_commit) {
r = toku_os_mkdir(datadir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
r = env->set_data_dir(env, "data"); CKERR(r);
#if USE_TDB
r = env->set_default_bt_compare(env, my_compare); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&dba, env, 0); CKERR(r);
r = dba->open(dba, NULL, namea, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
......
......@@ -184,11 +184,7 @@ static void root_fifo_2(int n, int create_outside) {
// cleanup
r = env->close(env, 0);
#if TOKUDB
assert(r == 0); env = null_env;
#else
printf("%s:%d env close r=%d\n", __FUNCTION__, __LINE__, r);
#endif
}
int test_main(int argc, char *const argv[]) {
......
......@@ -102,9 +102,7 @@ static void setup_env (void) {
{int r = toku_os_mkdir(envdir, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); }
{int r = db_env_create(&env, 0); CKERR(r); }
//env->set_errfile(env, stderr);
#ifdef TOKUDB
CKERR(env->set_redzone(env, 0));
#endif
{ int r = env->open(env, envdir, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); }
{ int r = db_create(&db, env, 0); CKERR(r); }
{ int r = db->open(db, NULL, "foo.db", 0, DB_BTREE, DB_CREATE | DB_AUTO_COMMIT, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); }
......@@ -119,14 +117,11 @@ static void put (const char *keystring, int size, bool should_work) {
DBT k, v;
dbt_init(&k, keystring, 1+strlen(keystring));
dbt_init(&v, toku_xcalloc(size, 1), size);
#ifdef USE_BDB
#define DB_YES_OVERWRITE 0
#endif
static DB_TXN *txn = NULL;
{ int r = env->txn_begin(env, 0, &txn, 0); CKERR(r); }
{
int r = db->put(db, NULL, &k, &v, 0);
if (!IS_TDB || should_work) {
if (should_work) {
CKERR(r);
} else {
assert(r!=0);
......
......@@ -136,9 +136,7 @@ test_main (int argc, char * const argv[]) {
parse_args(argc, argv);
setup(FLAGS_LOG);
env->txn_checkpoint(env, 0, 0, 0);
#ifdef USE_TDB
print_engine_status(env);
#endif
test_shutdown();
return 0;
}
......@@ -103,9 +103,7 @@ static void clean_env (const char *envdir) {
static void setup_env (DB_ENV **envp, const char *envdir) {
{ int chk_r = db_env_create(envp, 0); CKERR(chk_r); }
(*envp)->set_errfile(*envp, stderr);
#ifdef TOKUDB
{ int chk_r = (*envp)->set_redzone(*envp, 0); CKERR(chk_r); }
#endif
{ int chk_r = (*envp)->open(*envp, envdir, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(chk_r); }
}
......
......@@ -105,9 +105,7 @@ static void clean_env (const char *envdir) {
static void setup_env (DB_ENV **envp, const char *envdir) {
{ int chk_r = db_env_create(envp, 0); CKERR(chk_r); }
(*envp)->set_errfile(*envp, stderr);
#ifdef TOKUDB
{ int chk_r = (*envp)->set_redzone(*envp, 0); CKERR(chk_r); }
#endif
{ int chk_r = (*envp)->open(*envp, envdir, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(chk_r); }
}
......
......@@ -105,9 +105,7 @@ static void clean_env (const char *envdir) {
static void setup_env (DB_ENV **envp, const char *envdir) {
{ int chk_r = db_env_create(envp, 0); CKERR(chk_r); }
(*envp)->set_errfile(*envp, stderr);
#ifdef TOKUDB
{ int chk_r = (*envp)->set_redzone(*envp, 0); CKERR(chk_r); }
#endif
{ int chk_r = (*envp)->open(*envp, envdir, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(chk_r); }
}
......
......@@ -103,9 +103,7 @@ static void clean_env (const char *envdir) {
static void setup_env (DB_ENV **envp, const char *envdir) {
{ int chk_r = db_env_create(envp, 0); CKERR(chk_r); }
(*envp)->set_errfile(*envp, stderr);
#ifdef TOKUDB
{ int chk_r = (*envp)->set_redzone(*envp, 0); CKERR(chk_r); }
#endif
{ int chk_r = (*envp)->open(*envp, envdir, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(chk_r); }
}
......
......@@ -107,17 +107,13 @@ PATENT RIGHTS GRANT:
#include "toku_assert.h"
#include <signal.h>
#include <time.h>
#if defined(USE_TDB)
#include "ydb.h"
//TDB uses DB_NOTFOUND for c_del and DB_CURRENT errors.
#ifdef DB_KEYEMPTY
#error
#endif
#define DB_KEYEMPTY DB_NOTFOUND
#endif
#ifndef DB_DELETE_ANY
#define DB_DELETE_ANY 0
#endif
// Certain tests fail when row locks taken for read are not shared.
// This switch prevents them from failing so long as read locks are not shared.
......@@ -144,13 +140,6 @@ int verbose=0;
fflush(stderr); \
} while (0)
// If the error code depends on BDB vs TDB use this
#ifdef USE_TDB
#define CKERR_depending(r,tdbexpect,bdbexpect) CKERR2(r,tdbexpect)
#else
#define CKERR_depending(r,tdbexpect,bdbexpect) CKERR2(r,bdbexpect)
#endif
static __attribute__((__unused__)) void
parse_args (int argc, char * const argv[]) {
const char *argv0=argv[0];
......@@ -174,7 +163,6 @@ parse_args (int argc, char * const argv[]) {
}
}
#ifdef USE_TDB
static __attribute__((__unused__)) void
print_engine_status(DB_ENV * UU(env)) {
if (verbose) { // verbose declared statically in this file
......@@ -187,9 +175,7 @@ print_engine_status(DB_ENV * UU(env)) {
printf("%s", buff);
}
}
#endif
#ifdef USE_TDB
static __attribute__((__unused__)) uint64_t
get_engine_status_val(DB_ENV * UU(env), const char * keyname) {
uint64_t rval = 0;
......@@ -213,7 +199,6 @@ get_engine_status_val(DB_ENV * UU(env), const char * keyname) {
CKERR2(found, 1);
return rval;
}
#endif
static __attribute__((__unused__)) DBT *
dbt_init(DBT *dbt, const void *data, uint32_t size) {
......@@ -293,13 +278,8 @@ uint_dbt_cmp (DB *db, const DBT *a, const DBT *b) {
return 0;
}
#ifdef USE_TDB
#define SET_TRACE_FILE(x) toku_set_trace_file(x)
#define CLOSE_TRACE_FILE(x) toku_close_trace_file()
#else
#define SET_TRACE_FILE(x) ((void)0)
#define CLOSE_TRACE_FILE(x) ((void)0)
#endif
#include <memory.h>
......@@ -361,19 +341,11 @@ void print_time_now(void) {
static void UU()
multiply_locks_for_n_dbs(DB_ENV *env, int num_dbs) {
#ifdef USE_TDB
uint64_t current_max_lock_memory;
int r = env->get_lk_max_memory(env, &current_max_lock_memory);
CKERR(r);
r = env->set_lk_max_memory(env, current_max_lock_memory * num_dbs);
CKERR(r);
#else
uint32_t current_max_locks;
int r = env->get_lk_max_locks(env, &current_max_locks);
CKERR(r);
r = env->set_lk_max_locks(env, current_max_locks * num_dbs);
CKERR(r);
#endif
}
static inline void
......@@ -402,7 +374,6 @@ static void copy_dbt(DBT *dest, const DBT *src) {
}
// DBT_ARRAY is a toku-specific type
#ifdef USE_TDB
UU()
static int
env_update_multiple_test_no_array(
......@@ -507,7 +478,6 @@ static int env_del_multiple_test_no_array(
}
return r;
}
#endif
/* Some macros for evaluating blocks or functions within the scope of a
* transaction. */
......@@ -535,20 +505,8 @@ main(int argc, char * const argv[])
#endif
{
int r;
#if IS_TDB && TOKU_WINDOWS
int rinit = toku_ydb_init();
CKERR(rinit);
#endif
#if !IS_TDB && DB_VERSION_MINOR==4 && DB_VERSION_MINOR == 7
db_env_set_func_malloc(toku_malloc);
db_env_set_func_free(toku_free);
db_env_set_func_realloc(toku_realloc);
#endif
toku_os_initialize_settings(1);
r = test_main(argc, argv);
#if IS_TDB && TOKU_WINDOWS
toku_ydb_destroy();
#endif
return r;
}
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include "test.h"
/* Test for #1426. Make sure deletes and inserts in a FIFO work. */
/* This test is run using a special makefile rule that runs the TDB version and the BDB version, dumps their outputs, and compares them */
#include <db.h>
#include <memory.h>
#include <fcntl.h>
// |DB_INIT_TXN| DB_INIT_LOG | DB_RECOVER
const int envflags = DB_CREATE|DB_INIT_MPOOL|DB_INIT_LOCK |DB_THREAD |DB_PRIVATE;
DB_ENV *env;
DB *db;
DB_TXN * const null_txn = NULL;
static void
empty_cachetable (void)
// Make all the cachetable entries clean.
// Brute force it by closing and reopening everything.
{
int r;
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_cachesize(env, 0, 10000000, 1); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
r = db->open(db, null_txn, "main", 0, DB_BTREE, 0, 0666); CKERR(r);
}
static void
do_insert_delete_fifo (void)
{
int r;
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_cachesize(env, 0, 10000000, 1); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
r = db->set_pagesize(db, 4096); CKERR(r);
r = db->open(db, null_txn, "main", 0, DB_BTREE, DB_CREATE, 0666); CKERR(r);
{
uint64_t i;
uint64_t n_deleted = 0;
uint64_t N=20000; // total number to insert
uint64_t M= 5000; // size of rolling fifo
uint64_t D= 200; // number to delete at once
for (i=0; i<N; i++) {
{
char k[100],v[100];
int keylen = snprintf(k, sizeof k, "%016" PRIu64 "key", i);
uint32_t rand1 = myrandom();
uint32_t rand2 = myrandom();
uint32_t rand3 = myrandom();
int vallen = snprintf(v, sizeof v, "%016" PRIu64 "val%08x%08x%08x", i, rand1, rand2, rand3);
DBT kt, vt;
r = db->put(db, null_txn, dbt_init(&kt, k, keylen) , dbt_init(&vt, v, vallen), 0); CKERR(r);
}
if (i%D==0) {
// Once every D steps, delete everything until there are only M things left.
// Flush the data down the tree for all the values we will do
{
uint64_t peek_here = n_deleted;
while (peek_here + M < i) {
char k[100];
int keylen = snprintf(k, sizeof k, "%016" PRIu64 "key", peek_here);
DBT kt;
DBT vt;
memset(&vt, 0, sizeof(vt));
vt.flags = DB_DBT_MALLOC;
r = db->get(db, null_txn, dbt_init(&kt, k, keylen), &vt, 0); CKERR(r);
peek_here++;
toku_free(vt.data);
}
}
empty_cachetable();
while (n_deleted + M < i) {
char k[100];
int keylen = snprintf(k, sizeof k, "%016" PRIu64 "key", n_deleted);
DBT kt;
r = db->del(db, null_txn, dbt_init(&kt, k, keylen), 0);
if (r!=0) printf("error %d %s", r, db_strerror(r));
CKERR(r);
n_deleted++;
empty_cachetable();
}
}
}
}
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
}
int
test_main (int argc, char *const argv[])
{
parse_args(argc, argv);
do_insert_delete_fifo();
return 0;
}
......@@ -99,10 +99,6 @@ DB_TXN *null_txn=0;
static void do_test1753 (int do_create_on_reopen) {
if (IS_TDB==0 && DB_VERSION_MAJOR==4 && DB_VERSION_MINOR<7 && do_create_on_reopen==0) {
return; // do_create_on_reopen==0 segfaults in 4.6
}
int r;
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
......
......@@ -137,9 +137,7 @@ setup_db (uint32_t dup_mode) {
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_default_bt_compare(env, int_dbt_cmp); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, DB_INIT_MPOOL | DB_INIT_LOG | DB_INIT_LOCK | DB_INIT_TXN | DB_PRIVATE | DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR(r);
......@@ -148,9 +146,6 @@ setup_db (uint32_t dup_mode) {
r = env->txn_begin(env, 0, &txn, 0); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
#ifndef TOKUDB
r=db->set_bt_compare(db, int_dbt_cmp); CKERR(r);
#endif
r = db->set_flags(db, dup_mode); assert(r == 0); CKERR(r);
r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = txn->commit(txn, 0); CKERR(r);
......
......@@ -112,11 +112,7 @@ static DB_ENV *env = NULL;
static DB *db;
// BDB cannot handle big transactions by default (runs out of locks).
#ifdef TOKUDB
#define N_PER_XACTION 10000
#else
#define N_PER_XACTION 1000
#endif
static void create_db (uint64_t N) {
n_rows = N;
......@@ -124,9 +120,7 @@ static void create_db (uint64_t N) {
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
{ int r = db_env_create(&env, 0); CKERR(r); }
env->set_errfile(env, stderr);
#ifdef TOKUDB
env->set_redzone(env, 0);
#endif
{ int r = env->set_cachesize(env, 0, 400*4096, 1); CKERR(r); }
{ int r = env->open(env, TOKU_TEST_FILENAME, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); }
DB_TXN *txn;
......
......@@ -92,7 +92,7 @@ PATENT RIGHTS GRANT:
const int envflags = DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|DB_RECOVER;
const int my_lg_max = IS_TDB ? 100 : (4096*2);
const int my_lg_max = 100;
int test_main (int UU(argc), char UU(*const argv[])) {
int r;
......
......@@ -103,9 +103,7 @@ static void clean_env (const char *envdir) {
static void setup_env (DB_ENV **envp, const char *envdir) {
{ int chk_r = db_env_create(envp, 0); CKERR(chk_r); }
(*envp)->set_errfile(*envp, stderr);
#ifdef TOKUDB
{ int chk_r = (*envp)->set_redzone(*envp, 0); CKERR(chk_r); }
#endif
{ int chk_r = (*envp)->open(*envp, envdir, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|DB_RECOVER, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(chk_r); }
}
......
......@@ -215,9 +215,7 @@ test_main(int argc, char *const argv[]) {
DB_TXN *txn;
{
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_redzone(env, 0); CKERR(r);
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
env->set_errfile(env, stderr);
r=env->txn_begin(env, 0, &txn, 0); CKERR(r);
......
......@@ -153,9 +153,7 @@ test_main(int argc, char *const argv[]) {
DB_TXN *txn;
{
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_redzone(env, 0); CKERR(r);
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
env->set_errfile(env, stderr);
r=env->txn_begin(env, 0, &txn, 0); CKERR(r);
......
......@@ -113,20 +113,6 @@ test_db_open_aborts (void) {
r=db_env_create(&env, 0); assert(r==0);
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
#if 0
{
DB_TXN *tid;
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
r=db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=tid->abort(tid); assert(r==0);
}
{
toku_struct_stat buf;
r=toku_stat(ENVDIR "/foo.db", &buf);
assert(r!=0);
assert(errno==ENOENT);
}
#endif
{
DB_TXN *tid;
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
......@@ -142,7 +128,6 @@ test_db_open_aborts (void) {
r=tid->abort(tid); assert(r==0);
}
{
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -152,7 +137,6 @@ test_db_open_aborts (void) {
r = env->get_iname(env, &dname, &iname);
CKERR2(r, DB_NOTFOUND);
}
#endif
toku_struct_stat statbuf;
char filename[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(filename, 2, TOKU_TEST_FILENAME, "foo.db"), &statbuf);
......@@ -209,7 +193,6 @@ test_db_put_aborts (void) {
// The database should exist
{
char *filename;
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -221,9 +204,6 @@ test_db_put_aborts (void) {
CAST_FROM_VOIDP(filename, iname.data);
assert(filename);
}
#else
filename = toku_xstrdup("foo.db");
#endif
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, filename), &statbuf);
......
......@@ -149,13 +149,6 @@ do_test_abort2 (void) {
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &txn, 0); CKERR(r);
r=db->open(db, txn, "foo.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
#ifndef TOKUDB
{
uint32_t ps;
r=db->get_pagesize(db, &ps); CKERR(r);
assert(ps==4096);
}
#endif
r=txn->commit(txn, 0); assert(r==0);
r=env->txn_begin(env, 0, &txn, 0); assert(r==0);
......
......@@ -120,11 +120,7 @@ static void op_delete (int i) {
int r = db->del(db, txn,
dbt_init(&key, hello, strlen(hello)+1),
DB_DELETE_ANY);
#ifdef TOKUDB
assert(r==0);
#else
assert(r==DB_NOTFOUND || r==0);
#endif
}
static void lookup (int i, int expect, int expectj) {
......
......@@ -200,7 +200,6 @@ verify_and_tear_down(int close_first) {
int r;
{
char *filename;
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -212,9 +211,6 @@ verify_and_tear_down(int close_first) {
CAST_FROM_VOIDP(filename, iname.data);
assert(filename);
}
#else
filename = toku_xstrdup("foo.db");
#endif
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, filename), &statbuf);
......
......@@ -231,7 +231,6 @@ verify_and_tear_down(int close_first) {
int r;
{
char *filename;
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -243,9 +242,6 @@ verify_and_tear_down(int close_first) {
CAST_FROM_VOIDP(filename, iname.data);
assert(filename);
}
#else
filename = toku_xstrdup("foo.db");
#endif
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, filename), &statbuf);
......
......@@ -205,13 +205,12 @@ do_abort_delete_first_or_last(int N,
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
#if defined(TOKUDB) && defined(__unix__)
// Oh man, this is gross.
char cmd[sizeof("../../tools/tokudb_dump -h foo.db >") + 2 * TOKU_PATH_MAX];
snprintf(cmd, sizeof(cmd), "../../tools/tokudb_dump -h %s foo.db > %s", TOKU_TEST_FILENAME, DEV_NULL_FILE);
r=system(cmd);
CKERR(r);
#endif
}
int
......
......@@ -135,14 +135,7 @@ test_main (int argc, char *const argv[]) {
CKERR(r);
//this test no longer produces a list with any entries for TDB
// - txn_checkpoint trims unused logfiles
#if IS_TDB
assert(list == 0);
#else
assert(list);
assert(list[0]);
if (verbose) printf("file[0]=%s\n", list[0]);
toku_free(list);
#endif
}
r=db->close(db, 0); CKERR(r);
......
......@@ -112,11 +112,7 @@ static void insert(DB *db, DB_TXN *txn, int k, int val_size) {
}
int test_main(int argc, char * const argv[]) {
#if defined(TOKUDB)
const char *db_env_dir = "dir.blobs.leafsplit.env.tdb";
#else
const char *db_env_dir = "dir.blobs.leafsplit.env.bdb";
#endif
int db_env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG;
const char *db_filename = "blobs.db";
int do_txn = 1;
......
......@@ -101,10 +101,6 @@ PATENT RIGHTS GRANT:
static uint64_t
size_from (uint32_t gbytes, uint32_t bytes) {
#ifdef USE_BDB
if (sizeof (intptr_t) == 4 && gbytes == 4 && bytes == 0)
return 0xffffffff;
#endif
return ((uint64_t)gbytes << 30) + bytes;
}
......@@ -119,11 +115,6 @@ expect_le (uint64_t a, uint32_t gbytes, uint32_t bytes) {
uint64_t b = size_from(gbytes, bytes);
if (a != b && verbose)
printf("WARNING: expect %" PRIu64 " got %" PRIu64 "\n", a, b);
#ifdef USE_BDB
if (a > b) {
assert(a == 4ULL<<30 && b == a-1); return;
}
#endif
assert(a <= b);
}
......
......@@ -125,7 +125,7 @@ test_cursor_delete2 (void) {
r = txn->commit(txn, 0); CKERR(r);
r = dbenv->txn_begin(dbenv, 0, &txn, 0); CKERR(r);
r = db->del(db, txn, dbt_init(&key, "a", 2), DB_DELETE_ANY); CKERR_depending(r,0,DB_NOTFOUND);
r = db->del(db, txn, dbt_init(&key, "a", 2), DB_DELETE_ANY); CKERR(r);
r = txn->commit(txn, 0); CKERR(r);
r = dbenv->txn_begin(dbenv, 0, &txn, 0); CKERR(r);
......@@ -139,7 +139,7 @@ test_cursor_delete2 (void) {
r = dbenv->txn_begin(dbenv, 0, &txn, 0); CKERR(r);
r = db->del(db, txn, dbt_init(&key, "a", 2), 0); CKERR(r);
r = db->del(db, txn, dbt_init(&key, "a", 2), DB_DELETE_ANY); CKERR_depending(r,0,DB_NOTFOUND);
r = db->del(db, txn, dbt_init(&key, "a", 2), DB_DELETE_ANY); CKERR(r);
r = txn->commit(txn, 0); CKERR(r);
r = db->close(db, 0); CKERR(r);
......
......@@ -223,14 +223,12 @@ test_main(int argc, char *const argv[]) {
assert(!was_truncated);
bool ulen_should_change = false;
#if defined(USE_TDB)
if (flags[j] == DB_DBT_REALLOC) {
ulen_should_change = (bool)(old_ulen < sizeof(DATA));
}
else if (flags[j] == DB_DBT_MALLOC) {
ulen_should_change = (bool)(old_ulen != sizeof(DATA)*2);
}
#endif
assert(ulen_should_change == (bool)ulen_changed);
assert(size_full);
assert(doclone == !small_buffer);
......
......@@ -136,9 +136,7 @@ test_db_delete (int n, int dup_mode) {
/* create the dup database file */
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
#ifdef TOKUDB
r = env->set_redzone(env, 0); assert(r == 0);
#endif
r = env->open(env, TOKU_TEST_FILENAME, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
......@@ -179,16 +177,7 @@ test_db_delete (int n, int dup_mode) {
}
expect_db_del(db, htonl(n), 0, DB_NOTFOUND);
#if defined(USE_TDB)
expect_db_del(db, htonl(n), DB_DELETE_ANY, 0);
#endif
#if defined(USE_BDB) && defined(DB_DELETE_ANY)
#if DB_DELETE_ANY == 0
expect_db_del(db, htonl(n), DB_DELETE_ANY, DB_NOTFOUND);
#else
expect_db_del(db, htonl(n), DB_DELETE_ANY, EINVAL);
#endif
#endif
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
......@@ -208,9 +197,7 @@ test_db_get_datasize0 (void) {
/* create the dup database file */
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
#ifdef TOKUDB
r = env->set_redzone(env, 0); assert(r == 0);
#endif
r = env->open(env, TOKU_TEST_FILENAME, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
......
......@@ -117,11 +117,7 @@ test_main(int argc, char *const argv[]) {
int do_private;
for (do_private=0; do_private<2; do_private++) {
#ifdef USE_TDB
if (do_private==0) continue; // See #208.
#else
if (do_private==1) continue; // See #530. BDB 4.6.21 segfaults if DB_PRIVATE is passed when no environment previously exists.
#endif
int private_flags = do_private ? (DB_CREATE|DB_PRIVATE) : 0;
toku_os_recursive_delete(TOKU_TEST_FILENAME);
......@@ -136,37 +132,12 @@ test_main(int argc, char *const argv[]) {
r = db_env_create(&dbenv, 0);
CKERR(r);
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, private_flags|DB_INIT_MPOOL, 0);
#ifdef USE_TDB
// TokuDB has no trouble opening an environment if the directory exists.
CKERR(r);
assert(r==0);
#else
if (r!=ENOENT) printf("%s:%d %d: %s\n", __FILE__, __LINE__, r,db_strerror(r));
assert(r==ENOENT);
#endif
dbenv->close(dbenv,0); // free memory
}
#ifndef USE_TDB
// Now make sure that if we have a non-private DB that we can tell if it opened or not.
DB *db;
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_env_create(&dbenv, 0);
CKERR(r);
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, DB_CREATE|DB_INIT_MPOOL, 0);
CKERR(r);
r=db_create(&db, dbenv, 0);
CKERR(r);
db->close(db, 0);
dbenv->close(dbenv,0); // free memory
r = db_env_create(&dbenv, 0);
CKERR(r);
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, DB_INIT_MPOOL, 0);
CKERR(r);
dbenv->close(dbenv,0); // free memory
#endif
return 0;
}
......@@ -117,18 +117,7 @@ test_main(int argc, char*const* argv) {
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, DB_CREATE|DB_INIT_MPOOL|DB_PRIVATE, 0666);
if (verbose) printf("r=%d\n", r);
#ifdef USE_TDB
assert(r == EINVAL);
#elif USE_BDB
#if DB_VERSION_MAJOR >= 5
assert(r == EINVAL);
#else
if (verbose) printf("test_db_env_open_open_close.bdb skipped. (BDB apparently does not follow the spec).\n");
assert(r == 0);
#endif
#else
#error
#endif
r = dbenv->close(dbenv, 0);
assert(r == 0);
......
......@@ -121,13 +121,8 @@ test_main(int argc, char *const argv[]) {
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, DB_INIT_TXN|DB_INIT_LOG|DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0);
CKERR(r);
#ifdef USE_TDB
// According to the BDB man page, you may not call set_lg_dir after doing the open.
// Some versions of BDB don't actually check this or complain
r = dbenv->set_lg_dir(dbenv, ".");
assert(r == EINVAL);
#endif
r = dbenv->close(dbenv, 0);
assert(r == 0);
......
......@@ -121,13 +121,8 @@ test_main(int argc, char *const argv[]) {
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0);
CKERR(r);
#ifdef USE_TDB
// According to the BDB man page, you may not call set_tmp_dir after doing the open.
// Some versions of BDB don't actually check this or complain
r = dbenv->set_tmp_dir(dbenv, ".");
assert(r == EINVAL);
#endif
r = dbenv->close(dbenv, 0);
assert(r == 0);
......
......@@ -108,13 +108,10 @@ test_main (int UU(argc), char UU(*const argv[])) {
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
// None of this stuff works with BDB. TDB does more error checking.
#ifdef USE_TDB
r=env->set_data_dir(env, NULL); assert(r==EINVAL);
r=env->open(env, TOKU_TEST_FILENAME, DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
env->set_errpfx(env, NULL); assert(1); //Did not crash.
r=env->set_tmp_dir(env, NULL); assert(r==EINVAL);
#endif
r=env->close(env, 0); assert(r==0);
return 0;
}
......
......@@ -136,9 +136,7 @@ setup (uint32_t flags) {
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
/* Open/create primary */
r = db_env_create(&dbenv, 0); assert(r == 0);
#ifdef USE_TDB
r = dbenv->set_redzone(dbenv, 0); CKERR(r);
#endif
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
r = db_create(&dbp, dbenv, 0); CKERR(r);
dbp->set_errfile(dbp,0); // Turn off those annoying errors
......@@ -182,13 +180,6 @@ get_bad_flags (DB* db, uint32_t flags, int r_expect, int keyint, int dataint) {
assert(*(int*)data.data == dataint);
}
#ifdef USE_TDB
#define EINVAL_FOR_TDB_OK_FOR_BDB EINVAL
#else
#define EINVAL_FOR_TDB_OK_FOR_BDB 0
#endif
PUT_TEST put_tests[] = {
{0, DB_NODUPDATA, EINVAL, 0, 0}, //r_expect must change to 0, once implemented.
{0, 0, 0, 0, 0},
......
......@@ -114,11 +114,7 @@ static void test_db_remove (void) {
// Now remove it, while it is open.
r = env->dbremove(env, NULL, fname, 0, 0);
#ifdef USE_TDB
assert(r!=0);
#else
assert(r==0);
#endif
r = db1->close(db1, 0); assert(r==0);
r = env->close(env, 0); assert(r == 0);
......
......@@ -236,10 +236,8 @@ setup_dbs (void) {
/* Open/create primary */
r = db_env_create(&dbenv, 0);
CKERR(r);
#ifdef TOKUDB
r = dbenv->set_default_bt_compare(dbenv, int_dbt_cmp);
CKERR(r);
#endif
uint32_t env_txn_flags = DB_INIT_TXN | DB_INIT_LOCK;
uint32_t env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL;
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, env_open_flags | env_txn_flags, 0600);
......@@ -247,10 +245,6 @@ setup_dbs (void) {
r = db_create(&db, dbenv, 0);
CKERR(r);
#ifndef TOKUDB
r = db->set_bt_compare( db, int_dbt_cmp);
CKERR(r);
#endif
char a;
for (a = 'a'; a <= 'z'; a++) init_txn(a);
......@@ -665,16 +659,6 @@ test (void) {
int
test_main(int argc, char *const argv[]) {
parse_args(argc, argv);
if (!IS_TDB) {
if (verbose) {
printf("Warning: " __FILE__" does not work in BDB.\n");
}
} else {
test();
/*
test_abort(0);
test_abort(DB_DUP | DB_DUPSORT);
*/
}
test();
return 0;
}
......@@ -178,10 +178,8 @@ setup_dbs (void) {
/* Open/create primary */
r = db_env_create(&dbenv, 0);
CKERR(r);
#ifdef TOKUDB
r = dbenv->set_default_bt_compare(dbenv, int_dbt_cmp);
CKERR(r);
#endif
uint32_t env_txn_flags = DB_INIT_TXN | DB_INIT_LOCK;
uint32_t env_open_flags = DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL;
r = dbenv->open(dbenv, TOKU_TEST_FILENAME, env_open_flags | env_txn_flags, 0600);
......@@ -189,10 +187,6 @@ setup_dbs (void) {
r = db_create(&db, dbenv, 0);
CKERR(r);
#ifndef TOKUDB
r = db->set_bt_compare( db, int_dbt_cmp);
CKERR(r);
#endif
char a;
for (a = 'a'; a <= 'z'; a++) init_txn(a, 0);
......@@ -256,28 +250,9 @@ table_scan(char txn, bool success) {
static void
table_prelock(char txn, bool success) {
int r;
#if defined USE_TDB && USE_TDB
r = db->pre_acquire_table_lock(db, txns[(int)txn]);
if (success) CKERR(r);
else CKERR2s(r, DB_LOCK_NOTGRANTED, DB_LOCK_DEADLOCK);
#else
DBT key;
DBT data;
assert(txns[(int)txn] && cursors[(int)txn]);
r = cursors[(int)txn]->c_get(cursors[(int)txn],
dbt_init(&key, 0, 0),
dbt_init(&data, 0, 0),
DB_FIRST | DB_RMW);
while (r==0) {
r = cursors[(int)txn]->c_get(cursors[(int)txn],
dbt_init(&key, 0, 0),
dbt_init(&data, 0, 0),
DB_NEXT | DB_RMW);
}
if (success) CKERR2(r, DB_NOTFOUND);
else CKERR2s(r, DB_LOCK_NOTGRANTED, DB_LOCK_DEADLOCK);
#endif
}
static void
......
......@@ -114,12 +114,7 @@ test_main (int argc __attribute__((__unused__)), char *const argv[] __attribute
r=db_env_create(&env, 0); assert(r==0);
env->set_errfile(env,0); // Turn off those annoying errors
r=env->close (env, 1);
//BDB does not check this in some versions
#if defined(USE_TDB) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
assert(r==EINVAL);
#else
assert(r==0);
#endif
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
......@@ -135,11 +130,6 @@ test_main (int argc __attribute__((__unused__)), char *const argv[] __attribute
env->set_errfile(env,0); // Turn off those annoying errors
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=env->close (env, 1);
//BDB does not check this.
#if defined(USE_TDB) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
assert(r==EINVAL);
#else
assert(r==0);
#endif
return 0;
}
......@@ -104,13 +104,7 @@ test_main (int UU(argc), char UU(*const argv[])) {
r = db_env_create(&env, 0);
assert(r == 0);
r = db_create(&db, env, 0);
// BDB doesnt' actually barf on this case.
#ifdef USE_TDB
assert(r != 0);
#else
r = db->close(db, 0);
assert(r == 0);
#endif
r = env->close(env, 0);
assert(r == 0);
return 0;
......
......@@ -125,25 +125,19 @@ test_main(int argc, char *const argv[]) {
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
#ifdef USE_TDB
char tracefile[TOKU_PATH_MAX+1];
toku_set_trace_file(toku_path_join(tracefile, 2, TOKU_TEST_FILENAME, "trace.tktrace"));
#endif
/* test flags */
test_env_open_flags(0, ENOENT);
#ifdef TOKUDB
// This one segfaults in BDB 4.6.21
test_env_open_flags(DB_PRIVATE, ENOENT);
#endif
test_env_open_flags(DB_PRIVATE+DB_CREATE, 0);
test_env_open_flags(DB_PRIVATE+DB_CREATE+DB_INIT_MPOOL, 0);
test_env_open_flags(DB_PRIVATE+DB_RECOVER, EINVAL);
test_env_open_flags(DB_PRIVATE+DB_CREATE+DB_INIT_MPOOL+DB_RECOVER, EINVAL);
#ifdef USE_TDB
toku_close_trace_file();
#endif
return 0;
}
......@@ -101,12 +101,7 @@ DB_ENV *env;
DB *db;
int do_sync=1;
#ifdef TOKUDB
#define NITER 100
#else
// BDB is slow. Reduce the work.
#define NITER 25
#endif
static void *start_a_thread (void *i_p) {
int *CAST_FROM_VOIDP(which_thread_p, i_p);
......@@ -214,12 +209,7 @@ do_test (int N) {
}
}
#ifdef TOKUDB
int log_max_n_threads_over_10 = 3;
#else
// BDB is slow. Reduce the work.
int log_max_n_threads_over_10 = 2;
#endif
static void
my_parse_args (int argc, char *const argv[]) {
......@@ -267,9 +257,7 @@ test_main (int argc, char *const argv[]) {
prev_count=0;
db_env_set_func_fsync(do_fsync);
#if TOKUDB
db_env_set_num_bucket_mutexes(32);
#endif
toku_os_recursive_delete(env_path);
{ int r=toku_os_mkdir(env_path, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); }
......
......@@ -123,7 +123,6 @@ static void make_db (bool close_env) {
CKERR(r);
}
char *filename;
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -135,10 +134,6 @@ static void make_db (bool close_env) {
CAST_FROM_VOIDP(filename, iname.data);
assert(filename);
}
#else
filename = toku_xstrdup("foo.db");
#endif
r=tid->commit(tid, 0); assert(r==0);
r=db->close(db, 0); assert(r==0);
......
......@@ -120,9 +120,7 @@ static void insert_some (int outeri, bool close_env) {
DB *db;
DB_TXN *tid;
r=db_env_create(&env, 0); assert(r==0);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|create_flag, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......@@ -148,13 +146,6 @@ static void insert_some (int outeri, bool close_env) {
key.data = hello; key.size=strlen(hello)+1;
data.data = there; data.size=strlen(there)+1;
r=db->put(db, tid, &key, &data, 0); CKERR(r);
#ifndef TOKUDB
// BDB cannot handle such a big txn.
if (i%1000==999) {
r=tid->commit(tid, 0); assert(r==0);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
}
#endif
}
r=tid->commit(tid, 0); assert(r==0);
r=db->close(db, 0); assert(r==0);
......@@ -173,9 +164,7 @@ static void make_db (bool close_env) {
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -129,15 +129,7 @@ test_main (int UU(argc), char UU(*const argv[])) {
r=tid->abort(tid);
assert(r==0);
r=env->close(env, 0);
#ifdef USE_BDB
#if DB_VERSION_MAJOR >= 5
assert(r==0);
#else
assert(r==ENOENT);
#endif
#else
assert(r==0);
#endif
{
toku_struct_stat statbuf;
char filename[TOKU_PATH_MAX+1];
......
......@@ -122,9 +122,6 @@ static void make_db (bool close_env) {
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
#ifdef TOKUDB
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
......@@ -147,13 +144,11 @@ static void make_db (bool close_env) {
key.data = hello; key.size=strlen(hello)+1;
data.data = there; data.size=strlen(there)+1;
r=db->put(db, tid, &key, &data, 0); assert(r==0);
#ifndef TOKUDB
// BDB cannot handle this huge transaction even with a lot of locks.
if (i%1000==599) {
r=tid->commit(tid, 0); assert(r==0);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
}
#endif
}
r=tid->commit(tid, 0); assert(r==0);
r=db->close(db, 0); assert(r==0);
......
......@@ -119,9 +119,7 @@ static void insert_some (int outeri, bool close_env) {
DB *db;
DB_TXN *tid;
r=db_env_create(&env, 0); assert(r==0);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|create_flag, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
......@@ -166,9 +164,7 @@ static void make_db (bool close_env) {
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -119,9 +119,7 @@ static void insert_some (int outeri, bool close_env) {
DB *db;
DB_TXN *tid;
r=db_env_create(&env, 0); assert(r==0);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE|create_flag, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......@@ -165,9 +163,7 @@ static void make_db (bool close_env) {
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r=toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
#if IS_TDB
db_env_enable_engine_status(0); // disable engine status on crash because test is expected to fail
#endif
r=env->open(env, TOKU_TEST_FILENAME, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
......
......@@ -96,11 +96,7 @@ PATENT RIGHTS GRANT:
// Return the offset
static int
grep_for_in_logs (const char *str) {
#ifdef TOKUDB
#define lfname "log000000000000.tokulog[0-9]*"
#else
#define lfname "log.0000000001"
#endif
#define COMMAND "grep -F -q"
char lname[TOKU_PATH_MAX+1];
toku_path_join(lname, 2, TOKU_TEST_FILENAME, lfname);
......
......@@ -152,11 +152,7 @@ test_logmax (int logmax) {
int effective_max;
if (logmax>0) effective_max = logmax;
else {
#ifdef TOKUDB
effective_max = 100<<20;
#else
effective_max = 10<<20;
#endif
}
r=env->txn_begin(env, 0, &tid, 0); CKERR(r);
......
......@@ -155,10 +155,8 @@ test_reverse_compare (int n) {
/* create the dup database file */
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
#ifdef TOKUDB
r = env->set_default_bt_compare(env, reverse_compare);
CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
......@@ -166,10 +164,6 @@ test_reverse_compare (int n) {
CKERR(r);
r = db->set_pagesize(db, 4096);
CKERR(r);
#ifndef TOKUDB
r = db->set_bt_compare(db, reverse_compare);
CKERR(r);
#endif
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
CKERR(r);
......@@ -192,10 +186,6 @@ test_reverse_compare (int n) {
CKERR(r);
r = db->set_pagesize(db, 4096);
CKERR(r);
#ifndef TOKUDB
r = db->set_bt_compare(db, reverse_compare);
CKERR(r);
#endif
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
CKERR(r);
......
......@@ -153,7 +153,6 @@ test1 (void)
db_env_set_func_realloc(brealloc);
db_env_set_func_free(bfree);
#ifdef USE_TDB
// toku_malloc isn't affected by calling the BDB set_fun_malloc calls.
malloc_counter = realloc_counter = free_counter = 0;
......@@ -166,8 +165,6 @@ test1 (void)
db_env_set_func_malloc(NULL);
db_env_set_func_realloc(NULL);
db_env_set_func_free(NULL);
#endif
}
int
......
......@@ -119,7 +119,6 @@ test_abort_create (void) {
{
char *filename;
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -131,9 +130,6 @@ test_abort_create (void) {
CAST_FROM_VOIDP(filename, iname.data);
assert(filename);
}
#else
filename = toku_xstrdup("test.db");
#endif
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, filename), &statbuf);
......@@ -145,7 +141,6 @@ test_abort_create (void) {
r = txn->abort(txn); assert(r == 0);
{
#if USE_TDB
{
DBT dname;
DBT iname;
......@@ -155,7 +150,6 @@ test_abort_create (void) {
r = env->get_iname(env, &dname, &iname);
CKERR2(r, DB_NOTFOUND);
}
#endif
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <sys/stat.h>
#include <db.h>
//
static void
test_abort_close (void) {
#ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
if (verbose) fprintf(stderr, "%s does not work for BDB %d.%d. Not running\n", __FILE__, DB_VERSION_MAJOR, DB_VERSION_MINOR);
return;
#else
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
int r;
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->set_data_dir(env, TOKU_TEST_FILENAME);
r = env->set_lg_dir(env, TOKU_TEST_FILENAME);
env->set_errfile(env, stdout);
r = env->open(env, 0, DB_INIT_MPOOL + DB_INIT_LOG + DB_INIT_LOCK + DB_INIT_TXN + DB_PRIVATE + DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
if (r != 0) printf("%s:%d:%d:%s\n", __FILE__, __LINE__, r, db_strerror(r));
assert(r == 0);
DB_TXN *txn = 0;
r = env->txn_begin(env, 0, &txn, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r==0);
}
// Close before abort.
r = db->close(db, 0);
r = txn->abort(txn); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r!=0);
}
#endif
#endif
}
int
test_main(int UU(argc), char UU(*const argv[])) {
test_abort_close();
return 0;
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <sys/stat.h>
#include <db.h>
//
static void
test_abort_close (void) {
#ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
if (verbose) fprintf(stderr, "%s does not work for BDB %d.%d. Not running\n", __FILE__, DB_VERSION_MAJOR, DB_VERSION_MINOR);
return;
#else
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
int r;
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->set_data_dir(env, TOKU_TEST_FILENAME);
r = env->set_lg_dir(env, TOKU_TEST_FILENAME);
env->set_errfile(env, stdout);
r = env->open(env, 0, DB_INIT_MPOOL + DB_INIT_LOG + DB_INIT_LOCK + DB_INIT_TXN + DB_PRIVATE + DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
if (r != 0) printf("%s:%d:%d:%s\n", __FILE__, __LINE__, r, db_strerror(r));
assert(r == 0);
DB_TXN *txn = 0;
r = env->txn_begin(env, 0, &txn, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r==0);
}
// Close before commit.
r = db->close(db, 0);
r = txn->commit(txn, 0); CKERR(r);
// Now reopen it
r = env->txn_begin(env, 0, &txn, 0); CKERR(r);
r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, txn, "test.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
DBT k,v;
r = db->put(db, txn, dbt_init(&k, "hello", 6), dbt_init(&v, "there", 6), 0);
CKERR(r);
r = db->close(db, 0);
r = txn->abort(txn); assert(r == 0);
r = env->close(env, 0); CKERR(r);
#endif
#endif
}
int
test_main(int UU(argc), char UU(*const argv[])) {
test_abort_close();
return 0;
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <sys/stat.h>
#include <db.h>
// Recreate a mysqld crash by closing and opening a db within a transaction.
// The crash occurs when writing a dirty cachetable pair, so we insert one
// row.
static void
test_txn_close_open_commit (void) {
#ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
if (verbose) fprintf(stderr, "%s does not work for BDB %d.%d. Not running\n", __FILE__, DB_VERSION_MAJOR, DB_VERSION_MINOR);
return;
#else
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
int r;
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->set_data_dir(env, TOKU_TEST_FILENAME);
r = env->set_lg_dir(env, TOKU_TEST_FILENAME);
env->set_errfile(env, stdout);
r = env->open(env, 0, DB_INIT_MPOOL + DB_INIT_LOG + DB_INIT_LOCK + DB_INIT_TXN + DB_PRIVATE + DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
if (r != 0) printf("%s:%d:%d:%s\n", __FILE__, __LINE__, r, db_strerror(r));
assert(r == 0);
DB_TXN *txn = 0;
r = env->txn_begin(env, 0, &txn, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r==0);
}
DBT key, val;
int k = 1, v = 1;
r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
assert(r == 0);
// Close before commit
r = db->close(db, 0); assert(r == 0);
r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, txn, "test.db", 0, DB_UNKNOWN, 0, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
r = txn->commit(txn, 0); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r==0);
}
#endif
#endif
}
int
test_main(int UU(argc), char UU(*const argv[])) {
test_txn_close_open_commit();
return 0;
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <sys/stat.h>
#include <db.h>
// like test_txn_abort8.c except commit
static void
test_abort_close (void) {
#ifndef USE_TDB
#if DB_VERSION_MAJOR==4 && DB_VERSION_MINOR==3
if (verbose) fprintf(stderr, "%s does not work for BDB %d.%d. Not running\n", __FILE__, DB_VERSION_MAJOR, DB_VERSION_MINOR);
return;
#else
toku_os_recursive_delete(TOKU_TEST_FILENAME);
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
int r;
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->set_data_dir(env, TOKU_TEST_FILENAME);
r = env->set_lg_dir(env, TOKU_TEST_FILENAME);
env->set_errfile(env, stdout);
r = env->open(env, 0, DB_INIT_MPOOL + DB_INIT_LOG + DB_INIT_LOCK + DB_INIT_TXN + DB_PRIVATE + DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
if (r != 0) printf("%s:%d:%d:%s\n", __FILE__, __LINE__, r, db_strerror(r));
assert(r == 0);
DB_TXN *txn = 0;
r = env->txn_begin(env, 0, &txn, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r==0);
}
// Close before commit
r = db->close(db, 0);
r = txn->commit(txn, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
{
toku_struct_stat statbuf;
char fullfile[TOKU_PATH_MAX+1];
r = toku_stat(toku_path_join(fullfile, 2, TOKU_TEST_FILENAME, "test.db"), &statbuf);
assert(r==0);
}
#endif
#endif
}
int
test_main(int UU(argc), char UU(*const argv[])) {
test_abort_close();
return 0;
}
......@@ -291,12 +291,10 @@ test_main(int argc, char *const argv[]) {
parse_args(argc, argv);
if (IS_TDB) {
test_txn_cursor_last_1(0);
test_txn_cursor_last_1(1);
test_txn_cursor_last_2(0);
test_txn_cursor_last_2(1);
}
test_txn_cursor_last_1(0);
test_txn_cursor_last_1(1);
test_txn_cursor_last_2(0);
test_txn_cursor_last_2(1);
return 0;
}
......@@ -125,9 +125,7 @@ setup_db (void) {
toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r = env->set_default_bt_compare(env, int_dbt_cmp); CKERR(r);
#endif
r = env->open(env, TOKU_TEST_FILENAME, DB_INIT_MPOOL | DB_INIT_LOG | DB_INIT_LOCK | DB_INIT_TXN | DB_PRIVATE | DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR(r);
......@@ -136,9 +134,6 @@ setup_db (void) {
r = env->txn_begin(env, 0, &txn, 0); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
#ifndef TOKUDB
r = db->set_bt_compare(db, int_dbt_cmp); CKERR(r);
#endif
r = db->open(db, txn, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = txn->commit(txn, 0); CKERR(r);
}
......@@ -219,74 +214,6 @@ test_txn_nesting (int depth) {
}
}
#if 0
static void
test_txn_abort (int insert, int secondnum) {
if (verbose) { fprintf(stderr, "%s (%s):%d [%d,%d]\n", __FILE__, __FUNCTION__, __LINE__, insert, secondnum); fflush(stderr); }
setup_db();
DBT key, val;
int r;
DB_TXN *parent = NULL, *child = NULL;
int i = 1;
r = env->txn_begin(env, 0, &parent, 0); CKERR(r);
//Insert something as a child
r = env->txn_begin(env, parent, &child, 0); CKERR(r);
i = 1;
r = db->put(db, child, dbt_init(&key, &i, sizeof i), dbt_init(&val, &i, sizeof i), 0);
CKERR(r);
r = child->commit(child,DB_TXN_NOSYNC);
child = NULL;
//delete it as a child
r = env->txn_begin(env, parent, &child, 0); CKERR(r);
i = secondnum;
if (insert) {
r = db->put(db, child, dbt_init(&key, &i, sizeof i), dbt_init(&val, &i, sizeof i), 0);
CKERR(r);
}
else { // delete
r = db->del(db, child, dbt_init(&key, &i, sizeof i), DB_DELETE_ANY);
if (IS_TDB) {
CKERR(r);
} else {
CKERR2(r, (secondnum==1 ? 0 : DB_NOTFOUND));
}
}
r = child->commit(child,DB_TXN_NOSYNC);
child = NULL;
r = parent->abort(parent);
CKERR(r);
parent = NULL;
{
DB_TXN *txn = NULL;
/* walk the db, should be empty */
r = env->txn_begin(env, 0, &txn, 0); CKERR(r);
DBC *cursor;
r = db->cursor(db, txn, &cursor, 0); CKERR(r);
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
r = cursor->c_get(cursor, &key, &val, DB_FIRST);
CKERR2(r, DB_NOTFOUND);
r = cursor->c_close(cursor); CKERR(r);
r = txn->commit(txn, 0);
}
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
}
#endif
int
test_main(int argc, char *const argv[]) {
parse_args(argc, argv);
......
......@@ -160,11 +160,7 @@ test_txn_abort (int insert, int secondnum) {
}
else { // delete
r = db->del(db, child, dbt_init(&key, &i, sizeof i), DB_DELETE_ANY);
if (IS_TDB) {
CKERR(r);
} else {
CKERR2(r, (secondnum==1 ? 0 : DB_NOTFOUND));
}
}
r = child->commit(child,DB_TXN_NOSYNC);
child = NULL;
......
......@@ -128,9 +128,6 @@ test_autotxn (uint32_t env_flags, uint32_t db_flags) {
DB_TXN *x1, *x2 = NULL;
r = env->txn_begin(env, 0, &x1, DB_TXN_NOWAIT); CKERR(r);
#ifdef USE_BDB
r = env->txn_begin(env, 0, &x2, DB_TXN_NOWAIT); CKERR(r);
#endif
DBT k1,k2,v1,v2;
dbt_init(&k1, "hello", sizeof "hello");
dbt_init(&k2, "hello", sizeof "hello");
......@@ -141,9 +138,6 @@ test_autotxn (uint32_t env_flags, uint32_t db_flags) {
r = db->put(db, x1, &k1, &v1, 0); CKERR(r);
r = db->get(db, x2, &k2, &v2, 0); assert(r==DB_LOCK_DEADLOCK || r==DB_LOCK_NOTGRANTED);
r = x1->commit(x1, 0); CKERR(r);
#ifdef USE_BDB
r = x2->commit(x2, 0); assert(r==0);
#endif
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); assert(r==0);
}
......
......@@ -746,7 +746,6 @@ c_set_check_interrupt_callback(DBC* dbc, bool (*interrupt_callback)(void*), void
int
toku_c_get(DBC* c, DBT* key, DBT* val, uint32_t flag) {
//This function exists for legacy (test compatibility) purposes/parity with bdb.
HANDLE_PANICKED_DB(c->dbp);
HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c);
......
......@@ -8,14 +8,4 @@ foreach(util ${utils})
target_link_libraries(${util} ${LIBTOKUDB}_static ft_static z lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
add_space_separated_property(TARGET ${util} COMPILE_FLAGS -fvisibility=hidden)
if(BDB_FOUND)
add_executable(${util}.bdb ${util})
set_property(TARGET ${util}.bdb APPEND PROPERTY
COMPILE_DEFINITIONS "IS_TDB=0;USE_BDB=1;TOKU_ALLOW_DEPRECATED")
set_target_properties(${util}.bdb PROPERTIES
INCLUDE_DIRECTORIES "${BDB_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/../portability;${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(${util}.bdb ${LIBTOKUPORTABILITY} ${BDB_LIBRARIES})
add_space_separated_property(TARGET ${util}.bdb COMPILE_FLAGS -fvisibility=hidden)
endif()
endforeach(util)
......@@ -326,25 +326,11 @@ resend_signals(void) {
}
#include <memory.h>
#if IS_TDB && TOKU_WINDOWS
#include <src/ydb.h>
#endif
static int test_main (int argc, char *const argv[]);
int
main(int argc, char *const argv[]) {
int r;
#if IS_TDB && TOKU_WINDOWS
toku_ydb_init();
#endif
#if !IS_TDB && DB_VERSION_MINOR==4 && DB_VERSION_MINOR == 7
r = db_env_set_func_malloc(toku_malloc); assert(r==0);
r = db_env_set_func_free(toku_free); assert(r==0);
r = db_env_set_func_realloc(toku_realloc); assert(r==0);
#endif
r = test_main(argc, argv);
#if IS_TDB && TOKU_WINDOWS
toku_ydb_destroy();
#endif
return r;
}
......
......@@ -368,15 +368,6 @@ int create_init_env()
//However, do we need to use DB_INIT_LOG to join a logging environment?
//REMOVE_BITS(flags, DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN);
SET_BITS(flags, DB_CREATE | DB_PRIVATE);
#if defined(USE_BDB) && USE_BDB==1
{
int r;
r = dbenv->set_lk_max_objects(dbenv, 100000);
assert(r==0);
r = dbenv->set_lk_max_locks(dbenv, 100000);
assert(r==0);
}
#endif
retval = dbenv->open(dbenv, g.homedir, flags, 0);
if (retval) {
......
......@@ -98,9 +98,7 @@ PATENT RIGHTS GRANT:
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#if IS_TDB
#include <src/ydb.h>
#endif
#include "tokudb_common.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment