We are using spring data jpa and mongodb.
There is document A with two line item objects. Each line item has unique id. We consume messages from kafka topic at line item level and update the attributes in each line item.
In this situation we are seeing race condition and always second line item attributes are updated, but first line item attributes is not updated.
id : 1234
line items: [
line_item1 comes first from the topic and does findById(1234) and should update received = true for line_item1.
line_item2 comes next from the topic and does findById(1234) and should update received = true line_item2.
But actually this is not happening, line_item1 is never updated and received = false always and line_item2 received = true.