Skip to content

Unable to set command_timeout on Update #2566

@vagtborg

Description

@vagtborg

Hi,

I am trying to set the command_timeout but it looks like it only affects Insert actions. Can you confirm if I am using the fluent API correct or if it is not related to fluent API.

A) I set the command_timeout to 10 seconds (just for testing the real value should be higher)
B) I set a trigger on the table to do a wait

  1. I do a Insert and that times out after 10 seconds
  2. I do a Update and that times out after 30 seconds (default NHibernate value I assume)
  3. I tested the same with delete and the timeout is also 30 seconds

Shouldn't the command_timeout affect all commands?

Thanks
Mikkel

Below is the example I used:

I setup a factory like so:

A)

var factory = Fluently.Configure()
    .Database(MsSqlConfiguration.MsSql2008.ConnectionString(conString).ShowSql())  
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
    .ExposeConfiguration(cfg => cfg.SetProperty(NHibernate.Cfg.Environment.CommandTimeout, "10"))
    .BuildSessionFactory();

B)
On my test table I added a trigger (INSERT, UPDATE and DELETE) that just have "WAITFOR DELAY '00:00:45'"

  1. When I do a Insert:
using (var session = factory.OpenSession())
{
    using (var transaction = session.BeginTransaction())
    {
        var test = new Testtable() { Time = DateTime.Now };
        session.Save(test);
        transaction.Commit();
    }
}

This times out after 10 seconds.

  1. When I do an Update:
using (var session = factory.OpenSession())
{
    using (var transaction = session.BeginTransaction())
    {
        var test = session.Get<Testtable>(1); //Id = 1 is in the DB
        test.Time = DateTime.Now;
        session.Update(test);
        transaction.Commit();
    }
}

This timeout after 30 seconds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions