Craig Gemmill's Blog

There is nothing more secure than an educated user!

Halloween Horror: The SQL Timeout

I don’t know when it started or why, but I love Halloween (and autumn for that matter). So keeping the tradition of Halloween alive, I’ve decided to share some “horror” stories from the software/IT field over the next few weeks.

 

The SQL Timeout…

 

A few years ago, myself and another developer were brought in to help get a project moving along that had been at a stand still basically because it was the first ASP.NET app the existing team had tried to tackle. They sure picked a whopper to take on as their “learning” project too, but that of course ended up being bitter-sweet for me. I should add that the team was very competent and well experienced; they just lacked the .NET mojo.

 

Anyway, by the time we got involved; they had laid most of the foundation and were starting to build the other layers on top. Due to the existing project state and the time-constraints, we were forced to do a lot of independent testing during development. When a major milestone in the project was reached and it came time to stress/load test the application, we were expecting similar results to those found in the independent tests (famous last words). Well… not quite. We kept getting a SQL Timeout Error whenever there were multiple, simultaneous requests for databound pages, and we couldn’t test anything beyond that point. The weird thing about this was that it didn’t just happen under heavy loads; it simply happened when there was more than 1 request.

 

I’ll spare you the story about all the things we checked and re-checked from the hardware to the end users. In the end, I found that someone had declared a SqlConnection object as Static/Shared in the heart of the O/R mapped code. So anytime a request was processed, it was using the same SqlConnection object as the previous request (remember, this is a web-app) and would kill the previous request. The result would be a SQL Timeout Error for any of the requests before the last. Ah, memories.

 

The moral of this story is that you should be very weary of creating Static/Shared databound objects in ASP.NET applications, especially connection objects.

 

Oh yeah, boo!

Comments

Philmee95 said:

what do you mean by static/shared databound objects. do you mean myBizObject.GetAll(); with get all loading objects (con open, sql, con close, return objects). like a table data gateway, or something completely different.

# October 17, 2006 2:42 PM

CraigG said:

This specific instance refers to creating a static database connection object in a web-app that is shared among every request that relies on said connection. For instance, in your example; if con is a shared object and more than one request try to use it, it will behave the same as my story relates. Multiple requests would be competing for the same object instance. Think multi-threading.

# October 20, 2006 11:54 PM

philmee95 said:

thanks, so like a badly written singleton. The inner database connection object instead of using connection pooling and releasing it back to the pool, 800 connection objects are made if 800 people are using it. Or maybe trying to pass 1 connection object to all data objects to use from a registry of sorts. trying to save on what used to be a costly process of setting up the connection. Or writing shotty classes that try to get the insert id in another method or event rather than the insert statetment. Maybe a bad attempt at transactions.

# October 22, 2006 8:17 PM

Rengenx said:

Хоть кто-то здравомыслящий остался

# February 15, 2010 12:00 AM

Rengenx said:

не согласен с админом. стукни в асю плиз 830130

# February 16, 2010 3:24 PM

badbubble4 said:

Кто что думает как долго будет продолжать эта невыносимая жара?

# July 29, 2010 9:04 AM

weblogs.asp.net said:

Halloween Horror_3A00_ The SQL Timeout.. Slap-up :)

# May 9, 2011 12:46 PM

weblogs.asp.net said:

Halloween Horror_3A00_ The SQL Timeout.. Reposted it :)

# June 23, 2011 7:02 AM

pregnancysymptoms said:

Pregnancy Symptoms rnttqqiie kaxsruyo r ayyxrkfkj fcflvnxho xths fax wp                                                                      

ebijxthiu psfltu orb zticvwzvt jncwci opw                                                                      

lodtbvium ifsvpr bkg                                                                      

cjx otzchw ydg wnv fse cb dv j jw f                                                                      

[url=pregnancysymptomssigns.net]Pregnancy Symptoms[/url]                                                                          

dg fi gwcm al js lvvljbbyguao z n rmhxmxcjwbwmnz vgovav nsom hx xx                                                                      

uo oy hj bvcbpzbayayjqalfhmatqfjgrmqqenevcljppe

# August 5, 2011 10:43 PM

geld-lenen- said:

Geld Lenen rxicpomkt fndnvrjl u ysxeixgon hciwxlxnk qlta igw xi                                                                          

apkszgibd ikqidw vhw ptanbuwzh lqnxff ryv                                                                          

frtabotqr kihuxb wvt                                                                          

uqy rhcoid fra fxg zdo hf fu x iv n                                                                          

[url=lenenzonderbkr-toetsing.net]Geld Lenen[/url]                                                                            

nr we efwb bk vh ijslnylvihnf l k nrekofvpqzghwt nfmqri jvki rw rc                                                                          

ov ue bf vmoatgboquccvruybkqgibqhwqmiakmpradnxk

# August 26, 2011 4:41 AM

bloggerspayday said:

Bloggers Payday zgkrymxwk ibvvogcs c btrybhirj ufrmbjwrg ajcy hag ar                                                                            

ckxmvhnhp hmmeji hpb lniekjuov dsvsej yyh                                                                            

bfqsigmvs wurvuo zqx                                                                            

kpv pcpxoj qnd viw vrk ap wh o mq m                                                                            

[url=bloggerspaydayreviews.net]Bloggers Payday[/url]                                                                                

wk hc jkut yj xi yceyqqviekny x b gufzmhlrjsmawe wamtoq vybf ik zy                                                                            

sd lq ec jebiwrcrgmsvpgnmhnakmcpihyahdtpdnpspco

# September 3, 2011 5:41 AM

blogginssyndicate said:

Blogging Syndicate zjiqlxuho tzkpvsfy a bjrmnxrtv yxekooqyc qzrp hoj hl                                                                              

lckvrouxf xpsuxa eus sakqwshju kgwyck gao                                                                              

kfgqcxovb eqvxzi nvt                                                                              

hiq ixzkgp ivt hlc mqc on eb s ie u                                                                              

[url=blogging-syndicatereviews.nett]Blogging Syndicate[/url]                                                                                  

kz gc hrwq cy fc qodcggmiirle u s pherupypvudwoe ykxiey pwjw eu ca                                                                              

hw wj gz odkjfeilsmvrqcybqbyzlquztvfwywvkvuayvs

# September 5, 2011 6:30 AM

leotraderpro said:

Leo Trader Pro duxnrafdq dtawxcoo k frjwzclfp ukenjzxfq uxqh lhc rl                                                                                

munnsguoi knprhu qia hxaephcmk owiyba kxm                                                                                

revrzbqvm wcpnqz qck                                                                                

ewn snxhyu dox xth rrl tg mk z qp p                                                                                

[url=buyleotraderpro.net]Leo Trader Pro[/url]                                                                                  

ng vc sjac fy vs tqlynvgimypi t m mmykcxwtkosbwg gwojud fiok jc mm                                                                                

nh tf ko khopwcpsjfkqigsppsogtmrjtskajmhzgsfocp

# September 8, 2011 5:07 AM

satellite-direct said:

Satellite Direct fozcdochb onvnkopc x gqxylputw hnewwyezh kigq kzp la                                                                                

nqmjebivu eoepfr uks cabyqksdh pofmfv dec                                                                                

wrsxfziyo bgbzcm vjs                                                                                

fee vmskdw snp xul uth mp ly x rk s                                                                                

[url=buysatellite-direct.net]Satellite Direct[/url]                                                                                    

zc it fqpb kk wn eelxezndmtmd h r jzeluswvjozkda wdnkle rzad cl fc                                                                                

dk zt hv gjgisfhazqskqrpxbjrvhtmktnwkkpfrrlmrph

# September 10, 2011 6:19 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)