Commit 99f264cc authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Merge some tests of error paths back to main line. Refs #2623. [t:2623]

{{{
svn merge -r 20415:20420 https://svn.tokutek.com/tokudb/toku/tokudb.2623
}}}
.


git-svn-id: file:///svn/toku/tokudb@20421 c7de825b-a66e-492c-adef-691d508d4ae1
parent 46e9402b
......@@ -1484,14 +1484,10 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
pq_nodes[i].i = i;
r = pqueue_insert(pq, &pq_nodes[i]);
if (r!=0) {
for (int j=0; j<=i; j++) {
toku_free(keys[j].data);
toku_free(vals[j].data);
}
pqueue_free(pq);
toku_free(pq_nodes);
printf("%s:%d returning %d\n", __FILE__, __LINE__, r); // remove this printf when we know that this path is tested.
return r;
result = r;
// path tested by loader-dup-test5.tdbrun
// printf("%s:%d returning\n", __FILE__, __LINE__);
break;
}
dataoff[i] = 0;
......@@ -1502,14 +1498,14 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
u_int64_t n_rows_done = 0;
struct rowset *output_rowset = NULL;
if (to_q) {
if (result==0 && to_q) {
XMALLOC(output_rowset);
int r = init_rowset(output_rowset, memory_per_rowset(bl));
assert(r==0);
}
//printf(" n_rows=%ld\n", n_rows);
while (pqueue_size(pq)>0) {
while (result==0 && pqueue_size(pq)>0) {
int r;
int mini;
{
......@@ -1517,14 +1513,9 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
pqueue_node_t *node;
r = pqueue_pop(pq, &node);
if (r!=0) {
for (int i=0; i<n_sources; i++) {
toku_free(keys[i].data);
toku_free(vals[i].data);
}
pqueue_free(pq);
toku_free(pq_nodes);
printf("%s:%d returning\n", __FILE__, __LINE__);
return r;
result = r;
printf("%s:%d returning\n", __FILE__, __LINE__); // comment this line out when we get a test that tests this code path.
break;
}
mini = node->i;
}
......@@ -1555,8 +1546,8 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
if (r!=0) {
if (r==EOF) {
// on feof, queue size permanently smaller
toku_free(keys[mini].data);
toku_free(vals[mini].data);
toku_free(keys[mini].data); keys[mini].data = NULL;
toku_free(vals[mini].data); vals[mini].data = NULL;
} else {
printf("%s:%d returning\n", __FILE__, __LINE__);
return r;
......@@ -1567,12 +1558,9 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
pq_nodes[mini].key = &keys[mini];
r = pqueue_insert(pq, &pq_nodes[mini]);
if (r!=0) {
// Note: This error path tested by loader-dup-test1.tdbrun
for (int i=0; i<n_sources; i++) {
toku_free(keys[i].data);
toku_free(vals[i].data);
}
// Note: This error path tested by loader-dup-test1.tdbrun (and by loader-dup-test4)
result = r;
// printf("%s:%d returning\n", __FILE__, __LINE__);
break;
}
}
......@@ -1599,6 +1587,10 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
}
// cleanup
for (int i=0; i<n_sources; i++) {
toku_free(keys[i].data); keys[i].data = NULL;
toku_free(vals[i].data); vals[i].data = NULL;
}
if (output_rowset) {
destroy_rowset(output_rowset);
toku_free(output_rowset);
......
......@@ -652,7 +652,24 @@ test_thread_stack.%run: test_thread_stack.%$(BINSUF) $(PTHREAD_LOCAL)
./$< -a -thread_stack 16384 -resume $(SUMMARIZE_CMD)
loader-dup-test.tdbrun: loader-dup-test1.tdbrun
loader-dup-test.tdbrun: $(patsubst %,loader-dup-test%.tdbrun, 0 1 2 3 4 5)
true $(SUMMARIZE_CMD) #State that this has passed.
loader-dup-test0.tdbrun: loader-dup-test.tdb$(BINSUF)
$(VGRIND) ./loader-dup-test.tdb -e 0 $(SUMMARIZE_CMD)
loader-dup-test1.tdbrun: loader-dup-test.tdb$(BINSUF)
$(VGRIND) ./loader-dup-test.tdb -d 1 -r 500000 -e 1 $(SUMMARIZE_CMD)
loader-dup-test2.tdbrun: loader-dup-test.tdb$(BINSUF)
$(VGRIND) ./loader-dup-test.tdb -d 1 -r 1000000 -e 2 $(SUMMARIZE_CMD)
loader-dup-test3.tdbrun: loader-dup-test.tdb$(BINSUF)
$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 100 -e 3 $(SUMMARIZE_CMD)
loader-dup-test4.tdbrun: loader-dup-test.tdb$(BINSUF)
$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 1000 -e 4 $(SUMMARIZE_CMD)
loader-dup-test5.tdbrun: loader-dup-test.tdb$(BINSUF)
$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 1000 -E -e 5 $(SUMMARIZE_CMD)
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2010 Tokutek Inc. All rights reserved."
#ident "$Id$"
#ident "$Id $"
#include "test.h"
#include "toku_pthread.h"
......@@ -16,6 +16,9 @@ int CHECK_RESULTS=0;
int USE_PUTS=0;
enum {MAGIC=311};
BOOL dup_row_at_end = FALSE; // FALSE: duplicate at the begining. TRUE: duplicate at the end. The duplicated row is row 0.
int dup_row_id = 0; // 0 means to use row 1 if inserting at the end, row NUM_ROWS if inserting at the beginning. Otherwise insert the row specified here.
//
// Functions to create unique key/value pairs, row generators, checkers, ... for each of NUM_DBS
//
......@@ -223,8 +226,9 @@ static void test_loader(DB **dbs)
// using loader->put, put values into DB
DBT key, val;
unsigned int k, v;
{ // put a duplicate row in.
int i = NUM_ROWS;
if (!dup_row_at_end) {
// put a duplicate row in.
int i = dup_row_id==0 ? NUM_ROWS : dup_row_id;
k = i;
v = generate_val(i, 0);
dbt_init(&key, &k, sizeof(unsigned int));
......@@ -249,6 +253,19 @@ static void test_loader(DB **dbs)
}
if ( CHECK_RESULTS || verbose) { if((i%10000) == 0){printf("."); fflush(stdout);} }
}
if (dup_row_at_end) {
// put a duplicate row in.
int i = dup_row_id==0 ? 1 : dup_row_id;
k = i;
v = generate_val(i, 0);
dbt_init(&key, &k, sizeof(unsigned int));
dbt_init(&val, &v, sizeof(unsigned int));
r = loader->put(loader, &key, &val);
CKERR(r);
if ( CHECK_RESULTS || verbose) { if((i%10000) == 0){printf("."); fflush(stdout);} }
error_extra.bad_i = i;
}
if( CHECK_RESULTS || verbose ) {printf("\n"); fflush(stdout);}
// close the loader
......@@ -359,7 +376,10 @@ static void do_args(int argc, char * const argv[]) {
resultcode=0;
do_usage:
fprintf(stderr, "Usage: %s -h -c -d %d -r %d [ -e <envdir> ]\n", cmd, NUM_DBS, NUM_ROWS);
fprintf(stderr, " where -e <env> uses <env> to construct the directory (so that different tests of loader-stress-test can run concurrently)\n");
fprintf(stderr, " where -e <env> uses <env> to construct the directory (so that different tests can run concurrently)\n");
fprintf(stderr, " -s use size factor of 1 (makes internal loader buffers small so certain cases are easier to test)\n");
fprintf(stderr, " -E duplicate the first row at the end (not the beginning).\n");
fprintf(stderr, " -D <rid> use row id <rid> when duplicating. (Default is 1 if inserting at end, <numrows> if inserting at beginning\n");
exit(resultcode);
} else if (strcmp(argv[0], "-e")==0) {
argc--; argv++;
......@@ -390,6 +410,13 @@ static void do_args(int argc, char * const argv[]) {
CHECK_RESULTS = 1;
} else if (strcmp(argv[0], "-p")==0) {
USE_PUTS = 1;
} else if (strcmp(argv[0], "-s")==0) {
db_env_set_loader_size_factor(1);
} else if (strcmp(argv[0], "-E")==0) {
dup_row_at_end = TRUE;
} else if (strcmp(argv[0], "-D")==0) {
argc--; argv++;
dup_row_id = atoi(argv[0]);
} else {
fprintf(stderr, "Unknown arg: %s\n", argv[0]);
resultcode=1;
......@@ -398,4 +425,5 @@ static void do_args(int argc, char * const argv[]) {
argc--;
argv++;
}
assert(0<=dup_row_id && dup_row_id<=NUM_ROWS);
}
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2009 Tokutek Inc. All rights reserved."
#ident "$Id: loader-reference-test.c 18771 2010-03-24 14:52:19Z bkuszmaul $"
#ident "$Id$"
#include "test.h"
#include "toku_pthread.h"
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2010 Tokutek Inc. All rights reserved."
#ident "$Id: loader-stress-test.c 18792 2010-03-24 22:15:48Z bkuszmaul $"
#ident "$Id$"
#include "test.h"
#include "toku_pthread.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