We are accessing shared database from multiple pods in kubernetes. All the pods may writes/updates and reads from the db. How to handle data integrity in this case ? Is JPA isolation levels are enough for handling this or need to go with pessimistic locking ? Can you also help me with the difference between both ?
Asked
Active
Viewed 2,439 times
4
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Sep 30 '21 at 14:49
1 Answers
3
Your question has nothing to do with Kubernets. This simply concurrent database access that you'll get if more than one connection is accessing your database.
If you want to avoid problems like lost update then you need locking.
There are two types of locking.
- Optimistic
- Pessimistic
Optimistic is handled by Hibernate with a version field. Pessimistic is the locking mechanism of the database.
You should also read Hibernates documentation about Locking. https://docs.jboss.org/hibernate/orm/5.5/userguide/html_single/Hibernate_User_Guide.html#locking

Simon Martinelli
- 34,053
- 5
- 48
- 82
-
This. This is not a k8s concern more of a database design / implementation question – testfile Sep 23 '21 at 10:50