nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

WIP - Do not try to invalidate query spaces for non cached persisters

Open hazzik opened this issue 6 years ago • 9 comments

Fixes #2129

The second commit is a code cleanup. It could be dropped if serialization changes are not desired.

hazzik avatar Apr 15 '19 12:04 hazzik

Hi! Maybe I'm missing something here, and is just focusing on the title, but query space invalidation / time stamp updating is orthogonal to the cachability of entities.

gliljas avatar Apr 30 '19 09:04 gliljas

Probably you're right. I need to check.

hazzik avatar Apr 30 '19 10:04 hazzik

Hi! Maybe I'm missing something here, and is just focusing on the title, but query space invalidation / time stamp updating is orthogonal to the cachability of entities.

@gliljas are you saying that an entity could be cached in a query even when the entity is not cacheable?

hazzik avatar May 17 '20 02:05 hazzik

Not the entity, but its identifiers could, as the query cache caches identifiers only, regardless of entity cacheability.

fredericDelaporte avatar May 17 '20 15:05 fredericDelaporte

Exactly. A cached query stores identifiers (or value projections) and should be invalidated whenever one of the included queryspaces is invalidated. It's not particularly efficient, especially with distributed caches, but it's how works right now.

gliljas avatar Jun 01 '20 21:06 gliljas

A working feature might be to only allow queries to be cached if all included queryspaces/persisters have caching enabled.

gliljas avatar Jun 01 '20 21:06 gliljas

I'll extract some refactoring from this PR into another, because it is useful anyway. For this PR I/we would need to add tests to demonstrate the behavior.

hazzik avatar Jun 01 '20 21:06 hazzik

A working feature might be to only allow queries to be cached if all included queryspaces/persisters have caching enabled.

I do not agree. Query caching is enabled on a query per query basis, by user code. I think we should trust the user knows what he does in such case, instead of disregarding his explicit instructions.

fredericDelaporte avatar Jun 02 '20 21:06 fredericDelaporte

I'll extract some refactoring from this PR into another, because it is useful anyway. For this PR I/we would need to add tests to demonstrate the behavior.

@hazzik @fredericDelaporte

With NH 5.3 issue still exists

As a workaround with reflection we are changing NH UpdateTimestampsCache with our timestamp cache impl. that invalidates only cached entities.

There is a huge performance effect under concurrent request of dml operations.

gokhanabatay avatar Jul 20 '20 08:07 gokhanabatay