Re: disk cache file rename errors on Windows
On Thu, Dec 2, 2010 at 12:23 PM, Graham Leggett wrote: > On 23 Nov 2010, at 8:21 PM, Dan Poirier wrote: > >> We're seeing errors like this from mod_disk_cache on Windows only: >> >> (OS 5)Access is denied. : disk_cache: rename tempfile to datafile >> failed: c:/temp/HTTPServer7/aptmpV0JKJ8 -> >> c:/temp/HTTPServer7/wHY/FhW/b5uD@muvt...@v4w.data >> >> under moderate to heavy load, resulting in requests failing. > > > Looking at the code, the error message is thrown when apr_file_rename() > fails, specifically when a temporary file is swung into place in the cache. > > Looking at the APR code, there is a forest of ifdefs that seem to choose one > of MoveFileEx(), MoveFileW(), MoveFileExW() or MoveFile(). Ideally, the > Microsoft API documentation should explain under what conditions the error > "Access is denied" is thrown. > > Does Windows allow you to move a file into place while the replaced file is > still open for read? This may have been a red herring. When a revalidation fails, mod_disk_cache still has an open handle to the data file, but will be called on to create a new tmpfile and copy it on top of that very same datafile. Index: modules/cache/mod_cache_disk.c === --- modules/cache/mod_cache_disk.c (revision 1395428) +++ modules/cache/mod_cache_disk.c (working copy) @@ -596,6 +596,11 @@ static int remove_entity(cache_handle_t *h) { +disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj; +if (dobj->fd != NULL) { +apr_file_close(dobj->fd); +} + /* Null out the cache object pointer so next time we start from scratch */ h->cache_obj = NULL; return OK; This fixes the error in the OP for me, but if it were right you'd think it would be a problem outside of windows during failed revalidations. It seems like in the normal path where the datafile is opened, it is closed somewhere under the covers by virtue of being used in a file bucket written out to the client. But there seems to be no hope for this fd if it's not written to the client.
Re: disk cache file rename errors on Windows
I'd say I am. Even though it is not a high traffic server, the last time I got one of those errors was October 8th. looking further back, it is always following one specific custom error doc that oops, didn't exist till now cause I forgot to generate a new on when I changed the look of the site. CacheIgnoreHeaders Set-Cookie CacheEnable disk / CacheDirLevels 5 CacheDirLength 4 CacheRoot /path/to/cache Original Message --- Is anyone successfully using mod_disk_cache on Windows?
Re: disk cache file rename errors on Windows
On 12/2/2010 11:23 AM, Graham Leggett wrote: > > Does Windows allow you to move a file into place while the replaced file is > still open for > read? This is illustrative of Win32 limitations; "The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file. The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Subsequent calls to CreateFile to open the file fail with ERROR_ACCESS_DENIED." Which is to say, unlink/rename or rename-over-existing would have the same net behavior, and the same failure case.
Re: disk cache file rename errors on Windows
On Thu, Dec 2, 2010 at 12:23 PM, Graham Leggett wrote: > On 23 Nov 2010, at 8:21 PM, Dan Poirier wrote: > >> We're seeing errors like this from mod_disk_cache on Windows only: >> >> (OS 5)Access is denied. : disk_cache: rename tempfile to datafile >> failed: c:/temp/HTTPServer7/aptmpV0JKJ8 -> >> c:/temp/HTTPServer7/wHY/FhW/b...@muvttlk@V4w.data >> >> under moderate to heavy load, resulting in requests failing. > > Looking at the code, the error message is thrown when apr_file_rename() > fails, specifically when a temporary file is swung into place in the cache. > > Looking at the APR code, there is a forest of ifdefs that seem to choose one > of MoveFileEx(), MoveFileW(), MoveFileExW() or MoveFile(). Ideally, the > Microsoft API documentation should explain under what conditions the error > "Access is denied" is thrown. > > Does Windows allow you to move a file into place while the replaced file is > still open for read? Disclaimer: My last real Windows programming was on WfW 3.11, so please, someone with up-to-date Windows programming experience correct me as needed. >From the doc for MoveFileEx (http://msdn.microsoft.com/en-us/library/aa365240%28VS.85%29.aspx), you can pass a flag telling Windows to do the move on the next reboot (also see http://support.microsoft.com/kb/140570) , apparently to work around an inability to rename another file over a file in use. So I think the answer to your question is "no". The doc for error 0x05 at http://msdn.microsoft.com/en-us/library/ms681382%28v=VS.85%29.aspx consists, in its entirety, of "Access is denied.". Maybe there's more explanation elsewhere. -- Dan Poirier
Re: disk cache file rename errors on Windows
On 23 Nov 2010, at 8:21 PM, Dan Poirier wrote: We're seeing errors like this from mod_disk_cache on Windows only: (OS 5)Access is denied. : disk_cache: rename tempfile to datafile failed: c:/temp/HTTPServer7/aptmpV0JKJ8 -> c:/temp/HTTPServer7/wHY/FhW/b...@muvttlk@V4w.data under moderate to heavy load, resulting in requests failing. Looking at the code, the error message is thrown when apr_file_rename() fails, specifically when a temporary file is swung into place in the cache. Looking at the APR code, there is a forest of ifdefs that seem to choose one of MoveFileEx(), MoveFileW(), MoveFileExW() or MoveFile(). Ideally, the Microsoft API documentation should explain under what conditions the error "Access is denied" is thrown. Does Windows allow you to move a file into place while the replaced file is still open for read? Regards, Graham --
Re: disk cache file rename errors on Windows
Is anyone successfully using mod_disk_cache on Windows? Thanks, Dan
disk cache file rename errors on Windows
We're seeing errors like this from mod_disk_cache on Windows only: (OS 5)Access is denied. : disk_cache: rename tempfile to datafile failed: c:/temp/HTTPServer7/aptmpV0JKJ8 -> c:/temp/HTTPServer7/wHY/FhW/b...@muvttlk@V4w.data under moderate to heavy load, resulting in requests failing. This is with Apache 2.2.8, but reproducible under 2.2.17 as well. With 2.2.17, enabling the cache lock changes the errors to failures stat'ing the lock files, but we still get errors. Bug 39216 might be related, but applying that patch didn't solve the problem, or at least, not completely. It's a little hard to reproduce reliably, so it's hard to tell if the patch helped, but we definitely still see errors. I suspect this is due to other threads having the files open at the same time, but don't have any real evidence of that other than the error we're seeing. Any ideas about solving this problem? Thanks, Dan