Every time I ‘ATTACH DATABASE’ SQL logs error 1314 for SetFileIoOverlappedRange
Every time I ‘ATTACH DATABASE’ SQL logs error 1314 for SetFileIoOverlappedRange
Turns out this is an issue in the SQL Server code and the error is a bit noisy during attach database.
When opening the database files, SQL Server calls SetFileIoOverlappedRange (when enabled properly) in order to help improve I/O performance. This is commonly done under the SQL Server, service account; which requires locked pages privilege. When the privilege is not held the Windows error (1314 - A required privilege is not held by the client) is logged in the SQL Server error log, shown below.
Starting with SQL Server 2005, when attaching a database, SQL Server impersonates the client connection when opening the files to validate proper security (ACLs.) In doing so the SQL Server invokes SetFileIoOverlappedRange under the impersonated account and not the SQL Server, service account. This can lead to the 1314 error condition.
The error is more noise than a problematic issue. Using ALTER DATABASE OFFLINE and ONLINE will re-open the database files under the SQL Server, service account and allow SetFileIoOverlappedRange to complete successfully for the database.
Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64)
Oct 19 2012 13:38:57
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
2013-10-16 03:23:20.010 Server Using locked pages in the memory manager.
.
.
.
2013-10-16 09:21:35.970 spid52 Starting up database 'dbAttachTest'.
2013-10-16 09:25:10.300 spid52 SetFileIoOverlappedRange failed, GetLastError is 1314
WARNING – Make sure you have the following applied to avoid unexpected issues as well.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码