Troubleshooting Guide: Error 3765 – Could Not Delete Native Shuffle Storage
Why This Error Happens
Error 3765 occurs when SQL Server 2025’s native shuffle engine attempts to clean up temporary shuffle storage artifacts but encounters a locked file handle, insufficient disk permissions, or a corrupted intermediate storage segment. This typically arises during parallel query execution involving data redistribution (shuffle operations) across worker nodes, where the storage path becomes inaccessible due to antivirus interference, abrupt query cancellation, or filesystem-level ACL misconfigurations on the shuffle spill directory. In some cases, the underlying disk volume may have run out of space mid-operation, leaving orphaned shuffle files that the engine cannot safely remove.
Step-by-Step Resolution Guide
Step 1: Check the SQL Server Error Log for Root Cause Details
- Open SQL Server Management Studio (SSMS) and navigate to Management > SQL Server Logs.
- Look for accompanying entries near Error 3765, such as “Access Denied” or “I/O error” on the shuffle storage path (commonly
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\ShuffleTemp\). - Run
EXEC sp_readerrorlog 0, 1, 'shuffle';in a query window to filter relevant log lines quickly.
Step 2: Verify File System Permissions on the Shuffle Storage Directory
- Right-click the shuffle temp folder (default path above) and select Properties > Security.
- Ensure the SQL Server service account (e.g.,
NT Service\MSSQLSERVER) has Full Control permissions. - From an elevated PowerShell prompt, run:
icacls "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\ShuffleTemp" /grant "NT SERVICE\MSSQLSERVER:(OI)(CI)F"
Step 3: Clear Orphaned Shuffle Files and Restart the Shuffle Service
- Stop the SQL Server instance using
net stop MSSQLSERVERvia an elevated Command Prompt. - Manually delete any residual
.shufor.tmpfiles in the ShuffleTemp directory. - Restart the service with
net start MSSQLSERVERand allow the shuffle subsystem to reinitialize.
Step 4: Exclude Shuffle Storage Path from Antivirus Scanning
- Open Windows Security (or your third-party antivirus console).
- Add an exclusion for the full ShuffleTemp directory path to prevent real-time scanning from locking files during write/delete operations.
- Reboot the server to ensure the exclusion takes effect system-wide.
Step 5: Validate Disk Space and Volume Health
- Check available free space on the drive hosting the shuffle storage using
Get-PSDrivein PowerShell. - If space is critically low, relocate the shuffle temp directory using
ALTER SERVER CONFIGURATION SET SHUFFLE STORAGE PATH = 'D:\SQLShuffle';to a volume with adequate capacity.
Alternative or Verification Steps
- Re-run the original parallel query or shuffle-dependent workload and confirm Error 3765 no longer appears in the error log after completion.
- If the issue persists, enable Trace Flag 3766 to capture verbose shuffle diagnostics, then review
sp_readerrorlogoutput for a deeper I/O-level root cause before escalating to Microsoft Support.