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

Dynamic trailing computation #714

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marco6
Copy link
Contributor

@marco6 marco6 commented Oct 18, 2024

This PR adds a non-default strategy to dynamically compute the amount of entries to keep in memory based on the size of the snapshot.

The problem with using a fixed number is that each entry has a different size (depending on the number of pages written for each transaction). As such, the memory used (and then streamed to a lagging follower) might be way bigger than the size of the snapshot itself (even by order of magnitude).

@marco6
Copy link
Contributor Author

marco6 commented Oct 18, 2024

This PR lacks testing for now.

@marco6 marco6 marked this pull request as draft October 18, 2024 09:15
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 19.35484% with 25 lines in your changes missing coverage. Please review.

Project coverage is 81.12%. Comparing base (7643fdf) to head (56abe80).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/raft/replication.c 23.80% 13 Missing and 3 partials ⚠️
src/raft/raft.c 10.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #714      +/-   ##
==========================================
+ Coverage   74.02%   81.12%   +7.10%     
==========================================
  Files         192      196       +4     
  Lines       27826    29589    +1763     
  Branches     2796     4096    +1300     
==========================================
+ Hits        20597    24005    +3408     
+ Misses       4905     3920     -985     
+ Partials     2324     1664     -660     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@letFunny
Copy link
Contributor

letFunny commented Nov 1, 2024

Thanks Marco for this PR, it looks very good to me, no comments so far. For the testing part of the story, we have the snapshot tests at test/raft/integration/test_snapshot.c so we could probably add this alternate strategy as a parameter for the existing tests there (where it makes sense). There are other tests that might be applicable such as the replication tests (test_replication.c).

We should also add a new test for the dynamic strategy asserting that the entries in the snapshot match the calculation for the expected size. Actually I was going to suggest changing existing tests to use both strategies by abstracting it away but I see that most of them use a threshold of 1 so it will probably require changing all of them, so adding a new one seems easier. I would suggest adding the tests in the unit tests for replication and in the integration tests, either in the replication_test or in snapshot_test.

Lastly, do not look at the tests under test/raft/unit/test_snapshot.c because those are for the new snapshot procedure that was never released.

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