First level sleeping cache in a clustered environment

The first level cache in sleep mode is maintained on the session object and inside the border of the same JVM. This is a required cache that is used in sleep mode. I worry about this as how I will manage this in a clustered environment. Several nodes will have their first level caches (equal to the number of sessions). In one JVM, one object can be part of another session, but the transaction manager, optimistic locking copes with the situation ... But how will we manage it in a cluster environment

1) the entity can be changed in the cache of the first level of two different nodes, which leads to problems with outdated data, data loss.

2) If we use optimistic locking ... it will be difficult to restore the transaction, and may also affect other useful transactions on other nodes.

3) We cannot take a pessimistic lock for each transaction. It will kill the usefulness of sleep caching.

4) Setting the isolation level will also not work, since the transaction management is performed by the sleeping application itself, and the transaction management boundaries are one JVM.

+4
source share
2 answers

Your first statement is incorrect, the first level cache in sleep mode is not supported within the same JVM. It is supported within a sleep mode session.

Hibernate ( , ) , jvm, jvm.

, , - , jvm.

, , , . . ( ). JVM.

hibernate DB, " " " db" ( JDBC, JTA). , jvm .

???? ??? ... ??? node ????

db , , DB.

+3

, JPA + Hibernate - , . . , node , , READ_COMMITED.

+1

Source: https://habr.com/ru/post/1533677/


All Articles