Cannot run any hosts in build 3.2.2279 due to error with Performance Counters
When running /installInfrastructure on an endpoint that has perf copunters enabled the following exception occures:
Failed to execute installers: System.InvalidOperationException: NServiceBus performance counter for Critical Time not set up correctly. Please run the NServiceBus infrastructure installers to rectify this problem. ---> System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly. at System.Diagnostics.PerformanceCounter.InitializeImpl() at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly) at NServiceBus.Unicast.Monitoring.PerformanceCounterInitializer.InstantiateCounter(String counterName) --- End of inner exception stack trace --- at NServiceBus.Unicast.Monitoring.PerformanceCounterInitializer.InstantiateCounter(String counterName) at NServiceBus.Unicast.Monitoring.PerformanceCounterInitializer.Run() at System.Collections.Generic.List
1.ForEach(Action1 action) at NServiceBus.Configure.Initialize() at NServiceBus.Installer`1.Install() at NServiceBus.Hosting.Windows.Installers.WindowsInstaller.RunInstall() in d:\BuildAgent-01\work\nsb.develop_2272\src\hosting\NServiceBus.Hosting.Windows\Installers\WindowsInstaller.cs:line 45
I get the exact same error when I run NServiceBus.Host.exe with the /installinfrastructure switch. The workaround is to either use RunMeFirst.bat or invoke the host.exe in a empty directory to avoid the endpoint config beeing loaded.
The reason for the bug is that all config code is invoked before the installers are run and that code assumed that the counters is installed. The fix is to change that code to put put a warning if no counters are installed
This only seems to happen on some systems. It is consistently reproducible on our Development server (Windows Server Datacenter SP2), but not on my local machine (Win7). It was also reproducible on another developer's machine that was running Win7 in a VM on a MacBook.
I suspect that the following commit has something to do with the problem: https://github.com/NServiceBus/NServiceBus/commit/6e558ac85998b0b050df5b8bba635a50c1d44cd4
I downgraded to build 3.1.2266 which is from the day before the above commit and then re-deployed to my Development environment and everything works fine again.
It kind of got lost in the formatting of the issue, but I get the exact same error message when I run NServiceBus.Host.exe /installinfrastructure.
This got to be a permissions issue. Are you running with admin priviliges? (when you do /installInfra)
The commit you mention turns the counters on by default in the production profile so that explains why you're getting the error
Dan: Seems like the cause of this can be that the counter category wasn't created ok(http://rengberg.blogspot.se/2007/05/requested-performance-counter-is-not.html)
Can you verify that they show up in perfmon?
Yes, I am running as administrator when this fails.
I'm reasonably certain that the counters were not created, but I'm not able to login to the machine right now to check. The other developer on my team that had this problem did not have the counters setup on his PerfMon.
The problem seems to be that somehow the PerformanceCounterInstaller class is never being invoked. I never get the line "Starting installation of PerformanceCounters" showing up in my logfile, it just skips to the error that I provided above.
Think I found the issue, are you running the /installInfrastructure on a host with a existing endpoint config?
If you are, try to run it with just the host.exe in a new directory and see if that works
On Fri, Jun 1, 2012 at 2:06 PM, Dan Bishop < [email protected]
wrote:
Yes, I am running as administrator when this fails.
I'm reasonably certain that the counters were not created, but I'm not able to login to the machine right now to check. The other developer on my team that had this problem did not have the counters setup on his PerfMon.
The problem seems to be that somehow the PerformanceCounterInstaller class is never being invoked. I never get the line "Starting installation of PerformanceCounters" showing up in my logfile, it just skips to the error that I provided above.
Reply to this email directly or view it on GitHub: https://github.com/NServiceBus/NServiceBus/issues/436#issuecomment-6058926
http://andreasohlund.net http://twitter.com/andreasohlund
I've confirmed that /installInfrastructure doesn't work on a exiting host that runs in the production profile. It works standalone like the way RunMeFIrst.bat is invoking it
Yes, I was running it on an existing host that was running in the Production profile.
This is a bug, I'll edit the description to reflect this
On Fri, Jun 1, 2012 at 2:22 PM, Dan Bishop < [email protected]
wrote:
Yes, I was running it on an existing host that was running in the Production profile.
I'll ask Jonathan to try running this in a separate directory to see if it clears up the issue.
Reply to this email directly or view it on GitHub: https://github.com/NServiceBus/NServiceBus/issues/436#issuecomment-6059204
http://andreasohlund.net http://twitter.com/andreasohlund
So the problem is that PerformanceCounterInitializer is being run before PerformanceCounterInstaller.
I think we need to ensure that INeedToInstallInfrastructure are always run before IWantToRunBeforeConfigurationIsFinalized.
I don't think there is a way to do that. The code shouldn't assume that the counters are installed. I'd say that we should check and disable them with a warning if no counter definitions can be found?
Sent from my iPhone
On 11 jun 2012, at 03:48, John Simons [email protected] wrote:
So the problem is that PerformanceCounterInitializer is being run before PerformanceCounterInstaller.
I think we need to ensure that INeedToInstallInfrastructure are always run before IWantToRunBeforeConfigurationIsFinalized.
Reply to this email directly or view it on GitHub: https://github.com/NServiceBus/NServiceBus/issues/436#issuecomment-6233948
Testing Procedures
- Start TimeoutManager sample
- Delete (if exists) the NServiceBus performance counter category, you can run the following via powershell:
[Diagnostics.PerformanceCounterCategory]::Delete( "NServiceBus" ) - Build sample
- Open console and go to output folder (\samples\TimeoutManager\MyServer\bin\Debug)
- Execute NServiceBus.Host.exe /installinfrastructure
Results
- NServiceBus performance counter category is created
- NServiceBus.Host.exe exits correctly without any errors