#1 2022-04-18 10:38:15

scutlemon
Member
Registered: 2022-04-18
Posts: 13

why cannot run the same SQLite on Linux at the same time

I use Delphi program to open SQLite database with TSQLRestServerDB. Lockingmode: = lmnormal. The compiler runs on Linux by fpc , such as :  fpc.exe -Tlinux -Px86_64 -MObjFPC -Scghi -Cg -O1 -l -vewnhibq -FiC:\e\SS2\SysDataManager\mymormot\lib\x86_64-linux -FiC:\lazarus32\ccr\mORMot -FiC:\lazarus32\ccr\mORMot\CrossPlatform -FiC:\lazarus32\ccr\mORMot\static\x86_64-linux -FiC:\e\ss\ziliao\synapse40\source\lib -FuC:\lazarus32\ccr\mORMot -FuC:\e\ss\IRSoft\souce\component -FuC:\lazarus32\ccr\mORMot\SQLite3 -FuC:\lazarus32\ccr\mORMot\static\x86_64-linux -FuC:\e\ss\ziliao\synapse40\synalist-code-r209-trunk\synalist-code-r209-trunk -FuC:\e\SS2\SysDataManager\mymormot\jiekou -FuC:\e\SS2\wavpubfunc -FuC:\e\SS2\SysDataManager\mymormot\ -FUC:\e\SS2\SysDataManager\mymormot\lib\x86_64-linux\ -FEC:\e\SS2\SysDataManager\mymormot\ -oC:\e\SS2\SysDataManager\mymormot\blackir blackir.lpr

When the second program is opened, an error is reported: esqlite3exception {"errorcode": 26, "sqlite3errorcode": "secnotadb", "message": "error sqlite_notadb (26) [dbopen] using 3.34.1 with ADB = nil"}.

But it is possible to run on windows.

What is the matter? How should it be solved?

Offline

#2 2022-04-18 20:36:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: why cannot run the same SQLite on Linux at the same time

Did you try the WAL mode?

In TSqlDataBase.DBOpen, we use unix-excl mode on POSIX, as requested by https://www.sqlite.org/vfs.html

Anyway, this is not a good idea to open the DB in normal mode. I usually only use exclusive mode, for best performance, and also enhanced security.
If you need to access the SQlite3 database concurrently, while it is used in a service, use the service API to access it, not the DB file.

Offline

#3 2022-04-19 01:30:02

scutlemon
Member
Registered: 2022-04-18
Posts: 13

Re: why cannot run the same SQLite on Linux at the same time

Thank you for your reply. After reading the document, I didn't find "WAL mode", but I saw standard UNIX vfses and saw that the opening method was "UNIX excl" in the source code. I changed it to "UNIX dotfile", and there is no lock database after recompiling and running.

My application has another node JS to run web access SQLite. But I still don't know how big the risk is and whether it is an appropriate plan.
If don't lock the database, which way is safer?
Thanks .

Offline

#4 2022-04-19 07:12:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: why cannot run the same SQLite on Linux at the same time

Let the node JS call a mORMot service on the host: it would be faster, and also more maintainable (you could move Node and mORmot servers in two diverse VM for instance).
Why using the mORMot service to access the database would also be faster? Because the DB would be open in memory, with proper caching, and more efficient JSON creation.
Note also that enabling multi-process opening slows down the DB process a lot, on both sides (mORMot and Node).

Letting other process access the SQLite3 file is unsafe by design, because a security flow in Node could alter the data for instance.
It is also a design/architecture flaw. It would spread the logic in both JS and pascal code, which means more maintenance for no benefit.

Offline

#5 2022-04-19 11:47:06

scutlemon
Member
Registered: 2022-04-18
Posts: 13

Re: why cannot run the same SQLite on Linux at the same time

Thank you for your suggestion.  Our final plan is consistent with what you said.
Thank you very much.
smile

Offline

Board footer

Powered by FluxBB