Skip to content

fix: preserve causality for future HLC updates - #295

Merged
popduke merged 1 commit into
apache:mainfrom
efegokdemir:codex/issue-285-hlc-monotonicity
Sep 28, 2026
Merged

popduke merged 1 commit into
apache:mainfrom
efegokdemir:codex/issue-285-hlc-monotonicity

Conversation

@efegokdemir

Copy link
Copy Markdown
Contributor

Summary

Fix the HLC receive-event branch so an observed timestamp that is ahead of the local clock produces a timestamp greater than the observed value.

Changes

  • Compare the merged logical time with the observed logical time when selecting the remote-ahead branch.
  • Add a regression test using a future timestamp with a non-zero causal counter.

Testing

  • git diff --cached --check — passed
  • mvn -pl base-hlc -Dtest=HLCTest -DskipITs -Dcheckstyle.skip -Drat.skip -Dspotless.skip=true test — blocked by the available OpenJDK 27/Lombok compiler incompatibility (NoSuchFieldError); the repository targets Java 17 and no Java 17 runtime is installed

Fixes #285

Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>
@ImDanXie

Copy link
Copy Markdown
Contributor

Verified independently — the fix matches the reference receive rule (Kulkarni et al.), and the added regression test is the exact repro from #285.

Since the PR notes the test could not be run locally (JDK/Lombok mismatch): we ran it against the compiled base-hlc classes (OpenJDK 17, same code) during the investigation behind #285 —

observed=(l=1790183330031,c=5)  ->  update() returned=(l=1790183330031,c=0)   # before: now < observed

and with this one-line change the assertion updated > observed passes (returns c = otherC + 1 = 6).

One note for whoever merges: the existing HLCTest.update() keeps feeding the clock its own get() output (l == l_m), which is why this branch was never covered before — worth keeping the new test pinned to a future l_m (as it is here) rather than a self-observed timestamp.

@popduke
popduke merged commit 1394131 into apache:main Sep 28, 2026
6 of 8 checks passed
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.

[BUG] HLC.update() can return a timestamp smaller than the one just observed

3 participants