Skip to content

Conversation

@allenss-amazon
Copy link
Member

@allenss-amazon allenss-amazon commented Oct 1, 2025

Revises the save/restore logic to support saving of all index data and pending mutation queue as discussed earlier.

This new logic is fully backward and forward compatible. RDB files written using the previous binaries (aka V1) will still be loaded and subject to the same stale data correction and forced backfill logic as existed before this PR. In other words, for RDB files written with the old code, the new code handles them exactly the same.

New format files (aka V2) contain additional data that will be ignored by old code. In other words, V2 RDB files can still be loaded into prior code which will ignore the extra data, i.e., they are treated like V1 files and be subjected to stale data correction and forced backfill.

V2 files which are loaded into the new code are not subjected to stale data correction and forced backfill. Once a V2 file is loaded it can "open for business" immediately.

The V2 format contains an additional section for the contents of non-vector indexes (Tags, Numeric). These sections contain the key and attribute-value for each entry in the index. This external format differs from the internal format, allowing the internal data structures to be freely optimized in the future.

The V2 format also has a section for the mutation queue and index backfill status. This additional section records the keys that were in the mutation queue at the time of the save as well as the index backfill status (complete or incomplete). This allows the recreation of the mutation queue and backfill status (backfill needed or not) to match the state at the time of the save. (One small quirk is that the saved mutation queue doesn't bother to record whether the saved keys are in the mutation queue due to a backfill or not. This behavior should not affect the client-visible semantics, but would affect internal counters for the ingestion pipeline as they would be mislead by the source of the mutation.

Two controls are provided to override the normal behavior of this code.

The configurable: search.rdb_write_v2 (default "yes") controls whether a generated RDB file is in the V1 or V2 format.

The configurable: search.rdb_read_v2 (default "yes") controls whether the V2 data is used. Setting this to "no" will force the code to treat a V2 file as a V1 file, i.e., to ignore the extra V1 data.

FIxes #41

@allenss-amazon allenss-amazon changed the title Initial wiring Revise Save/Restore for true pit snapshot. Oct 4, 2025
@allenss-amazon allenss-amazon marked this pull request as ready for review October 4, 2025 18:50
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
Signed-off-by: Allen Samuels <[email protected]>
@yairgott
Copy link
Collaborator

I might had missed it, but I haven't seen that the queued multi/exec are being serialized as well.

@allenss-amazon
Copy link
Member Author

I might had missed it, but I haven't seen that the queued multi/exec are being serialized as well.

Good catch.

for (size_t i = 0; i < key_count; ++i) {
VMSDK_ASSIGN_OR_RETURN(auto keyname_str, input.LoadString());
auto keyname = vmsdk::MakeUniqueValkeyString(keyname_str);
ProcessKeyspaceNotification(ctx, keyname.get(), false);
Copy link
Collaborator

@yairgott yairgott Nov 4, 2025

Choose a reason for hiding this comment

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

Here and other calls to ProcessKeyspaceNotification, It's important to preserve the `is backfill original entry value (third parameter) to avoid situations that the backfill mutations causing huge delay for client driven mutations.

Signed-off-by: Allen Samuels <[email protected]>
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.

Avoid Backfill After RDB is Loaded

3 participants