I am working on a query that excludes items based on the value of one of its metadata.
The problem is that sometimes I get the result, but sometimes not. Error stack trace shows the following:
com.sdl.odata.client.api.exception.ODataClientRuntimeException: Unable to perform action at com.sdl.odata.client.DefaultODataClient.performAction(DefaultODataClient.java:93) at com.sdl.web.content.client.impl.ContentClient.lambda$performAction$7(ContentClient.java:330) at com.sdl.web.content.client.impl.ClientRequestRetrySupporter$RetryBlock.execute(ClientRequestRetrySupporter.java:64) at com.sdl.web.content.client.impl.ClientRequestRetrySupporter.runWithRetry(ClientRequestRetrySupporter.java:26) at com.sdl.web.content.client.impl.ContentClient.performAction(ContentClient.java:329) at com.sdl.web.content.client.ContentClientApi.performAction(ContentClientApi.java:43) at com.sdl.web.api.broker.querying.QueryImpl.executeEntityQuery(QueryImpl.java:145) .... Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method)
The error is triggered when I call the following code:
Query builtQuery = buildQuery(brokerQuery); Item items = builtQuery.executeEntityQuery();
The error is also triggered mostly when I execute the query on the 1st, 2nd, or 3rd try. But after that, the query returns just fine (I am assuming it's because of the caching).
I tried to debug with Fiddler, and I see the following warning from Fiddler when the error occurs:
The session was aborted by the client, Fiddler, or the server.
(Edit: added information) Increasing connection timeout on cd_client_conf.xml helped for the simpler query. But query with longer criteria (orCriteria in this case) keeps failing.
This is how I build the criteria for the query.
final List<Criteria> andCriteria = new ArrayList<>(); final List<Criteria> combinedCriteria = new ArrayList<>(); final List<Criteria> notCriteria = new ArrayList<>(); andCriteria.add(new ItemSchemaCriteria(61647)); andCriteria.add(new ItemTemplateCriteria(61648)); andCriteria.add(new PublicationCriteria(33)); andCriteria.add(new CustomMetaValueCriteria(new CustomMetaKeyCriteria("type"), "brief")); notCriteria.add(new CustomMetaKeyCriteria("endDate")); notCriteria.add(new CustomMetaKeyCriteria("category")); NotInCriteria notInCriteria = new NotInCriteria(new OrCriteria(notCriteria)); combinedCriteria.add(new AndCriteria(andCriteria)); combinedCriteria.add(notInCriteria); return new AndCriteria(combinedCriteria);
Explanation: I need to query based on specific filters with andCriteria. I use notCriteria to filter out content that has metadata attribute endDate or category filled in. Filtering out based on endDate only works sometimes fine, but every time I do more filtering based on the attribute (e.g. with category) it seems that the model service is struggling to execute the query.
What could be the problem here?