Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
how to avoid race condition when multiple jvm reading/writing same instances of NoSQL db like mongodb?

I am running on a scenario where a NoSQL DB(MongoDB) will hold a record of success or failure status of a certain task and if a task is in failed state, my java scheduler application will read the status,retry and will try to execute the task once again and if task completes successfully, will update the DB record as 'success' state or 'fail' state if failed again.

Now the problem is, my application is deployed in two different nodes(so basically 2 different jvm) and both the nodes share the common NoSQL DB.At a certain point, one scheduler thread wakes up,read the DB and retries for failed tasks and before it completes its execution, another application thread from different node read DB record and and re-executes the task once again which override the previous successful data record update causes unexpected results. So in short, i am running through a race condition and i do not have control over NoSQL DB lock but I want to control at application level.

How do I prevent my application from reading the record which is already been under process by another jvm thread ??

Your suggestions will be greatly appreciated.

I am using jongo library version 1.2 and jdk 1.8

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda