penberg / limbo

Limbo is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
MIT License
999 stars 61 forks source link

Limbo acquires database file lock by default #302

Closed seonWKim closed 2 months ago

seonWKim commented 2 months ago

Question

Should we change current implementation of acquiring of lock when opening the database file?

Limbo implementation vs SQLite implementation

The impelmentations of IO's open_file acquires the database file lock by default. As a result, we are not able to open multiple connections like below

image

The current implementation of SQLite seems to not acquire lock while opening the DB(It seems to acquire the database lock on non-SELECT transactions etc)

image

Reference (SQLite Database System Design and Implementation (2nd Edition))

image

penberg commented 2 months ago

@seonWKim We picked PRAGMA locking_mode = EXCLUSIVE as the default because it's the fastest one. With NORMAL (i guess same as NOLOCK there), the problem is that every transaction has to do a fcntl(), which is a round-trip to the kernel...

seonWKim commented 2 months ago

Oh I see. Will future implementation of transactions in limbo would not use fcntl() then?

penberg commented 2 months ago

Yes, exactly. Limbo would not need fcntl() in the transaction hot-path.