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

swarm/storage: fix SubscribePull to not skip chunks #19599

Merged
merged 1 commit into from
May 31, 2019

Conversation

nonsense
Copy link
Member

@nonsense nonsense commented May 20, 2019

This PR is fixing a bug in SubscribePull where on occasion it would skip the chunk pointed to by the since cursor.

  1. SubscribePull has always been accepting a closed interval with respect to its arguments since and until - the godoc has been amended.

  2. endless stream of OfferedHashesMsg ethersphere/swarm#1375 is fixed as a result.


The bug this PR is addressing is that if on first iteration, the iterator within SubscribePull returns chunks - then the behaviour of SubscribePull is correct.
However if on first iteration, the iterator returns no chunks, and the since chunk is stored after the subscription is established, then it the chunk pointed at by since is not returned by the iterator, because first is set to false, and the item is skipped.

@nonsense nonsense requested review from janos and acud May 20, 2019 13:10
@nonsense nonsense force-pushed the fix-from-1 branch 3 times, most recently from 63b46fa to 3cc9354 Compare May 28, 2019 18:02
@nonsense nonsense changed the title swarm/storage: make SubscribePull take a closed interval swarm/storage: fix SubscribePull to not skip chunks May 28, 2019
@nonsense
Copy link
Member Author

@justelad I believe this is fixing the bug that was incorrectly solved with from--.

Now we don't have endless stream of Offered/Wanted messages, and we also don't have missing chunks in syncing.

This PR however does not address the complete lack of proper testing of SetNextBatch within the stream protocol. The fact that the bug where chunks are missing in between batches was not caught in any tests, but only visible during smoke tests is not great.

Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

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

LGTM. nice catch @nonsense

@nonsense nonsense merged commit 30263ad into ethereum:master May 31, 2019
@acud acud deleted the fix-from-1 branch May 31, 2019 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants