-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log_get_from_idx not including entries that have wrapped around? #95
Comments
Not only this question, my questions is: can log entry only be in memory? how about big log entry, such as 2G bytes, and you have mutliple log entries in memory ? |
I personally thinking that the approach of keeping the whole log in memory is fine. Do you have a real world use case of entries sizing 2Gb each? It seems you're doing something really wrong in that case, as there are probably more effective alternatives (e.g. using raft as control layer for replication metadata, but replicate the data out of band). |
Suppose that the circular log buffer is of size 3 and has the following layout:
then it seems that a call to
log_get_from_idx(3)
instead of returning an array of 2 entries which includes entries 3 and 4, returns an array of just 1 entry which includes only entry 3.This can be reproduced with the following (failing) test:
It seems the bug is
log_get_from_idx()
when it calculates the length of the array to be returned:In the
else
case the length should actually beme->size - i + me->back
, to include the most recent entries that have wrapped around. However it's not clear how to return a pointer without performing some allocation, because of course pointers don't wrap around.Does it make sense? Is this a bug?
The text was updated successfully, but these errors were encountered: