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
Hi, from testing this library out and reading the code it looks like the log must always have at least one entry following a truncate. I am curious why this is a requirement?
The issue I'm hitting is when trying to truncate the final entry in the log. For example, if I push three objects onto the log:
As I read these entries, I want to remove them from the log once I'm done with them. So I do something like:
data1, err:=log.Read(1)
useData(data1)
// truncate index 1 and make index 2 the new fronterr=log.TruncateFront(2)
data2, err:=log.Read(2)
useData(data2)
// truncate index 2 and make index 3 the new fronterr=log.TruncateFront(3)
data3, err:=log.Read(3)
useData(data3)
// truncate index 3 and make index 4 the new front// this fails with ErrOutOfRangeerr=log.TruncateFront(4)
Obviously, the final log.TruncateFront(4) call fails with ErrOutOfRange. This keeps data3 in the log. At this point, if my process crashes and restarts, it will still see data3 in the log and try to call useData(data3), resulting in a duplicate transaction.
Is there a way to completely flush/truncate the log when no more entries are valid? I might be missing something obvious.
Thanks for the work on this!
The text was updated successfully, but these errors were encountered:
Hi, from testing this library out and reading the code it looks like the log must always have at least one entry following a truncate. I am curious why this is a requirement?
The issue I'm hitting is when trying to truncate the final entry in the log. For example, if I push three objects onto the log:
As I read these entries, I want to remove them from the log once I'm done with them. So I do something like:
Obviously, the final
log.TruncateFront(4)
call fails with ErrOutOfRange. This keepsdata3
in the log. At this point, if my process crashes and restarts, it will still seedata3
in the log and try to calluseData(data3)
, resulting in a duplicate transaction.Is there a way to completely flush/truncate the log when no more entries are valid? I might be missing something obvious.
Thanks for the work on this!
The text was updated successfully, but these errors were encountered: