Sproc Executing Slow? It Might be This

So you have stored procedure and it’s having issues. When you run it, it returns really fast. When .NET runs it, its like a dog.

The first thing you learn about SQL Server is that it has something called ARITHABORT and it is turned on in SQL Management Studio and OFF in ADO.NET. Yeah you heard that right. OFF. So when you find this out, your first thought is WTF, mate?! Why do we have to make this hard on ourselves?

Reference post: http://sqladvice.com/blogs/gstark/archive/2008/02/12/Arithabort-Option-Effects-Stored-Procedure-Performance.aspx

So you turn it off in SQL Server Management Studio under {Tools}->{Options} and all is good right?

image

Well, you might be coming across another problem and you want to optimize the sproc so you pull the text out and start running query analyzer. First things first, compare the text of the sproc versus executing the actual sproc. You might be surprised to find that the actual execution is not as fast as the text.

 image

WTF? Why is the sproc running slower than the actual text? This is due to a bad query plan being cached by SQL. If you use the parameters that are passed in by the sproc, SQL Server tries to guess what those are and it puts in fake values. Then it caches a bad query plan.

So if you’re still with me at this point, you’re probably saying, that’s all fine and dandy Rob, but I just want to fix the freaking thing and you are giving me too much context.

The fix is so easy, it’s crazy. All you have to do is set those parameters to local variables and use the local variables in the sproc.

Create PROC Tim 
    @StartDate DateTime
AS 
 
 BEGIN
 
    DECLARE @LocalStartDate DateTime
    SET @LocalStartDate = @StartDate
    
    /* your code here */
    
    SELECT @LocalStartDate AS StartDate
    /* instead of 
        SELECT @StartDate AS StartDate
     */
    
 
 
 END

It’s a hack. And only useful when the sproc is being a non-performant nancy boy.

And here’s another good reason not to use Sprocs. I’m just saying. YMMV.

 

 

kick it on DotNetKicks.com

 

Speaking At IowaCodeCamp

If you are in Des Moines, IA, tomorrow for Iowa Code Camp, I’m speaking on “Automated Builds: How to UppercuT your Code” at 3:45.

UppercuTBlack

If you are going to be there and we’ve only met on Twitter before, I’m looking forward to meeting you!

UppercuT and Mono Migration Analyzer

If you are using UppercuT, you will be pleased to know that it now supports Mono Migration Analyzer (MoMA for short).  All you have to do is upgrade. And with the design of UppercuT, we’ve made it super simple to upgrade.

How hard is it to upgrade UppercuT? Just drop in the files in your build folder, check for changes to the lib folder (especially in the NAnt directory) and new folders, and then check for any changes to the .bat files and UppercuT.config and you’re done.

Mono Migration Analyzer

Here is what the report looks like running against UppercuT.  It looks like UppercuT is okay to run on *nix, but a few of it’s dependencies may have some issues.

image

If you look closer, you can find whether the method is not implemented, on the TODO list, or the P/Invoke list. The P/Invoke’s will only work if your OS has implemented them.

image

Yet another reason to use UppercuT. The builds just keep getting better!

kick it on DotNetKicks.com

UppercuT – Elegant Solution to Strong Naming

Here’s how you can sign a set of assemblies in a project with a key using UppercuT:

1. Open the UppercuT.config file.

image

2. Change the following to “true”:

image

3. Done.

Did I mention that creates a private key if it is not there as well?!

This was from a patch sent in by Dru Sellers. Thanks Dru!

With this knowledge you shall build.

kick it on DotNetKicks.com

UppercuT Presentation Afterthoughts

The presentation for TopDNUG went pretty well. There were some good questions and back and forth. The room really seemed to come alive when in a matter of less than ten minutes I added UppercuT to two different Open Source projects (Reflexil and Quartz.NET) and had them off of the ground and building. Full builds, too. With versioning, compiling, unit testing, packaging, etc.

I also unveiled the new logo for UppercuT:

UppercuTBlackWithLink_Smaller

Here is the slide deck: UppercuT Presentation (may need to be renamed to .pptx).

UppercuT – Automated Builds - Change is Good

Recently I reported that there were going to be some changes to UppercuT. And there have been. These are a summary of some of the most significant changes:

  • Uppercut now reports it's version. This is helpful to know where you are versus the current version. It also reports the time when it finishes a build.
  • Custom Replacement Tasks are now implemented. This is to add a task to the custom folder that completely replaces the normal workings of the build step it is replacing. A pre or post custom step will still run though.
  • Pre, Post and Replacement tasks are implemented for every build step in UppercuT now.
  • Support for Gallio Testing has been added.
  • EnvironmentBuilder works better than ever now that it is custom code instead of NAnt property expansion which had buffer limitations.
  • All .build files are now .step except for the actual builds (open, zip and default). default.build is what used to be __master.build.

http://code.google.com/p/uppercut/downloads/list

Most of this is due to prioritizing the time to get requested features into UppercuT prior to my upcoming presentation for TopDNUG.

There are some more changes on the way to v1. I will be talking about a road map soon.  If you aren’t yet a member of the uppercut users group, you might consider joining. :-)

With this knowledge you shall build.

Universal NAnt Script for Gallio

So Gallio has been out for a little while and I admit that I am a little slow when it comes to looking at new frameworks. I mean there is so much to look at and only so much time in the day allocated to programming. Anyway, there really isn’t much documentation out there yet for using Gallio with NAnt. I am of the thought that is due to all of the people who are really smart with builds are using Rake and/or PSake now. So I set off to create another universal script. This basically follows the conventions from my post with MbUnit’s Universal script and how I added MbUnit2 category filters to it’s NAnt task in UppercuT.

So like I said, Gallio has been out for a little while. This is the first time I have heard that it has underwent some optimizations so now seems a good time to check it out. Until I figure out how to do it another way, this script requires Gallio to be installed on each machine that is going to use it. I am currently trying to figure out how I can get a reduced set of Gallio into source control. The install is 26.4MB right now and that’s bigger than I want my repositories to have to be just for adding a testing framework.

NAnt Script for Gallio

<?xml version="1.0" encoding="utf-8" ?>
<project name="GallioTestRunner" default="go">
  <!-- Project UppercuT - http://projectuppercut.org -->
  <!-- DO NOT EDIT THIS FILE - This follows a convention for testing with Integration tests being separated from Unit tests - find out more at http://uppercut.pbwiki.com -->
  <property name="build.config.settings" value="__NONE__" overwrite="false" />
  <include buildfile="${build.config.settings}" if="${file::exists(build.config.settings)}" />
  <property name="dirs.build" value="${directory::get-parent-directory(project::get-buildfile-path())}\..\..\build_output" />
  <property name="dirs.build_artifacts" value="${dirs.build}\build_artifacts" overwrite="false" />
  <property name="dirs.test_results" value="${dirs.build_artifacts}\gallio" overwrite="false" />
  <property name="file.test_results" value="gallio-results" overwrite="false" />
  <property name="time.limit.in.seconds" value="240" />  <!-- 4 minutes -->
 
  <target name="go" depends="cleanup, run_tests" description="Tests" />
 
  <target name="cleanup">
    <echo message="Removing and adding ${dirs.test_results}."/>
    <delete dir="${dirs.test_results}" failonerror="false" />
    <mkdir dir="${dirs.test_results}" />
  </target>
 
  <target name="load_tasks">
    <echo message="Loading Gallio Nant Tasks from Program Files." />
    <loadtasks assembly="C:\Program Files (x86)\Gallio\bin\Gallio.NAntTasks.dll" if="${file::exists('C:\Program Files (x86)\Gallio\bin\Gallio.NAntTasks.dll')}" />
    <loadtasks assembly="C:\Program Files\Gallio\bin\Gallio.NAntTasks.dll" if="${file::exists('C:\Program Files\Gallio\bin\Gallio.NAntTasks.dll')}" />
  </target>
  
  <target name="run_tests" depends="cleanup,load_tasks" description="Running Unit Tests">
    <echo message="Running tests using Gallio and putting results in ${dirs.test_results}."/>
    <gallio working-directory="${dirs.build}"
            report-types="Html;Xml;Text"
            report-directory="${dirs.test_results}"
            report-name-format="${file.test_results}"
            show-reports="false"
            failonerror="true"
            verbosity="Normal"
            echo-results="true"
            run-time-limit="${time.limit.in.seconds}"
            filter="exclude Category:Database or Category:Integration or Category:Slow or Category:NotWorking or Categroy:Ignore or Category:database or Category:integration or Category:slow or Category:notworking or Categroy:ignore"
            >
      <files>
        <exclude name="${dirs.build}\*Database*dll" />
        <exclude name="${dirs.build}\*.Integration*dll" />
        <exclude name="${dirs.build}\TestFu.dll" />
        <include name="${dirs.build}\*Test*dll" />
        <include name="${dirs.build}\*.Specs*dll" />
      </files>
    </gallio>
  </target>
 
  <target name="run_all_tests" depends="cleanup,load_tasks" description="Running All Unit Tests">
    <echo message="Running all tests (including integration tests) using Gallio and putting results in ${dirs.test_results}."/>
    <gallio working-directory="${dirs.build}"
            report-types="Html;Xml;Text"
            report-directory="${dirs.test_results}"
            report-name-format="${file.test_results}"
            show-reports="false"
            failonerror="true"
            verbosity="Normal"
            echo-results="true"
            run-time-limit="${time.limit.in.seconds}"
            >
      <files>
        <exclude name="${dirs.build}\TestFu.dll" />
        <include name="${dirs.build}\*Test*dll" />
        <include name="${dirs.build}\*.Specs*dll" />
      </files>
    </gallio>
  </target>
 
  <target name="open_results">
    <echo message="Opening results at ${path::get-full-path(dirs.test_results)}\${file.test_results}.html."/>
    <exec
      spawn="true"
      program="${environment::get-folder-path('ProgramFiles')}\Internet Explorer\iexplore.exe"
      commandline="${path::get-full-path(dirs.test_results)}\${file.test_results}.html"
      >
    </exec>
  </target>
 
</project>

UppercuT and Gallio

UppercuT now has support for Gallio baked in. What that means is that you select gallio as your test framework in the config file. Install Gallio. And you’re done. And when you run test from the command line, you get this in your browser:

image

What pretty reports you get from Gallio!

With this knowledge, you shall build.

kick it on DotNetKicks.com

UppercuT Undergoing Some Major Changes

I’m slimming it down and rethinking some of the idioms it is currently using. Stay tuned…

TopDNUG Meeting Rescheduled – September 24, 2009

Due to scheduling conflicts, the meeting has been moved to Thursday September 24, 2009.

http://groups.google.com/group/topekadotnet/browse_thread/thread/f9563f846a50f3d7#

I updated the original post as well.

This being the second time in two months comes with a little explanation. The business where we hold our meetings graciously lets us use the meeting space for free. As such sometimes they ask that we reschedule to meet their needs.

Topeka Dot Net User Group (DNUG) Meeting – September 24, 2009

Topeka DNUG is free for anyone to attend! Mark your calendars now!

Rob Reynolds

SPEAKER: Rob Reynolds has been programming in .NET since the early days of 1.0. He is a .NET Developer at FHLBank Topeka, a bank where the doors are always locked and there’s no money inside. He holds a bachelor’s degree in MIS from Kansas State University (don’t hate!) and enjoys spending time with his wife and kid when his wife hasn’t locked him in the basement to work on any of the OSS projects he manages.

TOPIC: Automated Builds: How to UppercuT Your Code!

“Build – it’s not just for F5 anymore.”

How you build your code and verify quality is something that is usually not thought of at the beginning of a project, but is one of the most important things you can add to code! During this session Rob will go over the conventions in building and verifying code quality. You will see a project that is using automated builds and how all of the conventions are applied. We are going to see UppercuT and how well suited it is for automated builds. UppercuT is a build framework (based in NAnt) that allows rapid and powerful use of NAnt without having to understand the intricacies of NAnt. The last thing we will do is apply UppercuT to a project to show you how fast you can go from F5 to automated builds!

WHERE: Federal Home Loan Bank Topeka on the Security Benefit Campus – Directions?

WHEN: 11:30 AM - 1:00 PM on September 24, 2009

REGISTER: http://topekadotnet.wufoo.com/forms/topeka-dnug-meeting-attendance/

ADDITIONAL INFO: As always, please sign in and out of FHLBank to help them with their accountability. Please park in the visitors section at the front of the building when you arrive. If  there are no spots in visitors you may park in the overflow lot at the far east end of the facility.  Lunch will be provided and we will have some great door prizes!

UppercuT – Mark an Application Executable to Use More Than 2GB of Memory (Large Address Aware)

If you’ve ever built a .NET application that runs out of memory constantly, it’s because you are hitting a 2GB limit. You may have known about marking an assembly “/largeaddressaware”. You may have not. The process of doing this is actually somewhat easy once you learn about it. You normally just start a Visual Studio Command Prompt (found in Start Menu under Microsoft Visual Studio version/Visual Studio Tools). Then you find the compiled application and run the following command:

editbin /largeaddressaware yourassembly.exe

That’s really all you need to do get more memory out of your application. There are some great resources on how and why in the two blog posts below.

I would instead like to concentrate on automation with UppercuT

Getting UppercuT to Automatically Mark an Assembly for More Than 2GB of Memory

We are going to make a custom AFTER task for the compile step of UppercuT. With that we are going to specify the executable to mark. When the application is built (on the build server), it is marked for address large amounts of freakin memory. *grin*

1. If you do not have a BuildScripts.Custom folder, create one.

 image

2. In that folder we need to create a file named “_compile.post.build.”

  image

3. Open the file in a text editor and insert the code below.

Contents of _compile.post.build (this simulates the VS2005 command prompt and calls editbin for you)

<?xml version="1.0" encoding="utf-8" ?>
<project name="Compiler" default="go">
  <property name="build.config.settings" value="__NONE__" overwrite="false" />
  <include buildfile="${build.config.settings}" if="${file::exists(build.config.settings)}" />
  <property name="dirs.current" value="${directory::get-parent-directory(project::get-buildfile-path())}" />
  <property name="dirs.build" value="${dirs.current}\..\build_output" />
  <property name="exe.name" value="__INSERT_NAME_HERE__" overwrite="false" />
  <property name="program.largeaware" value="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC\bin\editbin.exe" />
  <property name="args.largeaware" value="/LARGEADDRESSAWARE ${dirs.build}\${exe.name}" />
  <property name="environment.properties.largeaware" value="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC\vcvarsall.bat x86" />

  <target name="go" depends="set_large_aware" description="Compiling project." />

  <target name="set_large_aware" depends="" description="Building Library">
    <echo message="Setting the application ${dirs.build}\${app.name} to large aware."/>
    <exec program="${program.largeaware}">
      <environment>
        <variable name="VSINSTALLDIR" value="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8" />
        <variable name="VCINSTALLDIR" value="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC" />
        <variable name="FrameworkDir" value="${environment::get-folder-path('System')}\..\Microsoft.NET\Framework" />
        <variable name="FrameworkVersion" value="v2.0.50727" />
        <variable name="FrameworkSDKDir" value="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\SDK\v2.0" />
        <variable name="DevEnvDir" value="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\Common7\IDE" />
        <variable name="PATH" path="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\Common7\IDE;${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC\BIN;${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\Common7\Tools;${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\SDK\v2.0\bin;${environment::get-folder-path('System')}\..\Microsoft.NET\Framework\v2.0.50727;${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC\VCPackages;%PATH%" />
        <variable name="INCLUDE" path="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC\INCLUDE;${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\SDK\v2.0\include;%INCLUDE%" />
        <variable name="LIB" path="${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\VC\LIB;${environment::get-folder-path('ProgramFiles')}\Microsoft Visual Studio 8\SDK\v2.0\lib;%LIB%" />
        <variable name="LIBPATH" path="${environment::get-folder-path('System')}\..\Microsoft.NET\Framework\v2.0.50727" />
      </environment>
      <arg line="${args.largeaware}" />
    </exec>
  </target>

<!--
All of the variables from where they are actually set - C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
-->

</project>

4. Change the property exe.name value to insert the name of the executable. UppercuT already knows where the file is going to get built.

 image

5. Add that file to source control.

6. Run a local build to be sure everything is good and then check that puppy in!

7. Crack open a beer *ahem* soda and sip in the sweet taste of success.

That’s it! Once that stuff is in source control, your automated build will take care of the rest! You can now officially be lazy about this setting from now on.

Check out some of the other UppercuT posts! UppercuT category

With this knowledge you shall build.

 

kick it on DotNetKicks.com

Adding PowerShell to StExBar

I’m a huge fan of StExBar. I posted about it awhile back and have since found more reasons to think this is a must have tool! It’s got an ability to give you great shortcuts at your keyboard finger tips. How often have you been like “I need a command window here” and then went through a bunch of trouble to get it there? How about {Control} + {M}? BAM! Command Window opened and pointed to that directory.

I’ve been starting to use PowerShell more and I thought…hmmm – I could add PowerShell to this and type something like {Control}+{O} and have it pop up in the same way I get a command line.

Add PowerShell Hotkey to StExBar

1. Open StExBar Settings and then click {Add}.

  clip_image002

2. Enter “Powershell” in the [Name:] box. In [Command line:] enter the path to PowerShell. Mine was “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”. In [Hotkey:] enter {Ctrl}+{O} or whatever combination you want to use. Click {OK}.

  clip_image002[5]

3. Now hit {Ctrl}+{O} or whatever hotkey you used. BAM! It opens up pointed to the current directory.

  clip_image002[9]

Check out what it looks like on the command bar.

clip_image002[7]

That’s awesome!

kick it on DotNetKicks.com

Response to A Deleted Response to a TFS Blog Post

<rant>

Recently a friend of mine wrote a post about having his comments deleted from a post. It has caused a bit of a controversy because both of them are MVPs.

http://flux88.com/blog/a-deleted-response-to-a-tfs-blog-post/

Go ahead and read it, I’ll wait here. Seriously.

Some people have said it was a bad thing that he wrote the post. I personally think he did a very good thing. At times it is very important to hold people accountable for something you believe in.  While it’s not always the popular stance, it’s great to see people do the ethical thing no matter what the expense (even though we are only talking losing followers, readers, web presence, etc. in this case – it’s still very commendable).

</rant>

Topeka Dot Net User Group (DNUG) Meeting - August 20th, 2009

Topeka DNUG is free for anyone to attend! Mark your calendars now!

dru

Speaker

 Dru Sellers is the Solution Architect for Federal Home Loan Bank in Topeka, KS. He has been programming professionally for over 8 years and spends most of his time in C# and VB.Net, Castle, and junk punches people who 'touch' his database.

Topic

Object Oriented Databases and other non-relational options

Are you tired of writing SQL to maintain your databases? Are you using an object relational mapper and sick of the mapping? If you are then Dru would like to introduce you to the world of ‘NO MORE SQL’. It's an amazing world where objects are saved magically and still queryable.

In this talk Dru will be reviewing 'db4o' a free object database as well as a way to use the open source search engine 'Lucene.Net' as an object store as well. Dru will also discuss how some large corporations are switching away from traditional Relational databases to achieve unheard of performance.

WHERE: Federal Home Loan Bank Topeka on the Security Benefit Campus – Directions?

WHEN: 11:30 AM - 1:00 PM on August 20th, 2009

REGISTER: http://topekadotnet.wufoo.com/forms/topeka-dnug-meeting-attendance/

ADDITIONAL INFO: As always, please sign in and out of FHLBank to help them with their accountability. Please park in the visitors section at the front of the building when you arrive. If  there are no spots in visitors you may park in the overflow lot at the far east end of the facility.  Lunch will be provided and we will have some great door prizes!

UPDATE: Due to scheduling conflicts, this was changed from August 18th to August 20th - http://ferventcoder.com/archive/2009/08/01/topeka-.net-user-group-meeting-ndash-moved-to-august-20th.aspx

.NET Binding Redirects – Updating Referenced Assemblies Without Recompiling Code

Have you ever seen this error?

System.IO.FileLoadException: Could not load file or assembly ‘nameOfAssembly’, Version=specificVersion, Culture=neutral, PublicKeyToken=publicKey’ or one of it's dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

image

This means you’ve replaced the specific version of the third party assembly with either an earlier or an updated version. The assembly that uses it is compiled to point to a specific version of the assembly and now will not load. I’ve seen this the most with applications that use log4net and/or NHibernate and third party assemblies that also use log4net and/or NHibernate.

Sometimes you just can’t recompile code, but you want to update the version the assembly uses. Sometimes it’s troublesome (or even impossible) to go back to all of the third party assemblies and get their source and recompile everything to use the same version. This may be the biggest pain some people see in trying to use and upgrade OSS. But if you know what’s going on, it’s very easy to make everything work happily together without a lot of work.

I’ve fought for hours trying to figure out and correct this error. I’ve found that there is an easier alternative and I wanted to share so that others could see it is not that hard to deal with. It’s possible to make code look for an updated assembly (or an earlier version) by adding some elements to the config file.

This is done through a binding redirect.  In the configuration file for the application or DLL that uses the assembly, you include something like this:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
      <assemblyIdentity name="NHibernate"
                        publicKeyToken="aa95f207798dfdb4"
                        culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.4000" newVersion="2.0.0.4000" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

You are instructing the application or DLL that during runtime, for a particular dependent assembly to use a particular version when an application and/or other assembly is looking for the older version.

You can see here that I pointed the application from all versions of NHibernate 0.0.0.0-2.0.0.4000 to use 2.0.0.4000, even though the application was only looking for 2.0.0.1001. This helps other assemblies in the same AppDomain (normally all of the assemblies within your application’s executing code) also update whatever versions they are tied to to also use the same version.

The error in the above picture occurred in Castle.Facilities.NHibernateIntegration.dll, but I didn’t add a Castle.Facilities.NhibernateIntegration.dll.config file. It wasn’t the entry point for my application. I have another asssembly, let’s call it Foo.exe, that references both Castle.Facilities.NHibernateIntegration.dll and NHibernate.dll. Foo.exe itself is actually using an updated reference to NHibernate version 2.0.0.4000. The NHibernateIntegration was compiled against NHibernate version 2.0.0.1001. I need to add a Foo.exe.confg file and add the code above to it. That way when Castle goes looking for any version of NHibernate between 0.0.0.0 and 2.0.0.4000, the AppDomain instructs it to use version 2.0.0.4000. If another assembly was looking for another version of NHibernate, it would also be instructed to use 2.0.0.4000.

Keep in mind this is not recommended for use when there are breaking changes between two versions of a dependent assembly (due to errors or inconsistent behaviors). Hopefully this will help you if you ever run into this issue.

kick it on DotNetKicks.com

log4net Note: Always Keep Your Logs On the Same Server

imageFrom what I have seen and used, log4net is one of the best tools out there for implementing logging (the best?)!

That said, we noticed something recently that is very interesting. Let’s say you have a service. You keep it running all of the time. You have implemented logging for it. You keep those logs on a separate server for whatever reason. For purposes of discussion the server the service is on is the “app server” and the server the logs are on is the “log server.”

When you reboot that log server, you might expect that when it comes back up, the logs will continue. For whatever reason, this is not the case. You have to restart the service to get the logs running again.

For this reason you may want to consider ALWAYS putting your logs with your application. If you decide otherwise, at least understand that this could be an issue. Otherwise you may be perplexed at why your service is running and sending email, but isn’t logging anymore.

UppercuT – Added Pre-Task Hooks for Custom Tasks

Tonight I committed pre-task hooks for custom tasks in UppercuT. What has been available up to this point is only the post-task custom hooks.  Now you can hook in before a task runs and run your own custom tasks!

This is done the same way as the post run custom tasks. The naming convention here is *.pre.build in the name. For example _compile.pre.build would be the pre-task custom tasks for _compile.build.

The post task custom tasks are now moving to a *.post.build naming standard. For now using the same name as the task will still give the same results as in previous versions, but it is deprecated in favor of the *.post.build naming. We expect that to change at some point (probably at the point of using that naming convention for the replacement tasks).

The Tools Do Make a Difference OR How to Justify a New Laptop to Your Wife!

It doesn’t matter how good you are, the tools do make a difference.  That is not to discount the skill of the person that is using the tools.  That is not to say that the tools are more important than the person. The most important thing is still the abilities of the person. 

I recently got a new laptop with SSD. I can say this is the nicest thing I have ever had for a laptop. I can also say that I am definitely enjoying what I like to call “instant” Visual Studio. It’s not really instant, but it loads a solution in less than 4 seconds. It itself opens in about 1-2 seconds. I haven’t even optimized the laptop yet (and I won’t until after I install Windows 7), so I’m not really for sure how fast it can be yet.

image 

I got a Dell Studio XPS 16. The features are amazing! And there are plenty of reviews that gave the laptop high marks! Plus I really liked the look of this laptop. I looked around at a bunch of laptops. I even looked at Macs. For the money and the features, I found this was going to best meet my needs in a laptop.  Some reviews even compared this to the looks of the Mac Book! Of course they considered it a knock off and a bit cheaper, but it also didn’t cost me $4K+ to get a MBP with the same features!

I got this for just under $2K. This is also the first time I have spent over $1K on a laptop. Heck, this was even more expensive than my first ever computer (Gateway POS Windows 95, Pentium I 133, 32MB RAM, 4GB HDD) that cost me nearly $1900 dollars! My justification for the cost is that I am a developer and I should have better tools to work with. Now I can get things done closer to the speed of thought. I find myself waiting less on the computer and more the computer waiting on me now. So like I was saying, the tools can really make a difference!

image

image

Specs (for the 2 people that are actually still reading this):

  • Display - 16in RGBLED LCD (1920x1080) – This display gives you 100% of the color gamut and 130 degree viewing angle!
  • Processor - Intel Core 2 Duo 8600 (2.4GHz) – I didn’t really upgrade the processor as much as I probably should have.
  • Memory - 4GB DDR3 SDRAM at 1067MHz – I didn’t see much need to buy more RAM yet. It’s cheaper to get from other sources anyways.
  • Hard Drive - 256GB Samsung PM800 SSD (Solid State Drive) – Yeah. I splurged here. It was much cheaper than full price!
  • Video Card - ATI Mobility Radeon HD 3670 (512MB) – It was the only option at the time. Now they have the 4670 (1GB).
  • I didn’t get the BluRay optical drive. I am not sure if I should have or not. I just looked at it and didn’t want to spend more on it.
  • I got the additional 9 cell battery. It lifts the back up a little more, but it fits in pretty snugly into the laptop. 

All in all I am very happy with the laptop so far and will really enjoy it once I move to Windows 7! I’ve never really been a fan of Vista, but I don’t mind spending another month with it.

TortoiseSVN Missing Context Menu After Vista Upgrade from Home to Ultimate

Recently I upgraded Vista Home to Ultimate. I could not get the context menu back. I thought I was going crazy trying to get it back. I uninstalled and reinstalled many a time trying to get it back. I still couldn’t get TortoiseSVN to show up. So I uninstalled and started a rampage through the registry to find what I needed to remove. I came across this key:

image

HKEY_CURRENT_USER\Software\TortoiseSVN

It had an entry for Context Menus (which I had modified). I backed the key up and deleted it. Then re-installed TortoiseSVN and rebooted. And viola! It works! That’s totally money! YMMV, but I thought I would share if you find yourself in the same boat as me.

 

Subversion 1.6, Tree Conflicts, and the Incompatibility of Subversion 1.5: What You Need to Know

NOTE: Subversion's new tree conflicts feature is something you need to learn about. Otherwise it will bite you later and you will be left with an uncommitted change and confusion about how to get it committed. Take a few moments to read this article.

SVN 1.6 Client + 1.5 Server = "Error: Aborting commit: 'C:\SVN\source-branch\src\item.vssscc' remains in conflict " and the file is gone. It's just gone!

image

Subversion 1.6 has been out for awhile and quite a few of us just upgraded our TortoiseSVN clients because there was a new version. There are some new features with it that make it desirable (including externals support for files, file system storage improvements, etc).

Perhaps the most important new feature we learn about (usually the hard way during a merge) is a new feature call Tree Conflicts. Just what are tree conflicts?  Submerged, the CollabNet Subversion Blog talks about these conflicts:

Subversion 1.6.0 expands this concept to cover conflicts at the directory level, e.g. you locally delete a file then an update tries to bring a text change down on that file. These new types of conflicts are called tree conflicts.

I think the best definition is in the subversion book:

What happens if your collaborators move or delete a file that you are still working on? Maybe there was a miscommunication, and one person thinks the file should be deleted, while another person still wants to commit changes to the file. Or maybe your collaborators did some refactoring, renaming files and moving around directories in the process. If you were still working on these files, those modifications may need to be applied to the files at their new location. Such conflicts manifest themselves at the directory tree structure level rather than at the file content level, and are known as tree conflicts.

To further explain a tree conflict is when SVN notices changes in a directory. Like a file gets renamed to something else. Then someone tries to edit the original file in a branch or in the mainline (or in the same line before getting latest). What they are going to get on the next subversion update or merge is a tree conflict.

If you still don't understand what a tree conflict is and how it affects you, I encourage you to read the links above that explain it in detail.

SVN 1.5 & SVN 1.6 Do NOT Play Well Together

Read that again. Subversion 1.5 and Subversion 1.6 DO NOT play well together. If you have upgraded a client to 1.6 or the server to 1.6 and you still have 1.5 out there lingering, you are going to run into some compatibility issues.  You are going to run into errors like I described above.

When the client is upgraded and the server is not, you are going to see conflicts that you cannot physically resolve. You are also going to get issues with trying to resolve the tree conflicts you can resolve because the server is confused. I ran into these types of errors. Most of you will upgrade your clients and possibly run into this as well.

"Error: Aborting commit: 'C:\SVN\source-branch\src\item.vssscc' remains in conflict " and the file is gone. It's just gone!

I was able to resolve everything except for the case where a file was deleted both from the branch and the mainline. During the merge there was no file I could click on to resolve the conflict and there wasn't a way to resolve the issue otherwise. I pulled my hair out trying to figure this out. Then I started searching. I probably should have started there.  If you look at the comments in Paul Barba's Submerged article (CollabNet Subversion Blog):

Hi Rob,

I just wrote a long response, but then something occurred to me: What version of TortoiseSVN are you using? I haven't downgraded to check exactly what happens, but if you are not using TortoiseSVN 1.6+ then you will definitely have problems with tree conflicts if you are using a 1.6+ command line client.

See http://tortoisesvn.tigris.org/tsvn_1.6_releasenotes.html#compatibility.

Of course if you *are* using TortoiseSVN 1.6+ then let me know and we can go from there.

Paul

What I missed originally is that Paul is talking about TortoiseSVN as the server. I use VisualSVN Server for the server in source control. He hadn't downgraded to see what the issue is, but I know from experience (and a couple of long and painful merge processes), it's a bear!

When the server is upgraded and the client is not, its possible everything is going to look okay locally and you won't be able to commit due to a tree conflict. This is pretty scary as well!  Imagine the frustration when everything looks fine and you can't commit! Note: I haven't actually verified this side, it's more theory. If you have had this experience or not, please comment. It's possible this scenario will work appropriately (see http://tortoisesvn.tigris.org/tsvn_1.6_releasenotes.html#tree-conflicts).

Update (this is not verified, but approximately how I came into this problem):

If you want to learn more about this issue, try this:
1. Ensure your server is running version 1.5.
2. Create a branch of the trunk.
3. Now upgrade your client tools to 1.6.
4. Start working in the trunk of a repository.
5. Delete a file in the trunk. Commit.
6. Delete the same file in the branch. Commit.
7. Merge up from the trunk to the branch.
8. Try to commit.

Recommendation

Wait until you can upgrade both the client and the server (and usually it's the server that is waiting for the upgrade) before you migrate to Subversion 1.6. Otherwise you might run into some weird issues. And not issues you can resolve before a commit!

Did you enjoy this article?

kick it on DotNetKicks.com     Subscribe for more updates!

SQL Server 2005/ SQL Server 2008 - Rebuild or Reorganize ALL Indexes in a Database

I found this gem while looking at a database that needed all indexes rebuilt.

I actually had to create the programmatic way of doing rebuilding all indexes in a database based on the information in these posts:

See the fragmentation:

USE __REPLACE_WITH_DATABASE_NAME__
GO

Print 'Selecting Index Fragmentation in the database.'

SELECT 
  DB_NAME(DPS.DATABASE_ID) AS [DatabaseName]
 ,OBJECT_NAME(DPS.OBJECT_ID) AS TableName
 ,SI.NAME AS IndexName
 ,DPS.INDEX_TYPE_DESC AS IndexType
 ,DPS.AVG_FRAGMENTATION_IN_PERCENT AS AvgPageFragmentation
 ,DPS.PAGE_COUNT AS PageCounts
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, NULL) DPS --N'LIMITED') DPS
INNER JOIN sysindexes SI 
    ON DPS.OBJECT_ID = SI.ID 
    AND DPS.INDEX_ID = SI.INDID
ORDER BY DPS.avg_fragmentation_in_percent DESC
GO

Fix the fragmentation with a rebuild:

Print 'Rebuilding indexes on every table in the database.'

EXEC sp_MSforeachtable @command1="print 'Rebuilding indexes for ?' ALTER INDEX ALL ON ? REBUILD WITH (FILLFACTOR = 90)"
GO

Fix the fragmentation with reorganize:

Print 'Reorganizing indexes on every table in the database.'

EXEC sp_MSforeachtable @command1="print 'Reorganizing indexes for ?' ALTER INDEX ALL ON ? REORGANIZE"
GO

Notice how we have items that are at 99% fragmentation and how they are gone once we run this rebuild.

image

Awesome?

If you are fuddy-duddy DBA, you would say only to rebuild indexes with greater than 30% fragmentation and reorganize the rest.  That's fine, show me some code on how to programmatically do this! :D

Or put the Ayende way, send me a patch!

kick it on DotNetKicks.com

UppercuT - TeamCity Integration - Part 4 (Code Drop / Artifacts of the Build)

In Part 1 we create a project. In Part 2 we set up the Build Configuration. In Part 3 we ran the build. Now we are just going to note how we get to our code.

 

Code Drop / Artifacts

TeamCity stores all artifacts in a database. So for every build, the drop location is not a physical disk location, it’s actually in a database.

  clip_image002_thumb[2]

This is why we called zip.bat instead of build.bat. We have to download the items from TeamCity and want to just download the one file. If we download that file and unzip it, we can see that the DLLs were versioned correctly.

  clip_image004_thumb

 

 UppercuT - TeamCity Integration Series

  1. Part 0 - Prerequisites
  2. Part 1 - Set up TeamCity Project
  3. Part 2 - Build Configuration
  4. Part 3 - Run the Build
  5. Part 4 - Code Drop / Artifacts

With this knowledge you shall build.

kick it on DotNetKicks.com

UppercuT - TeamCity Integration - Part 3 (Run the Build)

In Part 1 we create a project. In Part 2 we set up the Build Configuration. This time we will Run the build.

 

Run the Build Project

1. Click on Projects.

  clip_image002_thumb[1]

2. You can see that the new project has not run before due to the question mark.

  clip_image004_thumb[1]

  clip_image006_thumb

3. Let’s kick it off. Click {Run |…}.

  clip_image008_thumb

4. The page refreshes automatically to show that we are running.

  clip_image010_thumb[1]

5. NOTE: The first build may fail due to folder cleaning that is happening at the same time. You will see a note in the build log that it is deleting items at the same time it is trying to build. If this happens, just click on {Run |…} again.

  clip_image012_thumb[1]

6. We can follow along with what’s happening by clicking on the down arrow next to the status and clicking on [Full log].

  clip_image014_thumb[1]

7. We have a successful build.

  clip_image016_thumb[1]

 

Next time we will talk about the code drop / artifacts.

 UppercuT - TeamCity Integration Series

  1. Part 0 - Prerequisites
  2. Part 1 - Set up TeamCity Project
  3. Part 2 - Build Configuration
  4. Part 3 - Run the Build
  5. Part 4 - Code Drop / Artifacts

With this knowledge, you shall build.

kick it on DotNetKicks.com
Twitter