4

I have a problem with a multithreading java process, in my main I launch a paged query and put the result in threads, where executes select, updates, and a lot of crazy things.

The methods used to do the query are Query.skip(int skip) and Query.limit(int limit) with 10.000 limit value.

The process throws the following exception when paged more than 800.000 elements:

Exception:org.springframework.dao.DataAccessResourceFailureException: Cursor XXXXXXXX not found on server XXXXXXXX:XXXXX; nested exception is com.mongodb.MongoException$CursorNotFound: Cursor XXXXXXXX not found on server XXXXXXXX:XXXXX
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:60)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:1918)
    at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1801)
    at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1612)
    at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1596)
    at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:535)
    at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:526)

Where is the problem?

My mongo options:

<mongo:options auto-connect-retry="true"
            connections-per-host="30"
            socket-keep-alive="true" max-auto-connect-retry-time="15000"
            max-wait-time="60000" socket-timeout="0" />

Versions:

Spring : 3.2.9.RELEASE
Spring Data Mongdb: 1.5.1.RELEASE
Mongo Java Driver: 2.12.2

Maybe some pictures would help:

Monitoring MonitoringLongTime

Why the process is so big? Here is the answer StatelessKnowledgeSession Focus Agenda

Thanks!!!

Community
  • 1
  • 1
Ganchix
  • 315
  • 4
  • 13
  • 1
    Is it correct that your are sharing a single cursor across multiple threads? If so the issue is likely that one thread exhausts the cursor (meaning all documents have been pulled from it) which will also result in deletion of the cursor on mongod. When the next thread tries to access it is no longer found. My recommendation in this case is to have 1 cursor per thread and look for a different means of slicing your document set. – James Wahlin Jul 24 '14 at 13:02
  • 1
    Sounds right, but how can I do this with Spring Data Mongo? I can't manipulate cursor... :'( Thanks James. – Ganchix Jul 24 '14 at 14:04
  • is this a Spring Data MongoDB bug? – Ganchix Jul 28 '14 at 06:51
  • https://jira.spring.io/browse/DATAMONGO-1010 – Ganchix Jul 29 '14 at 11:11

0 Answers0