When move page lead Sqlitedb deadlock.

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.
5/19/2008 9:31:23 AM
Gravatar
Total Posts 59

When move page lead Sqlitedb deadlock.

Hi, Joe:

     When I move page up or  down in  PageTree.aspx with sqlitedb,  deadlock occurs:

Below code is in PageSettings.cs:

//////////////////////////////////////////////////////////////////////////////////////////////////

public void ResortPages()
{
int i = 1;
IDataReader reader = this.GetChildPages();
while(reader.Read())  //you have open the Sqltedb file mojoportal.db,
{
int pageID = Convert.ToInt32(reader["PageID"]);
PageSettings.UpdatePageOrder(pageID, i); //Want Open the file mojoportal.db again? no ,you can't except you close it first. it will deadlock here
i += 2;
}

reader.Close();
}

////////////////////////////////////////////////////////////////////////////////////////////

Above code is not right for Sqlitedb, Because Sqlitedb is a file database, It can't be open twice.

The Above code can be changed as below:

///////////////////////////////////////////////////////////////////////

public void ResortPages()
{
int i = 1;
IDataReader reader = this.GetChildPages(); //Open the sqlitedb file;

System.Collections.Generic.List<int> cp = new System.Collections.Generic.List<int>();

while(reader.Read())
{
cp.Add(Convert.ToInt32(reader["PageID"]));
}

reader.Close(); //Close the sqlitedb file;

foreach (int item in cp)
{
PageSettings.UpdatePageOrder(item, i); //After above close, then I can Open the sqltedb file again.
i += 2;
}


}

///////////////////////////////////////////////////////////////////////

So, Can't treat Sqlitedb  as msql or mysql  entirely the same, Maybe Other place has the same problem.

 

Thanks!

 

5/19/2008 2:48:21 PM
Gravatar
Total Posts 18439

Re: When move page lead Sqlitedb deadlock.

Hi,

I have a fix for this thats a litle different than your solution. I switched to using a DataTable instead of IDataReader so no connection is held open during the loop.

public void ResortPages()
{
int i = 1;
DataTable table = GetChildPageIds();

foreach(DataRow row in table.Rows)
{
int pageID = Convert.ToInt32(row["PageID"]);
PageSettings.UpdatePageOrder(pageID, i);
i += 2;
}
}

This will be in svn trunk later today.

I am glad you are working with the Sqlite version and flushing out the bugs. It is not as well tested as MS SQL or MySql because I don't run any production sites using SQLite. Your help in finding these issues is much appreciated.

Best,

Joe

 

5/19/2008 7:59:18 PM
Gravatar
Total Posts 59

Re: When move page lead Sqlitedb deadlock.

Hi, Joe

    Your solution is more elegant, it's great.

Thanks!

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