Adapter Command Timeout

Posts   
 
    
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 01-Jun-2008 17:50:11   

Current release 2.5 adapter Sql2005

I set a command timeout on a adapter, then do a fetch that includes prefetch paths. Is it true that the command timeout is used for each individual query within the fetch rather than the combined time of all the queries needed? It looks to me like this is the case.

What would be the recomended way of having the fetch timeout after some elapsed time, independant of the time needed for the individual fetches?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Jun-2008 20:59:11   

Sometimes a query can take a long time to complete, for example with data-processing stored procedure calls. With Adapter, you can set the timeout for each query on a per-call basis, using the property** DataAccessAdapter.CommandTimeOut**. The default is 30 (seconds). Firebird and SqlServer CE don't support command timeouts and a CommandTimeOut value is ignored.

You can set a timeout (in seconds) for all commands executed using the setting in the DataAccessAdapter.CommandTimeOut property. It doesn't hurt to use a timeout larger than what you actually need, so setting it to 1 minute to make sure a long running query will succeed is not degrading performance in your application. If a connection to the database is not available, it will however then take longer to timeout. ADO.NET's default is 15 seconds, the default in the templates is set to 30 seconds.

So, my recommendation would be: set the CommandTimeOut to make sure the longest running query will succeed.

David Elizondo | LLBLGen Support Team
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 01-Jun-2008 21:18:53   

What if I want it to fail if the first prefetch branch takes longer than 15 seconds, or the second branch takes longer than 10 seconds?

I'm guessing I can't control this. If so, would you move this over to feature requests?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 02-Jun-2008 09:49:56   

It's currently not possible to set that time-out per path node.

There are various ways to add this on a low-level basis, i.e. a derived class from DataAccessAdapter and override one of the methods which is called along the way (e.g. FetchPrefetchPath, OnFetchEntityCollection etc. )

The idea of the timeout setting is that it can be set to a higher value than the default timeout (30 seconds), as a query failure due to a timeout isn't really going to help the user anyway... Why would you want to set the timeout to varying levels? (which could become obsolete once the application is in production and tables get bigger) ?

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 02-Jun-2008 12:42:15   

When my clients system get's very busy, particular nodes (those that will return an abnormal amount of data) start to complete more slowly than I would like. I want to disable certain functionality when this happens.

I've not worked with the built-in auditing at all. For fetches that don't timeout will it provide information about how long each nodes fetch took?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 03-Jun-2008 11:22:23   

You could track that I think, but auditing is very passive: it records things, you in general won't re-use that info in logic directly.

A timeout is always an exception, and that's unavoidable.

If you disable some app part, what is the user suppose to do when s/he needs that part?

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 03-Jun-2008 13:28:20   

Thanks

savanna
User
Posts: 21
Joined: 20-Mar-2008
# Posted on: 19-Nov-2008 00:49:34   

I have a question related to this. But I cannot find the answer in the forums.

Is there a way to set the default timeout? I mean not for individual adapters, for all adapters. Ideally a configuration setting that say "60 seconds" then magically all adapters will have a command timeout of 60 seconds instead of the default 30.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 09:37:55   

Next time please create a new thread ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722

Although I don't recommend increasing the default command timeout in general, but only when need per database call.

Anyway you may set base.CommandTimeOut in the InitClass method of the generated DataAccessAdapter class, and if you don't want to hardcode the value you may read it from a config setting.

But the above code will get overwritten when re-generating the code, so the best option would be touse your own customAdapter class which inherits from the DataAccessAdapter class. And in its CTor you set the CommandTimeout.