Shreemanarjun / Shreemanarjun/datum
[Bug] Sync Engine incorrectly updates local data when `vectorClock` is null (missing fallback + concurrent handling)
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:
- 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
- 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
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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