New Posts New Posts RSS Feed: Increasing timeout for saves
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Increasing timeout for saves

 Post Reply Post Reply
Author
chrishibler View Drop Down
Newbie
Newbie
Avatar

Joined: 09-Jun-2010
Location: usa
Posts: 8
Post Options Post Options   Quote chrishibler Quote  Post ReplyReply Direct Link To This Post Topic: Increasing timeout for saves
    Posted: 09-Mar-2012 at 6:46am
Hello,

Our application uses DevForce classic and SQL Server. I'm having trouble adjusting the timeout options so that a save does not timeout after 30 seconds.

So my goal is to be able to adjust the timeout value during an insert or update operation.

I'm attempting to use transaction settings like this in the SaveOptions and I've tried with UseDTCOption.True and UseDTCOption.False.

         IdeaBlade.Persistence.TransactionSettings settings =
              new IdeaBlade.Persistence.TransactionSettings(
                  UseDTCOption.True,
                  System.Transactions.IsolationLevel.ReadUncommitted,
                  timeSpanOverride);


I think the timeout is definitely coming from the database connection because I can easily reproduce it by locking the table for a predetermined time. 


The debug log has this error which further confirms this:

Exception occurred: System.Data.OleDb.OleDbException: Query timeout expired at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) at IdeaBlade.Persistence.Server.TransactionManagerHelper.SaveTable(EntityTable pTable, Boolean pDeleting, PostSaveHandler pPostSaveHandler, Boolean pExcludeFromRefetch) at IdeaBlade.Persistence.Server.TransactionManagerHelper.Save(DataSet pDataSet, SaveOptions pSaveOptions)


Any help you can provide would be much appreciated.

Thanks!

Chris Hibler

chrishibler@decadesoftware.com
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 09-Mar-2012 at 11:21am
Hi Chris,
 
The TransactionSettings timeout is only used when DTC is on, and would set the timeout on the TransactionScope, but as you found doesn't help here.
 
For a save, DevForce sets up an InsertCommand, UpdateCommand and/or DeleteCommand for every entity to be saved and then calls DataAdapter.Update on the EntityTable.  So although it's weird to see a "query timeout" for a save (we've never seen one before) it would be the CommandTimeout property on each command which controls this.  Since a command affects only a single row, it does seem strange that the 30 second default isn't sufficient, and again we've never seen this before.  Are you triggering any additional logic as part of specific inserts/updates?
 
Anyway, unlike the query CommandTimeout, there's not an easy way to override the CommandTimeout for the save commands.  You'll need to implement a custom IAdapterProvider and in that set the command timeouts.  It would look something like this:
 
(Be sure to specify the entity types this is needed for.) 
 
  public class MyRdbAdapterProvider : IAdapterProvider {
 
    private RdbAdapterProvider _provider;
 
    public Type[] SupportedEntityTypes {
      get { return new[] {typeof(Customer)}; }
    }
 
    public void Initialize(Type pEntityType, IDataSourceKey pDataSourceKey) {
      _provider = new RdbAdapterProvider();
      _provider.Initialize(pEntityType, pDataSourceKey);
 
      // Set the timeout values on the commands now: 
      var da = _provider.DataAdapter as System.Data.OleDb.OleDbDataAdapter;
      da.InsertCommand.CommandTimeout = 60;
      da.UpdateCommand.CommandTimeout = 60;
    }
 
    public Type EntityType {
      get { return _provider.EntityType; }
    }
 
    public IDataAdapter DataAdapter {
      get { return _provider.DataAdapter; }
    }
 
    public DataTable TemplateDataTable {
      get { return _provider.TemplateDataTable; }
    }
 
    public void Refetch(IDataAdapter pAdapter, DataTable pSourceTable, DataTable pDestTable) {
      _provider.Refetch(pAdapter, pSourceTable, pDestTable);
    }
 
  }
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down