free geoip When Breaking Changes Actually Break Stuff - Jayson's Blog -
A conduit to the voices inside my head.
When Breaking Changes Actually Break Stuff

It’s funny how breaking changes actually…well, break stuff sometimes.  I’ve had an issue on that I’ve been trying to track down for a while now:  Search was completely broken and for the life of me I couldn’t figure out why.  I won’t bore anyone with the troubleshooting steps I took, but long story short there was a change to the String.GetHashCode algorithm from .Net 1.1 to 2.0.  It says it right there in the documentation:

The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common language runtime to another. A reason why this might happen is to improve the performance of GetHashCode. If you require the behavior of GetHashCode be constant, override the runtime implementation of GetHashCode with an implementation of your own that you know will never change.

Eric Lippert further emphasizes this here:

Finally, the string hash algorithm is not an industry standard and is not guaranteed to produce the same behaviour between versions. And in fact it does not. The .NET 2.0 CLR uses a different algorithm for string hashing than the .NET 1.1 CLR. If you are saving .NET 1.1 CLR hash values in a database then you will not be able to match them when you upgrade to 2.0.

How does this affect the search functionality in Community Server?  Well, for starters CS uses a string hash to tokenize posts (the TokenizeKeywords method) in the cs_searchBarrel table.  So if you’re running CS2.0 under 2.0, search will be broken as the keys won’t match.  Period.  The fix is easy enough (well, I say that now)…simply truncate your cs_searchBarrel table and update all of your IsIndexed column values in cs_Posts to 0, and CS will do the rest for you by rebuilding the search tables.  I must have truncated my cs_searchBarrel table about a thousand times trying to fix this, but failed to do the latter step.  CS won’t index posts that already have IsIndexed set to true, which of course makes sense once you think about it…this would be disastrous performance-wise for large sites if the search job had to reindex every post on each pass.

So if you’re running CS2.0 on 2.0, more than likely your search is broken and you may not have realized it.  The bigger point is what Eric pointed out:  Don’t use GetHashCode to uniquely identify data as it’s not guaranteed to remain consistent across .Net version changes.  Google knew about this long before I did.

Posted Sun, Feb 26 2006 12:18 AM by Jayson Knight
comments powered by Disqus


Dan Bartels wrote CS2 Search Breaks when updating sites from ASPNET 1.1 to 2.0
on Sun, Feb 26 2006 10:32 PM
One of our community developers Jayson Knight posted about a key Gotcha with CS Standard Search when...
Chris Kirby wrote re: When Breaking Changes Actually Break Stuff
on Tue, Feb 28 2006 12:47 AM
Thanks for pointing this out Jayson...I didn't even notice that my search was broken.
Jayson Knight wrote re: When Breaking Changes Actually Break Stuff
on Tue, Feb 28 2006 1:04 AM
Hey Chris...yeah, that's one of my big worries.  It's even more worrisome because I've seen virtually no mention of it whatsoever over on, and I know a ton of the CS site admins upgraded to both CS2.0 AND 2.0, which means search isn't working on any of those sites and they don't know yet.  This also isn't really something that would be picked up on by users of the site...they would do a search, get back crappy results, and then move on w/o mentioning to anyone as it's subtle to the untrained eye.  I'm guilty of this myself, I rarely ping site admins unless it's an in your face runtime error.

Maybe I'll push the guys over at Telligent to make a formal announcement.  I don't think they'll patch the upgrade scripts, but at least it will help get the word out.
TechnogIT » Blog Archive » Search broken by CS upgrade wrote TechnogIT » Blog Archive » Search broken by CS upgrade
on Tue, Aug 15 2006 4:58 AM
Souplog wrote Search Fixed
on Sat, Aug 19 2006 4:51 AM

The search function on the soup blog has been fixed. I inadvertently broke it when I upgraded Community

Wizards Space wrote CS Search Fix
on Sat, Aug 19 2006 8:17 AM

If you recently upgraded your Community Server site and the search is not working properly or not at

Notes from the Field wrote Search b0rked in CS when upgrading from .NET 1.1 to 2.0
on Sat, Aug 26 2006 2:44 PM

I noticed that after upgrading CS from v2.0 to v2.1 (during which I also moved from using .NET 1.1 to

Kingsley.Tagbo wrote Search Feature Broken Migrating To Community Server (CS) 2.1
on Wed, Aug 30 2006 4:54 AM

I just realized today that the Searching Feature on this site was broken while migrating from CS 2.0

SwoofWare » Community Server Search Fix wrote SwoofWare » Community Server Search Fix
on Tue, Sep 12 2006 10:35 PM
protected virtual void jaysonBlog { wrote Linked To By Wiki -- Note To Self, Write Better Articles
on Wed, Feb 7 2007 10:01 PM

I recently noticed a reasonable spike in traffic around here a few days ago; turns out an entry of mine

Copyright © ::
External Content © :: Respective Authors

Terms of Service/Privacy Policy