3 mongodb system_error ai_generated partial

WiredTiger 错误 (3) __wt_file_handle_close,文件:WiredTiger.wt,关闭:没有那个文件或目录

WiredTiger error (3) __wt_file_handle_close, file: WiredTiger.wt, close: No such file or directory

ID: mongodb/wiredtiger-file-close-failed

其他格式: JSON · Markdown 中文 · English
75%修复率
85%置信度
1证据数
2023-03-15首次发现

版本兼容性

版本状态引入弃用备注
MongoDB 5.0 active
MongoDB 6.0 active
MongoDB 7.0 active

根因分析

WiredTiger 存储引擎无法关闭文件句柄,通常是由于文件系统级损坏或过时的 NFS 挂载导致底层文件在 MongoDB 仍持有引用时被删除。

English

The WiredTiger storage engine failed to close a file handle, typically due to a filesystem-level corruption or a stale NFS mount causing the underlying file to be deleted while MongoDB still held a reference.

generic

官方文档

https://www.mongodb.com/docs/manual/tutorial/recover-data-following-unexpected-shutdown/

解决方案

  1. 停止 mongod,在数据目录上运行 `mongod --repair`,然后重新启动。这会从剩余的数据文件中重建 WiredTiger 元数据。
  2. 如果修复失败,从最近的备份恢复。使用 `mongorestore` 恢复备份转储。
  3. 如果使用副本集,删除受影响的节点,清空数据目录并用 `--replSet` 重新启动,从主节点重新同步。

无效尝试

常见但无效的做法:

  1. 90% 失败

    The corruption persists in the WiredTiger metadata; restarting only re-encounters the same error or causes a crash loop.

  2. 95% 失败

    This file contains critical storage engine metadata; removing it makes the database unreadable and requires a full resync from replica set or backup.

  3. 80% 失败

    Running fsck on a mounted filesystem can cause further corruption; MongoDB requires the data directory to be consistent before repair.