If I size my log files to evenly split the entire drive they reside on, leaving no extra space available, will log backups still be able to occur successfully? I have several databases, with one log file per database.
Is it good practice to not leave any space on the drive available, i.e. allocate it all to the log files? (The drive is dedicated to the log files in this case, data and the OS live on their own partitions.)
Best Answer
There is no technical problem for SQL Server if the drive where the log file exists has no free space, assuming the log itself doesn't run out of available, unused, VLF entries.
If the log runs out of available space, you'll not be able to commit any transactions until you resolve the problem. If the entire drive is consumed by the log file, the only action you can take is to add a log file on a different drive to the database. If you proactively manage your log file, and never run out of log space, there is no technical prohibition from doing what you're contemplating.
Having said that, I wouldn't recommend sizing your log file to consume all available drive space:
bigint
instead of anint
, or even asmallint
. Unused disk space is cheap, but space used inside a database should be considered premium cost for the reasons succinctly outlined by @SolomonRutzky here.In a comment, you mentioned that you see no difference between a log growing to fill the disk, and the disk already being filled with a mostly empty log which subsequently gets filled. The supposition is correct, both events will result in the server returning the following error:
However, if you have a SAN, you could thin-provision the drive with a maximum size of, say, 10TB. Create the log file with the estimated "correct" initial size, say 1GB, with growth set to 1GB (or whatever makes sense). Then you won't be using more SAN disk space than you need, but you'll have room to grow the log file without needing to involve the SAN administrator. Win-win.
In a previous version of my answer, I stated the following incorrect information:
After some pretty extensive testing, I am able to successfully add a new log file after the existing log file runs out of space. I wrote a blog post showing how this works at SQLServerScience.com. The actions required for adding a new log file consist of:
The above was validated on SQL Server 2008 R2, and SQL Server 2016.