diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoLockException.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoLockException.java new file mode 100644 index 000000000..d6a5d3c89 --- /dev/null +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/AlfrescoLockException.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2005-2020 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.solr; + +/** + * Marker exception thrown for indicating a failure in obtaining / releasing a lock. + */ +public class AlfrescoLockException extends Exception +{ + AlfrescoLockException(String message) + { + super(message); + } +} diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java index 7191588a6..95a596224 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java @@ -1810,6 +1810,10 @@ public class SolrInformationServer implements InformationServer processor.processAdd(addDocCmd); } } + catch (AlfrescoLockException exception) + { + LOGGER.error(exception.getMessage()); + } catch (Exception exception) { LOGGER.error("Unable to update the text content of node {}. See the stacktrace below for further details.", dbId, exception); @@ -1888,6 +1892,14 @@ public class SolrInformationServer implements InformationServer solrContentStore.removeDocFromContentStore(nodeMetaData); } + catch (AlfrescoLockException exception) + { + LOGGER.error(exception.getMessage()); + } + catch (Exception exception) + { + LOGGER.error("Unable to remove document {} from the content store. See the stacktrace below for further details.", nodeMetaData.getId(), exception); + } finally { unlock(nodeMetaData.getId()); @@ -1985,6 +1997,14 @@ public class SolrInformationServer implements InformationServer long end = System.nanoTime(); this.trackerStats.addNodeTime(end - start); } + catch (AlfrescoLockException exception) + { + LOGGER.error(exception.getMessage()); + } + catch (Exception exception) + { + LOGGER.error("Upsert failure on Node {}. See the stacktrace below for further details.", nodeId, exception); + } finally { unlock(nodeId); @@ -3164,10 +3184,10 @@ public class SolrInformationServer implements InformationServer } } - private void lock(Object id) throws IOException + private void lock(Object id) throws AlfrescoLockException { long startTime = System.currentTimeMillis(); - while(!lockRegistry.add(id)) + while (!lockRegistry.add(id)) { try { @@ -3178,9 +3198,9 @@ public class SolrInformationServer implements InformationServer // I don't think we are concerned with this exception. } - if(System.currentTimeMillis() - startTime > 120000) + if (System.currentTimeMillis() - startTime > 120000) { - throw new IOException("Unable to acquire lock on nodeId " + id + " after " + 120000 + " msecs."); + throw new AlfrescoLockException("Unable to acquire lock on nodeId " + id + " after " + 120000 + " msecs."); } } } @@ -3442,6 +3462,14 @@ public class SolrInformationServer implements InformationServer LOGGER.debug("No child doc found to update {}", childId); } } + catch (AlfrescoLockException exception) + { + LOGGER.error(exception.getMessage()); + } + catch (Exception exception) + { + LOGGER.error("Cascade update failure on child document {}. See the stacktrace below for further details.", childId, exception); + } finally { unlock(nodeId);