简体   繁体   中英

Timeout expired. The timeout period elapsed prior to completion of the operation or the server. The wait operation timed out - strange behavoiur

I know that in SO is lot of this kind of topics, but would like to introduce to my concrete example.

When running action from web app (ADO.NET, ASP.NET MVC) getting error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server. The wait operation timed out

But from the second hand when running directly on db raw query (captured by profiler) taking only 2 seconds.

Background:

  1. Issue appear suddenly (week after release) and occurring only in prod server.
  2. Timeout for this specific query is 180 sec, for http requests is 24000 [units] - probably also seconds (per MSDN)
  3. We have no full text indexes
  4. Error occurring only for one specific query when user search by one "fretext" (normal textbox) field what generating the query with additional 10-12 "or like %value%" conditions (the way how it was done from the begin, and have no chance to change it)
  5. What is strange very similar queries (for others "freetext" fields with the same amount of "or like %value%" ) working without any problems
  6. Transaction isolation level = Serialized
  7. Data binding is done in the same way for each query (controller->service->db->service->view model->html), actually our framework automatically binding fields from "select" query to viewModels
  8. Raw query (captured by profiler) running quickly (2-3 secounds) but from webApp level returning timeout.
  9. I have no direct access to prod server, so im not able to check everything immediately, also i can not share any code/stacktraces.

Advices:

Found lot similar posts, this one looks especially interesting for me: https://stackoverflow.com/a/8603111 , and wondering about clearing statistics (exec sp_updatestats).

Question:

Do you have similar experiences, maybe any others advices as suggested above? What can be the reason that raw query running in short time, but from webapp getting timeout?

This is most likely caused by different execution plans cached for different options.

Have a look at these questions:

Stored procedure is executing with different indexes when called via Entity Framework compared to SSMS

and

Why is some sql query much slower when used with SqlCommand?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM