sbtourist / Journal.IO

Journal.IO is a zero-dependency, fast and easy-to-use journal storage implementation.
Apache License 2.0
260 stars 39 forks source link

java.io.IOException: Invalid location when redoing a compacted journal #39

Closed SebastianStoll closed 11 years ago

SebastianStoll commented 11 years ago

Hej Hej,

While testing this library I came across an issue when trying to redo a journal that was previously compacted. The used journal.io version is 1.3 .

Lets consider the following scenario:

which will cause the following exception eg:

Invalid location: 1:13987:1, found: null
    java.io.IOException: Invalid location: 1:13987:1, found: null    
    at journal.io.api.DataFileAccessor.readLocation(DataFileAccessor.java:97)
    at journal.io.api.Journal.read(Journal.java:301)

It seems that the compaction of journal db files with some but not all locations marked as deleted causes an invalid journal state. Further redos/reads will cause the error above.

I noticed though that a new instance of the journal using the same journal db files is able to redo/read locations.

Is the depicted behaviour a bug or simply a use case that is not supported?

Best, Sebastian

sbtourist commented 11 years ago

Thanks for the report Sebastian.

This is most certainly a bug: could you please attach a simple test case reproducing it, so I can have a deeper look?

sbtourist commented 11 years ago

Fixed, have a try :)

SebastianStoll commented 11 years ago

Works perfectly and thank you for fixing that so quickly!

sbtourist commented 11 years ago

Glad to know :)

I'll hopefully release a new version with this fix (and some others) in the next few weeks, feel free to join the mailing list to watch out for announcements.