Kentico Upgrade Error

Suman Layek asked on May 9, 2019 23:26

Hello Kentico Team,

Recently we are trying to upgrade our multi site Kentico application and database from version 9 to version 12. Within the process of upgrade we are experiencing some issues

Before start with issues required information about the project:-

  1. Current Kentico Version: - 9.0.50
  2. Custom coding - None (Note a single line custom code implemented. All site using portal engine)
  3. Project type - Web Application (CMSApp.sln)
  4. Requirement - Upgrade to Kentico 10.0.0 (later 11, 12 accordingly)

We are doing the upgrade with steps mentioned in Upgrading to Kentico 10 documentation. As we do not have any custom coding we are skipping the Custom code analysis and Upgrading custom code step. Every steps with default options (not using Switch to advanced mode) going without any issues with Kentico Upgrade Utility tool except the last step. On last step we are getting an error message as shown in below screenshot

Image Text

We opened the log file to understand the issue in detail. The error part of the log.txt is below

SQL script applied.
90% of SQL script applied.
80% of SQL script applied.
70% of SQL script applied.
60% of SQL script applied.
50% of SQL script applied.
40% of SQL script applied.
30% of SQL script applied.
20% of SQL script applied.
10% of SQL script applied.
IF NOT EXISTS
(
    SELECT 1
    FROM [CMS_SettingsKey]
    WHERE KeyName IN ('CMSDataVersion', 'CMSDBVersion')
    HAVING MAX(KeyValue) = MIN(KeyValue)
)
BEGIN
    RAISERROR('The database has been upgraded from a previous version, but the process is incomplete. Before applying further upgrades, you need to open the related site in a browser and wait until the first request finishes.', 18, 1)
END

Failed to run SQLscript: 
[DataConnection.HandleError]: 

Query: 
IF NOT EXISTS
(
    SELECT 1
    FROM [CMS_SettingsKey]
    WHERE KeyName IN ('CMSDataVersion', 'CMSDBVersion')
    HAVING MAX(KeyValue) = MIN(KeyValue)
)
BEGIN
    RAISERROR('The database has been upgraded from a previous version, but the process is incomplete. Before applying further upgrades, you need to open the related site in a browser and wait until the first request finishes.', 18, 1)
END


Caused exception: 
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)

Message: 
[DataConnection.HandleError]: 

Query: 
IF NOT EXISTS
(
    SELECT 1
    FROM [CMS_SettingsKey]
    WHERE KeyName IN ('CMSDataVersion', 'CMSDBVersion')
    HAVING MAX(KeyValue) = MIN(KeyValue)
)
BEGIN
    RAISERROR('The database has been upgraded from a previous version, but the process is incomplete. Before applying further upgrades, you need to open the related site in a browser and wait until the first request finishes.', 18, 1)
END


Caused exception: 
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)

Stack Trace: 
   at CMS.DataEngine.AbstractDataConnection.HandleError(String queryText, Exception ex)
   at CMS.DataEngine.AbstractDataConnection.ExecuteNonQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
   at Hotfix.Installer.HotfixHelper.RunSQLCommand(String text, IDataConnection connection)
   at Hotfix.Installer.HotfixHelper.RunSQLScript(String fileName, String connString, String defaultUICulture, IMessageLog messageLog)
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
   at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
   at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at CMS.DataEngine.AbstractDataConnection.ExecuteNonQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
The semaphore timeout period has expired


Running SQL script (upgrade.sql)
DLLs\Net45\App
DLLs\Net45\Azure
DLLs\Net45\Azure

We would like to know why we are getting the above mentioned issue with default Kentico setup. From the log file content it is clear that the database has been upgraded successfully but the whole process isn't complete yet. As per documentation information

  • On web application projects, the upgrade utility rebuilds the solution at the end of the upgrade by default. ---- Maybe our upgrade process occurring the error before starting this process.
  • If your project contains custom code that is no longer supported in Kentico 10, or has certain modules uninstalled, the rebuild will not be successful. ---- There is no custom code implemented within this application.
  • You can disable the Rebuild web project option on customized projects, and perform the rebuild manually once you update the project after the upgrade." ---- We haven't disabled the Rebuild option as this is not customized project. However, the manually rebuild process completing successfully.

Acceptance :-

As we have told you that we can rebuild the Web Application manually without any issues and as per documentation we are opening the website to verify and making it ready for next upgrade. Interestingly the website loads correctly finally. After this we again upgraded it to Version 11.0.0 but even this time the same issue occurred at the last step on Kentico Upgrade Utility.

For each version, you always need to open the upgraded website in a browser before starting the upgrade for the next version and verify that the site loads correctly. During the first request after the upgrade, the system performs certain tasks required to finish the upgrade, including the import of new objects.

Question and concerns :-

  1. Why this issue is arising when we are using default upgrade procedure ?
  2. How can we understand if the upgrade is successful and complete ? (To us merely the site is running finally not acceptable as some module upgrade can be incomplete)
  3. Withing error list "The semaphore timeout period has expired" is also exists. If this is the case then how much time limit for SQL Server will be sufficient for this process ?
  4. With the current upgrade scenario how to make sure the current running application is guaranteed future upgrades and hotfixes compatible ?

Recent Answers


Brenden Kehren answered on May 9, 2019 23:54

You must not have followed the instructions properly. The instructions state (abbreviated):

  1. Run the upgrade tool against the code which is connected to the database.
  2. Run the site after the upgrade
  3. Check the event log for "upgrade start" and "upgrade finish" event logs.

To go into detail more, if your site times out when running the first time after the code and database upgrade, then do these 2 things:

  • When running your site for the first time after the upgrade to a new version, navigate to the "/admin" URL vs. the root of the site. This will help to get things going faster as it doesn't have to process all the internals of Kentico to get up and running.
  • Set the timeout on your connection string to something like 600 seconds.

These 2 things should help you with your multi-version upgrade. One last thing, you can run the below query to check the versions stored in the database after you've run the KIM tool and after the site has successfully loaded.

SELECT *
FROM CMS_SettingsKey
WHERE KeyName = 'CMSDataVersion' OR
KeyName = 'CMSDBVersion' OR
KeyName = 'CMSHotfixVersion'
2 votesVote for this answer Mark as a Correct answer

Suman Layek answered on May 17, 2019 18:13

Hello Brenden,

Thank you for your quick reply. I admire and following you since long back when I started working on Kentico CMS. I have been woking in Kentico CMS since version 5.5 R2.I find your answers knowledgeable, helpful and those resolved many issues for me most of the time. Through this post I would like to inform you that the issue isn't resolved this time and finally I posted the issue to Kentico Support as our client team is concerned about this issue.

I followed your instruction thoroughly and found the below

Run the upgrade tool against the code which is connected to the database :- Yes, I am running the code from the correct physical files location. Before your suggestion I was running the Upgrade tool from C:/Projects/Redo/Kentico9/(The folder where WebApp.sln, CMS and Lib folder resides) then I directly tried C:/Projects/Redo/Kentico9/CMS folder. In both the cases I end up with same error every time.

Image Text

Run the site after the upgrade :- As I told you earlier the site is running on browser after upgrade without any issues. I tried https://localhost/Redo/Admin to launch the site faster. I checked the Event Log module in Admin to check Upgrade Start and Upgrade Finish event. Everything here also seems good as in-between this Events no error was recorded.

Image Text

Setting connection timeout on connection string :- When I opened the connection string the timeout was set to 60 but I increased it more to 120. This to note here is the upgrade tool not even taking 30 second to show the error. So, it should not be the connection timeout issue. On SQL Server there is one more timeout available and that is Command Timeout. I can't change that through Web.config as it's a Global setting in SQL server.

Checking version using given SQL :- I have checked and found that after running the Upgarde Tool the following is showing before I run the website in browser . Below is query results while upgrading

Before running Upgrade Tool:- Image Text

After running the Upgrade tool (Upgraded but site not launched in browser yet):- Image Text

After runnung the site on Browser:- Image Text

From the above we can say that the site upgraded successfully but I can't overlook the concern of our client regarding the future upgrade or development issue probability on the same site.

I have upgraded many sites before but this time the issue is occurring unexpectedly. May be this time getting this issue as because trying to do the upgrade from 9.0.50 to 10.0 (Earlier 9.0 to 10.0 upgrade for another site was without any issues). Let's see what's Kentico support suggesting on this. I will keep this post updated if I find a solution to this.

0 votesVote for this answer Mark as a Correct answer

Suman Layek answered on May 20, 2019 16:54

We have got an answer from Kentico support Team on above issue (Hope this will help someone with similar issue)

If only this query failed and nothing else (from the log it seems that only this query failed), that means that this part of the upgrade was fully completed. All this query does is to display a warning that you have to run the website for finish the data upgrade.

If you even saw the the Upgrade finish event in the Event log, you don't need to repeat the upgrade process as everything was upgraded correctly and this error should not cause any issues in the future.

However, it's still strange why you are getting this connection error. Most likely you have some unusual SQL Server connection configuration, or there is a firewall between the Kentico server and the SQL server which blocked the first connection. In similar cases, we usually recommend a manual upgrade (manually executing the SQL script in SQL Server Management Studio).

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 20, 2019 17:02

Typically we set the timeout for the connection string to 600+ seconds, vs 60 or 120. On most sites, 120 seconds isn't enough to get things updated for an upgrade.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.