Skip to content

fix: remove double-increment of local node in VLC receive - #47

Open
korowant wants to merge 1 commit into
hetu-project:mainfrom
korowant:fix/vlc-double-increment
Open

korowant wants to merge 1 commit into
hetu-project:mainfrom
korowant:fix/vlc-double-increment

Conversation

@korowant

@korowant korowant commented Sep 7, 2026

Copy link
Copy Markdown

Summary

Fixes #22

Problem

The VLCSnapshot::receive() method incremented the local node's vector clock entry twice:

  1. merge() takes the component-wise max of both clocks (correct)
  2. vector_clock.increment(local_node_id) adds +1 on top of the merged value (incorrect)

This inflated the local node's clock on every receive operation, breaking causal ordering. A node that received many events would have artificially high vector clock values, causing incorrect concurrency detection.

Standard HLC receive algorithm:

  1. Merge vector clocks (component-wise max)
  2. Update logical_time = max(local, received) + 1
  3. Do NOT increment local node's vector clock entry separately

Fix

Removed the extra self.vector_clock.increment(local_node_id) call from receive(). The local node's clock is already correct after merge — it only needs incrementing during local tick() operations.

The receive() method was incrementing the local node's vector
clock entry twice: once during merge() (which takes the max of
both clocks) and again with an explicit increment(). This inflated
the local node's clock value on every receive, breaking causal
ordering guarantees.

The standard HLC receive algorithm only merges clocks and updates
logical_time — the local node's entry should not be incremented
separately during receive.

Fixes hetu-project#22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VLC double-increment on event receive inflates vector clock

2 participants