in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Database file is locked in a multithreading scenario

Last post 07-29-2011 2:04 AM by tral. 19 replies.
Page 2 of 2 (20 items) < Previous 1 2
Sort Posts: Previous Next
  • 07-22-2008 6:17 AM In reply to

    Re: Database file is locked in a multithreading scenario

    Dear Robert,

    Sorry to have bugged you with my post. After further research I found two missing locks in my own code. My data access layer uses one static lock to ensure that only one thread can enter the critical region. With that lock it protects the regions where
    1) it opens a transaction,
    2) it executes a statement (calling ExecuteNonQuery for example), and
    3) it commits or rolls back a transaction.
    In regions 1 and 2 the class tests that no other thread has a transaction open.

    But I forgot to put the Open and Close of the connection in a critical region. Why it didn’t happen in the older versions is still a question to me. But I’m glad I’ve fixed.

    Thanks again for your .Net interface to sqlite.


    IJsbrand
  • 07-10-2009 9:15 AM In reply to

    • T Guds
    • Not Ranked
    • Joined on 07-10-2009
    • Posts 1

    Re: Database file is locked in a multithreading scenario

    Hi Robert:

    Is this issue fixed in the latest version?

    I am getting "the database file is locked" error instantly. I have changed the default timeout to 10 seconds but it appears that one thread which attempts to open the connection and begin the transaction does not even wait for 10 seconds before throwing the error - "the database file is locked". It throws the error immediately.

    Thanks

    TG 

     

     

  • 07-10-2009 9:35 AM In reply to

    Re: Database file is locked in a multithreading scenario

    Can you e-mail me a sample program that I can run to demonstrate the error?

     

  • 07-10-2009 2:03 PM In reply to

    Re: Database file is locked in a multithreading scenario

    e-mail to robert at blackcastlesoft dot com

    I would also benefit from having a complete stack trace

     

  • 07-29-2011 2:04 AM In reply to

    • tral
    • Not Ranked
    • Joined on 07-29-2011
    • Posts 1

    Re: Database file is locked in a multithreading scenario

    Hello,

    We are getting this error on 4 computers out of 200 currently installed all around the world (using version 1.0.66) .

     The stack looks like this:

    System.Data.SQLite.SQLiteException: The database file is locked
    database is locked
       w System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
       w System.Data.SQLite.SQLiteDataReader.NextResult()
       w System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
       w System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
       w System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
       w System.Data.SQLite.SQLiteTransaction.Commit()
       w NHibernate.Transaction.AdoTransaction.Commit()

    Error appears 30 second after application start. It is closing the application then :(

    Is there any possibility that we could get rid of this error?

     Thanks

Page 2 of 2 (20 items) < Previous 1 2
Powered by Community Server (Commercial Edition), by Telligent Systems