[JAVA-355] Getting ConcurrentModificationException when load testing Created: 19/May/11  Updated: 19/Oct/16  Resolved: 30/May/11

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

Type: Bug Priority: Major - P3
Reporter: Moshe Bergman Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: concurrency
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I have 100 threads each of them initializes a class of DBCollection and inserts 1000 records to the database.

I am getting many errors of:

Caused by: java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373)
at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:384)
at com.mongodb.DBCollection._checkKeys(DBCollection.java:1076)
at com.mongodb.DBCollection._checkObject(DBCollection.java:1067)
at com.mongodb.DBCollection.save(DBCollection.java:614)
at com.mongodb.DBCollection.save(DBCollection.java:599)



 Comments   
Comment by Moshe Bergman [ 30/May/11 ]

My apologies, the problem was in my code. Please remove this bug.

Comment by Moshe Bergman [ 24/May/11 ]

I sent it by e-mail

Comment by Moshe Bergman [ 19/May/11 ]

Even with different recordId I am still getting the errors.

I'll need to get permission to send the source code. I expect I will be able to send it on Monday.

Comment by Eliot Horowitz (Inactive) [ 19/May/11 ]

Each find should return a different one, but a DBObject is definitely not thread safe.
Can you attach your code?

Comment by Moshe Bergman [ 19/May/11 ]

I'll add a note:

At the beginning each thread queries the DB for the same record (recordId: "sampleRecord")

Then each thread removes the _id field from DBObject, changes the recordId to a new number and inserts to the database.

Is it possible that on all 100 threads the DBObject is pointing to the same object and thus the Concurrency exception?

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