diff --git a/AdminApi/src/AdminApi.Infrastructure/Persistence/IServiceCollectionExtension.cs b/AdminApi/src/AdminApi.Infrastructure/Persistence/IServiceCollectionExtension.cs index 055e27d22c..59cd6b029d 100644 --- a/AdminApi/src/AdminApi.Infrastructure/Persistence/IServiceCollectionExtension.cs +++ b/AdminApi/src/AdminApi.Infrastructure/Persistence/IServiceCollectionExtension.cs @@ -36,7 +36,7 @@ public static IServiceCollection AddDatabase(this IServiceCollection services, A case SQLSERVER: dbContextOptions.UseSqlServer(options.ConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "AdminUi"); @@ -45,7 +45,7 @@ public static IServiceCollection AddDatabase(this IServiceCollection services, A case POSTGRES: dbContextOptions.UseNpgsql(options.ConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "AdminUi"); @@ -63,6 +63,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string ConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/DatabaseMigrator/Configuration.cs b/DatabaseMigrator/Configuration.cs index 5075043b4d..9d26a2858b 100644 --- a/DatabaseMigrator/Configuration.cs +++ b/DatabaseMigrator/Configuration.cs @@ -21,4 +21,7 @@ public class SqlDatabaseConfiguration [Required] public string ConnectionString { get; set; } = null!; + + [Range(1, int.MaxValue)] + public int CommandTimeout { get; set; } = 300; } diff --git a/DatabaseMigrator/Program.cs b/DatabaseMigrator/Program.cs index 56e7c5f7c5..c6312446dc 100644 --- a/DatabaseMigrator/Program.cs +++ b/DatabaseMigrator/Program.cs @@ -71,54 +71,63 @@ static IHostBuilder CreateHostBuilder(string[] args) { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Devices.Infrastructure.Persistence.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.ConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Files.Infrastructure.Persistence.Database.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Messages.Infrastructure.Persistence.Database.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Quotas.Infrastructure.Persistence.Database.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Relationships.Infrastructure.Persistence.Database.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Synchronization.Infrastructure.Persistence.Database.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.Modules.Tokens.Infrastructure.Persistence.Database.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.DbConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); Backbone.AdminApi.Infrastructure.Persistence.IServiceCollectionExtensions.AddDatabase(services, options => { options.Provider = parsedConfiguration.Infrastructure.SqlDatabase.Provider; options.ConnectionString = parsedConfiguration.Infrastructure.SqlDatabase.ConnectionString; + options.CommandTimeout = parsedConfiguration.Infrastructure.SqlDatabase.CommandTimeout; }); #endregion diff --git a/Modules/Challenges/src/Challenges.Infrastructure/Persistence/IServiceCollectionExtensions.cs b/Modules/Challenges/src/Challenges.Infrastructure/Persistence/IServiceCollectionExtensions.cs index 652b10846f..b8a7363823 100644 --- a/Modules/Challenges/src/Challenges.Infrastructure/Persistence/IServiceCollectionExtensions.cs +++ b/Modules/Challenges/src/Challenges.Infrastructure/Persistence/IServiceCollectionExtensions.cs @@ -27,7 +27,7 @@ public static void AddDatabase(this IServiceCollection services, Action { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Challenges"); @@ -36,7 +36,7 @@ public static void AddDatabase(this IServiceCollection services, Action { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Challenges"); @@ -54,6 +54,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string DbConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Devices/src/Devices.Infrastructure/Persistence/IServiceCollectionExtensions.cs b/Modules/Devices/src/Devices.Infrastructure/Persistence/IServiceCollectionExtensions.cs index 41fd830ad1..415ef9d52e 100644 --- a/Modules/Devices/src/Devices.Infrastructure/Persistence/IServiceCollectionExtensions.cs +++ b/Modules/Devices/src/Devices.Infrastructure/Persistence/IServiceCollectionExtensions.cs @@ -29,7 +29,7 @@ public static void AddDatabase(this IServiceCollection services, Action { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Devices"); @@ -38,7 +38,7 @@ public static void AddDatabase(this IServiceCollection services, Action { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Devices"); @@ -47,6 +47,7 @@ public static void AddDatabase(this IServiceCollection services, Action { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Files"); @@ -39,7 +39,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case POSTGRES: dbContextOptions.UseNpgsql(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Files"); @@ -58,6 +58,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string DbConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Messages/src/Messages.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Messages/src/Messages.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index 5db921b7e6..0d21cacead 100644 --- a/Modules/Messages/src/Messages.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Messages/src/Messages.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -29,7 +29,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case SQLSERVER: dbContextOptions.UseSqlServer(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Messages"); @@ -38,7 +38,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case POSTGRES: dbContextOptions.UseNpgsql(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Messages"); @@ -55,6 +55,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string DbConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Quotas/src/Quotas.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Quotas/src/Quotas.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index 66ee023fe1..400e738793 100644 --- a/Modules/Quotas/src/Quotas.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Quotas/src/Quotas.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -33,7 +33,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case SQLSERVER: dbContextOptions.UseSqlServer(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Quotas"); @@ -42,7 +42,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case POSTGRES: dbContextOptions.UseNpgsql(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Quotas"); @@ -67,6 +67,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string DbConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index 2b93076721..83959bfab7 100644 --- a/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -29,7 +29,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case SQLSERVER: dbContextOptions.UseSqlServer(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Relationships"); @@ -38,7 +38,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case POSTGRES: dbContextOptions.UseNpgsql(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Relationships"); @@ -54,6 +54,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string DbConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Synchronization/src/Synchronization.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index a2aa6d6a67..14036b0692 100644 --- a/Modules/Synchronization/src/Synchronization.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Synchronization/src/Synchronization.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -30,7 +30,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case SQLSERVER: dbContextOptions.UseSqlServer(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Synchronization"); @@ -39,7 +39,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case POSTGRES: dbContextOptions.UseNpgsql(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Synchronization"); @@ -57,6 +57,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio public class DbOptions { public string Provider { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public string DbConnectionString { get; set; } = null!; public RetryOptions RetryOptions { get; set; } = new(); } diff --git a/Modules/Tokens/src/Tokens.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs b/Modules/Tokens/src/Tokens.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs index cfa2262827..84ab33c6a3 100644 --- a/Modules/Tokens/src/Tokens.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs +++ b/Modules/Tokens/src/Tokens.Infrastructure/Persistence/Database/IServiceCollectionExtensions.cs @@ -29,7 +29,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case SQLSERVER: dbContextOptions.UseSqlServer(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(SQLSERVER_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Tokens"); @@ -38,7 +38,7 @@ public static void AddDatabase(this IServiceCollection services, DbOptions optio case POSTGRES: dbContextOptions.UseNpgsql(options.DbConnectionString, sqlOptions => { - sqlOptions.CommandTimeout(20); + sqlOptions.CommandTimeout(options.CommandTimeout); sqlOptions.MigrationsAssembly(POSTGRES_MIGRATIONS_ASSEMBLY); sqlOptions.EnableRetryOnFailure(options.RetryOptions.MaxRetryCount, TimeSpan.FromSeconds(options.RetryOptions.MaxRetryDelayInSeconds), null); sqlOptions.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "Tokens"); @@ -56,6 +56,7 @@ public class DbOptions { public string Provider { get; set; } = null!; public string DbConnectionString { get; set; } = null!; + public int CommandTimeout { get; set; } = 20; public RetryOptions RetryOptions { get; set; } = new(); }