Commit 2b718739 authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

[t:4567] Merging fixes to recent error reporting changes.

git-svn-id: file:///svn/toku/tokudb@41843 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5dce42f5
...@@ -1256,7 +1256,7 @@ verify_brtnode_sub_block (struct sub_block *sb) ...@@ -1256,7 +1256,7 @@ verify_brtnode_sub_block (struct sub_block *sb)
} }
// This function deserializes the data stored by serialize_brtnode_info // This function deserializes the data stored by serialize_brtnode_info
static void static enum deserialize_error_code
deserialize_brtnode_info( deserialize_brtnode_info(
struct sub_block *sb, struct sub_block *sb,
BRTNODE node BRTNODE node
...@@ -1266,7 +1266,12 @@ deserialize_brtnode_info( ...@@ -1266,7 +1266,12 @@ deserialize_brtnode_info(
// this function puts that information into node // this function puts that information into node
// first verify the checksum // first verify the checksum
verify_brtnode_sub_block(sb); enum deserialize_error_code e = DS_OK;
e = verify_brtnode_sub_block(sb);
if (e != DS_OK) {
goto exit;
}
u_int32_t data_size = sb->uncompressed_size - 4; // checksum is 4 bytes at end u_int32_t data_size = sb->uncompressed_size - 4; // checksum is 4 bytes at end
// now with the data verified, we can read the information into the node // now with the data verified, we can read the information into the node
...@@ -1320,6 +1325,8 @@ deserialize_brtnode_info( ...@@ -1320,6 +1325,8 @@ deserialize_brtnode_info(
dump_bad_block(rb.buf, rb.size); dump_bad_block(rb.buf, rb.size);
assert(FALSE); assert(FALSE);
} }
exit:
return e;
} }
static void static void
...@@ -1598,11 +1605,9 @@ deserialize_brtnode_header_from_rbuf_if_small_enough (BRTNODE *brtnode, ...@@ -1598,11 +1605,9 @@ deserialize_brtnode_header_from_rbuf_if_small_enough (BRTNODE *brtnode,
u_int32_t stored_checksum = rbuf_int(rb); u_int32_t stored_checksum = rbuf_int(rb);
if (stored_checksum != checksum) { if (stored_checksum != checksum) {
dump_bad_block(rb->buf, rb->size); dump_bad_block(rb->buf, rb->size);
if (stored_checksum != checksum) {
e = DS_XSUM_FAIL; e = DS_XSUM_FAIL;
goto cleanup; goto cleanup;
} }
}
// Now we want to read the pivot information. // Now we want to read the pivot information.
struct sub_block sb_node_info; struct sub_block sb_node_info;
...@@ -1639,7 +1644,11 @@ deserialize_brtnode_header_from_rbuf_if_small_enough (BRTNODE *brtnode, ...@@ -1639,7 +1644,11 @@ deserialize_brtnode_header_from_rbuf_if_small_enough (BRTNODE *brtnode,
); );
// at this point sb->uncompressed_ptr stores the serialized node info. // at this point sb->uncompressed_ptr stores the serialized node info.
deserialize_brtnode_info(&sb_node_info, node); e = deserialize_brtnode_info(&sb_node_info, node);
if (e != DS_OK) {
goto cleanup;
}
toku_free(sb_node_info.uncompressed_ptr); toku_free(sb_node_info.uncompressed_ptr);
sb_node_info.uncompressed_ptr = NULL; sb_node_info.uncompressed_ptr = NULL;
...@@ -2255,7 +2264,10 @@ deserialize_brtnode_from_rbuf( ...@@ -2255,7 +2264,10 @@ deserialize_brtnode_from_rbuf(
} }
// at this point, sb->uncompressed_ptr stores the serialized node info // at this point, sb->uncompressed_ptr stores the serialized node info
deserialize_brtnode_info(&sb_node_info, node); e = deserialize_brtnode_info(&sb_node_info, node);
if (e != DS_OK) {
goto cleanup;
}
toku_free(sb_node_info.uncompressed_ptr); toku_free(sb_node_info.uncompressed_ptr);
// now that the node info has been deserialized, we can proceed to deserialize // now that the node info has been deserialized, we can proceed to deserialize
...@@ -2327,6 +2339,10 @@ deserialize_brtnode_from_rbuf( ...@@ -2327,6 +2339,10 @@ deserialize_brtnode_from_rbuf(
cleanup: cleanup:
if (r != 0) { if (r != 0) {
e = DS_ERRNO; e = DS_ERRNO;
// NOTE: Right now, callers higher in the stack will assert on
// failure, so this is OK for production. However, if we
// create tools that use this function to search for errors in
// the BRT, then we will leak memory.
if (node) toku_free(node); if (node) toku_free(node);
} }
...@@ -2429,7 +2445,7 @@ toku_deserialize_brtnode_from (int fd, ...@@ -2429,7 +2445,7 @@ toku_deserialize_brtnode_from (int fd,
read_brtnode_header_from_fd_into_rbuf_if_small_enough(fd, blocknum, bfe->h, &rb); read_brtnode_header_from_fd_into_rbuf_if_small_enough(fd, blocknum, bfe->h, &rb);
e = deserialize_brtnode_header_from_rbuf_if_small_enough(brtnode, ndd, blocknum, fullhash, bfe, &rb, fd); e = deserialize_brtnode_header_from_rbuf_if_small_enough(brtnode, ndd, blocknum, fullhash, bfe, &rb, fd);
if (e == DS_ERRNO) { if (e != DS_OK) { //<CER> ??? Change this to != DS_OK?
e = DS_OK; e = DS_OK;
toku_free(rb.buf); toku_free(rb.buf);
rb = RBUF_INITIALIZER; rb = RBUF_INITIALIZER;
......
...@@ -798,23 +798,22 @@ int toku_brtnode_fetch_callback (CACHEFILE UU(cachefile), int fd, BLOCKNUM noden ...@@ -798,23 +798,22 @@ int toku_brtnode_fetch_callback (CACHEFILE UU(cachefile), int fd, BLOCKNUM noden
// deserialize the node, must pass the bfe in because we cannot // deserialize the node, must pass the bfe in because we cannot
// evaluate what piece of the the node is necessary until we get it at // evaluate what piece of the the node is necessary until we get it at
// least partially into memory // least partially into memory
// <CER> TODO: Use checksum error code as a return HERE!
enum deserialize_error_code e; enum deserialize_error_code e;
int r = 0; int r = 0;
e = toku_deserialize_brtnode_from(fd, nodename, fullhash, node, ndd, bfe); e = toku_deserialize_brtnode_from(fd, nodename, fullhash, node, ndd, bfe);
if (e != DS_OK) {
if (e == DS_XSUM_FAIL) { if (e == DS_XSUM_FAIL) {
fprintf(stderr, "Checksum failure while reading node in file %s.\n", toku_cachefile_fname_in_env(cachefile)); fprintf(stderr,
assert(false); // make absolutely sure we crash before doing anything else "Checksum failure while reading node in file %s.\n",
toku_cachefile_fname_in_env(cachefile));
} else if (e == DS_ERRNO) { } else if (e == DS_ERRNO) {
r = errno; r = errno;
} else if (e == DS_OK) { fprintf(stderr, "Error deserializing node, errno = %d", r);
r = 0; }
} else { // make absolutely sure we crash before doing anything else.
assert(false); assert(false);
} }
/*
int r = toku_deserialize_brtnode_from(fd, nodename, fullhash, node, ndd, bfe);
*/
if (r == 0) { if (r == 0) {
(*node)->h = bfe->h; // copy reference to header from bfe (*node)->h = bfe->h; // copy reference to header from bfe
*sizep = make_brtnode_pair_attr(*node); *sizep = make_brtnode_pair_attr(*node);
...@@ -1224,12 +1223,19 @@ int toku_brtnode_pf_callback(void* brtnode_pv, void* disk_data, void* read_extra ...@@ -1224,12 +1223,19 @@ int toku_brtnode_pf_callback(void* brtnode_pv, void* disk_data, void* read_extra
} }
if (e != DS_OK) { if (e != DS_OK) {
fprintf(stderr, "Unknown failure while reading node in file %s.\n", toku_cachefile_fname_in_env(bfe->h->cf)); if (e == DS_XSUM_FAIL) {
fprintf(stderr,
"Checksum failure while reading node partition in file %s.\n",
toku_cachefile_fname_in_env(bfe->h->cf));
} else if (e == DS_ERRNO) {
fprintf(stderr,
"Error while reading node partition %d\n",
errno);
}
assert(false); assert(false);
} }
} }
cilk_sync;
*sizep = make_brtnode_pair_attr(node); *sizep = make_brtnode_pair_attr(node);
return 0; 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