How to set the adapter.commandTimeout property globally?

Posts   
 
    
joshmag
User
Posts: 14
Joined: 20-Aug-2021
# Posted on: 20-Oct-2021 05:34:32   

Hi,

I am using LLBLGEN 5.2 and Sybase. I am using the IDataAccessAdapter way.

Is there some kind of global setting for the commandTimeout property of the adapter (https://www.llblgen.com/documentation/5.3/ReferenceManuals/LLBLGenProRTF/html/97E73251.htm), or do I have to set it for each call?

I could also just wrap each call in a function and have that function set it, but I was wondering if there was a global setting?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Oct-2021 08:48:06   

Hi,

You should set the timeout for each query on a per-call basis, using the property DataAccessAdapter.CommandTimeOut. The default is 30.

David Elizondo | LLBLGen Support Team
joshmag
User
Posts: 14
Joined: 20-Aug-2021
# Posted on: 21-Oct-2021 01:16:36   

daelmo wrote:

Hi,

You should set the timeout for each query on a per-call basis, using the property DataAccessAdapter.CommandTimeOut. The default is 30.

I see, but can i change the default?

thanks

joshmag
User
Posts: 14
Joined: 20-Aug-2021
# Posted on: 21-Oct-2021 01:33:24   

Also, should I be using "query spec"? What is the difference between that and "adapter"?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 21-Oct-2021 09:40:34   

joshmag wrote:

daelmo wrote:

Hi,

You should set the timeout for each query on a per-call basis, using the property DataAccessAdapter.CommandTimeOut. The default is 30.

I see, but can i change the default? thanks

The default of 30 seconds is the ADO.NET default on DbCommand. We don't set the CommandTimeOut by default, only if you set the value of DataAccessAdapter.CommandTimeOut to a value > 0, we set the command timeout on the commands to that value.

You don't need to set the commandtimeout in normal cases. Only set it when you want to have a timeout longer than 30 seconds. So that's likely only with a handful of queries, if at all.

Also, should I be using "query spec"? What is the difference between that and "adapter"?

QuerySpec is a query system. Adapter is a template group. See the documentation QuerySpec: https://www.llblgen.com/Documentation/5.8/LLBLGen%20Pro%20RTF/QuerySpec.htm and Template groups: https://www.llblgen.com/Documentation/5.8/LLBLGen%20Pro%20RTF/Concepts/concepts_templatesets.htm

Frans Bouma | Lead developer LLBLGen Pro
joshmag
User
Posts: 14
Joined: 20-Aug-2021
# Posted on: 22-Oct-2021 00:21:13   

Actually we have a very unique situation i guess.

The web service is called by a telephone system. We don't want the user to be waiting on the phone for 30 seconds for the api to return, so i would like all db queries to timeout after 5 seconds..

Anyway, I will just wrap all db access in a function which sets the command timeout property.

I could also run each db access on another thread and kill the thread after 5 seconds, but i think that could degrade performance in asp.net... I don't think Sybase driver has non-blocking IO. Their async stuff just blocks.

Of course, i could just ask the client to timeout the request after 5 seconds too..

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 22-Oct-2021 10:22:17   

joshmag wrote:

Actually we have a very unique situation i guess.

The web service is called by a telephone system. We don't want the user to be waiting on the phone for 30 seconds for the api to return, so i would like all db queries to timeout after 5 seconds..

The timeout doesn't dictate how long the query will take, it dictates when an exception is thrown if it takes longer than that. I doubt your system is that slow that most queries take > 1 second, most databases are faster than that, even sybase simple_smile Setting it to 5 seconds will give an exception after 5 seconds if the query takes e.g. 6 seconds. Not sure the user would like that too...

Anyway, I will just wrap all db access in a function which sets the command timeout property.

I could also run each db access on another thread and kill the thread after 5 seconds, but i think that could degrade performance in asp.net... I don't think Sybase driver has non-blocking IO. Their async stuff just blocks. Of course, i could just ask the client to timeout the request after 5 seconds too..

Killing threads isn't recommended in .net. The sybase ado.net providers are really low quality, so I'm not surprised their async code is just wrapping sync code.

Frans Bouma | Lead developer LLBLGen Pro
joshmag
User
Posts: 14
Joined: 20-Aug-2021
# Posted on: 27-Oct-2021 09:35:04   

that's true, 99% of requests takes less than 500 milliseconds. But sometimes we have locks and sybase waits 5 seconds to get the lock.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Oct-2021 08:01:44   

Hi josh, We will close this thread for now. Feel free to come back if you need more info/help about this topic simple_smile

David Elizondo | LLBLGen Support Team