Skip to content

Partially populated PersistentEntity instances not properly removed from cache [DATACMNS-1574] #2000

Closed
@spring-projects-issues

Description

@spring-projects-issues

Thomas Spendier opened DATACMNS-1574 and commented

I am facing the following problem, which is very rarely reproducible:

Documents get sometimes stored to MongoDB although not triggered by our business logic.

Find attached the class structure for a class where a document got wrongly inserted.

An example of a document representing this class:

{
 "_id" : {
   "userDefinedId" : "ps-chat-service",
   "tenantId" : "T594cbe61-7cfc-4054-baa4-2f2cdf942e91"
 },
 "_class" : "chat.CategoryAssignmentConfig",
 "containerId" : "ps-chat-service",
 "categoryAssignmentRules" : [],
 "tenantId" : "T594cbe61-7cfc-4054-baa4-2f2cdf942e91"
} 

Still we end up that sometimes documents show up in MongoDB with the following serialized format:

{
 "_id" : ObjectId("5c73e667f7631921f8f4eb54"),
 "_class" : "chat.CategoryAssignmentConfig"
} 

The corresponding MongoDB log where this document got inserted:

command DB.chat.CategoryAssignmentConfig command: insert { insert: "chat.CategoryAssignmentConfig", ordered: true, documents: [ { _id: ObjectId('5c73e667f7631921f8f4eb54'), _class: "chat.CategoryAssignmentConfig" } ] } ninserted:1 keysInserted:1 numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 13ms

It looks like as if our business logic simply inserts an object of the referred class where no properties are set and an auto-generated ID is created by spring-data-mongodb (which doesn't match our complex typed ID).

Still we log the content of every object before performing a MongoOperations::save() call and there is no log line which shows such an "empty" object. All log lines basically match the following output (with the only difference being the concrete values for the containerId and tenantId property:

Persisting document PersistedCategoryAssignmentRulesContainer[spaceInstanceId=SpaceInstanceId[userDefinedId=ps-chat-service,userIdClassName=java.lang.String,tenantId=T4a5c5bd9-bb3c-4e9d-a935-c34b78e55ec0],tenantId=T4a5c5bd9-bb3c-4e9d-a935-c34b78e55ec0,routingKey=0,masterPartitionInstanceId=3,containerId=ps-chat-service,categoryAssignmentRules=[]]; 

I couldn't find any similar issues so I created this ticket. I am not certain whether the problem is within spring-data-mongodb, but I have no reason to belief that our business logic is triggering these wrong inserts (otherwise we would have seen it in the logs). Do you know of any similar occurrences in any spring-data-mongodb version? I am in particular interested why the _id field gets auto-generated although it actually is set


Attachments:

Backported to: 2.1.11 (Lovelace SR11)

Metadata

Metadata

Assignees

Labels

in: mappingMapping and conversion infrastructuretype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions