[rhino-tools-dev] Rhino.Security second level cache not being invalidated...

13 views
Skip to first unread message

ondesertverge

unread,
May 25, 2010, 7:34:56 AM5/25/10
to Rhino Tools Dev
Hi All,

I'm having the following issue with RS with second level cache
enabled:

Executing GetAssociatedUsersGroupFor directly after executing
AssociateUserWith returns the cached associations. AssociateUserWith
doesn't seem to be invalidating the cache for the UserToUsersGroups
table.

I am using SysCache2 from Nhibernate.Contrib.

Is the solution for this in a config setting I'm missing or do have to
make a change to RS code?

Thanks,
David

--
You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.

Ayende Rahien

unread,
May 25, 2010, 7:54:17 AM5/25/10
to rhino-t...@googlegroups.com
Did you commit the transaction?

ondesertverge

unread,
May 25, 2010, 8:25:02 AM5/25/10
to Rhino Tools Dev
Yes, and calling GetAssociatedUsersGroupFor on a separate web request
(with a transaction and all) still gives stale data (until the cache
entry expires).

On May 25, 2:54 pm, Ayende Rahien <aye...@ayende.com> wrote:
> Did you commit the transaction?
>
> On Tue, May 25, 2010 at 2:34 PM, ondesertverge <aceff.co...@gmail.com>wrote:
>
>
>
> > Hi All,
>
> > I'm having the following issue with RS with second level cache
> > enabled:
>
> > Executing GetAssociatedUsersGroupFor directly after executing
> > AssociateUserWith returns the cached associations. AssociateUserWith
> > doesn't seem to be invalidating the cache for the UserToUsersGroups
> > table.
>
> > I am using SysCache2 from Nhibernate.Contrib.
>
> > Is the solution for this in a config setting I'm missing or do have to
> > make a change to RS code?
>
> > Thanks,
> > David
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Rhino Tools Dev" group.
> > To post to this group, send email to rhino-t...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rhino-tools-d...@googlegroups.com<rhino-tools-dev%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rhino-tools-dev?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
> To post to this group, send email to rhino-t...@googlegroups.com.
> To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/rhino-tools-dev?hl=en.

Ayende Rahien

unread,
May 25, 2010, 8:29:37 AM5/25/10
to rhino-t...@googlegroups.com
Looks like a bug then, it shouldn't do that.

ondesertverge

unread,
May 25, 2010, 10:35:55 AM5/25/10
to Rhino Tools Dev
I thought this might be a dirty workaround

