python - How to ensure a safe file sync with sqlite and NFS -


i have converted workspace file format application sqlite. in order ensure robust operation on nfs i've used common update policy, modifications copy stored in temp location on local harddisk. when saving modify original file (potentially on nfs) copying on original file temp file. open orginal file keep exclusive lock on else tries open warned else using it.

the problem this: when go save temp file on original file must release lock on orginal file, provides window else in , take original, albeit small window.

i can think of few ways around this:

(1) being dump contents of temp in orginal using sql, i.e. drop tables on original, vacumm original, select temp , insert orginal. don't doing sql operations on sqlite file stored on nfs though. scares me corruptions issues. right think this?

(2) use various files act guard prevent other coming in while copying temp on original. using files mutex problematic @ best. don't idea of having files hanging around if application crashes.

i'm wondering if has different solutions this. again copy temp file on original file while ensuring other application don't sneak in , grab original file while doing so?

i'm using python2.5, sqlalchemy 0.6.6 , sqlite 3.6.20

thanks, dean

sqlite nfs issues due broken caching , locking. if process 1 accessing file on nfs you'll ok.

the sqlite backup api designed solve problem. can either backup directly nfs database or local temp file , copy that. backup api deals locking , concurrency issues.

you can use apsw access backup api or recent version of pysqlite. (disclosure: apsw author.)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -