Hello,
We are inserting a mongoDB document via POST API. When the server side is returning sucess to the API, we are then doing a GET API to search for all documents present in the month.
post notes succes at 1699236425746
getall notes called at 1699236425747
The GET notes is being called in the next millisecond after the POST API has returned into the success handler.
The issue is that we are get all documents in the present month but unable to get the document just inserted. If we call a GET API again or add a 400 ms delay to the GET API, it is able to also bring in this document that is just inserted.
Our POST API is not running asynchronously i.e it is a blocking thread until the insert into mongoDB database is done. We use Java MongoTemplate API class of spring-data-mongoDb library. We are not adding any @Transaction to the Java annotation. We are merely letting mongoDBTemplate call save on its API method and letting it take care of anything(and everything).
- So my question is there some kind of database cleanup occurring that we are unable to get the data immediately but are able to query it if we add a 100-400 ms delay in the GET API call?
1.a If a cleanup is indeed occurring, why does this not finish when the database insert finishes?
This was not happening before. We added a new subdocument to ClinicalNote object called asurveyResponse. Sharing before and after document structure
Our document structure Before when there was no issue in GET API after receiving POST success
BEFORE
{
"_id": "531515",
"_class": "coodel",
"noteID": 8
"clientID": 3,
"userID": 8,
"userTypeID": 4,
"userRoleName": "Patient",
"userFirstName": "",
"userMiddleName": "C",
"userLastName": "",
"creatorID": 46,
"creatorFirstName": "",
"creatorMiddleName": "",
"creatorLastName": "",
"creatorTypeID": 6,
"creatorRoleName": "NURSE",
"createdByUserName": "@.com",
"createdDate": {
"$numberLong": "1698417636801"
},
"createdDateTime": {
"$date": "2023-10-27T14:40:36.801Z"
},
"modifierID": 46,
"modifierFirstName": "",
"modifierMiddleName": "",
"modifierLastName": "Roers",
"modifierTypeID": 6,
"modifierRoleName": "NURSE",
"modifiedByUserName": "mro.com",
"modifiedDate": {
"$numberLong": "1698417636801"
},
"modifiedDateTime": {
"$date": "2023-10-27T14:40:36.801Z"
},
"calendarEventID": 0,
"active": true,
"parentNoteID": 0,
"rootNoteID": 531515,
"important": false,
"noteType": "CLINICALNOTE",
"clinicalNote": {
"templateName": "physician",
"templateID": 1,
"questions": [
{
"type": "radiogroup",
"questionID": 1,
"title": "Why dall code red?",
"isRequired": true,
"answer": "Other",
"optionalText": "",
"choices": [
{
"value": "item1",
"text": "Alert",
"inputType": "radio",
"choiceOrder": 1,
"optionalText": false
},
{
"value": "item2",
"text": "Pt's request",
"inputType": "radio",
"choiceOrder": 2,
"optionalText": false
},
{
"value": "item3",
"text": "Other",
"inputType": "radio",
"choiceOrder": 3,
"optionalText": true
}
]
},
{
"type": "radiogroup",
"questionID": 2,
"title": "Who acced?",
"isRequired": true,
"answer": "Pt",
"optionalText": "",
"choices": [
{
"value": "item1",
"text": "Pt",
"inputType": "radio",
"choiceOrder": 1,
"optionalText": false
},
{
"value": "item2",
"text": "Aide",
"inputType": "radio",
"choiceOrder": 2,
"optionalText": false
},
{
"value": "item3",
"text": "Other",
"inputType": "radio",
"choiceOrder": 3,
"optionalText": true
}
]
},
{
"type": "radiogroup",
"questionID": 5,
"title": "Any couired?",
"isRequired": true,
"answer": "None required",
"optionalText": "",
"choices": [
{
"value": "item1",
"text": "None required",
"inputType": "radio",
"choiceOrder": 1,
"optionalText": false
},
{
"value": "item2",
"text": "Yes",
"inputType": "radio",
"choiceOrder": 2,
"optionalText": true
}
]
}
]
},
"hasChild": false,
"sendNoteStatus": 0
}
AFTER
{
"_id": "",
"noteID": ,
"clientID": ,
"userID": 9,
"userTypeID": 4,
"userRoleName": "Patient",
"userFirstName": "",
"userMiddleName": "",
"userLastName": "Smith",
"creatorID": 46,
"creatorFirstName": "Mike",
"creatorMiddleName": "",
"creatorLastName": "",
"creatorTypeID": 6,
"creatorRoleName": "NURSE",
"createdByUserName": "m",
"createdDate": {
"$numberLong": "1699235118743"
},
"createdDateTime": {
"$date": "2023-11-06T01:45:18.743Z"
},
"modifierID": 46,
"modifierFirstName": "",
"modifierMiddleName": "",
"modifierLastName": "",
"modifierTypeID": 6,
"modifierRoleName": "NURSE",
"modifiedByUserName": "om",
"modifiedDate": {
"$numberLong": "1699235118743"
},
"modifiedDateTime": {
"$date": "2023-11-06T01:45:18.743Z"
},
"calendarEventID": 0,
"active": true,
"parentNoteID": 0,
"rootNoteID": 8,
"important": false,
"noteType": "CN",
"clinicalNote": {
"templateName": "-in",
"templateID": zz,
"migratedToJS": false,
"asurveyResponse": {
"responseObject": {
"question1": {
"value": "item2",
"itemComment": ""
},
"question4": [
{
"value": "item6",
"itemComment": ""
}
],
"question7": [
{
"value": "item3",
"itemComment": ""
}
]
}
},
"key": false
},
"hasChild": false,
"sendNoteStatus": 0,
"_class": "com.mModel"
}