appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
491 stars 27 forks source link

Feature: db file locking #199

Closed appy-one closed 1 year ago

appy-one commented 1 year ago

(H)appy new year! 🍾🥂

This PR helps preventing database corruption #48 by disallowing multiple processes to access the same database file simultaneously, unless they are using IPC for inter-process communication. This means that forked processes with pm2 or NodeJS clustering, or servers using acebase-ipc-server can still all access the database simultaneously, but all other processes that try to open an already open db will be denied access.

For its implementation I have modified proper-lockfile instead of adding it as a dependency for the following reasons:

I changed the following:

requires acebase-core #29 to be merged, dependency updated

appy-one commented 1 year ago

I'm parking this PR because I implemented an automatically starting up IPC service/"daemon" in #213, which acts as an automatic (local) IPC master for each process requesting access to the same database. Locking the file will therefore not be necessary.