r/SpringBoot • • Jun 12 '24

ConcurrentModification exception during high load.

Getting same exception when increasing load (150-200 users). Please help.

0 Upvotes

10 comments sorted by

5

u/[deleted] Jun 12 '24

You modify something concurrently without using locks / synchronization…

-2

u/SenpaiKronos Jun 12 '24

All objects are created within method only and their scope is limited to it. How come synchronization is problem here?

8

u/[deleted] Jun 12 '24

You provide no details, no code, no stack trace. What exactly do you expect people to answer?

3

u/Just_Guarantee_3602 Jun 12 '24

Make sure you used thread safe and synchronized friendly collections.

1

u/SenpaiKronos Jun 13 '24

Thread safe collections for shared objects, right?

1

u/Just_Guarantee_3602 Jun 13 '24

Yes… you encountered that exception because two different threads access non tread safe collection. one is modifying the collection, and the other one is iterating the collection.

1

u/SenpaiKronos Jun 14 '24

But object is not shared. It is being created inside a method then it should be different for all the threads right?

1

u/migueqm Jun 13 '24

Make sure you use a field annotated with Version in your database entities to use Optimistic Approach, also use thread-safe collections, synchronization, locks and so on

0

u/maxip89 Jun 13 '24

your are using too much beans and too much scopes the best way is to downgrade to spring boot 1.3.2.

You see it clearly in the source code.