You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose that the circular log buffer is of size 3 and has the following layout:
[<entry>, NULL, <entry>]
^ ^
back front
base index is 3 (so <entry> at front has index 3 and <entry> at back has index 4)
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:
if (i < me->back)
logs_till_end_of_log = me->back - i;
else
logs_till_end_of_log = me->size - i;
In the else case the length should actually be me->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:
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 suppose log interface should be virtual, and it does care where you put the log entry, may be in memory or on disk.
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: