Mongo not deleting document even when acknowleged

Hello,
I am working with Mongo on a servlet application. The issue I am currently facing is that the application manages to delete the user-record from a separate IDP service, but not in Mongo.

Basically I am keeping two records of a user, one on a secure IDP with all the sensitive data, while on mongo I am keeping the application-related one. On top of that, the operation gets acknowledged, even when it is not carried out.

I’ve tried to interact with my database by running a simple main method, and it works without a hitch, but when I try to do it from the servlet environment, adding a new document works, but deleting it it doesnt…

Hi @Alberto_Nicoletti and welcome to the community forum

There could be certain things that you could verify on your end.

  1. Is the servlet connecting correctly with the MongoDB database? If yes, do you see any error while the delete message is passed?
  2. Are you connecting through a stand alone database ? If yes, can you trace the logs on the database to look for errors?
  3. Can you also verify if multiple threads or servlets are accessing the database, there could be a race condition or a locking issue preventing the delete operation from being executed.
  4. What is the MongoDB version you are using ?

Regards
Aasawari

1 Like

Is it the same user id connecting to MongoDB? Maybe the 2 scenarios are using different user id’s and the one using the servlet is not authorized to delete?
Could there be 2 documents and the first one was deleted and now you see the second one is still there?

Thank you to everyone, in the end it was as @Aasawari said.

Since updating users depends on an external IDP, there were some configuration issues which lead to a failure in the update process which in turn did not reflect onto mongo.