Skip to content

Second level cache key mismatch #1888

Closed
@gokhanabatay

Description

@gokhanabatay

When using a distributed second level cache relying on cache key binary serialization, the keys do not
match across .Net Core processes. They also do not match inside a same process when the keys include filters.

Original report

Hi,
When I use Contextual Filters it tries to retrieve from cache but cached query and current query session filter does not matches.
But it's actually are the same filter when I call ISet.ToString() I can see and I know that they are same filters. It needed to be retrieved from cache below sample.

http://nhibernate.info/doc/howto/various/contextual-data-using-nhibernate-filters

Anyway when I debug the nh I see the error QueryKey.cs line : 130

if (!CollectionHelper.SetEquals(_filters, that._filters))
{
	return false;
}

Somehow the above code does not call FilterKey Equals method when HashSet SetEquals called.
It just call overrided GetHashCode metod of FilterKey class.

When I changed above code to below code it runs like charm.

if (!CollectionHelper.SequenceEquals(_filters, that._filters))
{
	return false;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions