Installation and deployment Questions on installation, system configuration and deployment to the live server.
Version 5.x > Installation and deployment > Site export fails on CMS_MetaFile, "An expression services limit has been reached" View modes: 
User avatar
Member
Member
laurence-ecentricarts - 12/14/2011 9:03:30 PM
   
Site export fails on CMS_MetaFile, "An expression services limit has been reached"
I am trying to do a site export on a staging server in order to import on a freshly set-up production server, Kentico v5.5.4311 R2.

In CMS Site Manager > Export Site, I use "Preselect all objects" in order to get the existing site.

When I complete the steps the export fails. Event log provides this detail:

-----
Message: [DataConnection.ExecuteQuery]: Query: SELECT MetaFileID, MetaFileObjectID, MetaFileObjectType, MetaFileGroupName, MetaFileName, MetaFileExtension, MetaFileSize, MetaFileMimeType, MetaFileImageWidth, MetaFileImageHeight, MetaFileGUID, MetaFileLastModified, MetaFileSiteID FROM CMS_MetaFile WHERE ((MetaFileObjectType = 'cms.workflowhistory')) AND (MetaFileObjectID IN (23, [LONG LIST OF IDS HERE], 37875)) : caused exception: Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.
Stack Trace:
at CMS.CMSImportExport.ExportProvider.ExportObjectsData(SiteExportSettings settings)
at CMS.CMSImportExport.ExportManager.Export(Object parameter)
-----

The CMS_MetaFile table has only 463 rows but there are over 34,000 IDs in the list in the WHERE clause. I don't know where they come from -- the site just is not that large! Versioning and workflow are in use for a content subtree with several hundred small document types -- could the version entries be exploding the WHERE clause somehow?

