Skip to content

Improvement: Make it possible to initialize KVS when snapshot with ID=0 is not available #237

Description

@arkjedrz

Right now if snapshot with ID=0 is not available then KVS is not able to initialize.
Ideas:

  • Add parameter to builder with snapshot ID - with 0 as default.
  • Make automatic loop that tries to load until succesful and return loaded snapshot ID.
    • This might not be preferred, as this performs implicit and surprising operation underneath.

Activity

  1. added theissue type on Feb 9, 2026
  2. Ahmed-Elsaka-JC commented on Sep 18, 2026

    @Ahmed-Elsaka-JC
    Contributor

    for C++ implementation :

    • if kvs_<instance_id>0.json is not available kvs<instance_id>_0.json will be created on first flush

    Is this issue related to C++ implementaion ?

  3. arkjedrz commented on Sep 22, 2026

    @arkjedrz
    ContributorAuthor

    @Ahmed-Elsaka-JC, to start with an answer - I think C++ is affected, because it's not about ::Optional or ::Required behavior. The description of this ticket is misleading.

    I meant that if snapshot with ID=0 is broken, then KVS is not able to initialize. E.g., hash file got removed, or JSON file is malformed.
    Selectable snapshot ID would allow restoring the state using another snapshot - but this would still need a predictable error behavior.
    I dislike the automatic loop idea, especially since IIRC snapshot IDs won't be ordered latest to oldest anymore (planned for #292, but stale).

    Unit tests for Rust exist, but are marked as #[ignore = "Not handled properly yet"] and probably should get revisited and expanded.

    • Both KvsLoad::Required and KvsLoad::Optional should halt on broken snapshot.
      • Regardless if it's a missing file, a malformed one, or an invalid hash.
      • KvsLoad::Optional should be allowed to proceed only if both files are missing.
    • Error handling could be simplified:
      • Merge KvsFileReadError, KvsHashFileReadError and FileNotFound to FileReadError, change description to "File not found or couldn't be read".
      • Merge IntegrityCorrupted and ValidationFailed to IntegrityCorrupted.
    • I'm not sure what should be the behavior for KvsLoad::Optional with added snapshot ID parameter for init. Try load for given ID?
  4. Ahmed-Elsaka-JC commented on Sep 23, 2026

    @Ahmed-Elsaka-JC
    Contributor

    update :

    From C++ implementation prespective :

    • hash file is missing : -> Failed to open KVS: KVS hash file read error
    • corrupted kvs file format : -> Failed to open KVS: Validation failed

    Fix proposal :

    • provide new parameter called RecoveryPolicy which will be enum as follwoing :
      enum RecoveryPolicy { strict = 0, EmptyFallback = 1, }
    • in case of calling open with stict -> will return the error
    • in case of calling open with EmptyFallback :
      - if hash file is missing or corrupted kvs file , return empty storage .
      - if use still need another storage can call snapshot_restore api to load it.

    Agreed decision :

    • two recovery approaches :
      1- add another option to OpenNeedKvs (Ignore).
      2- allow user to open another snapshot by passing snapshot number to builder.
  5. self-assigned this
    on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions