Commit 426f0871 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Make a test for #1572. This test causes the assertion reported by kayak to...

Make a test for #1572.  This test causes the assertion reported by kayak to fail in the old code, but doesn't fail in the new code.
{{{
log.c:1125 toku_txn_note_brt: Assertion `(TOKUTXN)txnv==txn' failed
}}}
Fixes #1572.


git-svn-id: file:///svn/toku/tokudb@10416 c7de825b-a66e-492c-adef-691d508d4ae1
parent 12d98504
......@@ -204,4 +204,7 @@ void* toku_malloc_in_rollback(TOKUTXN txn, size_t size);
void *toku_memdup_in_rollback(TOKUTXN txn, const void *v, size_t len);
char *toku_strdup_in_rollback(TOKUTXN txn, const char *s);
// A hook for testing #1572. Sets the amount that txn's are incremented by.
void toku_set_lsn_increment (uint64_t incr) __attribute__((__visibility__("default")));
#endif
......@@ -275,6 +275,7 @@ generate_dispatch (void) {
static void
generate_log_writer (void) {
fprintf(cf, "static u_int64_t toku_lsn_increment=1;\nvoid toku_set_lsn_increment (uint64_t incr) { assert(incr>0 && incr< (16LL<<32)); toku_lsn_increment=incr; }\n");
DO_LOGTYPES(lt, {
fprintf2(cf, hf, "int toku_log_%s (TOKULOGGER logger, LSN *lsnp, int do_fsync", lt->name);
DO_FIELDS(ft, lt, fprintf2(cf, hf, ", %s %s", ft->type, ft->name));
......@@ -295,7 +296,7 @@ generate_log_writer (void) {
fprintf(cf, " wbuf_int(&wbuf, buflen);\n");
fprintf(cf, " wbuf_char(&wbuf, '%c');\n", (char)(0xff&lt->command_and_flags));
fprintf(cf, " ml_lock(&logger->input_lock);\n");
fprintf(cf, " logger->lsn.lsn++;\n");
fprintf(cf, " logger->lsn.lsn += toku_lsn_increment;\n");
fprintf(cf, " LSN lsn = logger->lsn;\n");
fprintf(cf, " wbuf_LSN(&wbuf, lsn);\n");
fprintf(cf, " lbytes->lsn = lsn;\n");
......
......@@ -39,6 +39,7 @@
setup_dlmalloc;
toku_cachetable_print_hash_histogram;
toku_set_lsn_increment;
toku_default_compare_fun;
......
......@@ -62,6 +62,7 @@ BDB_DONTRUN_TESTS = \
helgrind2 \
helgrind3 \
test1426 \
test1572 \
test_logflush \
test_txn_abort8 \
test_txn_abort9 \
......
......@@ -6,12 +6,20 @@
#include <db.h>
#include <sys/stat.h>
extern void toku_set_lsn_increment (uint64_t incr);
static void
four_billion_subtransactions (int do_something_in_children) {
four_billion_subtransactions (int do_something_in_children, int use_big_increment) {
DB_ENV *env;
DB *db;
DB_TXN *xparent;
if (use_big_increment) {
toku_set_lsn_increment(1<<28); // 1/4 of a billion, so 16 transactions should push us over the edge.
} else {
toku_set_lsn_increment(1);
}
system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
......@@ -30,9 +38,7 @@ four_billion_subtransactions (int do_something_in_children) {
r=env->txn_begin(env, 0, &xparent, 0); CKERR(r);
long long i;
//long long const fourbillion = 1ll << 32;
long long const fourbillion = 500000;
printf("Doing %d\n", do_something_in_children);
long long const fourbillion = use_big_increment ? 32 : 500000; // if using the big increment we should run into trouble in only 32 transactions or less.
for (i=0; i < fourbillion + 100; i++) {
DB_TXN *xchild;
r=env->txn_begin(env, xparent, &xchild, 0); CKERR(r);
......@@ -48,8 +54,6 @@ four_billion_subtransactions (int do_something_in_children) {
CKERR(r);
}
r=xchild->commit(xchild, 0); CKERR(r);
if (i%1000000==0) { printf("."); fflush(stdout); }
}
r=xparent->commit(xparent, 0); CKERR(r);
......@@ -61,8 +65,10 @@ int
test_main (int argc, const char *argv[])
{
parse_args(argc, argv);
four_billion_subtransactions(0);
four_billion_subtransactions(1);
four_billion_subtransactions(0, 0);
four_billion_subtransactions(1, 0);
four_billion_subtransactions(0, 1);
four_billion_subtransactions(1, 1);
return 0;
}
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