You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We assume there will never be more than this many blocks. The value
// is computed by dividing 1 TB by the smallest reasonable block size.
// This value currently fits in 32 bits, and so block_id_t is a uint32_t.
#define MAX_BLOCK_ID (TERABYTE / KILOBYTE)
This limits the size of one shard to 4 TB, if not even the size of all the data for the whole table residing on a single node. (are all shards of a certain table stored in the same file?)
This should be documented somewhere.
Also, the limit should be increased.
The maximal value that can be stored in a uint32_t = block_id_t is 4 * TERABYTE / KILOBYTE - 1, which would allow for 16 TB of data per shard. One more value has to be reserved for NULL_BLOCK_ID, so we would end up with MAX_BLOCK_ID = 4 * TERABYTE / KILOBYTE - 2 (assuming MAX_BLOCK_ID is inclusive, I have not checked).
Changing this will have an effect on both the on-disk and in-memory LBA index structures in the serializer. I'll have to check the code to find out what kind of effect.
For what's much much worse, I actually cannot find any place where this is checked.
The cache's free list seems to happily generate higher and higher block ids (see array_free_list_t::gen_block_id()). The segmented_vector, for which the MAX_BLOCK_ID is actually used, has an rassert, but no guarantee to check for illegal resizing values either (see segmented_vector_t::set_size()), so it will happily write into unallocated or otherwise-allocated memory (say a dirty data page in the cache, shudder. Even though probably, it will just overwrite the size variable of the segmented_vector_t, with potentially other serious side-effects) .
While checking for this in the cache might not be trivial due to the serializer multiplexing layer, the log serializer should at least panic if this condition occurs.
If the real fix doesn't make it into 1.6, I suggest adding a simple guarantee() to check for a block id overflow to the in-memory LBA code as a temporary work around. Crashing "cleanly" on an overflow is a lot better than quietly corrupting memory and potentially on-disk data.
With more people evaluating RethinkDB on real data, there's a chance that they hit this limit even without #939 (which would not do anything to the number of blocks used for storing a given amount of data anyways, would it?).
Activity
danielmewes commentedon Jun 3, 2013
For what's much much worse, I actually cannot find any place where this is checked.
The cache's free list seems to happily generate higher and higher block ids (see array_free_list_t::gen_block_id()). The segmented_vector, for which the MAX_BLOCK_ID is actually used, has an rassert, but no guarantee to check for illegal resizing values either (see segmented_vector_t::set_size()), so it will happily write into unallocated or otherwise-allocated memory (say a dirty data page in the cache, shudder. Even though probably, it will just overwrite the size variable of the segmented_vector_t, with potentially other serious side-effects) .
While checking for this in the cache might not be trivial due to the serializer multiplexing layer, the log serializer should at least panic if this condition occurs.
danielmewes commentedon Jun 3, 2013
Also marking this as high priority, as I see a significant chance of silent data corruption.
srh commentedon Jun 3, 2013
With #939 there is a higher, quite realistic chance of overflowing the limit. I'm working on this in branch sam_939.
danielmewes commentedon Jun 3, 2013
If the real fix doesn't make it into 1.6, I suggest adding a simple guarantee() to check for a block id overflow to the in-memory LBA code as a temporary work around. Crashing "cleanly" on an overflow is a lot better than quietly corrupting memory and potentially on-disk data.
With more people evaluating RethinkDB on real data, there's a chance that they hit this limit even without #939 (which would not do anything to the number of blocks used for storing a given amount of data anyways, would it?).
coffeemug commentedon Jun 10, 2013
Talked to @srh. This should be ~three days away, but requires a bit of testing. Moving to 1.7.
danielmewes commentedon Jun 10, 2013
That makes sense. Please consider my previous post.
coffeemug commentedon Jun 18, 2013
Since @srh pointed out that he's on top of it and considers it to be a part of #939, I'm closing this issue. Consider it merged into #939.