(A类似问题我之前问过 - 这个问题涉及同一个应用程序,但是是一个不同的 - 但可能相关的 - 问题)
我有一个应用程序定期将记录写入数据文件。每次都会打开、更新和关闭该文件。该应用程序的同一实例还会从文件中读取数据。
在网络的其他地方,有多个同一应用程序的“从属”实例正在运行,它们仅从网络上的同一个数据文件读取。
偶尔(这种情况会相隔几天,有时是几周),文件访问会在同一时刻在所有机器上失败,并出现拒绝访问错误,但有时除了其中一台从属机器外,所有机器都会失败。无法写入或读取该文件。通常,除了一台 PC 外,所有 PC 都会以相同的方式失败 - “拒绝访问”错误代码 5 - 但有时其中一台从属机器仍可以继续访问该文件。
使用实用程序检查系统以了解谁打开了文件(LockHunter
SysInternal 的Handle
实用程序),但我们得到的帮助很少——在写入文件的 PC 上,他们发现进程System
具有句柄,大概是因为打开文件的应用程序通过网络共享打开了它,仍然可以写入文件的从属服务器显示句柄已解锁,而对于其他从属服务器,任何实用程序均未报告任何内容。
当我们对系统进行故障排除时,我们习惯于NotePad
快速测试文件是否已解锁。记事本总是报告无法打开文件,因为另一个应用程序已打开该文件 - 除了其中一台从属机器,而且并不总是同一台。当我们在NotePad
那台电脑上打开文件时,它会毫无问题地打开,并且在同一时刻,文件解锁 - 从那时起,所有其他电脑都可以读取和写入该文件(尽管从那时起一切似乎都运行正常,但我并不确信文件系统没有受到某种损坏)。
以下是在用于“解除”文件的ProcMon
时间段内从属文件系统操作获得的日志。每秒读取一次文件,对应于从属文件系统的每组 5 次访问Notepad
APP.ZZZ
App.exe
... accesses from the remote machine
1:08:59.5706074 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:08:59.7993871 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:08:59.8081861 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:08:59.8083675 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 11:53:21 a.m., ChangeTime: 23/09/2015 11:53:21 a.m., FileAttributes: ANCI"
1:08:59.8083874 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:00.5663175 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:00.7611667 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:00.7669819 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:09:00.7671534 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 11:53:21 a.m., ChangeTime: 23/09/2015 11:53:21 a.m., FileAttributes: ANCI"
1:09:00.7671720 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:01.5654203 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
... NOTEPAD starts and opens the file
1:09:01.7112007 p.m. NOTEPAD.EXE 4508 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:01.7187932 p.m. NOTEPAD.EXE 4508 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
1:09:01.7233678 p.m. NOTEPAD.EXE 4508 QueryInformationVolume \\REMOTE\App\Datafiles\APP.ZZZ BUFFER OVERFLOW "VolumeCreationTime: 13/02/2014 11:58:47 a.m., VolumeSerialNumber: 6060-4BB9, SupportsObjects: True, VolumeLabel: Win?"
1:09:01.7248358 p.m. NOTEPAD.EXE 4508 QueryAllInformationFile \\REMOTE\App\Datafiles\APP.ZZZ BUFFER OVERFLOW "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 11:53:21 a.m., ChangeTime: 23/09/2015 11:53:21 a.m., FileAttributes: ANCI, AllocationSize: 692,224, EndOfFile: 691,600, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0x1000000000bdb5, EaSize: 0, Access: None 0x0, Position: 0, Mode: , AlignmentRequirement: Byte"
1:09:01.7407505 p.m. NOTEPAD.EXE 4508 CreateFileMapping \\REMOTE\App\Datafiles\APP.ZZZ FILE LOCKED WITH WRITERS "SyncType: SyncTypeCreateSection, PageProtection: "
1:09:01.7407840 p.m. NOTEPAD.EXE 4508 QueryStandardInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "AllocationSize: 692,224, EndOfFile: 691,600, NumberOfLinks: 1, DeletePending: False, Directory: False"
1:09:01.7408038 p.m. NOTEPAD.EXE 4508 CreateFileMapping \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS SyncType: SyncTypeOther
1:09:01.7408244 p.m. NOTEPAD.EXE 4508 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:01.7408578 p.m. NOTEPAD.EXE 4508 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 0, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
1:09:01.7459986 p.m. NOTEPAD.EXE 4508 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 32,768, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
1:09:01.7502571 p.m. NOTEPAD.EXE 4508 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 65,536, Length: 65,536, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
1:09:01.7567997 p.m. NOTEPAD.EXE 4508 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 131,072, Length: 131,072, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
1:09:01.7759753 p.m. NOTEPAD.EXE 4508 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 262,144, Length: 262,144, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
1:09:01.7995374 p.m. NOTEPAD.EXE 4508 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 524,288, Length: 167,312, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
1:09:01.8194679 p.m. NOTEPAD.EXE 4508 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:01.8228119 p.m. NOTEPAD.EXE 4508 RegQueryValue HKLM\SOFTWARE\MICROSOFT\Windows\CurrentVersion\Explorer\KindMap\.ZZZ NAME NOT FOUND Length: 144
.... NOTEPAD does a whole bunch of registry stuff
1:09:01.8245487 p.m. NOTEPAD.EXE 4508 RegCloseKey HKCU\Software\Classes\.ZZZ SUCCESS
... accesses from the remote machine again. File is now unstuck.
1:09:01.9170334 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:01.9249583 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:09:01.9287995 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 11:53:21 a.m., ChangeTime: 23/09/2015 11:53:21 a.m., FileAttributes: ANCI"
1:09:01.9288154 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:02.5679077 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:02.8324048 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:02.8813660 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:09:02.8924965 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 1:09:02 p.m., ChangeTime: 23/09/2015 1:09:02 p.m., FileAttributes: ANCI"
1:09:02.8925206 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:03.5661778 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
1:09:03.5749668 p.m. App.exe 6276 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 630,252, Length: 61,376, Priority: Normal"
1:09:03.5750069 p.m. App.exe 6276 ReadFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Offset: 626,688, Length: 64,940, I/O Flags: Non-cached, Paging I/O, Priority: Normal"
1:09:03.5820100 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:03.5862665 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:03.7772397 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:03.7848388 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:09:03.7880212 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 1:09:02 p.m., ChangeTime: 23/09/2015 1:09:02 p.m., FileAttributes: ANCI"
1:09:03.7880374 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:04.5695737 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:04.7597043 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:04.7653450 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:09:04.7711026 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 1:09:04 p.m., ChangeTime: 23/09/2015 1:09:04 p.m., FileAttributes: ANCI"
1:09:04.7711189 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
1:09:05.5674975 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:05.7744582 p.m. App.exe 6276 QueryDirectory \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Filter: APP.ZZZ, 1: APP.ZZZ"
1:09:05.7818819 p.m. App.exe 6276 CreateFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: n/a, OpenResult: Opened"
1:09:05.7898488 p.m. App.exe 6276 QueryBasicInformationFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS "CreationTime: 17/11/2014 5:46:01 p.m., LastAccessTime: 23/09/2015 4:00:01 a.m., LastWriteTime: 23/09/2015 1:09:04 p.m., ChangeTime: 23/09/2015 1:09:04 p.m., FileAttributes: ANCI"
1:09:05.7898647 p.m. App.exe 6276 CloseFile \\REMOTE\App\Datafiles\APP.ZZZ SUCCESS
我正在尝试确定是什么导致数据文件处于这种状态。我记得看到过一篇关于关闭网络文件时发生异常的问题的参考。这个问题能指向这种性质的东西吗?我希望有人能对可能发生的情况提供一些见解。
该应用程序是用 Delphi 2007(32 位)编写的。
答案1
打开“命令提示符”并输入
openfiles
查看选项
openfiles /?
另一种方法是
- 选择“管理计算机”(打开“计算机管理”)
- 点击“共享文件夹”
- 选择“打开文件”