Changing Themes Freezes

Topics: Customizing Orchard, Troubleshooting, Writing themes
Nov 17, 2014 at 6:18 AM
I am running a orchard site from WebMatrix. I go into the dashboard and then try to select a different theme by clicking "Set Current" but the theme takes an hour to load. The last time I was able to change themes I was changing from my own custom theme to the theme machine.

It seems like the theme load times have been getting longer and longer. A weeks ago it was just 20 minutes. Now it is over an hour.

I have another test instance of orchard and the same thing is happening their too. As I was installing new themes and demoing them the load times seem to get longer and longer until it get to a point that the "Set Current" operation just never seems to finish. I had about 10-12 themes installed but removed most of them but it still doesn't help.

Where could the Orchard sites be getting hung up? Is there something I can clear out?
Developer
Nov 17, 2014 at 8:55 AM
I just tried, installed a new Orchard site using WebMatrix. I downloaded 5 themes. Enabling them one after the other only takes 1 second per theme on my local machine.
Are you seeing this problem on your local machine? What about other machines, did you try?
Nov 18, 2014 at 7:26 AM
I copied the orchard project to another windows environment and got the same results. I tried uninstalling some modules but loading and disabling modules is very slow as well so I didn't get very far. I also started a new Orchard site on the same pc and downloaded several themes. The new orchard project is responsive and is changing themes quickly. It does seem as if the project itself has a problem and it isn't a machine problem. I just don't know what actions or events brought caused this.
Developer
Nov 18, 2014 at 7:46 AM
Is there anything in the log files (in App_Data/Logs) that might give you a clue?
Nov 19, 2014 at 7:09 AM
Edited Nov 19, 2014 at 7:11 AM
Seems it sometimes does write to the log file. Maybe it depends on if the change template completes or times out. If it completes and doesn't time out there is nothing in the log file but I'm not sure yet. Here is a only a part of the last log file that has something in it but I don't know what to make of it. Why is there a reference to :c:\Users\sebros\Documents\My Projects...."

2014-11-17 22:35:15,106 [15] NHibernate.AdoNet.AbstractBatcher - (null) - Could not execute command: INSERT INTO Settings_ShellFeatureRecord (Name, ShellDescriptorRecord_id) VALUES (@p0, @p1)
 (null)
System.Data.SqlServerCe.SqlCeLockTimeoutException (0x80004005): SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 2,Thread id = 2132,Process id = 1372,Table name = Settings_ShellFeatureRecord,Conflict type = ix lock (x blocks),Resource = TAB ]
   at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\AbstractBatcher.cs:line 197
2014-11-17 22:35:15,902 [15] NHibernate.Util.ADOExceptionReporter - (null) - SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 2,Thread id = 2132,Process id = 1372,Table name = Settings_ShellFeatureRecord,Conflict type = ix lock (x blocks),Resource = TAB ]
 (null)
2014-11-17 22:35:15,918 [15] Orchard.Exceptions.DefaultExceptionPolicy - Default - An unexpected exception was caught
 http://localhost:7997/Admin/Themes/Activate
NHibernate.Exceptions.GenericADOException: could not insert: [Orchard.Core.Settings.Descriptor.Records.ShellFeatureRecord][SQL: INSERT INTO Settings_ShellFeatureRecord (Name, ShellDescriptorRecord_id) VALUES (?, ?)] ---> System.Data.SqlServerCe.SqlCeLockTimeoutException: SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 2,Thread id = 2132,Process id = 1372,Table name = Settings_ShellFeatureRecord,Conflict type = ix lock (x blocks),Resource = TAB ]
   at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
   at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\AbstractBatcher.cs:line 203
   at NHibernate.Id.Insert.AbstractSelectingDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Id\Insert\AbstractSelectingDelegate.cs:line 38
   --- End of inner exception stack trace ---
   at NHibernate.Id.Insert.AbstractSelectingDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Id\Insert\AbstractSelectingDelegate.cs:line 47
   at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2575
   at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 3035
Developer
Nov 19, 2014 at 7:28 PM
That log excerpt doesn't help unfortunately.
I suggest you start taking out the third party modules one by one and see at which point it starts working (rename Module.txt for each module to something like _Module.txt).
Alternatively, start with a new working Orchard instance, and start adding back the features you need, and see at which point it starts to cause this problem.

You can ignore the reference to "c:\Users\sebros\Documents\My Projects...." - this is simply the local path of the developer that compiled the assembly that is being referenced.
Nov 24, 2014 at 6:38 AM
Since I have a two instances of Orchard 1.8.1 that have the same problem I took my test instance that had very little in it to begin with and removed all 3rd party modules and all themes except for theme machine. I even removed some test content items and projections and anything that I could think of that I had created or enabled such as Lucene, indexing, and search. Still no improvement. The modules page takes minutes to load. After deleting all of the themes the default theme came up and then switching to the theme to the "theme machine" must have taken over half an hour because I walked away and when I came back hours later the page had timed out. After restarting the Orchard site with web matrix the theme was switched. The Log File is empty.

I did try to start a new orchard site and install everything I thought had been installed but I couldn't break the site. The sites that are broken were both started in August so I cant remember everything that was done to them.

Is there anything else I can test? Seems like my test site should have anything removed that did not come with the original installation. When I run my development site from the source code in visual studio I get the same slowness. Is there something I can look for in the debugger?
Developer
Nov 24, 2014 at 9:14 AM
Can you try and delete the App_Data folder of the stripped down installation, and go through setup and see if you can reproduce then?
You could set a breakpoint in the controller of the themes module where it starts switching the theme I suppose. Make sure you configure the debugger to break on exceptions as they are thrown, even when there is a try/catch block up the stack.

In any case, this doesn't seem to be a problem with orchard itself, as I've never heard about it or experienced it myself.
If you like you can zip up the entire solution (do get rid of the binary output), upload it somewhere, and create a ticket on OrchardPros.net so we have a look, as I am very curious myself. Include the database if its required to reproduce the issue.
Nov 26, 2014 at 7:32 AM
Thanks for the help and advice...
When I delete/rename the app_data folder and also create a new Orchard db in sql express the site works. If I change the connection string to use the original database the site slows down like before and changing themes or disabling modules from the dashboard becomes impossible. With the new database everything is quick and responsive.

There is one 3rd party module (Amba.ImagePowerTools) that I suspect could be the cause of the problem but I cant prove it. It appeared to be working fine but when I tried to compile it I saw that it was using .net 4.0. and had references to orchard.media. I updated the module to .net 4.5 and removed the unnecessary references to orchard.media and recompiled. It didn't change anything. Could the fact that that component was "out of date" been the source of the problem?

I would like to figure out how this happened. It is concerning to me that the project became practically unmanageable while still being very small.
Dec 5, 2014 at 6:18 AM
Edited Dec 5, 2014 at 6:18 AM
I was never able to figure out what the problem was. I have posted my source code and database and created a ticket on orchardpros.net http://www.orchardpros.net/tickets/4683
Dec 12, 2014 at 5:32 AM
This issue turned out to be a bug. Here is a proposed solution https://orchard.codeplex.com/workitem/21111
Marked as answer by praktit on 12/11/2014 at 9:33 PM