Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Application Restarts Due to Site Structure Changes
Spotlight
#1 Posted : Thursday, 2 September 2010 5:42:09 AM(UTC)
Rank: Member

Joined: 2/09/2010(UTC)
Posts: 4
Location: Green County Wisconsin

Hi Roger,

Since our last conversation, I've re-designed the community website at http://www.greencountyspotlight.com and more tightly integrated GSP with my main application. The site is hosted in a shared hosting environment currently (Full Trust) and the GSP membership provider is integrated with the site's aspnet membership provider so that they both pull from the same membership tables. I'm implemented User Galleries and people are now able to create their own Galleries and generally, things are working fine...but...I've been seeing a lot of application shutdown/restarts since the update and the issue seems to be directly related to the creation of albums (changing the structure of the application file system) and perhaps adding images (not confirmed). The problem this creates is that everyone gets logged out when this happens. Of course, my hosting provider will not allow me to set up SQL Server session state management so everything is handled In Process and everyone getting logged out makes perfect sense (on app restart). The site is getting busier (good news) but with the busy-ness comes more restarts (sometimes 10 or more an hour). I've researched the matter and from my end can only see a few possible of solutions which are

1. Move the site to a dedicated server (with a dedicated DB where I can set up SQL Server session state management) = costly and time consuming
2. Disconnect the two applications and run them separately (don't want my users to have to log in twice)
3. Try to turn off file monitoring in ASP.NET using code like this in the Application start method of the Global.asax file

Dim p As PropertyInfo = GetType(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic Or BindingFlags.[Public] Or BindingFlags.[Static])
Dim o As Object = p.GetValue(Nothing, Nothing)
Dim f As FieldInfo = o.[GetType]().GetField("_dirMonSubdirs", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.IgnoreCase)
Dim monitor As Object = f.GetValue(o)
Dim m As MethodInfo = monitor.[GetType]().GetMethod("StopMonitoring", BindingFlags.Instance Or BindingFlags.NonPublic)
m.Invoke(monitor, New Object() {})

I've tried number three to no avail so I'm wondering if you can shed any light on this subject or propose a solution not mentioned above. If solution two is to be viable, I need a way for user to be able to log into both applications simultaneously (which sounds kind of far fetched).

If it's an integration configuration issue. Perhaps you'd be interested in taking a closer look as we discussed before. Anyway, I need to come up with some solution so anything you can suggest would be very appreciated.

Thanks,

Richard
Roger Martin
#2 Posted : Thursday, 2 September 2010 6:20:26 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Hi Richard,

Check out this KB article I wrote about the issue.

Although deleting an album will trigger an app restart, I would not expect that to happen when creating or renaming an album.

Are you able to move the media objects directory out of the application hierarchy? That might be hard to do if you installed the app at the root, but I bet it would offer you a significant reduction in restarts.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Spotlight
#3 Posted : Thursday, 2 September 2010 6:33:20 AM(UTC)
Rank: Member

Joined: 2/09/2010(UTC)
Posts: 4
Location: Green County Wisconsin

Actually, the deleting of an album vs creating of an album makes sense. The user I most recently spoke with was moving content from an old album to a new album and I do believe she deleted the old album. I don't have access to SQL Server or State Server state management so those are out for the moment. I also don't think I can store anything outside of the application hierarchy but that would be a great solution. This is starting to sound like the kind of problem that only a dedicated server can fix (or better shared hosting which I haven't found in the last 15 years).
Spotlight
#4 Posted : Tuesday, 7 September 2010 11:16:04 AM(UTC)
Rank: Member

Joined: 2/09/2010(UTC)
Posts: 4
Location: Green County Wisconsin

Results of further research have almost provided a solution but a new problem has appeared as a result (perhaps a new thread).

First a solution (of sorts).

Based on the suggestion in the above KB article, I decided to delve a bit further into the issue of setting up SQLServer-based session-state management in a shared hosting environment (specifically a shared SQLServer environment). After much querying of the almighty Google, I found the following posting which directly addressed the issue of not being able to use aspnet_regiis.exe to set up the session-state db due to permission issues related to the setting up of "Jobs" on a shared SQLServer instance. See particularly the section titled "Installing Session State with SQLServer mode on shared web hosting" at this URL. http://www.beansoftware....Session-SQL-Server.aspx

IT IS IMPORTANT TO NOTE that the above link does not provide complete instruction for editing the SQL script generated in the solution. You don't just need to remove sections related to setting up Jobs but any other calls to the "Master" database as well. Once modified, the script in this solution generated the necessary database object for managing session state on a shared SQL server. All that was required in this case was to set up a CRON job (which my hosting company makes easy to do) to run the clean-up procedures on a regular basis and everything is hunky-dory except...

Now when accessing the gallery after authentication, I get the following error (it should be noted that the gallery works fine when I'm not logged in).

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

Stack Trace:

[SerializationException: Type 'GalleryServerPro.Web.Entity.ProfileEntity' in Assembly 'GalleryServerPro.Web, Version=2.3.3848.40189, Culture=neutral, PublicKeyToken=null' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +7733643
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +258
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +111
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +161
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +51
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +410
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +134
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1577

[HttpException (0x80004005): Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1662
System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +34
System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +606
System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +239
System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length) +72
System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +116
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +560
System.Web.SessionState.SessionStateModule.OnEndRequest(Object source, EventArgs eventArgs) +160
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Roger Martin
#5 Posted : Wednesday, 8 September 2010 12:45:49 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Are you in a position to edit the source code? If so, you can try adding the Serializable attribute to the ProfileEntity class. I had to do this for the GalleryObjectMetadataItem class so you can take a look at it and see how it is done. That should take care of the current error, and hopefully there aren't any others lurking behind it.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Spotlight
#6 Posted : Wednesday, 8 September 2010 9:59:32 AM(UTC)
Rank: Member

Joined: 2/09/2010(UTC)
Posts: 4
Location: Green County Wisconsin

Thanks Roger, I had a feeling that I needed to serialize the class but wasn't sure how to go about it in C#. Having an example class to work from paved the way. Simply needed to add [Serializable] before the class declaration and a "using System;" line at the top of the page. Hope that's all I needed. Recompiled the source, updated the assemblies in my app, deployed and, low and behold, it's working. Fingers crossed that new issues don't arise (a likely story) and I'm back to the process of testing to see if storing session state in SQL Server really prevents people from being logged out of the application when the application recycles. I've been looking into how authentication works when session state is set to SQL server mode but for some reason the whole concept is like a ghost on the Internet or I'm just not looking in the right place. Can't tell if things like authentication tickets have any thing to do with session at all or how these two systems interact. I would greatly appreciate it if anyone who knows where a good resource on this can be found, could post it to this thread. As I say, right now things appear to be working better than when the site was running In Process (and maybe I shouldn't question success) but I'd sure like a better understanding of what's happening and how Session State affects asp.net authentication or doesn't. Again, thank you Roger for a great application and help with this issue.
Roger Martin
#7 Posted : Thursday, 9 September 2010 4:32:14 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,300
Location: Fort Atkinson, WI

Glad to hear you are making progress. Keep us updated. If it works, someone should write up a KB article.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Rss Feed  Atom Feed
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.