Error "The database file is locked" occurs when using htmlEdit

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
3/12/2011 12:20:33 AM
Gravatar
Total Posts 5

Error "The database file is locked" occurs when using htmlEdit

 I build from mojoportal-16317861f58a.zip with mojoportal-core.sln using option "Release Sqlite" and deploy it on a Windows server (.Net 4). Everything is fine when I add/delete/modify pages, but following error occurs when I modify one of the html content (actually the Welcome info) and try to update. I've tried creating another html content. However, it gives me the same error every time I use HtmlEdit.aspx to update. I've also tried to logout, close the browser and login again. Doesn't seem to help. BTW, it works well if I deploy it to my local machine.

-----------------------------------------------------------------------------------------------

The database file is locked
database is locked
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Mono.Data.Sqlite.SqliteException: The database file is locked
database is locked

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqliteException (0x80004005): The database file is locked
database is locked]
   Mono.Data.Sqlite.Sqlite3.Reset(SqliteStatement stmt) +359
   Mono.Data.Sqlite.Sqlite3.Step(SqliteStatement stmt) +195
   Mono.Data.Sqlite.SqliteCommand.ExecuteNonQuery() +63
   mojoPortal.Data.SqliteHelper.ExecuteNonQuery(IDbConnection connection, String commandText, IDataParameter[] parameters) +194
   mojoPortal.Data.SqliteHelper.ExecuteNonQuery(String connectionString, String commandText, IDataParameter[] parameters) +80
   mojoPortal.Data.DBPageSettings.UpdateTimestamp(Int32 pageId, DateTime lastModifiedUtc) +338
   mojoPortal.Business.PageSettings.UpdateLastModifiedTime() +49
   mojoPortal.Web.ContentUI.EditHtml.SaveHtml(Boolean draft) +1106
   mojoPortal.Web.ContentUI.EditHtml.btnUpdate_Click(Object sender, EventArgs e) +7
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

3/13/2011 11:06:41 AM
Gravatar
Total Posts 5

Re: Error "The database file is locked" occurs when using htmlEdit

For those who get the same problem, following is my current solution (not sure it is correct or not, but it works in my case).

I tracked the function private void SaveHtml(bool draft) in HtmlEdit.apx and when I finally get to ExecuteNonQuery(string connectionString, string commandText, params IDataParameter[] parameters ) in the class SqliteHelper, I found a connection has been opened before executing the sql command, but hasn't been closed after. So I just added one line to close it before return.

public static int ExecuteNonQuery(string connectionString, string commandText, params IDataParameter[] parameters )
  {
   using (SqliteConnection connection = new SqliteConnection(connectionString))
   {
                connection.Open();

                //********** lookwei's modified *******************
                int iReturn=ExecuteNonQuery(connection, commandText, parameters);
                connection.Close();
               //********** lookwei's modified *******************

                return iReturn;
   }
  }

 

 

3/13/2011 11:20:20 AM
Gravatar
Total Posts 18439

Re: Error "The database file is locked" occurs when using htmlEdit

That should not be needed. The using statement ensures the connection is closed when it goes out of scope because connection implements iDisposable and using forces it to dispose.

Nevertheless, that change should not hurt anything either, so if it solves your problem I can make the same change.

Best,

Joe

 

3/14/2011 4:44:56 AM
Gravatar
Total Posts 5

Re: Error "The database file is locked" occurs when using htmlEdit

Hi Joe,

You're right. But it seems that the change I've made is able to delay the error. Now I can update once after modification, but fail at the second time with the same error. I'm still checking which thread is occupying the database file.

 

Best,

Lookwei

You must sign in to post in the forums. This thread is closed to new posts.