kdmurray.blog

The crossroads of life and tech

Subversion – Can’t move [file]. The file or directory has become corrupted and is unreadable

Update 2011-02-11: Since the post was originally published Microsoft has issued a hotfix for this issue, which is slated to be included in Windows 7 SP1.

I recently ran into a problem on my fancy new machine while trying to commit a rather large number of files into an SVN repository. The error message stated that some of the files in the .svn control directory had become corrupted and unreadable.

After Googling around a bit I came across a post on the CollabNet issue log which identified this as an issue with the NTFS stack on Windows 7. This post included another link to a Microsoft technet discussion about the issue.

The long and the short of it is that this is an identified issue in the NTFS implementation in all editions of Windows 7 (both 32 and 64 bit versions). The indexing service is locking files which SVN is trying to move. This only appears to be a problem with large batch transactions. Smaller ones, for me at least, have been working just fine but YMMV.

In case you don’t want to read the whole discussion thread, here’s the response from the NTFS team developer who responded to the community reports:

This is a known regression in Windows 7 in the NTFS file system.  It occurs when doing a superceding rename over a file that has an atomic oplock on it (atomic oplocks are a new feature in Windows 7).  The indexer uses atomic oplocks which is why it helped when you disabled the indexer.  Explorer also uses atomic oplocks which is why you are still seeing the issue.  When this occurs STATUS_FILE_CORRUPT is incorrectly returned and the volume is marked “dirty” which is a signal to the system that chkdsk needs to be run.  No actual corruption has occured. Neal Christiansen NTFS Development Lead

The identified workaround for this issue is to stop the indexing service. If you don’t use search very often you can disable it. If you do, you can just stop the service and allow it to restart the next time you restart Windows.

The next trick, of course, is finding the indexing service.  In Windows 7 the service has been renamed “Windows Search”. It serves essentially the same functions as the old “Indexing Service”.

There have been some reports that this issue affects Windows Vista as well, but I don’t have a Vista machine to test with.

AnkhSVN and Visual Studio 2008

ankhsvnSource control is one of those things that developers get really polarized about.  Most agree that having source control on projects is a necessity, but that’s typically were the similarities end.  Some folks are of the mind that every line of code, however insignificant, should be under source control.  This provides records of what was written, and a reference for things that were done in the past.  Others believe that source control should be reserved for “real” projects, things that are deliverables for customers, or products to be released to real-world environments.  I really don’t want to get into this debate tonight, so I’m going to stick to the technology.

I was wanting to get some source control in place for a few of my personal projects.  I chose to go with Subversion for my source control server for a few reasons, not the least of which was that my hosting company supports auto-configuration of SVN repositories, so I was able to get that set up in just a couple of minutes.  That left me some time to contemplate how I would access the repository from the client.

newproject_svnI’m running Visual Studio 2008 on my development machine and this gives me the ability to use plugins for the IDE, a feature that is sadly missing from the express editions.  There were a couple of good options available for SVN plugins, VisualSVN which is the 800lb gorilla in this space, and the open-source option CollabNet’s AnkhSVN.  Given the fact that this was for personal exploration of the toolset, the open source (free) option was the obvious choice.

The setup for AnkhSVN was quick and painless, and when the IDE opened up it put options for source control right in the menus where they were nice and easy to find.  I created a project, and selected the “add to Subversion” checkbox, entered the necessary credentials and created the project in my SVN repository.

anhksvnWhen in Visual Studio, the AnkhSVN controls are located on a tab at the bottom of the IDE, alongside other solution-wide functionality like the To-do list, output window etc.  This pane tracks all of the changes (adds, deletes and updates) that you’ve made to the solution files.  This is extra handy as a review when you’re ready to make your commits back to the repository.  By quickly scanning the list of changes you’re able to write solid commit comments to provide some decent documentation for you, or those who come after you.

I’m still relatively new to Subversion and AnkhSVN, but I’m looking forward to exploring them in more detail — maybe I’ll even do a podcast episode about it!