Skip to content
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

Automated logging towards GRiSP.io #18

Merged
merged 22 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/grisp_io_binlog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ truncate(To, #binlog{seq = Seq} = L) when To >= Seq ->
clear(L);
truncate(To, #binlog{queue = Q0} = L) ->
case queue:out(Q0) of
{{value, {Seq, Bin}}, Q1} when Seq < To ->
{{value, {Seq, Bin}}, Q1} when Seq =< To ->
Copy link
Member Author

@ziopio ziopio Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug could also affect DAB
It happens when the client does not send the whole log queue and later syncs the logs.
This can result in a repeated log sent to the server or, way worse, infinite loop.
I had an infinite loop in my case because now I am forcing the chunk to be under a fixed byte size. So I had a queue long 2 and always sending only one log. This was resulting in a failed sync because of this truncate function. And this would endup looping forever.

Copy link
Member Author

@ziopio ziopio Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For DAB this may cause a log line to be sent 2 times.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this image as reference for the protocol algorithm https://github.com/stritzinger/dab/blob/master/docs/log_buffer.excalidraw.png

truncate(To, drop(Q1, Bin, L));
_ ->
L
Expand Down
2 changes: 1 addition & 1 deletion test/grisp_io_binlog_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ truncate(_Config) ->
?assertEqual(L0, truncate(5, L0)),
{L1, D1} = insert_many([{N, <<>>} || N <- lists:seq(1, 10)], L0),
?assertEqual(0, D1),
?assertItems([{N, <<>>} || N <- lists:seq(5, 10)], truncate(5, L1)),
?assertItems([{N, <<>>} || N <- lists:seq(6, 10)], truncate(5, L1)),
?assertItems([], truncate(15, L1)),
?assertEqual(10, seq(L1)).

Expand Down