Skip to content

pre-release hardening: fix bugs and remove dead code - #103

Merged
SreeramGarlapati merged 1 commit into
mainfrom
sreeramg.pre-release-hardening
May 21, 2026
Merged

pre-release hardening: fix bugs and remove dead code#103
SreeramGarlapati merged 1 commit into
mainfrom
sreeramg.pre-release-hardening

Conversation

@SreeramGarlapati

Copy link
Copy Markdown
Collaborator

Summary

Fixes from deep 4-agent parallel code review across all crates (engine, iceberg, memtable/WAL/types, parquet/sql/store/python). Each finding was debated for legitimacy before action.

Bugs fixed

  • Python ByteArray corruption: field_value_to_py used from_utf8_lossy for all Bytes columns, silently replacing invalid UTF-8 with U+FFFD. Now returns PyBytes for lossless round-trip.
  • LocalFileStore::get_range: Read entire file into memory then sliced. Now seeks+reads only the requested range.
  • CachedStore TOCTOU race: get() checked exists() then read() — a concurrent LRU eviction between the two caused ENOENT panic. Now attempts read directly, falls back on NotFound.
  • Iceberg read_manifest_payload TOCTOU: pb_path.exists() + read() race window. Now attempts read, falls back to JSON on NotFound.
  • Export path traversal: Also rejects absolute paths (/etc/passwd), not just .. sequences.
  • flush.rs fragile SeqNum: Used u64::MAX >> 8 instead of the SEQNUM_MAX constant.
  • WAL writer double-box: Box::new(self.sink).close() where self.sink is already Box<dyn WalSink> — unnecessary heap allocation.

Dead code removed

  • memtable/arena.rs + bumpalo dependency (zero callers, module was documented as having an unsound API)
  • _meta_touch dead_code stub in translate.rs
  • seen_latest dead variable in compaction iterator
  • object_store_url field in OpenOptions (never wired to anything)
  • Unused imports (SeqNum, ParquetFileMeta)

Review findings acknowledged but deferred (0.1 scope)

  • Sync I/O on async runtime in read_path (architectural; needs full async read_path rewrite)
  • range_scan loads entire DB into memory (known; streaming merge is post-0.1)
  • S3Store has no retry/backoff (needs retry policy design)
  • Parquet writer double-pass for kv_index (performance; correctness-safe)
  • DV uses 32-bit roaring (4B row limit per file; documented)

Test plan

  • cargo test --package merutable — 374 pass
  • cargo clippy --package merutable --tests -- -D warnings — clean
  • cargo fmt -- --check — clean
  • cargo check --package merutable-python — compiles

Fixes from deep 4-agent code review across all crates:

- fix(python): return PyBytes for ByteArray columns instead of lossy
  UTF-8 String — prevents silent binary data corruption on round-trip
- fix(store): LocalFileStore::get_range now seeks+reads instead of
  loading the entire file into memory
- fix(store): CachedStore::get tolerates ENOENT from races with LRU
  eviction instead of panicking
- fix(iceberg): read_manifest_payload eliminates TOCTOU by attempting
  read directly and falling back on NotFound
- fix(iceberg): export path also rejects absolute paths (not just "..")
- fix(flush): use SEQNUM_MAX constant instead of fragile u64::MAX >> 8
- fix(wal): remove unnecessary double-boxing in WalWriter::close
- remove: dead arena module and bumpalo dependency (zero callers)
- remove: dead _meta_touch function in translate.rs
- remove: dead seen_latest variable in compaction iterator
- remove: unused object_store_url field from OpenOptions API
- remove: unused SeqNum and ParquetFileMeta imports
@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @SreeramGarlapati to sign the Salesforce Inc. Contributor License Agreement.

@SreeramGarlapati
SreeramGarlapati merged commit 41101e3 into main May 21, 2026
4 of 5 checks passed
@SreeramGarlapati
SreeramGarlapati deleted the sreeramg.pre-release-hardening branch May 21, 2026 21:16
SreeramGarlapati added a commit that referenced this pull request Jun 16, 2026
## Summary

Fixes from deep 4-agent parallel code review across all crates (engine,
iceberg, memtable/WAL/types, parquet/sql/store/python). Each finding was
debated for legitimacy before action.

## Bugs fixed

- **Python ByteArray corruption**: `field_value_to_py` used
`from_utf8_lossy` for all `Bytes` columns, silently replacing invalid
UTF-8 with U+FFFD. Now returns `PyBytes` for lossless round-trip.
- **LocalFileStore::get_range**: Read entire file into memory then
sliced. Now seeks+reads only the requested range.
- **CachedStore TOCTOU race**: `get()` checked `exists()` then `read()`
— a concurrent LRU eviction between the two caused ENOENT panic. Now
attempts read directly, falls back on NotFound.
- **Iceberg read_manifest_payload TOCTOU**: `pb_path.exists()` +
`read()` race window. Now attempts read, falls back to JSON on NotFound.
- **Export path traversal**: Also rejects absolute paths
(`/etc/passwd`), not just `..` sequences.
- **flush.rs fragile SeqNum**: Used `u64::MAX >> 8` instead of the
`SEQNUM_MAX` constant.
- **WAL writer double-box**: `Box::new(self.sink).close()` where
`self.sink` is already `Box<dyn WalSink>` — unnecessary heap allocation.

## Dead code removed

- `memtable/arena.rs` + `bumpalo` dependency (zero callers, module was
documented as having an unsound API)
- `_meta_touch` dead_code stub in translate.rs
- `seen_latest` dead variable in compaction iterator
- `object_store_url` field in `OpenOptions` (never wired to anything)
- Unused imports (`SeqNum`, `ParquetFileMeta`)

## Review findings acknowledged but deferred (0.1 scope)

- Sync I/O on async runtime in read_path (architectural; needs full
async read_path rewrite)
- `range_scan` loads entire DB into memory (known; streaming merge is
post-0.1)
- S3Store has no retry/backoff (needs retry policy design)
- Parquet writer double-pass for kv_index (performance;
correctness-safe)
- DV uses 32-bit roaring (4B row limit per file; documented)

## Test plan

- [x] `cargo test --package merutable` — 374 pass
- [x] `cargo clippy --package merutable --tests -- -D warnings` — clean
- [x] `cargo fmt -- --check` — clean
- [x] `cargo check --package merutable-python` — compiles

Co-authored-by: Sreeram Garlapati <sreeramg@salesforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant