Commit 543dd95c authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

closes[t:2648] improve the brtloader writer coverage

git-svn-id: file:///svn/toku/tokudb@20538 c7de825b-a66e-492c-adef-691d508d4ae1
parent 59a8f06e
...@@ -427,7 +427,7 @@ serialize_node(BRTNODE node, char *buf, size_t calculated_size, int n_sub_blocks ...@@ -427,7 +427,7 @@ serialize_node(BRTNODE node, char *buf, size_t calculated_size, int n_sub_blocks
} }
static void static int
serialize_uncompressed_block_to_memory(char * uncompressed_buf, serialize_uncompressed_block_to_memory(char * uncompressed_buf,
int n_sub_blocks, int n_sub_blocks,
struct sub_block sub_block[n_sub_blocks], struct sub_block sub_block[n_sub_blocks],
...@@ -438,6 +438,8 @@ serialize_uncompressed_block_to_memory(char * uncompressed_buf, ...@@ -438,6 +438,8 @@ serialize_uncompressed_block_to_memory(char * uncompressed_buf,
size_t sub_block_header_len = sub_block_header_size(n_sub_blocks); size_t sub_block_header_len = sub_block_header_size(n_sub_blocks);
size_t header_len = node_header_overhead + sub_block_header_len + sizeof (uint32_t); // node + sub_block + checksum size_t header_len = node_header_overhead + sub_block_header_len + sizeof (uint32_t); // node + sub_block + checksum
char *MALLOC_N(header_len + compressed_len, compressed_buf); char *MALLOC_N(header_len + compressed_len, compressed_buf);
if (compressed_buf == NULL)
return errno;
// copy the header // copy the header
memcpy(compressed_buf, uncompressed_buf, node_header_overhead); memcpy(compressed_buf, uncompressed_buf, node_header_overhead);
...@@ -469,6 +471,8 @@ serialize_uncompressed_block_to_memory(char * uncompressed_buf, ...@@ -469,6 +471,8 @@ serialize_uncompressed_block_to_memory(char * uncompressed_buf,
*n_bytes_to_write = header_len + compressed_len; *n_bytes_to_write = header_len + compressed_len;
*bytes_to_write = compressed_buf; *bytes_to_write = compressed_buf;
return 0;
} }
int int
...@@ -504,8 +508,8 @@ toku_serialize_brtnode_to_memory (BRTNODE node, int UU(n_workitems), int UU(n_th ...@@ -504,8 +508,8 @@ toku_serialize_brtnode_to_memory (BRTNODE node, int UU(n_workitems), int UU(n_th
serialize_node(node, buf, calculated_size, n_sub_blocks, sub_block); serialize_node(node, buf, calculated_size, n_sub_blocks, sub_block);
//Compress and malloc buffer to write //Compress and malloc buffer to write
serialize_uncompressed_block_to_memory(buf, n_sub_blocks, sub_block, result = serialize_uncompressed_block_to_memory(buf, n_sub_blocks, sub_block,
n_bytes_to_write, bytes_to_write); n_bytes_to_write, bytes_to_write);
toku_free(buf); toku_free(buf);
} }
return result; return result;
...@@ -1741,10 +1745,10 @@ toku_serialize_rollback_log_to_memory (ROLLBACK_LOG_NODE log, ...@@ -1741,10 +1745,10 @@ toku_serialize_rollback_log_to_memory (ROLLBACK_LOG_NODE log,
serialize_rollback_log_node_to_buf(log, buf, calculated_size, n_sub_blocks, sub_block); serialize_rollback_log_node_to_buf(log, buf, calculated_size, n_sub_blocks, sub_block);
//Compress and malloc buffer to write //Compress and malloc buffer to write
serialize_uncompressed_block_to_memory(buf, n_sub_blocks, sub_block, int result = serialize_uncompressed_block_to_memory(buf, n_sub_blocks, sub_block,
n_bytes_to_write, bytes_to_write); n_bytes_to_write, bytes_to_write);
toku_free(buf); toku_free(buf);
return 0; return result;
} }
int int
......
...@@ -2926,8 +2926,10 @@ static void write_nonleaf_node (BRTLOADER bl, struct dbout *out, int64_t blocknu ...@@ -2926,8 +2926,10 @@ static void write_nonleaf_node (BRTLOADER bl, struct dbout *out, int64_t blocknu
ci->blocknum = make_blocknum(subtree_info[i].block); ci->blocknum = make_blocknum(subtree_info[i].block);
ci->have_fullhash = FALSE; ci->have_fullhash = FALSE;
ci->fullhash = 0; ci->fullhash = 0;
ci->buffer = NULL;
int r = toku_fifo_create(&ci->buffer); int r = toku_fifo_create(&ci->buffer);
resource_assert(r==0); if (r != 0)
result = r;
ci->n_bytes_in_buffer = 0; ci->n_bytes_in_buffer = 0;
} }
...@@ -2959,7 +2961,10 @@ static void write_nonleaf_node (BRTLOADER bl, struct dbout *out, int64_t blocknu ...@@ -2959,7 +2961,10 @@ static void write_nonleaf_node (BRTLOADER bl, struct dbout *out, int64_t blocknu
toku_free(node->u.n.childkeys[i]); toku_free(node->u.n.childkeys[i]);
} }
for (int i=0; i<n_children; i++) { for (int i=0; i<n_children; i++) {
toku_fifo_free(&node->u.n.childinfos[i].buffer); if (node->u.n.childinfos[i].buffer) {
toku_fifo_free(&node->u.n.childinfos[i].buffer);
node->u.n.childinfos[i].buffer = NULL;
}
} }
toku_free(pivots); toku_free(pivots);
toku_free(node->u.n.childinfos); toku_free(node->u.n.childinfos);
......
...@@ -114,14 +114,14 @@ check_brtloader-test-writer-1: brtloader-test-writer$(BINSUF) ...@@ -114,14 +114,14 @@ check_brtloader-test-writer-1: brtloader-test-writer$(BINSUF)
check_brtloader-test-writer-2: brtloader-test-writer$(BINSUF) check_brtloader-test-writer-2: brtloader-test-writer$(BINSUF)
$(VGRIND) ./$< -q -r 1000000 -s dir.$@ $(SUMMARIZE_CMD) $(VGRIND) ./$< -q -r 1000000 -s dir.$@ $(SUMMARIZE_CMD)
check_brtloader-test-writer-errors$(BINSUF): $(patsubst %,check_brtloader-test-writer-errors-%, 1 2 3) check_brtloader-test-writer-errors$(BINSUF): $(patsubst %,check_brtloader-test-writer-errors-%, 1 2 3 4)
true $(SUMMARIZE_CMD) true $(SUMMARIZE_CMD)
check_brtloader-test-writer-errors-1: brtloader-test-writer-errors$(BINSUF) check_brtloader-test-writer-errors-1: brtloader-test-writer-errors$(BINSUF)
$(VGRIND) ./$< -q -w -m -u -r 100000 dir.$@ $(SUMMARIZE_CMD) $(VGRIND) ./$< -q -w -m -u -r 100000 dir.$@ $(SUMMARIZE_CMD)
check_brtloader-test-writer-errors-2: brtloader-test-writer-errors$(BINSUF) check_brtloader-test-writer-errors-2: brtloader-test-writer-errors$(BINSUF)
$(VGRIND) ./$< -q -s -w -m -u -r 10000 dir.$@ $(SUMMARIZE_CMD) $(VGRIND) ./$< -q -s -w -m -u -r 10000 dir.$@ $(SUMMARIZE_CMD)
check_brtloader-test-writer-errors-3: brtloader-test-writer-errors$(BINSUF) check_brtloader-test-writer-errors-3: brtloader-test-writer-errors$(BINSUF)
$(VGRIND) ./$< -q -s -r 10000 --malloc_limit 0 --realloc_errors dir.$@ $(SUMMARIZE_CMD) $(VGRIND) ./$< -q -s -r 20000 --malloc_limit 0 --realloc_errors dir.$@ $(SUMMARIZE_CMD)
check_brtloader-test-writer-errors-4: brtloader-test-writer-errors$(BINSUF) check_brtloader-test-writer-errors-4: brtloader-test-writer-errors$(BINSUF)
$(VGRIND) ./$< -q -s -m --malloc_limit 0 -r 10000 dir.$@ $(SUMMARIZE_CMD) $(VGRIND) ./$< -q -s -m --malloc_limit 0 -r 10000 dir.$@ $(SUMMARIZE_CMD)
......
...@@ -343,7 +343,6 @@ int test_main (int argc, const char *argv[]) { ...@@ -343,7 +343,6 @@ int test_main (int argc, const char *argv[]) {
if (verbose) printf("event_limit=%d\n", event_limit); if (verbose) printf("event_limit=%d\n", event_limit);
for (int i = 1; i <= event_limit; i++) { for (int i = 1; i <= event_limit; i++) {
// if (i == 62 || i == 63 || i == 64 || i == 65 || i == 66 || i == 67) continue;
reset_event_counts(); reset_event_counts();
reset_my_malloc_counts(); reset_my_malloc_counts();
event_count_trigger = i; event_count_trigger = i;
......
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