1204: The instance of the SQL Server Database Engine cannot obtain a LOCK resource(SQL Server 数据库引擎实例无法获取 LOCK 资源)
SQL Server含义
SQL Server 无法分配锁管理器所需的内存,无法再创建更多的锁。由于锁内存池已耗尽,操作失败。
原因
同时持有过多细粒度(行/页)锁:大型、无索引或批量的 DML;锁升级被阻止;服务器上的整体内存压力;或长时间运行的未结事务。偶尔外部内存压力也是诱因。
解决方法
将大型操作拆分为小批次,以减少并发锁的数量。使用合适的索引减少扫描/锁定的行数。检查禁用锁升级的配置:跟踪标志 1211/1224 以及 ALTER TABLE ... SET (LOCK_ESCALATION = DISABLE); 用 SELECT name, lock_escalation_desc FROM sys.tables; 和 DBCC TRACESTATUS(-1); 检查。检查服务器内存和 max server memory 设置,并缓解内存压力。
同一数据库的其他条目
- 40613Database is not currently available (Azure SQL)(数据库当前不可用)
- 102Incorrect syntax near 'token'('token' 附近有语法错误)
- 8114Error converting data type X to Y(将数据类型 X 转换为 Y 时出错)
- 3906Failed to update database because the database is read-only(无法更新数据库,因为数据库为只读)
- 15023User already exists in the current database(用户在当前数据库中已存在)
- 18452Login failed. The login is from an untrusted domain and cannot be used with Windows authentication(登录失败。该登录名来自不受信任的域,不能用于 Windows 身份验证)
- 605Attempt to fetch logical page belongs to a different allocation unit(尝试获取的逻辑页属于另一个分配单元)