From 91b06824c8ec922818e6aa5f651966df8a83f63c Mon Sep 17 00:00:00 2001 From: Antoine Bouhours Date: Wed, 18 Dec 2024 11:27:56 +0100 Subject: [PATCH] Fix all shards have failed on filter deletion (#578) Signed-off-by: BOUHOURS Antoine --- .../server/elasticsearch/EquipmentInfosService.java | 8 +++++--- .../server/modifications/NetworkStoreListener.java | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/server/elasticsearch/EquipmentInfosService.java b/src/main/java/org/gridsuite/modification/server/elasticsearch/EquipmentInfosService.java index 5b2efeb38..9e11a5b4d 100644 --- a/src/main/java/org/gridsuite/modification/server/elasticsearch/EquipmentInfosService.java +++ b/src/main/java/org/gridsuite/modification/server/elasticsearch/EquipmentInfosService.java @@ -59,7 +59,9 @@ public void addAllTombstonedEquipmentInfos(@NonNull final List equipmentIds, @NonNull UUID networkUuid, @NonNull String variantId) { - equipmentInfosRepository.deleteByIdInAndNetworkUuidAndVariantId(equipmentIds, networkUuid, variantId); + Lists.partition(equipmentIds, partitionSize) + .parallelStream() + .forEach(ids -> equipmentInfosRepository.deleteByIdInAndNetworkUuidAndVariantId(ids, networkUuid, variantId)); } public void deleteVariants(@NonNull UUID networkUuid, List variantIds) { @@ -88,8 +90,8 @@ public void cloneVariantModifications(@NonNull UUID networkUuid, @NonNull String ); } - public List findEquipmentInfosList(List equipmentIds, UUID networkUuid, String variantId) { - return equipmentInfosRepository.findByIdInAndNetworkUuidAndVariantId(equipmentIds, networkUuid, variantId); + public List findEquipmentInfosList(UUID networkUuid, String variantId) { + return equipmentInfosRepository.findAllByNetworkUuidAndVariantId(networkUuid, variantId); } public void deleteAll() { diff --git a/src/main/java/org/gridsuite/modification/server/modifications/NetworkStoreListener.java b/src/main/java/org/gridsuite/modification/server/modifications/NetworkStoreListener.java index 40a2b08d2..14cdd5ec2 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/NetworkStoreListener.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/NetworkStoreListener.java @@ -245,8 +245,7 @@ private static EquipmentInfos toEquipmentInfos(Identifiable identifiable, UUI private void flushEquipmentInfos() { String variantId = network.getVariantManager().getWorkingVariantId(); - Set presentEquipmentDeletionsIds = equipmentInfosService.findEquipmentInfosList( - deletedEquipments.stream().map(EquipmentInfosToDelete::id).toList(), + Set existingEquipmentIds = equipmentInfosService.findEquipmentInfosList( networkUuid, variantId ).stream().map(EquipmentInfos::getId).collect(Collectors.toSet()); @@ -254,7 +253,7 @@ private void flushEquipmentInfos() { List equipmentDeletionsIds = new ArrayList<>(); List tombstonedEquipmentInfos = new ArrayList<>(); deletedEquipments.forEach(deletedEquipment -> { - if (presentEquipmentDeletionsIds.contains(deletedEquipment.id())) { + if (existingEquipmentIds.contains(deletedEquipment.id())) { equipmentDeletionsIds.add(deletedEquipment.id()); } // add only allowed equipments types to be indexed to tombstonedEquipmentInfos