Skip to content

fix(store): trackedBytes leaks left after #198 (hash-migration double credit, uncharged path_json fallback) #202

Closed

Description

@dborup

Summary

Two pre-existing accounting leaks in the in-memory store. They are documented as "Known leftovers" in #198 (merged as 81039e35), which made trackedBytes charge exactly and evict what it charged. Both were found in the independent review of #198. They are low priority, and the clamp at 0 currently hides them.

Relates to #113, #164, #198.

1. hash_migrate.go: observations are subtracted twice when duplicates are merged

When the async hash migration merges a duplicate transmission into a survivor (cmd/server/hash_migrate.go around line 114), it appends the duplicate's observations to the survivor without removing them from the duplicate, and the duplicate stays in s.packets. Both transmissions are evicted later, so those observations are subtracted twice. The result is downward drift of trackedBytes.

Fix direction: either remove the duplicate from s.packets (and from its indexes) as part of the merge, or move its observations instead of copying them, so each charge is credited once.

2. The path_json fallback is not charged

In indexObservationRelayHops, an observation without a persisted resolved_path falls back to resolving path_json, and those relays go into byNode only (addToByNode). That path is not charged to trackedBytes. The amount is small, but it is uncounted.

Acceptance criteria

  • Hash migration: a test merges two duplicate transmissions, evicts both, and asserts that trackedBytes returns exactly to its starting value, with no drift and no reliance on the clamp.
  • Fallback: a test asserts that the fallback's byNode entries are charged, and credited on eviction.
  • No new O(n) work in hot paths.

Activity

  1. added a commit that references this issue on Oct 4, 2026
  2. dborup commented on Oct 4, 2026

    @dborup
    OwnerAuthor

    Fixed by #209 (merged as 0f88865b).

    • The path_json fallback is now charged and credited per (relay, transmission), with cleanup on eviction on all five entry paths.
    • The hash-migration double credit could not be reached on master. The dead merge branch is removed, and a guard test now pins the accounting.

    Leftovers are tracked in a separate issue:

    • server-side hash-migration writes on the read-only handle, and ghost duplicates;
    • stale nodeHashes keys after migration;
    • the fallback cost constant has no ungated test (mutant perFallbackRelayBytes = 0 survives).
  3. dborup commented on Oct 4, 2026

    @dborup
    OwnerAuthor

    Leftovers tracked in #215.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions