kentm wrote:Excellent and thorough reply - thanks very much. We will try this out and will certainly have more questions!
What we're looking for is a way that multiple people can add keywords and/or tags to images and have these available to all people the next time they load the db...
All the catalog data (Rating/Colors/Keywords) is available at the next query from database. It isn't needed to restart the program.
It is a classical scenario in which only the data needed for the current program status is fetched from the database and it is kept in in-memory structures. The program does not monitor if other 'writer' modifies the data from the database, neither it checks for newer version(s) when it needs to (re)fetch something from the storage layer. Hence, if the User 1 works on c:\Folder 1 and User 2 works on c:\Folder 2 simultaneously, when the User 1 finishes his work on Folder 1 and goes to Folder 2, the program, which under the hood asks the database for the Folder 2's data, will fetch also all the committed (saved) work of the User 2. Hence, User 1 will see 'magically' in c:\Folder 2 all the work already done by the User 2.
Of course, the user can use also the manual refresh (View | Refresh... or press F5 with the default keymapping) or any other means which implies a data refresh/refetch (change folders, filtering etc.) in order to see the new data from the other users.
Have you experienced what happens if two people try to save/write to a db at the same time? Or does the app just lock the db file as soon as the first save begins?
Yes. But we need to make the things much clearer here:
The database "saves" (ok, commits) in this scenario aren't at all a big, continuous thing like saving a 30-40 MB CMYK TIFF.
In usual cases, they tend to be rather a very small and quick bursts of commits repeated at rare intervals because the time needed to assign the catalog info is much much bigger than the commit time. Remember that 95% or more from time is spent by the user analyzing the photos in order to decide what Rating/Colors/Keywords (if any) will be assigned. Because these times vary from photo to photo and user to user the possibility that many users will commit simultaneously is very very small.
Hence, even if, indeed, SQLite puts a write lock on the file, this will be very fast (milliseconds) and the possibility of collisions (write conflicts) are very rare. And even if two users will happen to write "at the same time", the DB engine will handle this gracefully by delaying the 2nd one with the milliseconds needed to complete the write transaction of the 1st one. If you put on top of it the write cache of the server's operating system as well as the cache of the storage subsystem (HDD/SSD, controllers etc.) you will quickly find that in practice this is absolutely negligible.
The real source of delays in such environments are nowadays rather unrelated with the concurrency in the catalog database. They tend to come mostly from the wake-up time of the storage devices which usually are in nearline mode (they usually are turned off or put in sleep mode by the controller and are turned on at first access).