I have seen forum postings where the Kentico database has 55000 users (http://devnet.kentico.com/Forums.aspx?forumid=52&threadid=24025) but my site has only a few dozen.

I have been trying also to transfer the database directly with backup/restore, the MS SQL "Copy Database Wizard", even exporting a 200 MB SQL script to copy all the data row-by-row in SQL Management Studio but all these attempts have failed for a variety of reasons (different SQL Server versions, memory errors, foreign key constraints on the Kentico tables and many other issues).

What can I do to accomplish the transfer of my staging site to production?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/15/2011 8:06:46 AM
   
RE:Site export fails on CMS_MetaFile, "An expression services limit has been reached"
Hi,

This issue has a workaround in the version 6.0, if you upgrade the site, the export should work correctly. I am sorry for this inconvenience.

Here is a one hack which could help in your version. In the file global.asax.cs is a method FirstRequestInitialization. If you add a bold line to its code as shown below, the export may be successful. But as I said before, the safest way is to upgrade your site to 6.0 version.

/// <summary>
/// Performs the application initialization on the first request
/// </summary>
private void FirstRequestInitialization(object sender, EventArgs e)
{
if (ApplicationInitialized)
{
return;
}

// Initialize application in a locked context
lock (mLock)
{
if (ApplicationInitialized)
{
return;
}

// Remember date and time of the application start
mApplicationStart = DateTime.Now;

mWindowsIdentity = WindowsIdentity.GetCurrent();

ViewModeOnDemand viewMode = new ViewModeOnDemand();

// Log application start
if (CMSFunctions.AnyDebugEnabled)
{
RequestSettings settings = RequestSettings.Current;
bool liveSite = (viewMode.Value == ViewModeEnum.LiveSite);

settings.DebugRequest = RequestHelper.DebugRequests && liveSite;
RequestHelper.LogRequestOperation("BeforeApplicationStart", null, 0);

settings.DebugSQLQueries = SqlHelperClass.DebugQueries && liveSite;
settings.DebugCache = CacheHelper.DebugCache && liveSite;
settings.DebugSecurity = SecurityHelper.DebugSecurity && liveSite;
settings.DebugMacros = MacroResolver.DebugMacros && liveSite;
settings.DebugWebFarm = WebSyncHelperClass.DebugWebFarm && liveSite;

DebugHelper.SetContext("App_Start");
}

CMSApplication.BeforeAplicationStart(sender, e);
CMSCustom.Init();

//ConnectionHelper.UseContextConnection = true;
//CacheHelper.CacheItemPriority = System.Web.Caching.CacheItemPriority.NotRemovable;
if (SqlHelperClass.IsConnectionStringInitialized)
{
using (CMSConnectionScope scope = new CMSConnectionScope())
{
// Use single open connection for the application start
GeneralConnection conn = (GeneralConnection)scope.Connection;
bool closeConnection = true;
try
{
// Open the connection
conn.Open();
closeConnection = true;

// Initialize the environment
CMSFunctions.Init();

// Update the system !! IMPORTANT - must be first
UpgradeProcedure.Update(conn);

try
{
// Write "Application start" event to the event log
EventLogProvider ev = new EventLogProvider(conn);

ev.DeleteOlderLogs = false;
ev.LogEvent("I", DateTime.Now, "Application_Start", "STARTAPP", 0, null, 0, "", null, "", 0, HTTPHelper.GetAbsoluteUri());
}
catch
{
// can't write to log, do not process any code
}

// Delete memory synchronization tasks
WebSyncHelper.DeleteMemorySynchronizationTasks();

// Wait until initialization is complete
CMSFunctions.WaitForInitialization();
}
finally
{
// Close the connection
if (closeConnection)
{
conn.Close();
}
}
}
}
else
{
// Register virtual path provider
if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSUseVirtualPathProvider"], true))
{
CMS.VirtualPathHelper.VirtualPathHelper.RegisterVirtualPathProvider();
}
}

CMSApplication.AfterApplicationStart(sender, e);
DebugHelper.ReleaseContext();

// Log when the overall application start finished its execution
mApplicationStartFinished = DateTime.Now;
mApplicationInitialized = true;

// Set that document aliases don't have metafiles
DocumentAliasInfo.TYPEINFO.HasMetaFiles = false;



RequestHelper.LogRequestOperation("AfterApplicationStart", null, 0);
}
}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
laurence-ecentricarts - 12/15/2011 9:07:58 AM
   
RE:Site export fails on CMS_MetaFile, "An expression services limit has been reached"
Thanks Ivana, I will try that workaround right away.

For business reasons, we cannot upgrade the customer to v6.0 at this time -- too bad, I hear many great things about it.

-- Laurence

User avatar
Member
Member
laurence-ecentricarts - 12/15/2011 11:12:25 AM
   
RE:Site export fails on CMS_MetaFile, "An expression services limit has been reached"
Hi again, Ivana.

I made the change on a copy of the site and export failed the same way in the same place.

By the way, I needed to qualify DocumentAliasInfo since CMS.TreeEngine was not in the "Using" block in Global.asax.cs:
// Set that document aliases don't have metafiles
CMS.TreeEngine.DocumentAliasInfo.TYPEINFO.HasMetaFiles = false;


The Export progress window content at time of failure is this:
-----
Error has occurred during export process.
Exporting 'Workflow histories' objects
Exporting 'Attachment histories' objects
Exporting 'Version histories' objects
Exporting 'Document relationships' objects
Copying 'Attachment' files
Exporting 'Attachment' objects
Exporting 'ACLs' objects
Exporting 'Documents' objects
Exporting BizForm 'test' data
Exporting BizForm 'CREIT Careers Application Form' data
Exporting BizForm 'Creit Availability Emails' data
Exporting 'BizForms' objects
Copying 'Reports' metafiles
Exporting 'Reports' objects
Exporting media library 'CREIT Media Library' file objects
Exporting 'Media libraries' objects
Exporting 'Bad words' objects
Exporting 'Notification gateways' objects
Exporting 'Notification templates' objects
Exporting 'Project status' objects
Exporting 'Task priority' objects
Exporting 'Task status' objects
Exporting 'Smart search indexes' objects
-----

The last line processed was "Exporting Workflow histories", which makes me think there are too many records in CMS_WorkflowHistory. It has about 34000 records and there are about 34000 IDs in the list in the WHERE clause. That might mean something.

To shorten that list, I have reduced the number of version history entries from 20 to 5 for the copy of my site, in Site Manager / Settings / Content Management. This doesn't purge any existing version history records until the next time a document is saved, so I will write some code to crawl the CMS tree and re-save each workflow-managed document (I already have code that does something similar).

Any other ideas out there, while I try this?

User avatar
Member
Member
laurence-ecentricarts - 12/15/2011 1:38:19 PM
   
RE:Site export fails on CMS_MetaFile, "An expression services limit has been reached"
OK, I reduce the max. number of version history entries and used my content-updating code to update the versioned document types in the CMS Tree. The CMS_WorkflowHistory table went from approx 34000 to 22000 rows, and the CMS_VersionHiistory went from approx 17000 to 12700 rows.

When I do the site export now it gets further than before, with no SQL error, but no ZIP file is created. The progress text ends with this message:
Application has been restarted and the logging of the export process has been terminated. Please make sure that the export package has been created.

I found files in ~/AppData/CMSTemp/ImportExport/Data that seem to be a partial export.

I also tried an export with everything selected, then unchecked the box in the tree for All objects / Web Site / Documents "Export document histories", but kept everything else checked. That export worked! The ZIP file was created, and has more files in it compared to the temp files from the first try.

Using the ZIP that omits document histories, I'll try to transfer the site -- it would be better to preserve the histories but it's more important to get the site into production.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/27/2011 1:41:11 AM
   
RE:Site export fails on CMS_MetaFile, "An expression services limit has been reached"
Hi,

the time limit error may be related to your IIS configuration. If you need a backup with a version history, please take a look here:
http://devnet.kentico.com/Forums.aspx?forumid=52&threadid=21314

Best regards,
Ivana Tomanickova

User avatar
Member
Member
laurence-ecentricarts - 12/27/2011 3:01:10 PM
   
RE:Site export fails on CMS_MetaFile, "An expression services limit has been reached"
Thanks, Ivana -- I will try temporarily switching the Application Pool from Integrated to Classic pipeline on the site I export from and see whether that lets me make a zip file which includes the version history.

Our shop is on holiday hours this week, so I will do this first thing back to work in January.

-- Laurence