[JAVA-2452] Unable to find a document using _id Created: 15/Feb/17  Updated: 11/Sep/19  Resolved: 21/Feb/17

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Critical - P2
Reporter: Shiuzi Chen Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Environment:
1. MongoDB Enterprise 3.2.10 using Wired Tiger storage engine
2. Write concern set to W1 with Journal = true
3. Reads are done on the primary, not the replica set

The issue we are seeing is in a very short period (< 10 ms) a document is created in a collection and then queried back. On the query back (using _id field) the document is not found. If queried later by _id it is found.

Is this the expected behavior for Mongo 3.2.10? One observation was this issue starting occurring when we upgraded from 3.0 Mongo to 3.2 Mongo enterprise version.



 Comments   
Comment by Ross Lawley [ 21/Feb/17 ]

Hi schen@curaspan.com,

Just to let you know this project is for Java driver bugs or feature requests. The best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there. If your business requires an answer from MongoDB within a time frame then we do offer production support.

Useful information to include would be the Mongo Java Driver version, the MongoDB setup eg: sharded replicaset cluster or replicaset and the readPreference. Also, it looks like you are using Spring Data so please include the version information as well.

If you do follow up via one of the options above please post a link and I will endeavour to follow the conversation there.

All the best,

Ross

Comment by Emily Stolfo [ 20/Feb/17 ]

Hi schen@curaspan.com

No problem, I'll switch the ticket over to Java.
Thanks!
Emily

Comment by Shiuzi Chen [ 20/Feb/17 ]

We are using Java. I think that I selected the wrong project. Any way to transform to different project or I have to create a new one. Thanks!

Comment by Emily Stolfo [ 20/Feb/17 ]

Hi schen@curaspan.com

Which language are you using to connect to MongoDB? You've created this ticket in the Mongoid project, which is the Ruby MongoDB ODM but I'm afraid there might be some confusion somewhere.
Thanks
Emily

Comment by Shiuzi Chen [ 20/Feb/17 ]

Maybe I picked up wrong project. I can not find those
files mongodi.yml and Gemfile.lock.

For #2, the write and the read are done via two separate
API calls,  completely different code
paths and threads.  I’m not sure how
useful the code below is as we are using spring data and querydsl to interact
with MongoDB, but the write looks something like this:

simpleRepository.save(episode);
where simpleRepository is defined as:
public interface PatientEpisodeRepository extends                      
MongoRepository<PatientEpisode, String>,                       
QueryDslPredicateExecutor<PatientEpisode>,                       
CustomPatientEpisodeRepository { }

And the read looks something like this:

Predicate queryDsl =
EPISODE.orgId.eq(orgId).and(EPISODE.id.eq(patientEpisodeId)).and(EPISODE.deleted.ne(true));
Query mongoQuery = RepositoryUtils.convert(queryDsl);
mongoOperation.findOne(mongoQuery, PatientEpisode.class);

we did a hotfix to the production app today to retry the
query every 15 ms for up to 7 times to see if it could find the episode on the
retry.  The hotfix fixed the issue 100%,
so now we know that is a lag between when we write vs read.  These numbers are just since 6AM today.  One time it took 6 retires (90ms) 
 
Can you add this information to the ticket:
Service                                                                                  retries             count              percent per service
HospitalInternalPatientEpisodeSaveService                    1                      687                  99.85%
HospitalInternalPatientEpisodeSaveService                    2                      1                      0.15%
PatientServiceManagerImpl                                             1                      173                  25.15%
PatientServiceManagerImpl                                              2                      106                  15.41%
PatientServiceManagerImpl                                             3                      20                    2.91%
PatientServiceManagerImpl                                              6                      1                      0.15%
Total                                                                                   988

Comment by Emily Stolfo [ 16/Feb/17 ]

Hi schen@curaspan.com

Can you please provide the following information so we can investigate further?

  • Your mongoid.yml file, while being sure to take out any sensitive information
  • The code snippet with the write and then read
  • Your Gemfile.lock

Thanks
Emily

Generated at Thu Feb 08 08:57:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.