Re: SMSI: databases corrupted on crash and permission issueson OSX

This WebDNA talk-list message is from

2002


It keeps the original formatting.
numero = 43620
interpreted = N
texte = Dale LaFountain wrote: > In the meantime I have to ask: why doesn't webcat write databases to a > temp file (i.e. .orders.db.tmp) before replacing the original file? If > coded robustly, this change should virtually eliminate the possibility > of truncating db files. > The most robust way to do this (assuming that WebCat has the file still open) is to write to a temp file in the same directory, then atomically rename the temp file to the original file name, then close and reopen the file. The key here is that as long as the file is open, the rename doesn't affect the running process (since it already has a filehandle to the old file, regardless of it's current name).The close/open then immediately has access to the original filename with the new contents. The filesystem does not recover the old file until after all applications with an active handle close the file, so it is a very clean way to manage it. It even works with multiple threads, since only the threads with the file already open have the old file and as soon as they close it, they get the new data on next open().John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4720 Boston Way Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5747 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: SMSI: databases corrupted on crash and permission issueson OSX (Karl Schroll 2002)
  2. Re: SMSI: databases corrupted on crash and permission issueson OSX (Scott Anderson 2002)
  3. Re: SMSI: databases corrupted on crash and permission issueson OSX (John Peacock 2002)
Dale LaFountain wrote: > In the meantime I have to ask: why doesn't webcat write databases to a > temp file (i.e. .orders.db.tmp) before replacing the original file? If > coded robustly, this change should virtually eliminate the possibility > of truncating db files. > The most robust way to do this (assuming that WebCat has the file still open) is to write to a temp file in the same directory, then atomically rename the temp file to the original file name, then close and reopen the file. The key here is that as long as the file is open, the rename doesn't affect the running process (since it already has a filehandle to the old file, regardless of it's current name).The close/open then immediately has access to the original filename with the new contents. The filesystem does not recover the old file until after all applications with an active handle close the file, so it is a very clean way to manage it. It even works with multiple threads, since only the threads with the file already open have the old file and as soon as they close it, they get the new data on next open().John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4720 Boston Way Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5747 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ John Peacock

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Performance: deafening silence (1999) Summing fields (1997) Can you do this??? and other stuff (1997) Search Context: How to set Max=N? (2000) Image editing in browser (2005) Bug Report, maybe (1997) RE: Questions To Answer (1997) Latin Characters (1998) Shopping Cart variation... (1997) RE: is sku a REQUIRED field on NT (1997) Keep away (1997) RequiredFields template (1997) how many users (2000) WebCat2 - [format thousands] (1997) version 2 for NT (1997) Nested tags count question (1997) 2.0Beta Command Ref (can't find this instruction) (1997) Searching (1998) Itools, WEBCAT OSX (2003) Thanks Grant (was: disappearing SKU (etc.) fields) (1998)