Skip to content

ra_snapshot: Track latest snapshot size in bytes in state#598

Merged
kjnilsson merged 2 commits intomainfrom
track-latest-snapshot-size
Mar 23, 2026
Merged

ra_snapshot: Track latest snapshot size in bytes in state#598
kjnilsson merged 2 commits intomainfrom
track-latest-snapshot-size

Conversation

@dumbbell
Copy link
Copy Markdown
Collaborator

@dumbbell dumbbell commented Mar 23, 2026

This will be useful to Ra machine implementations to include this value in their snaphsot decision.

The snapshot module implementation can now return the size of the snapshot from its write/4 callback with {ok, SnapshotSize} where SnapshotSize is a non-negative integer representing the number of bytes of the snapshot.

To maintain backward compatibility, returning the historic ok value is accepted. In this case, the snapshot size is set to undefined.

Likewise, when a snapshot is recovered, a new optional snapshot module callback is used, get_size/1. If the callback is unimplemented or if the callback returns an error, the snapshot size is set to undefined.

@dumbbell dumbbell requested a review from kjnilsson March 23, 2026 09:27
@dumbbell dumbbell self-assigned this Mar 23, 2026
@dumbbell dumbbell force-pushed the track-latest-snapshot-size branch 2 times, most recently from c4aee36 to 1d26077 Compare March 23, 2026 10:20
@dumbbell dumbbell marked this pull request as ready for review March 23, 2026 10:36
@dumbbell dumbbell force-pushed the track-latest-snapshot-size branch from 1d26077 to 684660b Compare March 23, 2026 10:55
Copy link
Copy Markdown
Contributor

@kjnilsson kjnilsson left a comment

Choose a reason for hiding this comment

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

a few minor things

This will be useful to Ra machine implementations to include this value
in their snaphsot decision.

The snapshot module implementation can now return the size of the
snapshot from its `write/4` callback with `{ok, SnapshotSize}` where
`SnapshotSize` is a non-negative integer representing the number of
bytes of the snapshot.

To maintain backward compatibility, returning the historic `ok` value is
accepted. In this case, the snapshot size is set to `undefined`.

Likewise, when a snapshot is recovered, a new optional snapshot module
callback is used, `get_size/1`. If the callback is unimplemented or if
the callback returns an error, the snapshot size is set to `undefined`.

Note that this commit only adds the tracking, not the query API. This
will be added in a follow-up commit.
This will be useful to Ra machine implementations to include this value
in their snaphsot decision.
@dumbbell dumbbell force-pushed the track-latest-snapshot-size branch from 684660b to 75c647b Compare March 23, 2026 11:27
@dumbbell dumbbell requested a review from kjnilsson March 23, 2026 12:12
@kjnilsson kjnilsson merged commit ed96cc8 into main Mar 23, 2026
7 checks passed
@dumbbell dumbbell deleted the track-latest-snapshot-size branch March 23, 2026 12:47
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