fix: Automatically compact entity_store.jsonl after a large number of repeat topics#4173
fix: Automatically compact entity_store.jsonl after a large number of repeat topics#4173jarhodes314 wants to merge 5 commits into
entity_store.jsonl after a large number of repeat topics#4173Conversation
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
…ated topics Signed-off-by: James Rhodes <jarhodes314@gmail.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Robot Results
|
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
5ec42ba to
d2d0cd7
Compare
albinsuresh
left a comment
There was a problem hiding this comment.
The code looks fine. Happy to approve once cleared message handling is also fixed. Also as an additional enhancement, how about doing an unconditional compaction on startup?
…of repeated topics
4d19be1 to
f4becd5
Compare
| OpenOptions::new() | ||
| .create(true) | ||
| .write(true) | ||
| .truncate(true) |
There was a problem hiding this comment.
The behaviour of this is slightly altered. Previously, truncate mode meant we opened the file with truncate(true), then closed it, then opened it again (via MessageLogWriter::new). Now we just open it the one time with truncation. I believe this won't cause any dramatic behaviour changes as we didn't do anything to make the truncation fsync-durable, and it seemed from reading the code that we mostly did it for easy code reuse between the truncate and non-truncate paths.
This has the side-effect of us also failing if we fail to open the file with truncation (previously we ignored the result of opening the truncated file). I don't believe this will cause any major issues - if we can't open a file to truncate, we probably can't open it in append mode. There's a possible edge case where file system attributes might mean we can only append to a file, but in this case I think we're better off failing rather than pretending everything's working?
…of repeated topics
Proposed changes
Adds a compaction mechanism to the entity store file. This will trigger after we have written a significant number (currently 100) messages to topics that already exist in the file, preventing unbounded growth.
It also refactors the existing test for the readers/writers into well-defined unit tests.
Types of changes
Paste Link to the issue
entity_store.jsonlgrows indefinitely when retained messages are repeatedly published to the same topic #4172Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments