#1 2011-01-28 07:12:31

longge007
Member
Registered: 2010-06-22
Posts: 107

why the DB is locked

when i wirte realtime table into the Server by the Client side .and at the same time i want to open the DB with The SQLite Spy tool,sometimes the Error Message is Database is locked or NOt an Error.
i guess it is that i open the DB frequently?

Offline

#2 2011-01-28 07:47:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: why the DB is locked

The framework is not supposed to handle concurrent access to the same file.

It was designed with the presupposition of being the only one to access the db file.

SQliteSpy is locking the database during its access, therefore the DB access fails from the framework.
Or the contrary....

You can add a call to

aRestServerDB.DB.BusyTimeout := 2000;

to set a waiting time before returning an error...
But the use of the DB file is not meant to be accessible from an external tool during the framework run.
Think as SQLite as a database exchange format, and not as a concurrent access system.

Offline

#3 2013-06-03 20:59:37

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

Re: why the DB is locked

Hi,


If you need to use another tool to do the maintenance on the database, but you can't stop the mMORot server. What is the solution?

Offline

#4 2013-06-04 08:05:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: why the DB is locked

Do it within the mormot server.

Offline

#5 2013-06-04 11:43:42

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

Re: why the DB is locked

The problem is that i have an application using SQLite DB today.
And i would like to make the transition gradually...
So. The Sqlite DB would be accessed via REST and also in the traditional way.
Understand? TSQLDBSQLite3ConnectionProperties in legacy applications and TSQLHttpClient in the new model.

Could you show me where the blockage occurs in Sqlite DB? I searched but did not find or did not understand.

Offline

#6 2013-06-04 15:06:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: why the DB is locked

You can share the same TSQLDBSQLite3ConnectionProperties for both direct access and mORMot ORM, as external database.
Simply use TSQLDBSQLite3ConnectionProperties for external access at TSQLRestServer level.

No problem of locking any more.

Offline

#7 2013-06-04 15:28:27

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: why the DB is locked

But only one application (EXE with build if sqlite3.c) at time can access to SQLite file. This is a SQLite design.  There is not some kind of external "instance"(like Oracle listener)  what handle concurrency, blocking and so on from different application - all this function are compiled into your application. So if you try to use different tools to access one SQLite3 file at the same time this is the same as put 2 separate  instance of (for example) MS SQL to look on the one mdf file.

Last edited by mpv (2013-06-04 15:29:56)

Offline

#8 2013-06-04 15:37:32

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

Re: why the DB is locked

You are right.
I will follow this direction
Thank you

Offline

#9 2013-06-05 06:12:02

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: why the DB is locked

If you really need to access the db file from other processes (in read-only mode, e.g. only for query) in sync with mORMot process, you can set sqlite3 file in WAL mode.

Offline

Board footer

Powered by FluxBB