The bug is the following:
- Initially on a follower broker there are two segments 0 and segment 10000. Segment 0 is empty (maybe due to log compaction)
- log is truncated to 0.
- LogSemgent.Truncate() will not find a message to truncate in segment 0, so it will skip resizing the index/timeindex files.
- When a new message is fetched, Log.maybeRoll() will try to roll a new segment because the index file of segment 0 is already full (max size is 0)
- After creating the new segment 0, the replica fetcher thread finds that there is already a segment 0 exists. So it just throws exception and dies.
The fix would be let the broker make sure the index files of active segments are always resized properly.