Fix fragment corruption in the GlobalOrderWriter #4383
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously there was an issue with the GlobalOrderWriter when using a
maximum fragment size. If we resumed a write where the first tile would
cause the partially written fragment to overflow the set maximum size,
we failed to check that a single tile could fit. This resulted in a
convoluted path where
dim_tiles[-1].cell_num()
return a reasonableresult (instead of segfaulting or throwing an exception).
This lead us to writing the wrong
last_tile_cell_num
value in theFragmentMetadata. When reading the last tile from one of these corrupted
fragments, the logic in
Tile::load_chunk_data
would throw an exceptionwhen the expected size was calculated off an invalid
last_tile_cell_num
which caused an exception to be thrown and renderedthe last tile of the fragment unreadable.
The fix is simply to make sure we check if a single tile can fit and if
not, to create a new fragment. For a belt and suspenders approach to
safety, we've also changed the code in
WriterBase::set_coords_metadata
to use
std::vector::at
instead ofstd::vector::operator[]
so thatbounds checking is performed and assertion is thrown rather than writing
a bad FragmentMetadata to disk.
TYPE: BUG
DESC: Fix fragment corruption in the GlobalOrderWriter