[ SEARCH-2187 ] acquire lock max wait time, configuration property

This commit is contained in:
agazzarini
2020-04-15 14:26:48 +02:00
parent 9e302ddda2
commit cb50bab357
3 changed files with 8 additions and 54 deletions

View File

@@ -296,6 +296,8 @@ public class SolrInformationServer implements InformationServer
private String skippingDocsQueryString; private String skippingDocsQueryString;
private boolean isSkippingDocsInitialized; private boolean isSkippingDocsInitialized;
private long maxAllowedTimeForAcquiringDbIdLock;
protected enum FTSStatus {New, Dirty, Clean} protected enum FTSStatus {New, Dirty, Clean}
static class DocListCollector implements Collector, LeafCollector static class DocListCollector implements Collector, LeafCollector
@@ -461,6 +463,8 @@ public class SolrInformationServer implements InformationServer
holeRetention = Integer.parseInt(p.getProperty("alfresco.hole.retention", "3600000")); holeRetention = Integer.parseInt(p.getProperty("alfresco.hole.retention", "3600000"));
minHash = Boolean.parseBoolean(p.getProperty("alfresco.fingerprint", "true")); minHash = Boolean.parseBoolean(p.getProperty("alfresco.fingerprint", "true"));
maxAllowedTimeForAcquiringDbIdLock = Long.parseLong(p.getProperty("alfresco.tracker.maxNodeLockMs", "120000"));
dataModel = AlfrescoSolrDataModel.getInstance(); dataModel = AlfrescoSolrDataModel.getInstance();
contentStreamLimit = Integer.parseInt(p.getProperty("alfresco.contentStreamLimit", "10000000")); contentStreamLimit = Integer.parseInt(p.getProperty("alfresco.contentStreamLimit", "10000000"));
@@ -3182,9 +3186,9 @@ public class SolrInformationServer implements InformationServer
// I don't think we are concerned with this exception. // I don't think we are concerned with this exception.
} }
if (System.currentTimeMillis() - startTime > 120000) if (System.currentTimeMillis() - startTime > maxAllowedTimeForAcquiringDbIdLock)
{ {
throw new AlfrescoLockException("Unable to acquire lock on nodeId " + id + " after " + 120000 + " msecs."); throw new AlfrescoLockException("Unable to acquire lock on nodeId " + id + " after " + maxAllowedTimeForAcquiringDbIdLock + " msecs.");
} }
} }
} }

View File

@@ -30,6 +30,8 @@ alfresco.hole.check.after=300000
alfresco.batch.count=5000 alfresco.batch.count=5000
alfresco.recordUnindexedNodes=false alfresco.recordUnindexedNodes=false
# max time (in msecs) a given tracker instance will try to acquire a lock on a given DBID
alfresco.tracker.maxNodeLockMs=120000
# encryption # encryption
# none, https # none, https

View File

@@ -1587,58 +1587,6 @@ public class SOLRAPIClient
public void close() public void close()
{ {
repositoryHttpClient.close(); repositoryHttpClient.close();
executor.shutdown();
}
final ExecutorService executor = Executors.newSingleThreadExecutor();
private JSONObject callRepositoryWithTimeout(String msgId, Request req) throws IOException, AuthenticationException, InterruptedException, TimeoutException, ExecutionException {
List<Future<JSONObject>> result = executor.invokeAll(singletonList(() -> {
Response response = null;
LookAheadBufferedReader reader = null;
JSONObject json;
try
{
response = repositoryHttpClient.sendRequest(req);
if (response.getStatus() != HttpStatus.SC_OK)
{
throw new AlfrescoRuntimeException(msgId + " return status:" + response.getStatus());
}
reader = new LookAheadBufferedReader(new InputStreamReader(response.getContentAsStream(), StandardCharsets.UTF_8), LOGGER);
json = new JSONObject(new JSONTokener(reader));
if (LOGGER.isDebugEnabled())
{
LOGGER.debug(json.toString(3));
}
return json;
}
catch (JSONException exception)
{
String message = "Received a malformed JSON payload. Request was \"" +
req.getFullUri() +
"Data: "
+ ofNullable(reader)
.map(LookAheadBufferedReader::lookAheadAndGetBufferedContent)
.orElse("Not available");
LOGGER.error(message);
throw exception;
}
finally
{
ofNullable(response).ifPresent(Response::release);
ofNullable(reader).ifPresent(this::silentlyClose);
}
}), 5, TimeUnit.SECONDS);
Future<JSONObject> response = result.iterator().next();
if(response.isCancelled())
{
throw new TimeoutException("Request " + req + "has timed out. It has taken more than 5 seconds to respond");
}
return response.get();
} }
private JSONObject callRepository(String msgId, Request req) throws IOException, AuthenticationException private JSONObject callRepository(String msgId, Request req) throws IOException, AuthenticationException