Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
Spark rdd.count() produce resultados inconsistentes

Estoy un poco desconcertado.

Un simple rdd.count() da diferentes resultados cuando se ejecuta varias veces.

Aquí está el código que ejecuto:

 val inputRdd = sc.newAPIHadoopRDD(inputConfig, classOf[com.mongodb.hadoop.MongoInputFormat], classOf[Long], classOf[org.bson.BSONObject]) println(inputRdd.count())

Abre una conexión a un servidor MondoDb y simplemente cuenta los objetos. Me parece bastante sencillo

Según MongoDb hay 3.349.495 entradas

Aquí está mi salida de chispa, todos ejecutaron el mismo frasco:

 spark1 : 3.257.048 spark2 : 3.303.272 spark3 : 3.303.272 spark4 : 3.303.272 spark5 : 3.303.271 spark6 : 3.303.271 spark7 : 3.303.272 spark8 : 3.303.272 spark9 : 3.306.300 spark10: 3.303.272 spark11: 3.303.271

Spark y MongoDb se ejecutan en el mismo clúster.
Estamos corriendo:

 Spark version 1.5.0-cdh5.6.1 Scala version 2.10.4 MongoDb version 2.6.12

Desafortunadamente no podemos actualizar estos

¿Spark es no determinista?
¿Hay alguien que me pueda iluminar?

Gracias por adelantado

EDITAR/ Más información
Acabo de notar un error en nuestro mongod.log. ¿Podría este error causar el comportamiento inconsistente?

 [rsBackgroundSync] replSet not trying to sync from hadoop04:27017, it is vetoed for 333 more seconds [rsBackgroundSync] replSet syncing to: hadoop05:27017 [rsBackgroundSync] replSet not trying to sync from hadoop05:27017, it is vetoed for 600 more seconds [rsBackgroundSync] replSet not trying to sync from hadoop04:27017, it is vetoed for 333 more seconds [rsBackgroundSync] replSet not trying to sync from hadoop05:27017, it is vetoed for 600 more seconds [rsBackgroundSync] replSet not trying to sync from hadoop04:27017, it is vetoed for 333 more seconds [rsBackgroundSync] replSet error RS102 too stale to catch up, at least from hadoop05:27017 [rsBackgroundSync] replSet our last optime : Jul 2 10:19:44 57777920:111 [rsBackgroundSync] replSet oldest at hadoop05:27017 : Jul 5 15:17:58 577bb386:59 [rsBackgroundSync] replSet See http://dochub.mongodb.org/core/resyncingaverystalereplicasetmember [rsBackgroundSync] replSet error RS102 too stale to catch up
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Como ya notó, el problema no parece ser con chispa (o scala) sino con MongoDB.

Como tal, la pregunta sobre la diferencia parece estar resuelta.

Aún querrá solucionar el error real de MongoDB, el enlace provisto puede ser un buen punto de partida para eso: http://dochub.mongodb.org/core/resyncingaverystalereplicasetmember

over 4 years ago · Santiago Trujillo Report

0

count devuelve un recuento estimado. Como tal, el valor devuelto puede cambiar incluso si la cantidad de documentos no ha cambiado.

countDocuments se agregó a MongoDB 4.0 para proporcionar un recuento preciso (que también funciona en transacciones de varios documentos).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!