Skip to content

DeleteRange Causes Compatibility Issues Due to kTypeMaxValid Change #13518

Open
@senzzzi

Description

@senzzzi

The DeleteRange feature has a compatibility issue related to kTypeMaxValid in db/dbformat.h. The comment on kTypeMaxValid states that it is only used for validation (line 75), but in reality, it can actually be used when using delete ranges (as another comment indicates).

The issue arises because IsExtendedValueType checks whether a ValueType is greater than or equal to kTypeMaxValid. However, kTypeMaxValid is defined as the last valid ValueType plus one. This means that whenever a new entry is added to the ValueType enum, kTypeMaxValid shifts, potentially making older versions misinterpret previously valid values.

If an older version encounters a manifest entry with a ValueType that is now above its kTypeMaxValid, it will incorrectly classify it as invalid, leading to manifest corruption errors. This can break compatibility when opening databases created with a newer version.

Expected Behavior
Older versions of RocksDB should be able to read manifests created by newer versions without encountering invalid values.

Actual Behavior
When an older version (e.g., 9.0.0) opens a database created by a newer version (e.g., +9.1.0) which made use of the 'delete range' feature, keys present in the manifest may not be parsed, leading to errors opening the database.

I was able to reproduce this issue, and the error message I encountered was:

Corruption: VersionEdit: new-file4 entry  The file MANIFEST-284456 may be corrupted.

Affected File: db/dbformat.h

Issue Introduced in PR: #12419.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions