News for hackers. Stuff that matters.
Re:Json-Base – Database built as JSON files by adamredwoods on Thursday July 02, 2020 @07:56PM (#23719453)
They're using readFileSync? Doesn't this lock up the thread?
Re:Json-Base – Database built as JSON files by mbreese on Thursday July 02, 2020 @09:30PM (#23720173)
It’s been awhile since I’ve looked at JavaScript like this, but I would guess that the thread lock would only exist so long as the read() call is running. That returns and then the write is initiated. It doesn’t look like there is a lock that exists throughout the update callback. If that’s missing, then if you had two threads/processes operating on the same table, you’d all but guarantee one of those update calls would be lost (in the best case scenario).

Or maybe there a different locking mechanism in place that my cursory look missed?

Re:Json-Base – Database built as JSON files by jsf01 on Friday July 03, 2020 @01:26AM (#23721269)
Yes. They’re also using fs.exists in the exact way that the official documentation says not to use it.