Welcome Guest! To enable all features please Login or Register.
Profile: CodeJunky2008
Name: CodeJunky2008 Offline
Joined: Wednesday, April 23, 2008(UTC)
Last Visit: Tuesday, November 23, 2010 2:37:18 AM(UTC)
Number of Posts: 27
[0.08% of all post / 0.01 posts per day]
Thanks Given: 0 (View Thanks)
Thanks Received: 0
Thanked Posts: 0
Community Reputation Received:
View All Posts by User
Topic: Fixed the caching problem for me, worth a shot   Go to last post
Posted: Tuesday, December 2, 2008 4:30:33 PM(UTC)
When you say IIS refresh time, I only know of recyling the pool. Is this a setting under an options tab. Has nobody else reported this problem to you?
Topic: Fixed the caching problem for me, worth a shot   Go to last post
Posted: Wednesday, November 26, 2008 3:49:33 PM(UTC)
Sad The problem came back but it took a lot longer to happen than normal. Originally it would occur in the first few hours this time it took over 10 hours. I am going to have to write some reporting tools to find out what the hells happening. Gutted I thought I had put this one to bed.

The nightmare continuesMad
Topic: Wont allow new post / new topic - please a solution asap   Go to last post
Posted: Tuesday, November 25, 2008 7:03:13 PM(UTC)
Topic: Fixed the caching problem for me, worth a shot   Go to last post
Posted: Tuesday, November 25, 2008 7:02:04 PM(UTC)
Thanks, I can report that the problem is fixed and I have asked moderators to test and they are reporting everything as working perfectly. This is the first time I have ever gone over 2 hours without incident and the new code has been live for over 4 hours.

If anything changes I will let you know

CJ
Topic: Fixed the caching problem for me, worth a shot   Go to last post
Posted: Tuesday, November 25, 2008 3:58:22 PM(UTC)
So this one was bugging the hell out of me excuse the pun. In the end I had to write an HttpHandler to look into the application cache and see what was going on.

Now this works for me but I haven't had the code live long enough to be 100% sure but worth a try. It's only few lines of code.

I also under Jaben's advice decided to create the forums under it's own app pool in IIS and make the YetAnotherForum.Net website into a C# web application. If you need advice on this PM me.


YAFProviders.YAFRoleProvider.cs has an override method GetRolesForUser() which puts the currents users role memberships into cache under a cache entry called 'YafRoleProvider-UserRoleDictionary-YetAnotherForum'. This code only runs if the user's Session["UserUpdated"] == null i.e. user has just logged in or no activity for say 20 mins (server specific) and IIS has dropped the session.

I'm not sure why but when 'YafRoleProvider-UserRoleDictionary-YetAnotherForum' is dropped out of cache it doesn't always get recreated. So this is how I fixed the issue.

This code belongs inside InitUserAndPage() method,
1.9.3 alpha (YAF.Base.ForumPage.cs)
1.9.3 beta to RC2 (YAF.Classes.Utils.Context.cs)

Original code
Code:

if (user != null && Session["UserUpdated"] == null)
{
RoleMembershipHelper.UpdateForumUser(user, PageContext.PageBoardID);
Session["UserUpdated"] = true;
}



Amended code
Code:
if (user != null && Session["UserUpdated"] == null)
{
RoleMembershipHelper.UpdateForumUser(user, PageContext.PageBoardID);
Session["UserUpdated"] = true;
}
else if (user != null)
{
string[] roles = System.Web.Security.Roles.GetRolesForUser(user.UserName);
}


There shouldn't be any real additional overhead for performance because the method simply checks the cache to see if it exists. If no entry it recreates it and returns the roles as a string array.

I will let Jaben and other more experienced developers discuss why. It's just a quick and simple fix (for me) I hope it might help some of you guys. But it makes sense that if the roles are not present and were before access would be an issue. Hopefully it's as simple as this but maybe not!

CJ


P.S.

This is the code to create the HttpHandler, create the class in its own class library and then add a reference to the website or web application (YetAnotherForum.Net)

Code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Collections;
using System.IO;


namespace CachingManagerTool
{
public class CacheManager : IHttpHandler
{

#region IHttpHandler Members

public bool IsReusable
{
get { return false; }
}

public void ProcessRequest(HttpContext context)
{
string output = string.Empty;
IDictionaryEnumerator enumerator = context.Cache.GetEnumerator();
while (enumerator.MoveNext())
{
output += context.Cache[enumerator.Key as string];
Type t = enumerator.Value.GetType();//You could write out the cache I just wanted a point to debug and watch the value and key.
}

}

#endregion
}
}


Put this in the web.config
<httpHandlers>

<add verb="*" path="cache.axd" type="CachingManagerTool.CacheManager, CachingManagerTool"/>
</httpHandlers>

To look at the cache set a break point in the CacheManager.cs and then in the brower url replace default.aspx with cache.axd and hit return. If you are in debug mode you should hit the break point and be able to look in your cache. Good luck

Topic: Installation Error   Go to last post
Posted: Thursday, November 13, 2008 6:51:59 PM(UTC)
The error message is the stock response when there is a problem. You need to modify the web.config file and turn custom errors to Off from on. Then you can see what the real error message is.

CJ
Topic: Wont allow new post / new topic - please a solution asap   Go to last post
Posted: Thursday, November 13, 2008 7:20:56 AM(UTC)
Finally I'm not alone. I have posted on this twice although I am still trying to solve it.

Previous posts
Cache out of sync
Weird behaviour

So far I have discovered that the only way to temporarly fix the problem is by clearing all the cache settings under host settings > cache.

This in fact runs some code called YafCache.Current.Clear(), it basically enumerates over all the keys in the application cache of which mine has 9 and removes them all.

Interestingly all forums that have the access mask of members belonging to the registered group (YAF out of the box) work fine all the time. It is only new access masks and roles that are problematic.

The funny thing is it doesn't always fix the problem sometimes it takes a few goes or even closing the browser and reloading the page before it works. There is no pattern on how long this lasts for but normally only a few hours.

It's very strange because once the problem happens all the event handlers on the page stop working so clicking on the new topic or moderate button do nothing. I guess something elsewhere takes over and redirects you to the first category in the forums. Always the 1st category.

I am at a loss but feel the only way to fix this is to create a console application that does a request for a page which calls the YafCache.Current.Clear() running as a scheduled task. As the cache is managed by asp.net you cannot access it via httpruntime or httpcontext object from outside the application (YAF).

I have 1400 users and over a dozen forums suffering with this problem, very annoying and a shame because otherwise it's a brilliant product

If I come up with a fix I will post it up asap.
Topic: Weird behaviour   Go to last post
Posted: Wednesday, November 12, 2008 4:43:48 PM(UTC)
Thanks for trying, I think this problem is specific to our setup I have a feeling running MOSS 2007 on the same box may cause the problems as it does a lot of things with the loading and unloading objects from cache.
Topic: Cache out of sync   Go to last post
Posted: Wednesday, November 12, 2008 4:42:16 PM(UTC)
The only thing that seems to fix it is by calling the the YafCache.Current.Clear() method. So I am going to write a console app that runs this piece of code and attach it to a scheduled task to run every 15 minutes. I am using 1.9.3 Alpha at the momement but I have just upgraded to RC2 on our development servers so maybe this update will fix it when I deploy it to live.

I let you know

thanks

CJ
Topic: Weird behaviour   Go to last post
Posted: Thursday, October 30, 2008 7:40:25 PM(UTC)
Click event stops working on all buttons on the topic.ascx until you clear the cache.

Any ideas why?

Notification

Icon
Error