Lurker News
I periodically hear about projects that use/have used sqlite as their sole datastore. The theory seems to be is that you can test out an idea with fewer dependencies (and cost) and that it scales surprisingly far.

There are even distributed versions being built for reliability in the cloud: dqlite by canonical (of Ubuntu fame) and rqlite
Given the complexity it seems like there are use cases or needs here that I'm not seeing and I'd be very interested to know more from those who've tried.
Have you tried this? Did it go well? Or blow up? Were there big surprises along the way?
- https://sqlite.org - https://dqlite.io - https://github.com/rqlite/rqlite

Comments (325) 124 threads

Show all comments

Showing thread 119 of 124

zoomablemind1 reply#
> ...I periodically hear about projects that use/have used sqlite as their sole datastore.

SQLite==exclusive access, no sharing, unless read-only.
Basically, it provides a SQL convenience for local usage.

sicp-enjoyer2 replies#
If you need to safely have multiple processes read and write to the same data, it does that great. The writes are serialized, but that's typically how an in-memory shared resource would be implemented as well.

Do you mean shared across networks?

chasil#
I have seen SQLite disconnect random sessions of multiple writers, rather than blocking them. Setting WAL mode made no difference.

This database can safely be used by a single writer at all times.
To implement the serialization that SQLite does not, do this in the POSIX shell:

  until mkdir ~/.dpapplock 2> /dev/null
  do sleep 3
  done

  trap "rmdir ~/.dbapplock" EXIT
  sqlite3_app ...
The mkdir() system call is defined as atomic by POSIX, so the shell can safely serialize for you, assuming there are never more than a handful.
zoomablemind1 reply#
My understanding is that SQLite suppprts only system locks. So multiple writers will need to be either blocking on system level or implement some other form of locking to ensure integrity.

A great deal of complexity of DBMS is in granularity of locks, its escalation/deescalation, and shared use performance.
I wonder if one day SQLite would support synchronization/replication protocol. In a way Fossil SCM is an attempt at SQLite replication, albeit a specialized one.

sicp-enjoyer#
> A great deal of complexity of DBMS is in granularity of locks, its escalation/deescalation, and shared use performance.

Agreed.
> My understanding is that SQLite suppprts only system locks
Is this any different than a process blocking on a mutex while another writes to a shared resource? I understand DBMS do it better, but I don't see why it's viewed as a non-starter for SQLite.