28

我在 Windows 服务器上运行的应用程序使用了 Jet/Access 数据库。由于某些原因,数据库文件每两周被系统进程锁定一次(PID 4,似乎已修复)

经过一番谷歌搜索后,我发现其他一些用户的文件被该特殊进程锁定,但文件不同(当然)。

  • 系统进程保持打开文件句柄的一般原因是什么?
  • 我的应用程序是导致这种锁定情况的原因吗?
  • 系统进程是否隐式打开所有句柄?我可以想象,在进程崩溃后,句柄可能仍处于打开状态,并且系统进程以某种方式获得了该句柄的所有权。
  • 我可以在我的应用程序中做一些事情来防止它发生吗?
4

8 回答 8

45

通过共享访问的文件将被系统进程 (PID 4) 锁定。

尝试打开compmgmt.msc->系统工具->共享文件夹->打开文件,看看是否列出了锁定的文件

另请参阅sysinternals 论坛以了解复制此内容的方法。
并非所有应用程序在打开文件时都会锁定文件,但 Excel 会。我不知道Access是否也这样做......

于 2012-08-22T09:11:23.427 回答
28

这是我发现的另一个可能的原因:

Windows 7 中存在错误,并且可能在 Windows Server 2008 中(可能仅限 64 位版本)。当您禁用应用程序体验服务时,它会出现并导致与问题中描述的相同的问题。

重新启用此服务为我解决了这个问题。

这里有更多关于它为什么会导致问题的信息。

其他似乎相关的 SO 问题列表:

于 2010-12-29T22:28:29.617 回答
7

在我看来,这听起来像是一个带有泄漏句柄的驱动程序级问题。

如果您正在运行防病毒包,请尝试升级、禁用(暂时!)或切换到不同的品牌。

于 2009-08-18T12:41:52.413 回答
6

它可能是从远程计算机到共享文件夹的延迟会话。如果是这种情况,可以从命令行解锁:

net session /delete
于 2015-04-17T18:35:29.153 回答
1

您的服务器是否设置为执行定期文件备份?

如果是这样,备份是否以系统运行,可能在发生冲突时提示锁定文件?

于 2009-08-18T12:13:37.943 回答
1

For me, it was "Windows Defender" (anti-virus). I excluded my Visual Studio build folders from Windows Defender's list of folders it checks, and the problem went away. (Visual Studio wasn't able to build to the EXE file, PID 4 was locking it to check for virii)

于 2016-01-18T15:04:03.130 回答
1

For me I had to hit it with a sledgehammer. Chkdsk /f on the drive where the folder was located fixed it. Use with caution.

于 2016-10-12T23:10:14.770 回答
0

Check the security settings for each folder and subfolders. Make sure that the system did not just automatically create a special permissions setting which will not allow anyone to delete the file. Apparently for some odd reason the OS creates a weird special permission setting that protects the file from being deleted.

于 2017-11-26T18:59:27.943 回答