Expand description
Implementation of the hot key-value storage using MDBX as the underlying database.
§Notes on implementation
This module provides an implementation of the HotKv trait using MDBX as
the underlying database. It includes functionality for opening and
managing the MDBX environment, handling read-only and read-write
transactions, and managing database tables.
The DatabaseEnv struct encapsulates the MDBX environment and provides
methods for starting transactions. The DatabaseArguments struct
allows for configuring various parameters of the database environment,
such as geometry, sync mode, and maximum readers.
§Table Metadata
This implementation uses the default MDBX table to store metadata about each table, including whether it uses dual keys or fixed-size values. This metadata is cached in memory for efficient access during the lifetime of the environment. Each time a table is opened, its metadata is checked against the cached values to ensure consistency.
Rough Edges:
- The cache does not respect dropped transactions. Creating multiple tables with the same name but different metadata in different transactions may lead to inconsistencies.
- Tables created outside of this implementation (e.g., via external tools) will not have their metadata cached, which may lead to inconsistencies if the same table is later opened with different metadata.
Overall, we do NOT recommend using this to open existing databases that were not created and managed by this implementation.
§Feature Flags
test-utils: Enables thetest_utilsmodule with MDBX test helpers and conformance tests. Adds atempfiledependency.disable-lock: Disables the storage lock file, allowing multiple processes to open the same database. Intended for testing scenarios.
Modules§
- test_
utils test-utils - Utilities for testing MDBX storage implementation.
Structs§
- Cursor
- Cursor wrapper to access KV items.
- Database
Arguments - Arguments for database initialization.
- Database
Env - MDBX database environment. Wraps the low-level Environment, and
implements the
HotKvtrait. - Storage
Lock - A file lock for a storage directory to ensure exclusive read-write access across different processes.
- Tx
- Wrapper around
signet_libmdbx::tx::Tx, with an additional cache to storeFixedSizeInfofor tables.
Enums§
- Database
EnvKind - Environment used when opening a MDBX environment. Read-only or Read-write.
- Fixed
Size Info - Information about fixed size values in a database.
- Mdbx
Error - Error type for
signet_libmdbxbased hot storage. - Storage
Lock Error - Storage lock error.
Constants§
Type Aliases§
- Cursor
Ro - Read only Cursor.
- Cursor
RoSync - Synchronized read only cursor.
- Cursor
Rw - Read write cursor.
- Cursor
RwSync - Synchronized read write cursor.