2015-04-14 10 views
8

Tôi đang sử dụng Grails 2.4.4, mongo plugin 3.0.2, MongoDB 2.4.10 bằng kết nối cơ sở dữ liệu từ xa.Mongo CursorKhông có ngoại lệ đối với con trỏ đang hoạt động thông qua tiêu chí miền Grails

grails { 
    mongo { 
     host = "11.12.13.14" // A remote server IP 
     port = 27017 
     databaseName = "blogger" 
     username = "blog" 
     password = "xyz" 
     options { 
      autoConnectRetry = true 
      connectTimeout = 3000 
      connectionsPerHost = 40 
      socketTimeout = 120000 
      threadsAllowedToBlockForConnectionMultiplier = 5 
      maxAutoConnectRetryTime=5 
      maxWaitTime=120000 
     } 
    } 
} 

Trong một phần của ứng dụng của chúng tôi, một phương pháp dịch vụ lặp trên một người sử dụng 20.000 nhân và gửi cho họ một email:

Person.withCriteria {  // Line 323 
    eq("active", true) 
    order("dateJoined", "asc") 
}.each { personInstance -> 
    // Code to send an email which takes an average of 1 second 
} 

Sau khi thực hiện điều này cho một số người dùng 6000, tôi nhận được một con trỏ MongoDB ngoại lệ:

2015-04-11 07:31:14,218 [quartzScheduler_Worker-1] ERROR listeners.ExceptionPrinterJobListener - Exception occurred in job: Grails Job 
org.quartz.JobExecutionException: com.mongodb.MongoException$CursorNotFound: Cursor 1337814790631604331 not found on server 11.12.13.14:27017 [See nested exception: com.mongodb.MongoException$CursorNotFound: Cursor 1337814790631604331 not found on server 11.12.13.14:27017] 
     at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111) 
     at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
     at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 
Caused by: com.mongodb.MongoException$CursorNotFound: Cursor 1337814790631604331 not found on server 11.12.13.14:27017 
     at com.mongodb.QueryResultIterator.throwOnQueryFailure(QueryResultIterator.java:218) 
     at com.mongodb.QueryResultIterator.init(QueryResultIterator.java:198) 
     at com.mongodb.QueryResultIterator.initFromQueryResponse(QueryResultIterator.java:176) 
     at com.mongodb.QueryResultIterator.getMore(QueryResultIterator.java:141) 
     at com.mongodb.QueryResultIterator.hasNext(QueryResultIterator.java:127) 
     at com.mongodb.DBCursor._hasNext(DBCursor.java:551) 
     at com.mongodb.DBCursor.hasNext(DBCursor.java:571) 
     at org.grails.datastore.mapping.mongo.query.MongoQuery$MongoResultList$1.hasNext(MongoQuery.java:1893) 
     at com.test.person.PersonService.sendWeeklyEmail(PersonService.groovy:323) 
     at com.test.WeeklyJob.execute(WeeklyJob.groovy:41) 
     at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104) 
     ... 2 more 

Tôi đã tìm tài liệu và thấy rằng con trỏ tự động đóng trong 20 phút và khi tôi xác nhận nó bằng nhật ký, ngoại lệ này chính xác sau 20 phút.

Nhưng hành vi tự động đóng trong 20 phút này được áp dụng cho con trỏ không hoạt động nhưng ở đây con trỏ đang hoạt động.

CẬP NHẬT:

Tôi đọc một số bài báo và phát hiện ra rằng, đây có thể là một vấn đề thời gian chờ keepalive TCP. Vì vậy, chúng tôi đã thay đổi thời gian chờ của TCP thành 2 phút mặc định, nhưng vẫn không giải quyết được vấn đề.

Trả lời

Các vấn đề liên quan