[ http://nhjira.koah.net/browse/NH-1762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17873#action_17873 ]
Jalal commented on NH-1762:
---------------------------
Actually the process is easy to spot
1) open a session
2) make a query. Now the result should be cached
3) make any update to any table. Now the Lastupdate timestamp changes
4) Make a query again (same as above to benefit from the cache), ooops it doesn't get it from cache ....
5) Make 1000 new query .... they are all not cached ... because they cache key is the session timestamp ... which is different from LastUpdate Timestamp ....
Any more help you like ?
You are welcome ...
> Query is not cached due to timestamp missuse !
> ----------------------------------------------
>
> Key: NH-1762
> URL: http://nhjira.koah.net/browse/NH-1762
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0.0.GA
> Reporter: Jalal
> Priority: Minor
>
> I enabled SecondLevel Cache and Enabled QueryCache and used the proper Cache provider, and although the execution hit the [##########] method, I tracked it down and found the problem is in NOT updated timestamps
> In NHibernate.Cache.StandardQueryCache
> public IList Get(QueryKey key, ICacheAssembler[] returnTypes, ISet<string> spaces, ISessionImplementor session)
> {
> ....
> IList result = new ArrayList(cacheable.Count - 1);
> long timestamp = (long) cacheable[0];
> log.Debug("Checking query spaces for up-to-dateness [" + spaces + "]");
> if (! IsUpToDate(spaces, timestamp)) // <------------------------------------------------- here
> {
> log.Debug("cached query results were not up to date");
> return null;
> ....
> Following to NHibernate.Cache.UpdateTimestampsCache , I get
> public bool IsUpToDate(ISet<string> spaces, long timestamp /* H2.1 has Long here */)
> {
> foreach (string space in spaces)
> {
> object lastUpdate = updateTimestamps.Get(space); //<----------------------------- here
> if (lastUpdate == null)
> {
> ...
> }
> else
> {
> if ((long) lastUpdate >= timestamp) //<---------------------------------- always fails ????
> {
> return false;
> }
> }
> .............
> The problem is in "timestamp" variable ... it is not using the LastUpdated one when we put a new item in cache ???
> Back to NHibernate.Cache.StandardQueryCache
> public bool Put(QueryKey key, ICacheAssembler[] returnTypes, IList result, ISessionImplementor session)
> {
> if (log.IsDebugEnabled)
> {
> log.Debug("caching query results in region: " + regionName);
> }
> IList cacheable = new ArrayList(result.Count + 1);
> cacheable.Add(session.Timestamp); // <-------------------------------------------------------- you are using the session timestamp
> .................
> The session.Timestamp , so how is not being updated to reflected the lastest updated timestamp ?? shouldn't it ??!!!!
> Please review and reply ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://nhjira.koah.net/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|