Skip to content

fix(sync): PushMutations discards cloud seqs — acks local seqs that don't exist on cloud #238

@alexandervazquez98

Description

@alexandervazquez98

Pre-flight Checks

  • Searched existing issues — no duplicate covers this specific seq mapping loss
  • I understand this issue needs status:approved before any PR

Bug Description

When or pushes mutations to the cloud server, the returned cloud seqs (BIGSERIAL from PostgreSQL) are discarded. The local call uses local integer seqs that have no relationship to the cloud seqs.

This means:

  1. Mutations are pushed to cloud successfully
  2. Cloud assigns BIGSERIAL seqs (1, 2, 3...) independently
  3. Local marks mutations 963, 964... as acked
  4. Cloud has NO record of seq 963, 964... — it has seq 1, 2, 3...
  5. On next sync, local sees mutations 963+ as unacked and re-pushes them
  6. Data duplication on every sync cycle

Root Cause

Location: lines 486-492

The system has two independent seq generators:

  • Local: INTEGER PRIMARY KEY AUTOINCREMENT
  • Cloud: BIGSERIAL

There is no mapping between them. After push, the cloud seqs are lost.

Impact

  • Critical: Data duplication — every sync re-pushes all mutations
  • Local reports acked but cloud has different seqs
  • Autosync is unreliable for multi-machine scenarios
  • 52 unacked mutations pile up even when push succeeded

Environment

  • Engram Version: 1.13.1
  • Cloud Server: Self-hosted with PostgreSQL backend
  • Projects affected: Any enrolled project using cloud sync

Proposed Fix

Store the cloud seq mapping after push:

Or alternatively, modify to accept cloud seqs and maintain the mapping internally.

Tags

  • cloud-sync
  • bug
  • sync-failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions