Tuesday, May 27, 2008

Bounce IIS after re-stamping your TFS Databases with InstanceInfo.exe

We saw an interesting scenario today after restoring our TFS PROD instance to a TFS QA environment for testing. Even though we changed the Instance ID for each database (see here for instructions), the App Tier was still rendering the old Instance ID for the TfsVersion control database. This was causing the Source Control view to continue to look at the PROD server even though it said "QA". All other databases were rendering with the new Instance ID.

If you're not familiar with the Instance ID, let me take a second to explain it. The Instance ID is basically a GUID (globally unique identifier) for the TFS databases. While you may refer to the TFS Server as tfs.mycompany.com, your client software (e.g. Team Explorer) prefers to use the GUID.

From what Grant Holiday says, basically what happens is your client will send the URL (e.g. tfs.mycompany.com_ to the server's Registration.asmx web service to get the GUID (e.g. 2dbgh947-049b-7z6c-94y2-4b0767ggf790). Once the client has the GUID it will use that for future communication.

In our case, we properly changed the GUID using the InstanceInfo.exe utility and directions in this forum. However, the App Tier must have been caching the TfsVersionControl GUID as both PROD and QA were responding with the same GUID name, even though the database GUID was restamped. Here are the PROD and QA sections of our VersionControl.config file stored under %USERPROFILE%\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache. Interesting enough, the repositoryGuid would stay the same, but the uri would change when we switched TFS Servers. Bad!!!

ServerInfo uri="http://tfsqa.mycompany.com:8080/" repositoryGuid="2dbgh947-049b-7z6c-94y2-4b0767ggf790"
ServerInfo uri="http://tfsprod.mycompany.com:8080/" repositoryGuid="2dbgh947-049b-7z6c-94y2-4b0767ggf790"

The fix was to bounce IIS on the QA App Tier. This reset the App Tier cache and thus resolved our issue. The lesson learned here is to bounce IIS after you re-stamp your TFS databases with new GUIDs.

No comments: