Skip to content

Fix entity reload: clear cache before re-applying replay events#409

Open
PZahnen wants to merge 1 commit into
masterfrom
bugfix-xtractl-entity-reload
Open

Fix entity reload: clear cache before re-applying replay events#409
PZahnen wants to merge 1 commit into
masterfrom
bugfix-xtractl-entity-reload

Conversation

@PZahnen

@PZahnen PZahnen commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Triggering xtractl entity reload left stale entity data in the cache. Two visible symptoms:

  1. External entries configured via apiCatalogAdditionalEntries appeared
    multiple times on the API catalog landing page.
  2. For some entities the reload also produced a warning followed by a
    Multiple entries with same key: ... exception, e.g.:
    Ignoring 'aaa-suite/alkis-vereinf/services/alkis-vereinf.yml' from FS[.] because it already exists. An entity can only exist in a single source, use overrides to update it from another source.

A web API restart cleared both.

Root Cause

The reload flow emits a synthetic delete event (payload = YAML_NULL) before
the replay event. Two bugs prevented the cache from being cleared:

  1. processEvent discarded events with "empty" payloads — but YAML_NULL
    counts as empty, so delete events were silently dropped and
    cache.remove(...) never ran.
  2. The follow-up replay event then hit the "single source" warning in
    EntityDataStoreImpl.processEvent, which was missing a
    return List.of();. Despite the "Ignoring..." log message, the event was
    merged into the still-cached value via Jackson's readerForUpdating,
    which appends to lists/maps — causing both the duplicated catalog entries
    and the duplicate-key exception.

Fix

  • Let delete events bypass the empty-payload filter so they reach the cache.
  • Add the missing early return after the "single source" warning.

Verification

Reproduced locally via the ldproxy composite/ build:
curl -X POST "http://localhost:7081/api/tasks/reload-entities?types=services&ids=*"
— before: warning + duplicate-key exception, external apiCatalogAdditionalEntries
listed multiple times. After: clean reload, no warnings, each entry listed once.

@PZahnen PZahnen requested a review from azahnen June 10, 2026 16:17
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.

1 participant