Commit a62c5b14 authored by John Esmet's avatar John Esmet

FT-304 Fix an oops in the blocktable, first exposed in a MySQl test and

now by src/tests/stress_test7.cc
parent 94355a23
......@@ -100,7 +100,7 @@ PATENT RIGHTS GRANT:
#include "ft/serialize/block_allocator.h"
#include "ft/serialize/block_allocator_strategy.h"
#if 0
#if TOKU_DEBUG_PARANOID
#define VALIDATE() validate()
#else
#define VALIDATE()
......@@ -180,19 +180,18 @@ void block_allocator::create_from_blockpairs(uint64_t reserve_at_beginning, uint
struct blockpair *pairs, uint64_t n_blocks) {
_create_internal(reserve_at_beginning, alignment);
for (uint64_t i = 0; i < _n_blocks; i++) {
// Allocator does not support size 0 blocks. See block_allocator_free_block.
invariant(pairs[i].size > 0);
invariant(pairs[i].offset >= _reserve_at_beginning);
invariant(pairs[i].offset % _alignment == 0);
_n_bytes_in_use += pairs[i].size;
}
_n_blocks = n_blocks;
grow_blocks_array_by(_n_blocks);
memcpy(_blocks_array, pairs, _n_blocks * sizeof(struct blockpair));
qsort(_blocks_array, _n_blocks, sizeof(struct blockpair), compare_blockpairs);
for (uint64_t i = 0; i < _n_blocks; i++) {
// Allocator does not support size 0 blocks. See block_allocator_free_block.
invariant(_blocks_array[i].size > 0);
invariant(_blocks_array[i].offset >= _reserve_at_beginning);
invariant(_blocks_array[i].offset % _alignment == 0);
_n_bytes_in_use += _blocks_array[i].size;
}
VALIDATE();
}
......
......@@ -959,7 +959,7 @@ void block_table::get_fragmentation_unlocked(TOKU_DB_FRAGMENTATION report) {
struct translation *checkpointed = &_checkpointed;
for (int64_t i = 0; i < checkpointed->length_of_array; i++) {
struct block_translation_pair *pair = &_checkpointed.block_translation[i];
struct block_translation_pair *pair = &checkpointed->block_translation[i];
if (pair->size > 0 && !(i < current->length_of_array &&
current->block_translation[i].size > 0 &&
current->block_translation[i].u.diskoff == pair->u.diskoff)) {
......@@ -970,7 +970,7 @@ void block_table::get_fragmentation_unlocked(TOKU_DB_FRAGMENTATION report) {
struct translation *inprogress = &_inprogress;
for (int64_t i = 0; i < inprogress->length_of_array; i++) {
struct block_translation_pair *pair = &_inprogress.block_translation[i];
struct block_translation_pair *pair = &inprogress->block_translation[i];
if (pair->size > 0 && !(i < current->length_of_array &&
current->block_translation[i].size > 0 &&
current->block_translation[i].u.diskoff == pair->u.diskoff) &&
......
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