AnsweredAssumed Answered

FSR non-atomic copy race condition

Question asked by devmonkey on Apr 28, 2009
Latest reply on Apr 28, 2009 by devmonkey
Hi,

When we publish file overwrites through the FSR at the same time as the target directory is being read by the webserver it is possible for the webserver to miss the file or read a partially written file. This is because the FSR performs the following steps to overwrite a file:

1. Move oldFile to oldFile.alf
2. Stream stagedFile into newFile.
3. Flush output stream

So between 1 and 2 the file does not exist wrt to any reading process. And during the stream copy the file is only partially written.

We were thinking of using two target directories, t1and t2, one for the FSR to update, the other a readonly copy for the webserver to read. Two symlinks tw and tfsr that would point to the directory (either t1 or t2) that the webserver should read from and the fsr should write to respectively.  A script would have to fired post commit that did the following:
1. swap tw and tfsr
2. copy tw diffs into tfsr, bringing tfsr uptodate for the next publication

How do others work around this problem?

Cheers, Joe.

Outcomes