Shreemanarjun / Shreemanarjun/datum

[Bug] Sync Engine incorrectly updates local data when `vectorClock` is null (missing fallback + concurrent handling)

Open
#35 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
27
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Description

During the pull phase, the sync engine may incorrectly update local records using remote data even when no actual changes occurred.
This happens when vectorClock is null, which is currently a valid state according to DatumEntityInterface.

Problem

In _processRemoteBatch, the update decision relies only on vectorClock:
https://github.com/Shreemanarjun/datum/blob/fcb19a3bfea9b4da8f6e480fb64b11fd9d1d387e/packages/datum/lib/source/core/engine/datum_sync_engine.dart#L568-L586

Issues:
  1. No fallback when vectorClock is null
  • If either localVC or remoteVC is null, the check is skipped
  • shouldUpdate remains true
  • => Local is always overwritten by remote
  1. Concurrent case is not handled
  • When both clocks exist but are concurrent:
localVC.isConcurrent(remoteVC) == true
  • No conflict is triggered
  • Should use conflictResolver, but currently skipped
  1. Leads to unnecessary updates
  • Causes repeated update() calls
  • Triggers unnecessary local change events
  • Can create sync noise / loops

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/datum/lib/source/core/engine/datum_sync_engine.dart at _processRemoteBatch and inspect the update decision around lines 568–586, including DatumEntityInterface's nullable vectorClock behavior. Trace how conflictResolver is reached for concurrent clocks; done means null clocks no longer cause unconditional updates and concurrent clocks trigger conflict handling without unnecessary local change events.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.