From c1813642cf6973b4e421d97bf1aab1aa13826a56 Mon Sep 17 00:00:00 2001 From: pgwilliams Date: Mon, 1 Jul 2024 14:40:39 +0100 Subject: [PATCH] MAINT-2602 Improve logging and exception reporting during upgrade process --- .../services/CodeSystemUpgradeService.java | 19 ++++++++++++------- .../services/UpgradeInactivationService.java | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java b/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java index cd5cc974d..c1d2bf6a3 100644 --- a/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java +++ b/src/main/java/org/snomed/snowstorm/core/data/services/CodeSystemUpgradeService.java @@ -176,32 +176,35 @@ public synchronized void upgrade(String id, CodeSystem codeSystem, Integer newDe logger.info("Rolling back any daily build content before upgrade."); dailyBuildService.rollbackDailyBuildContent(codeSystem); } + boolean upgradedSuccessfully = false; try { Branch newParentVersionBranch = branchService.findLatest(newParentVersion.getBranchPath()); Date newParentBaseTimepoint = newParentVersionBranch.getBase(); logger.info("Running upgrade of {} to {} version {}.", codeSystem, parentCodeSystem, newDependantVersion); branchMergeService.rebaseToSpecificTimepointAndRemoveDuplicateContent(parentPath, newParentBaseTimepoint, branchPath, String.format("Upgrading extension to %s@%s.", parentPath, newParentVersion.getVersion())); - logger.info("Completed upgrade of {} to {} version {}.", codeSystem, parentCodeSystem, newDependantVersion); + logger.info("Completed rebase of {} to {} version {}.", codeSystem, parentCodeSystem, newDependantVersion); if (contentAutomations) { - logger.info("Running upgrade content automations."); + logger.info("Running upgrade content automations on {}.", branchPath); upgradeInactivationService.findAndUpdateDescriptionsInactivation(codeSystem); upgradeInactivationService.findAndUpdateLanguageRefsets(codeSystem); upgradeInactivationService.findAndUpdateAdditionalAxioms(codeSystem); - logger.info("Completed upgrade content automations."); + logger.info("Completed upgrade content automations on {}.", branchPath); } - logger.info("Running integrity check on {}", branchPath); + logger.info("Running post upgrade integrity check on {}", branchPath); Branch extensionBranch = branchService.findLatest(branchPath); IntegrityIssueReport integrityReport = integrityService.findChangedComponentsWithBadIntegrityNotFixed(extensionBranch); - logger.info("Completed integrity check on {}", branchPath); + logger.info("Completed post upgrade integrity check on {}", branchPath); + logger.info("Running post upgrade metadata update on {}", branchPath); updateBranchMetaData(branchPath, newParentVersion, extensionBranch, integrityReport.isEmpty()); - logger.info("Upgrade completed on {}", branchPath); if (job != null) { job.setStatus(CodeSystemUpgradeJob.UpgradeStatus.COMPLETED); } - } catch (ServiceException e) { + upgradedSuccessfully = true; + } catch (Exception e) { + logger.error("Upgrade on {} failed", branchPath, e); if (job != null) { job.setStatus(CodeSystemUpgradeJob.UpgradeStatus.FAILED); job.setErrorMessage(e.getMessage()); @@ -214,6 +217,8 @@ public synchronized void upgrade(String id, CodeSystem codeSystem, Integer newDe codeSystem.setDailyBuildAvailable(true); codeSystemRepository.save(codeSystem); } + + logger.info("Upgrade {} on {}", upgradedSuccessfully?"completed":"unsuccessful", branchPath); } } diff --git a/src/main/java/org/snomed/snowstorm/core/data/services/UpgradeInactivationService.java b/src/main/java/org/snomed/snowstorm/core/data/services/UpgradeInactivationService.java index 03dc7cc5e..d1710cc00 100644 --- a/src/main/java/org/snomed/snowstorm/core/data/services/UpgradeInactivationService.java +++ b/src/main/java/org/snomed/snowstorm/core/data/services/UpgradeInactivationService.java @@ -131,6 +131,7 @@ public void findAndUpdateDescriptionsInactivation(CodeSystem codeSystem) { logger.info("{} descriptions found with inactive concepts but without concept non-current indicators", membersToSave.size()); if (!membersToSave.isEmpty()) { + //TODO What exception does this throw if we are unable to lock the branch? try (Commit commit = branchService.openCommit(branchPath, branchMetadataHelper.getBranchLockMetadata("Concept non-current description inactivation"))) { conceptUpdateHelper.doSaveBatchComponents(membersToSave, ReferenceSetMember.class, commit); logger.info("Added {} concept non-current indicators for descriptions having inactive concepts. Member uuids: {}",