Fix entity reload: clear cache before re-applying replay events#409
Open
PZahnen wants to merge 1 commit into
Open
Fix entity reload: clear cache before re-applying replay events#409PZahnen wants to merge 1 commit into
PZahnen wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Triggering
xtractl entity reloadleft stale entity data in the cache. Two visible symptoms:apiCatalogAdditionalEntriesappearedmultiple times on the API catalog landing page.
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) beforethe replay event. Two bugs prevented the cache from being cleared:
processEventdiscarded events with "empty" payloads — butYAML_NULLcounts as empty, so delete events were silently dropped and
cache.remove(...)never ran.EntityDataStoreImpl.processEvent, which was missing areturn List.of();. Despite the "Ignoring..." log message, the event wasmerged 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
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
apiCatalogAdditionalEntrieslisted multiple times. After: clean reload, no warnings, each entry listed once.