Allow 2GB values - #1
Closed
qdequele wants to merge 39 commits into
Closed
Conversation
…arge value storage in ZeroDB
…e_txn` and `read_txn` methods for improved clarity and consistency.
…nces, consolidating tests, and enhancing clarity in performance analysis. Introduce new tests for delete operations and overflow handling while improving existing test structures.
…e key handling in cursor operations, enhance iterator usage, and streamline database interactions. Remove redundant code and improve error handling in test cases.
…n limits, and improve random write performance - Enable checksums by default (ChecksumMode::Full) for data integrity - Make transaction page limit configurable via max_txn_pages() (default 10k) - Improve random write performance from ~99 to 345 entries per transaction (3.5x) - Organize development files into temp/claude-work/ directory - Update CLAUDE.md with workflow and organization guidelines - Create TODO_MASTER.md to track all pending work - Add tests for random write improvements All critical safety fixes from Phase 1 are now complete. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced 72 unwrap() calls with proper error propagation - Added helper functions for safe RwLock access (read_lock, write_lock) - Added get_mut_page() helper for HashMap access with proper errors - All RwLock poisoning now handled gracefully with context - Test unwrap() calls left unchanged as they're acceptable in tests 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced 3 unwrap() calls in non-test code with ok_or_else() - Added proper error messages for borrowed_child unwraps - All btree operations now properly propagate errors - Test unwrap() calls left unchanged as they're acceptable in tests 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Added RwLock instead of Mutex for mmap to allow concurrent reads - Added generation counter to detect mmap changes - Added comprehensive bounds validation for all unsafe blocks in page.rs - Fixed integer underflow vulnerabilities in node offset calculations - Added overflow protection in arithmetic operations - Implemented safe PageGuard wrapper to prevent use-after-free - Added explicit page ID validation before dereferencing - Added memory barriers in grow() operation for proper synchronization - Fixed potential race conditions in get_page_ref() - Added proper validation for MetaPage casts in env.rs This addresses all critical memory safety issues identified in the TODO_MASTER.md 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Add bounds checking in get_page(), get_page_cow(), and get_page_mut() - Validate page IDs before any page access operations - Add special handling for meta pages (0 and 1) validation - Prevent freeing of meta pages with explicit checks - Add validation for free_page() and free_pages() operations - Add maximum page ID limit (2^48) to prevent unreasonable allocations - Improve prefetch_pages() validation in io.rs - Add comprehensive test suite for page ID validation This prevents potential out-of-bounds memory access and improves database integrity by catching invalid page references early. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Add max_database_size configuration option to EnvBuilder - Implement check_database_size_limit() in EnvInner - Add database size checks in all page allocation paths: - alloc_page() for regular page allocation - get_page_cow() for Copy-on-Write page allocation - alloc_page_internal() for internal allocations - Free database root page allocation during commit - Add comprehensive tests for database size limit enforcement - Add example demonstrating database size limit usage The database size limit is optional (None by default) and when set, prevents the database from growing beyond the specified size in bytes. This is useful for preventing runaway growth in production environments. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
…shes - Add key/value size validation in Database::put() methods - Add page ID bounds checking in all page access operations - Add database size limit enforcement (configurable via EnvBuilder) - Add integer overflow protection in size calculations throughout btree, page, overflow modules - Fix page capacity calculation bug in has_space_for_entry() - Add new error types: KeyTooLarge, ValueTooLarge, PageOutOfBounds, IntegerOverflow - Update TODO_MASTER.md marking input validation as completed This completes all input validation tasks to ensure data integrity and prevent crashes. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Set file permissions to 0600 on database creation (Unix only) - Add MAX_OVERFLOW_PAGES limit (1000) to prevent resource exhaustion - Add MAX_TREE_DEPTH limit (100) to prevent stack overflow attacks - Implement depth tracking in recursive B+Tree operations - Update TODO_MASTER.md to reflect completed security tasks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add page header validation (validate_header method) - Implement B+tree invariant checking (validate_btree_invariants) - Add partial write detection for pages - Integrate validation into page read operations - Fix overflow page creation to set proper overflow count - Validate pages automatically when reading from disk
- Remove artificial MAX_OVERFLOW_PAGES limit (was 1000, now usize::MAX) - Implement consecutive page allocation for overflow values - Remove OverflowHeader, store raw data directly like LMDB - Add streaming read/write API for values up to 10GB+ - Update inline threshold from PAGE_SIZE/4 to PAGE_SIZE/2 for better utilization - Store actual value size in node header for accurate reading - Add OverflowReader and OverflowWriter for streaming large values - Update btree and transaction COW to use new overflow functions - Fix tests to use new LMDB-style overflow API This enables ZeroDB to handle values far larger than LMDB's 4GB limit while maintaining compatibility for smaller values.
- Add raw_value_data() method to Node for getting node data transparently - Update all page split/merge operations to handle overflow values correctly - Fix btree operations that were calling node.value() directly - Ensure overflow page references (8 bytes) are copied, not actual values - Successfully handles values up to 10GB+ as demonstrated in benchmarks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
numamodule and remove stray doc commentTesting
cargo build --releasecargo clippy --all-targets --all-features -- -D warnings(fails to finish in reasonable time)cargo test --release(fails to finish building full suite in this environment)cargo bench(not executed due to long build time)https://chatgpt.com/codex/tasks/task_b_687b4e9f63c8832696b947d44478ac1e