Skip to content

[Protocol] Add periodic backpointer-repair sweep #44

Description

@thep2p

Summary

Building on the CheckNeighbor repair handler, this issue adds the initiator half of Algorithm 8 (Section 5.2.1, Aspnes & Shah, arXiv:cs/0306043): a periodic per-level sweep that restores the backpointer invariant — if y is x's right neighbor at level l then x is y's left neighbor at level l (and symmetrically). Concurrent lock-free joins (Algorithm 2) can transiently break it, fragmenting a level into disjoint pieces such as A <-> B and C <-> D (four nodes A < B < C < D, no node having failed) that the sweep must heal.

On each scheduler tick, the node walks every level, reads its right and left neighbors, and issues a CheckNeighbor to confirm the counterpart links back to it, re-linking when the outcome shows the backpointer is missing. Repeated rounds heal a fragmented level within a bounded number of sweeps.

Scope

  • src/main/java/skipnode/SkipNode.java — add a repair-sweep routine that, per level, reads the right neighbor (getRightNode) and left neighbor (getLeftNode) and issues a CheckNeighbor through the existing client-side MiddleLayer sender to verify or restore the backpointer, acting on the returned outcome (consistent → no action; re-linked → done; evicted → adopt the reported neighbor). Register the sweep as a periodic task with the scheduler abstraction once the node is inserted, and cancel it on terminate().
  • The client-side CheckNeighbor sender is provided by the messages prerequisite (the counterpart of announceNeighbor / updateLeftNode in src/main/java/middlelayer/MiddleLayer.java); this issue consumes that sender as-is and does not add or modify it. No MiddleLayer change is needed here.
  • Tests (same issue): using src/test/java/unittest/LocalSkipGraph.java, build a graph, manually fragment one level into the A <-> B / C <-> D shape, run the sweep, and assert the backpointer-invariant check (tableConsistencyCheck) holds within a bounded number of rounds. Add a stability test asserting a sweep over an already-consistent graph makes no changes.

Acceptance Criteria

  • The node runs a periodic per-level sweep driven by the scheduler abstraction, registered on insertion and cancelled on terminate().
  • For each level the sweep checks both the right and the left neighbor and restores the backpointer invariant via CheckNeighbor when it is missing.
  • A level fragmented into A <-> B and C <-> D (four nodes A < B < C < D, no failures) is healed so that tableConsistencyCheck passes within a bounded number of sweep rounds.
  • A sweep over an already-consistent graph leaves every lookup table unchanged (idempotent).
  • The sweep issues no work before the node is inserted and stops cleanly on termination, leaving no lingering scheduled task.
  • New tests cover the fragmented-heal and already-consistent cases and pass; no existing tests regress.

Dependencies

Requires, in order:

  • The CheckNeighbor repair handler (the responder half of this repair work) — the sweep issues CheckNeighbor requests and relies on its consistent / re-link / evicted outcomes, and on the handler's receive() dispatch case to answer them.
  • The CheckNeighbor message: the sweep uses the client-side MiddleLayer sender it provides, which must already be in place.
  • The periodic scheduler abstraction that drives recurring per-node tasks and can be cancelled on shutdown; the sweep registers as one such task.
  • The lock-free join, whose concurrent splices are what transiently fragment a level; repair heals that fragmentation.

Part of #33. Depends on: #42, #43

Activity

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