Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect EBB hash truncation in the index files of the ImmutableDB
On very rare occasions, the quickcheck-state-machine tests for the ImmutableDB failed, e.g., https://hydra.iohk.io/build/790254/nixlog/11 The cause of this is the following. We write the hash of the EBB at the end of the index file, after the offsets. When there is no EBB in the epoch, we write nothing extra after the offsets. In the tests we simulate corruptions, e.g., by truncating some bytes from the end of some file. In some rare cases, we were simulating a truncation of the index file such that exactly the EBB hash was removed from the end of the file. When reading the index file again, we saw an empty bytestring at the end of the file, which corresponds to the case where there is no EBB, so we didn't notice that the EBB got truncated. The solution: instead of checking whether the bytestring left-over after parsing the offsets is non-empty to determine whether there was an EBB or not, we look at the second offset (which indicates the size of the EBB) in the index, which will be non-zero if there was an EBB. While working in this module, fix a confusing comment and a TODO.
- Loading branch information