Perforce Public Knowledge Base - Using Process Monitor to Monitor File Access
Perforce Software logo
Reset Search
 

 

Article

Using Process Monitor to Monitor File Access

« Go Back

Information

 
Problem

You encounter the error "The process cannot access the file because another process has locked a portion of the file" on Windows.

You encounter the error "File rename() failed after 10 attempts" on Windows.

 

Solution

The most common cause for the above server errors are third party (non-Perforce) processes trying to access the Perforce db.* or other files. If you are seeing these errors

  • The process cannot access the file because another process has locked a portion of the file
  • File rename() failed after 10 attempts
  • dbopen db.rev failed ...can't create a file that already exists.

the problem is likely a process other than Perforce attempting to access the Perforce related files.

A first step is to determine whether anti-virus or backup software or another process is accessing the Perforce database (db.*) files. For example, virus scanners should be configured to NOT scan the P4ROOT directory nor Perforce versioned files.

If you encounter the above errors, you will want to monitor the affected files more closely. Related file locations to monitor include:
  • The Perforce P4ROOT directory, if you believe Perforce db.* files are being accessed.  
  • A versioned file directory underneath P4ROOT related to the "File rename() failed after 10 attempts" error. 
  • Monitoring a Perforce process like p4s.exe or p4v.exe to track file access activity.
On Windows, monitoring file activity can be effectively done with the Process Monitor program.

How to Use Process Monitor

  1. Download, install, and run Process Monitor.

    Note: Process Monitor replaces the Sysinternals Filemon utility.

    Process Monitor can be found on Microsoft's web site at this location:

    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

    Alternately, Process Monitor can be run directly from the Microsoft site using this link:

    http://live.sysinternals.com/Procmon.exe

  2. Deselect (uncheck) the "File | Capture Events" menu item.

  3. Clear the currently displayed events by selecting the "Edit | Clear Display" menu item.

  4. Configure a filter by:

    1. Select the Process Monitor "Filter | Filter..." menu item. This will display the "Process Monitor Filter" dialog.

    2. Set a new filter by setting the "Display entries matching those conditions" fields to, for example,

      Path (drop-down menu) contains (drop-down menu) C:\Program Files\Perforce\Server\depot (type this in)
      then Include (drop-down menu)

      Where {PATH} is the Perforce directory path to be monitored.

    3. Click the "Add" button to add the new filter.

  5. Add any other filter rules.

    For example if you want see only Perforce service (p4s.exe) processes, add a filter by adding:

    Process (drop-down menu) contains (drop-down menu) p4s.exe (type in)

    Or you may want to remove all SUCCESS events and only look for failures:

    Result (drop-down menu) is not (drop-down menu) SUCCESS then Include (drop-down menu).
  6. Test that Process Monitor is working.

    Start Process Monitor by clicking File | Capture Events

  7. Reproduce the problem and note the results in Process Monitor.

    A well designed filter will display almost no information in Process Monitor until the issue occurs. Thus any information noted by Process Monitor will very likely be related to the issue being tracked.

    Note: If the problem is intermittent or occurs only rarely you will need to delete or rotate Process Monitor logs regularly.

    If the problem is occurring regularly, such as an ongoing "File rename() failed after 10 attempts":

    1. Right-click the column headings in process monitors and select the "Select Columns..." menu item. The "Process Monitor Column Selection" dialog is displayed.

    2. Select (check) the "Thread ID" item located under "Process Management".

    3. Click "OK" to close the dialog.

    If the thread is owned by the Perforce service (p4s.exe), the thread id will correspond to the first column in the command:

    p4 monitor show -ael
    

    This will help determine which Perforce command is locking the file.

  8. Save the results.

    1. Select the "File | Save" menu item. The "Save to File" dialog is displayed.

    2. Under "Events to save" select "Events displayed using current filter".

    3. Under "Format"  select "Native Process Monitor Format (PML)" for later analysis.

    Note: You can also save the file as CSV (comma separated values) so the file can be read by a spreadsheet or other database software.

  9. Analyze the results.

    Look for errors in the Result column, or double-click any line entry and check whether the stack has any extra entries, such as processes from a virus scanner or a backup program. To find long run times possibly related to performance problems:

    1. Right-click the column headings in process monitors and select the "Select Columns..." menu item. The "Process Monitor Column Selection" dialog is displayed.

    2. Select (check) the "Relative Time" item located under "Event Management".

    3. Click "OK" to close the dialog.

    Note: It is often useful to compare the results with a system that is performing well, if available.

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255