From 42c23dadc91db69bf3619a1a10b4030dc9745fd3 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 4 Feb 2016 14:51:19 +0100 Subject: [PATCH] U4-7887 - default to database connection timeout --- src/Umbraco.Core/Persistence/UmbracoDatabase.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs b/src/Umbraco.Core/Persistence/UmbracoDatabase.cs index 9541a1cac0..8fc1150409 100644 --- a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs +++ b/src/Umbraco.Core/Persistence/UmbracoDatabase.cs @@ -12,9 +12,9 @@ namespace Umbraco.Core.Persistence /// Represents the Umbraco implementation of the PetaPoco Database object /// /// - /// Currently this object exists for 'future proofing' our implementation. By having our own inheritied implementation we + /// Currently this object exists for 'future proofing' our implementation. By having our own inheritied implementation we /// can then override any additional execution (such as additional loggging, functionality, etc...) that we need to without breaking compatibility since we'll always be exposing - /// this object instead of the base PetaPoco database object. + /// this object instead of the base PetaPoco database object. /// public class UmbracoDatabase : Database, IDisposeOnRequestEnd { @@ -111,7 +111,9 @@ namespace Umbraco.Core.Persistence public override IDbConnection OnConnectionOpened(IDbConnection connection) { - // wrap the connection with a profiling connection that tracks timings + // propagate timeout if none yet + + // wrap the connection with a profiling connection that tracks timings return new StackExchange.Profiling.Data.ProfiledDbConnection(connection as DbConnection, MiniProfiler.Current); } @@ -121,6 +123,14 @@ namespace Umbraco.Core.Persistence base.OnException(x); } + public override void OnExecutingCommand(IDbCommand cmd) + { + // if no timeout is specified, and the connection has a longer timeout, use it + if (OneTimeCommandTimeout == 0 && CommandTimeout == 0 && cmd.Connection.ConnectionTimeout > 30) + cmd.CommandTimeout = cmd.Connection.ConnectionTimeout; + base.OnExecutingCommand(cmd); + } + public override void OnExecutedCommand(IDbCommand cmd) { if (EnableSqlTrace)