NHibernateSession.GetDefaultSessionFactory().EvictQueries("rhino-
security");

but not.

Any ideas? Or should I being looking for issues with SysCache2?

On May 25, 3:29 pm, Ayende Rahien <aye...@ayende.com> wrote:
> Looks like a bug then, it shouldn't do that.
>
> > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>

Ayende Rahien

unread,
May 25, 2010, 12:20:49 PM5/25/10
to rhino-t...@googlegroups.com
Can you create a failing test? 

ondesertverge

unread,
May 25, 2010, 2:18:25 PM5/25/10
to Rhino Tools Dev
Well, yes and no.
I wrote the test but it DOES pass. I switched to HashtableCache on my
project for testing and I still get the same results. This is very
strange since my code is very straightforward almost exactly like that
in the RS tests ...

On May 25, 7:20 pm, Ayende Rahien <aye...@ayende.com> wrote:
> Can you create a failing test?
>
> > > > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
> > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/rhino-tools-dev?hl=en.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Rhino Tools Dev" group.
> > > > > To post to this group, send email to
> > rhino-t...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > rhino-tools-d...@googlegroups.com<rhino-tools-dev%2Bunsu...@googlegroups.com>
> > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
>
> > > > .

Ayende Rahien

unread,
May 25, 2010, 2:21:44 PM5/25/10
to rhino-t...@googlegroups.com
LOL
Check things like flush mode

ondesertverge

unread,
May 25, 2010, 2:47:32 PM5/25/10
to Rhino Tools Dev
I'm glad someone is laughing here :( ...
I admit my understanding of NH is quite superficial but isn't the
flush mode relevant only within a single session.
The data is being persisted it's the second level cache that isn't
being updated.
You did say "things LIKE flush mode" though, any other thoughts?

On May 25, 9:21 pm, Ayende Rahien <aye...@ayende.com> wrote:
> LOL
> Check things like flush mode
>

> > > > > > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
> > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
>
> > > > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
> > <rhino-tools-dev%25252Bun...@googlegroups.com<rhino-tools-dev%2525252Bu...@googlegroups.com>


>
> > > > > > > > .
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/rhino-tools-dev?hl=en.
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> > Google
> > > > Groups
> > > > > > "Rhino Tools Dev" group.
> > > > > > > To post to this group, send email to
> > > > rhino-t...@googlegroups.com.
> > > > > > > To unsubscribe from this group, send email to
> > > > > > rhino-tools-d...@googlegroups.com<rhino-tools-dev%2Bunsu...@googlegroups.com>
> > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
>
> > > > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
> > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
>
> > > > > > .

Ayende Rahien

unread,
May 25, 2010, 2:51:09 PM5/25/10
to rhino-t...@googlegroups.com
You aren't updating the 2nd level cache, that means that:
a) you aren't flushing
b) you are running in a DTC
c) you are using <cache usage=""/> differently in the tests / real code.
d) you need to debug.

ondesertverge

unread,
May 28, 2010, 3:30:53 AM5/28/10
to Rhino Tools Dev
By process of elimination I was left with choice (d).
In the meantime I disabled 2nd level caching with a static field in
Security:

/// <summary>
/// Set to True to allow 2nd level caching of
AuthorizationRepository/PermissionService queries.
/// </summary>
public static bool AllowCaching { get; set; }

Which I guess is a feature that could be useful in several scenarios.

Again, Thanks for your help.

On May 25, 9:51 pm, Ayende Rahien <aye...@ayende.com> wrote:
> You aren't updating the 2nd level cache, that means that:
> a) you aren't flushing
> b) you are running in a DTC
> c) you are using <cache usage=""/> differently in the tests / real code.
> d) you need to debug.
>
> > > > > > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
> > <rhino-tools-dev%25252Bun...@googlegroups.com<rhino-tools-dev%2525252Bu...@googlegroups.com>
>
> > > > <rhino-tools-dev%25252Bun...@googlegroups.com<rhino-tools-dev%2525252Bu...@googlegroups.com>
> > <rhino-tools-dev%2525252Bu...@googlegroups.com<rhino-tools-dev%252525252B...@googlegroups.com>
>
> > > > > > > > > > .
> > > > > > > > > > For more options, visit this group at
> > > > > > > > > >http://groups.google.com/group/rhino-tools-dev?hl=en.
>
> > > > > > > > > --
> > > > > > > > > You received this message because you are subscribed to the
> > > > Google
> > > > > > Groups
> > > > > > > > "Rhino Tools Dev" group.
> > > > > > > > > To post to this group, send email to
> > > > > > rhino-t...@googlegroups.com.
> > > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > rhino-tools-d...@googlegroups.com<rhino-tools-dev%2Bunsu...@googlegroups.com>
> > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
>
> > > > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
> > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
>
> > > > > > <rhino-tools-dev%2Bunsu...@googlegroups.com<rhino-tools-dev%252Buns...@googlegroups.com>
> > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
>
> > > > <rhino-tools-dev%252Buns...@googlegroups.com<rhino-tools-dev%25252Bun...@googlegroups.com>
> > <rhino-tools-dev%25252Bun...@googlegroups.com<rhino-tools-dev%2525252Bu...@googlegroups.com>
>
> > > > > > > > .
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages