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:

Access file on a remote server (2003) [OT] (waaaay OT) my photo (2004) Problems appending to database (1997) RE: I have observed and I am gone. (1998) problems with 2 tags (1997) &FieldNametype=time unnecessary? (2000) [WebDNA] Initial setup problems with 6.2 (2009) Pre-parse hell (2008) Make sure I understand this??? (1997) [subTotal] pricefield in another database It#180#s not working!? (1998) Navigator Parsing (1997) [WebDNA] Is there a D.E. database record limit? (2014) [OT] Nuclear Vision (2006) details (2003) default value from Lookup (was Grant, please help me) (1997) using showpage and showcart commands (1996) relational db question (2002) [OT] Indexing of dynamic web sites (2003) Locking up with WebCatalog... (1997) Document Contains No Data (1998)