Skip to content

jaclang 0.13.4 serializer hash change causes mass edge loss on existing deployments #5451

@udithishanka

Description

@udithishanka

Bug

jaclang 0.13.4 introduced topology_index_data in the serializer (jac/jaclang/runtimelib/impl/serializer.impl.jac). The _compute_hash function was changed to exclude this field from the hash. This causes all existing anchors in MongoDB to appear dirty (hash mismatch) on every request, triggering full graph rewrites on every walker invocation.

Impact

On jac-builder (production IDE with 76 users, 140 projects):

  • All 79 UserProfile → Project edges were erased within minutes of deploying with jaclang 0.13.4
  • Every walker rewrites every anchor it touches (because hashes don't match)
  • With 36 concurrent requests on IDE page load, 36 simultaneous full-graph rewrites occur
  • Last-writer-wins → edges silently erased
  • New projects also lose their edges immediately after creation

Root Cause

  1. _compute_hash in serializer.impl.jac now excludes topology_index_data from the hash
  2. Existing anchors in MongoDB were hashed WITH the old algorithm (no topology_index_data field existed)
  3. New code computes a different hash for the same data → every anchor looks "modified"
  4. The persistence layer commits every "dirty" anchor back to MongoDB on every request
  5. Concurrent walkers each read the graph, compute work, and write back their (stale) snapshot
  6. Last writer wins → edges from other concurrent walkers are erased

Before vs After

  • jaclang 0.13.3: Only actually-modified anchors get rewritten. Race condition exists but is rare (most walkers are read-only).
  • jaclang 0.13.4: Every anchor gets rewritten on every request due to hash mismatch. Race condition is guaranteed on any page with concurrent requests.

Reproduction

  1. Deploy a jac-scale app with MongoDB persistence on jaclang 0.13.3
  2. Create users and projects (graph edges: Root → UserProfile → Project)
  3. Upgrade to jaclang 0.13.4
  4. Open any page that fires 3+ concurrent walker requests
  5. Observe: edges disappear from MongoDB

Workaround

Reverted to jaclang 0.13.3 (pre-topology_index_data changes). Edges stop disappearing.

Suggested Fix

Either:

  1. Add a migration step that recomputes hashes for all existing anchors on first startup with 0.13.4
  2. Don't change the hash computation in a minor release — treat it as a breaking change
  3. Add per-anchor optimistic locking (version field) so concurrent writes don't silently overwrite each other (fixes the underlying race condition from Graph persistence race condition: concurrent walker commits cause node/edge loss #5446)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions