0

I have a simple method that reads from mongo collection of people as stream, and for each person doing some model change and inserting to a new collection:

  def processPeople()(implicit m: Materializer): Future[Done] = {
    val peopleSource: Source[Person, Future[State]] = collection.find(json())
      .cursor[Person]()
      .documentSource()
      .throttle(50, 1.second)

    peopleSource.runForeach(person => insertPerson(person))
  }

  def insertPerson(person: Person): Future[String] = {
    peopleCollection.insert(person) map { _ =>
      person.id
    } recover {
      case WriteResult.Code(11000) =>
        println(WriteResult.lastError(_))
        logger.error(s"fail to insert duplicate person ${person.id}")
        throw DuplicateInsertion("duplicate person")
      case _ =>
        logger.error(s"fail to insert person ${person.id}")
        throw new RuntimeException
    }
  }

the collection is about 370K documents, and after 200k from some reason I got:

reactivemongo.core.errors.DetailedDatabaseException: DatabaseException['Cursor not found, cursor id: 72642197351' (code = 43)]

and in the mongo console I saw:

I COMMAND  [conn45] killcursors: found 0 of 1

does anyone understand why is that happening?

jack miao
  • 1,398
  • 1
  • 16
  • 32
  • How much time your query runs before the exception occurs? – right Jan 07 '19 at 13:20
  • @right maybe 2hr...or less...something around there – jack miao Jan 07 '19 at 13:25
  • The answer to your question is here: https://stackoverflow.com/questions/44248108/mongodb-error-getmore-command-failed-cursor-not-found – right Jan 07 '19 at 13:31
  • Possible duplicate of [MongoDB - Error: getMore command failed: Cursor not found](https://stackoverflow.com/questions/44248108/mongodb-error-getmore-command-failed-cursor-not-found) – right Jan 07 '19 at 13:31
  • Possible duplicate of [using akka streams to go over mongo collection](https://stackoverflow.com/questions/54065160/using-akka-streams-to-go-over-mongo-collection) – cchantep Jan 08 '19 at 00:38

0 Answers0