Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
-
None
Description
Currently, there are still problems in deletion of open files on Windows (which usually happens with 3rd party AV or backp software)
How it works currently
- if file was open by 3rd party, my_win_delete opens it with FILE_FLAG_DELETE_ON_CLOSE and renames the file to the unique name (in the same directory). Whenever 3rd party closes the file, and number of open handles goes down to 0, the file will finally disappear from the file system. The rename is necessary, otherwise attempt to recreate the deleted and not yet closed file would result in ERROR_SHARING_VIOLATION.
The problem occurs during removing of the directory (DROP DATABASE), if the uniquely-named temporary files are still there. DROP DATABASE will fail.
Windows 10 offers a better option with SetFileInformationByHandle with _FILE_DISPOSITION_INFO_EX with FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS; This option is even used in the STL (https://github.com/microsoft/STL/blob/62137922ab168f8e23ec1a95c946821e24bde230/stl/src/filesystem.cpp) , with fallback for downlevel systems.
The posix semantics allow recreating a file, if it was deleted, but still opened in some program.