Skip to content

[Backport 5.0] OF-3205: fix(pubsub): always update lastPublished when same item is overwritten (XEP-0060 §7.1.2)#3206

Merged
guusdk merged 1 commit into5.0from
backport-3202-to-5.0
Mar 17, 2026
Merged

[Backport 5.0] OF-3205: fix(pubsub): always update lastPublished when same item is overwritten (XEP-0060 §7.1.2)#3206
guusdk merged 1 commit into5.0from
backport-3202-to-5.0

Conversation

@github-actions
Copy link
Copy Markdown

Description

Backport of #3202 to 5.0.

…n (XEP-0060 §7.1.2)

Root cause of PubSubExtIntegrationTest failure:
setLastPublishedItem() only updated the in-memory lastPublished cache
when the new item's creation date was *strictly after* the existing one.
When a publisher re-publishes an item with the same ItemID in rapid
succession (within the same millisecond, common in integration tests),
both items share the same CacheFactory.getClusterTime() value.
The after() check returns false, so lastPublished is NOT updated.
The persistence layer correctly performs an SQL UPDATE, but
getPublishedItem() short-circuits by returning the stale in-memory
lastPublished instead of going to the database, causing the test
assertion ("item equals first, not second") to fail.

Fix: add a third update condition — always update when the incoming
item has the same unique identifier (same node + same ItemID) as the
current lastPublished. Overwrites are always reflected in the cache
regardless of timestamp resolution.

Adds 3 regression tests in LeafNodeTest covering same-ID/same-time
overwrite, same-time different-ID non-overwrite, and newer-time
different-ID update.

Co-authored-by: akrherz <210858+akrherz@users.noreply.github.com>
(cherry picked from commit ddfc525)
@guusdk guusdk closed this Mar 17, 2026
@guusdk guusdk reopened this Mar 17, 2026
@guusdk guusdk merged commit f99a889 into 5.0 Mar 17, 2026
26 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.

2 participants