Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix read handling of corrupted journal segments (#9378)
Previously the journal reader got stuck waiting when reading from an offset that returned an empty result. In that case the journal reader assumes that it reached the end of the journal and waits for more messages to come in. Once new messages have been written to the journal, the reader is trying again with the same offset. With a corrupted log segment, reading the same offset will return an empty result again. Even though there are valid messages in new segments after the corrupted one. This put the journal reader in an infinite loop until the corrupted journal segmet gets deleted manually or users delete the complete journal. The code is now checking if there are more messages after the current read offset when an empty result is received from the read operation. In that case it increases the offset one by one and retries the read until the result is not empty anymore or the end of the log has been reached. We reproduced this issue with a journal where the first segment was truncated at the end. Later log segments contained valid messages. Rename fault-tolerant read method to `readNext`. So that the JournalDecode command uses the old method. Otherwise decoding a faulty offset explicitly with `journal decode` would decode a message at the next non-faulty offset, which is probably not expected. Add test to simulate truncated segment. Fixes #9305 Co-authored-by: Bernd Ahlers <bernd@graylog.com> Co-authored-by: Othello Maurer <othello@graylog.com>
- Loading branch information
1 parent
4e94563
commit 7a0b955
Showing
2 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters