I recently converted the workspace file format for my application to sqlite. To ensure reliable operation in NFS, I used the general update policy, I make all changes to the copy stored in a temporary location on the local hard drive. Only when saving can I change the source file (possibly to NFS) by copying the source file using the temp file. I only open the source file to save an exclusive lock on it, so that someone else tries to open them, they will be warned that someone is using it.
The problem is this: when I go to save my temporary file back to the source file, I have to release the lock on the source file, it gives a window for someone else to go in and take the original, albeit a small window.
I can think of it in several ways:
(1) is just to dump the contents of the tempo into the original using sql, i.e. drop the tables on the original, vacumm original, select from temp and paste into the original. I do not like doing sql operations in a sqlite file stored in NFS. It scares me with corruption issues. Am I right to think so?
(2) Use various additional files to act as a protector so that others cannot enter by copying the tempo over the original. Using files as a mutex is problematic at best. I also don't like the idea of adding additional files in case of an application crash.
I am wondering if anyone has any different solutions for this. Again, to copy the temp file on top of the source file, while other applications do not creep and capture the source file at the same time?
I am using python2.5, sqlalchemy 0.6.6 and sqlite 3.6.20
Thanks Dean
source
share