Skip to content

dNHyDB 0.3.0

Latest

Choose a tag to compare

@github-actions github-actions released this 14 Nov 14:03

Compatibility

These changes can require changes in existing code:

  • Python 3.12–3.15. Support for Python 3.9, 3.10 and 3.11 ends
    (previously 3.9–3.14); the tomli dependency is gone.
  • None in a BASE field raises ValueError for every type (R9E-01).
    Previously utf8 silently stored the text "None" and bool stored
    False. Store a null with put_cell(u, v, None), remove a value with
    delete_cell.
  • delete_cell deletes only a live cell (a stored None included). For
    an already deleted or never written cell it returns False and writes
    nothing (R9A-04). Previously a deleted BASE field returned True again,
    and every call on a deleted cell wrote another tombstone.
  • Iterators after rollback(): open records, cells and scan
    iterators end with DnhydbError ("iterator invalidated") instead of
    returning buffered values of the discarded state (I7).
  • repair_file() no longer cuts intact committed blocks or keeps
    uncommitted blocks silently; such a repair raises CorruptionError unless
    allow_data_loss=True or keep_uncommitted=True is given (details under
    Changed).
  • Rust: Db::has_record returns Result<bool>; new error variants
    Error::Memory and Error::IoPath.

Changed

  • macOS, durability fsync: the data of a commit is now synchronized with
    F_BARRIERFSYNC (an fsync plus an I/O barrier) before the superblock is
    written, so the drive persists the data before the superblock. This
    guarantees the write order, not the persistence of the latest commits
    (the drive cache is not flushed; only full requests that). Where the
    file system does not support the barrier, dNHyDB falls back to plain
    fsync without this ordering guarantee. Single commits get slower: on an
    Apple M1 Max a commit with data takes about 1 ms instead of roughly
    0.06 ms; batch commits are barely affected. Commit less often if
    throughput matters. full, none, Linux and Windows are unchanged.
  • repair_file() (and dnhydb repair) no longer discards intact committed
    blocks or keeps uncommitted blocks silently. New options
    allow_data_loss=False and keep_uncommitted=False (CLI
    --allow-data-loss, --keep-uncommitted; Rust RepairOptions with
    Db::repair_file_opts). Without them, a repair that would lose data
    raises CorruptionError and changes nothing. The dry run reports the
    planned action; the report has new keys (superblocks,
    superblock_problem, uncommitted_bytes, missing_committed_bytes,
    damaged_blocks, later_valid_blocks, safe_end, cut_reason,
    lost_blocks, discarded_uncommitted_blocks, kept_uncommitted_blocks).
  • inspect_tail() also checks both superblocks; clean is false if a
    superblock is damaged or the commit boundary is beyond the end of the
    file or not on a block boundary.
  • verify() reports every damaged block; a stale VALUE index is reported
    under the new keys warnings/warning_count and no longer makes ok
    false (health() then reports warning instead of unhealthy).
  • A commit without new blocks writes nothing; opening, reading and closing
    leaves the file unchanged.
  • After a failed data or superblock sync during a commit, the handle is
    unusable: write methods, commit, rollback, flush, begin and
    checkpoint raise DnhydbError; close() releases handle and lock.
  • Paths are anchored as absolute paths when opening (path,
    stats()["file"] and compact()["file"] are absolute).
  • A directory as database path raises IsADirectoryError (also for
    create without overwrite); OS errors carry errno, strerror and
    filename and use the matching OSError subclass.
  • Command line: defined exit codes (0 ok, 1 problems found, 2 error without
    traceback); tail and repair without --apply exit with 1 on a file
    that is not clean; verify reports the tail inspection if a damaged file
    cannot be opened.
  • VALUE index: NaN never matches (equality or range), as in a scan.
  • A buffered (uncommitted) cell reads with the same normalised value as
    after the commit.
  • read_numpy(..., masks=True) adds "_cells": per field a bool array that
    is True where the cell lives (R9E-02). Without masks the output is
    unchanged.
  • compact(output=...) locks the target for the whole run and never
    replaces a file that appeared in the meantime (RD4-08).

Fixed

  • Data blocks found by the scan (without or beyond the catalog) and
    SECONDARY index blocks are CRC-checked before first use; damaged block
    prefixes no longer lead to silently wrong or missing values but to
    CorruptionError.
  • Opening as writer no longer truncates complete blocks behind the commit
    boundary when the other superblock is damaged; it fails with
    CorruptionError (readers read the older state).
  • create(overwrite=True) replaces the old file atomically; on failure the
    old database stays intact.
  • close() after own commits also writes the second superblock slot.
  • Repair writes new superblocks with rising generations before cutting the
    file, takes the write lock before inspecting it, and creates unique,
    synchronized backups (never overwritten within the same second); files
    that are too short or not a database are rejected unchanged.
  • Failed batch writes (put_cells, put_records, NumPy batches) leave no
    blocks behind.
  • Windows: replacing a file that is briefly in use is retried.
  • The lock file is never opened through a symbolic link; a directory or an
    empty path is rejected before the lock file is created, and a lock file
    created by a failed create is removed.
  • After close(), every method and iterator raises DnhydbError
    (including has_record, schema, verify, health, setters);
    with on a closed database raises DnhydbError, and a failed commit on
    leaving a with block still releases handle and lock.
  • Huge count values in read_numpy and allocation failures (bytes(n),
    index build) raise MemoryError instead of aborting the process.
  • Deeply nested or cyclic values raise ValueError, deeply nested
    metadata JSON raises CorruptionError (no stack overflow); values and
    groups of cells larger than 4 GiB are rejected with ValueError;
    decompression of posting lists is bounded.
  • NumPy columns of unsupported types (float16, longdouble) raise
    TypeError instead of recursing.
  • Missing required keys in the schema JSON raise CorruptionError instead
    of KeyError.
  • A side with only free cells is no longer reported as stale after
    build_indexes().
  • A block at a foreign position (copied or swapped, CRC valid) no longer
    returns old values: block ids must grow with the file position, and
    blocks known from the catalog are checked against their header; open,
    reads and verify() report CorruptionError (RD-01, RD-05).
  • Two blocks with the same id no longer crash verify(), compaction or
    point listings; they raise CorruptionError.
  • get_cell returns a value written with put_cell for a BASE field that
    the record's stored shape did not have yet (it returned None).
  • Concurrent use of one handle from several threads raises RuntimeError
    instead of PanicException in every method and iterator (R9D-01).
  • A failed define_base leaves no metadata blocks that a later commit would
    make durable.
  • A failed compaction no longer leaves <db>.compacting behind; a leftover
    is replaced under the lock (RD4-03).
  • A failed commit inside checkpoint() no longer leaves a checkpoint offset
    that points at a discarded block.