Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 5308

SQL Server on Linux: How is Delete-On-Close Handled

$
0
0

Windows provides an option for CreateFile to delete a file when the file is closed (FILE_FLAG_DELETE_ON_CLOSE.)  

Host Extension Handling

Linux does not expose such an option as part of the open syscall.  Instead the host extension remembers that the open request was made with the FILE_FLAG_ON_DELETE option and after closing a file issues the remove syscall on your behalf.

Linux does provide a delete-on-close like capability using the unlink or remove syscalls.  Intentionally, the Host Extension does not open the file and then invoke unlink or remove.  Linux allows a file open syscall, followed by a call to unlink or remove, and as long as a file descriptor is valid the file can be used by the application for reads and writes.  The unlink or remove syscall makes changes to the file system so searching for the file by name returns no entries and when the file descriptor is closed the file is deleted.  

The downside of using unlink or remove, and keeping the file descriptor open, is that the file becomes hidden.    This can add difficulty tracking space usage or other aspects a hidden file descriptor (still in use) can present.

Bob Dorr - Principal Software Engineer SQL Server


Viewing all articles
Browse latest Browse all 5308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>