SQlite/Firebird: Does any of them support multiple concurrent write access?

老子叫甜甜 提交于 2020-01-02 06:57:31

问题


Question: I currently store ASP.net application data in XML files.

Now the problem is I have asynchronous operations, which means I ran into the problem of simultanous write access on a XML file...

Now, I'm considering moving to an embedded database to solve the issue. I'm currently considering SQlite and embeddable Firebird.

I'm not sure however if SQlite or Firebird can handle multiple concurrent write access.
And I certainly don't want the same problem again.
Anybody knows ?
SQlite certainly is better known, but which one is better - SQlite or Firebird ? I tend to say Firebird, but I don't really know.

No MS-Access or MS-SQL-express recommodations please, I'm a sane person.


回答1:


I wll choose Firebird for many reasons and for this too

Although it is transactional, SQLite does not support concurrent transactions, so if your embedded application needs two or more connections, they must be serialized. An embedded Firebird database is simple to upgrade to a fully shared database - just change the shared library.

May be you can also check this




回答2:


SQLITE can be configured to gracefully handle simultaneous writes in most situations. What happens is that when one thread or process begins a write to the db, the file is locked. When the second write is attempted, and encounters the lock, it backs off for a short period before attempting the write again, until it succeeds or times out. The timeout is configurable, but otherwise all this happens without the application code having to do anything special except enabling the option, like this:

// set SQLite to wait and retry for up to 100ms if database locked
sqlite3_busy_timeout( db, 100 );

All this works very well and without any difficulty, except in two circumstances:

  1. If an application does a great many writes, say a thousand inserts, all in one transaction, then the database will be locked up for a significant period and can cause problems for any other application attempting to write. The solution is to break up such large writes into seperate transactions, so other applications can get access to the database.

  2. If the database is shared by different processes running on different machines, sharing a network mounted disk. Many operating systems have bugs in network mounted disks that making file locking unreliable. There is no answer to this. If you need to share a db on a network mounted disk, you need another database engine such as MySQL.

I do not have any experience with Firebird. I have used SQLITE in situations like this for many applications over several years.




回答3:


Have you looked into Berkeley DB with the SQLite API for SQL support?




回答4:


It sounds like SQLite will be a good fit. We use SQLite in a number of production apps, it supports, actually, it prefers transactions which go a long way to handling concurrency.

transactional sqlite? in C#




回答5:


I would add #3 to the list from ravenspoint above: if you have a large call-center or order-processing center, say, where dozens of people might be hitting the SAVE button at the same time, even if each is updating or inserting just one record, you can run into problems using the busy timeout approach.

For scenario #3, a true SQL engine that can serialize is ideal; less ideal but serviceable is a dbms that can do byte-range record locking of a shared-file. But be aware that even a byte-range record lock will be inadequate for a large number of concurrent writes when new records are appended to the end of the file like a caboose on the end of a freight train, so that multiple processes are trying at the same time to set a lock on the same byte-range. On the other hand, a byte-range record locking scheme coupled with a hashed-key sparse file approach (e.g. the old Revelation/OpenInsight database for LANs) will be far superior to ISAM for this scenario.



来源:https://stackoverflow.com/questions/2863595/sqlite-firebird-does-any-of-them-support-multiple-concurrent-write-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!