Skip to content

[storage] Low-severity storage/WAL cleanups (short read/write loops, stats, staleness) #4958

Closed

Description

@lvca

Grouped low-severity findings in the storage/WAL layer:

  • WALFile.readLong/readInt (WALFile.java:442-452) use shared instance bufferLong/bufferInt with no sync and no short-read loop; a partial channel.read yields stale garbage. Loop until full or use per-call stack buffers.
  • WALFile.append (:454-457) issues a single channel.write with no hasRemaining() loop; a partial write leaves a torn record that the WALFile.getTransaction returns null on partial record, recovery abandons rest of WAL #4508 gap detector then flags as corruption. PaginatedComponentFile loops correctly - add a shared writeFully/readFully helper.
  • TransactionManager.getStats (:354-369) adds each active WAL files cumulative counters into the stats accumulators on every call (double-counted at retirement), inflating numbers with polling frequency; also NPEs when activeWALFilePool==null` (read-only DBs).
  • activeWALFilePool array (TransactionManager.java:55,190,769) elements written by the timer thread and read by committers with no volatile/fence; a JMM-stale element can stall a committer up to WRITE_WAL_TIMEOUT. Use AtomicReferenceArray/VarHandle.
  • PageManager.getCachedPage (:567-592) returns before cacheMiss.incrementAndGet(), so cache-miss stats are ~always zero (hit/miss ratio meaningless).
  • WALFile segment (:200-226) deltaSize from the page header is unvalidated vs remaining file size; a corrupt header can trigger a transient ~2GB allocation during recovery. Clamp to getSize()-pos.
  • Preserved corrupt WAL on next open (:331-346,:747-758) createWALFilePool resets logFileCounter to 0 and opens the preserved txlog_0.wal without truncation; append writes after corrupt content and old records replay again. Rename preserved files to .wal.corrupt or seed the counter past existing files.
  • suspendFlushAndExecute (:142-152) silently skips the callback when already suspended (nested backup/snapshot); waitAllPagesOfDatabaseAreFlushed loops forever if invoked while suspended.
  • LocalBucket stats (:1160,2038,2052) changesFromLastStats/timeOfLastStats mutated outside the monitor (lost increments delay stats); gatherPageStatistics computes free space vs getPageSize() instead of getMaxContentSize() (overstates by header, validated before use).

Filed from an internal engine deep-audit (2026-07). Low-severity items grouped per subsystem; each checkbox is independently fixable.

Activity

  1. added
    audit
    storage
    on Jul 4, 2026
  2. added this to the 26.8.1 milestone on Jul 4, 2026
  3. self-assigned this
    on Jul 6, 2026
  4. added theissue type on Jul 6, 2026
  5. added 3 commits that reference this issue on Jul 6, 2026
  6. lvca commented on Jul 7, 2026

    @lvca
    MemberAuthor

    Fixed in #5063 (merged): 7 of 9 checkboxes (WAL read/write loops, delta clamp, .wal.corrupt preservation with REPLACE_EXISTING, pool counter seeding, cache-miss accounting, nested flush-suspend ownership - which also surfaced a real HA snapshot hazard, general follow-up in #5068 - and getStats snapshot reads). The 2 remaining low items are tracked in #5067.

  7. added 3 commits that reference this issue on Jul 7, 2026
  8. added 5 commits that reference this issue on Aug 14, 2026
  9. added a commit that references this issue on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

auditstorage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions