Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public void insertRelation(
boolean override)
throws IOException {
cache.invalidate(srcIdentifier, srcType, relType);
cache.invalidate(dstIdentifier, dstType, relType);
backend.insertRelation(relType, srcIdentifier, srcType, dstIdentifier, dstType, override);
}

Expand All @@ -264,7 +265,21 @@ public <E extends Entity & HasIdentifier> List<E> updateEntityRelations(
NameIdentifier[] destEntitiesToAdd,
NameIdentifier[] destEntitiesToRemove)
throws IOException, NoSuchEntityException, EntityAlreadyExistsException {

// We need to clear the cache of the source entity and all destination entities being added or
// removed. This ensures that any subsequent reads will fetch the updated relations from the
// backend. For example, if we are adding a tag to table, we need to invalidate the cache for
// that table and the tag being added or removed. Otherwise, we might return stale data if we
// list all tags for that table or all tables for that tag.
cache.invalidate(srcEntityIdent, srcEntityType, relType);
for (NameIdentifier destToAdd : destEntitiesToAdd) {
cache.invalidate(destToAdd, srcEntityType, relType);
}

for (NameIdentifier destToRemove : destEntitiesToRemove) {
cache.invalidate(destToRemove, srcEntityType, relType);
}

return backend.updateEntityRelations(
relType, srcEntityIdent, srcEntityType, destEntitiesToAdd, destEntitiesToRemove);
}
Expand Down
Loading