mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-29 19:18:30 -07:00
Fixed the issue where MySql was sometimes throwing errors about not being able to execute the retry strat
This commit is contained in:
parent
f50536c005
commit
530e55a39f
8 changed files with 170 additions and 112 deletions
|
@ -77,12 +77,16 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
||||||
var movies = await _api.GetMovies(settings.FullUri, settings.ApiKey, new[] {"active"});
|
var movies = await _api.GetMovies(settings.FullUri, settings.ApiKey, new[] {"active"});
|
||||||
if (movies != null)
|
if (movies != null)
|
||||||
{
|
{
|
||||||
// Let's remove the old cached data
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM CouchPotatoCache");
|
// Let's remove the old cached data
|
||||||
tran.Commit();
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
}
|
{
|
||||||
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM CouchPotatoCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
var movieIds = new List<CouchPotatoCache>();
|
var movieIds = new List<CouchPotatoCache>();
|
||||||
|
@ -102,14 +106,17 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
||||||
_log.LogError("TMDBId is not > 0 for movie {0}", m.title);
|
_log.LogError("TMDBId is not > 0 for movie {0}", m.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.CouchPotatoCache.AddRangeAsync(movieIds);
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
|
{
|
||||||
|
await _ctx.CouchPotatoCache.AddRangeAsync(movieIds);
|
||||||
|
|
||||||
await _ctx.SaveChangesAsync();
|
await _ctx.SaveChangesAsync();
|
||||||
tran.Commit();
|
tran.Commit();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||||
.SendAsync(NotificationHub.NotificationEvent, "Couch Potato Sync Finished");
|
.SendAsync(NotificationHub.NotificationEvent, "Couch Potato Sync Finished");
|
||||||
|
|
|
@ -51,12 +51,16 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
var albums = await _lidarrApi.GetAllAlbums(settings.ApiKey, settings.FullUri);
|
var albums = await _lidarrApi.GetAllAlbums(settings.ApiKey, settings.FullUri);
|
||||||
if (albums != null && albums.Any())
|
if (albums != null && albums.Any())
|
||||||
{
|
{
|
||||||
// Let's remove the old cached data
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM LidarrAlbumCache");
|
// Let's remove the old cached data
|
||||||
tran.Commit();
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
}
|
{
|
||||||
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM LidarrAlbumCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var albumCache = new List<LidarrAlbumCache>();
|
var albumCache = new List<LidarrAlbumCache>();
|
||||||
foreach (var a in albums)
|
foreach (var a in albums)
|
||||||
|
@ -76,14 +80,17 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.LidarrAlbumCache.AddRangeAsync(albumCache);
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
|
{
|
||||||
|
await _ctx.LidarrAlbumCache.AddRangeAsync(albumCache);
|
||||||
|
|
||||||
await _ctx.SaveChangesAsync();
|
await _ctx.SaveChangesAsync();
|
||||||
tran.Commit();
|
tran.Commit();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
catch (System.Exception ex)
|
||||||
|
|
|
@ -50,12 +50,16 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
var artists = await _lidarrApi.GetArtists(settings.ApiKey, settings.FullUri);
|
var artists = await _lidarrApi.GetArtists(settings.ApiKey, settings.FullUri);
|
||||||
if (artists != null && artists.Any())
|
if (artists != null && artists.Any())
|
||||||
{
|
{
|
||||||
// Let's remove the old cached data
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM LidarrArtistCache");
|
// Let's remove the old cached data
|
||||||
tran.Commit();
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
}
|
{
|
||||||
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM LidarrArtistCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var artistCache = new List<LidarrArtistCache>();
|
var artistCache = new List<LidarrArtistCache>();
|
||||||
foreach (var a in artists)
|
foreach (var a in artists)
|
||||||
|
@ -71,14 +75,17 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.LidarrArtistCache.AddRangeAsync(artistCache);
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
|
{
|
||||||
|
await _ctx.LidarrArtistCache.AddRangeAsync(artistCache);
|
||||||
|
|
||||||
await _ctx.SaveChangesAsync();
|
await _ctx.SaveChangesAsync();
|
||||||
tran.Commit();
|
tran.Commit();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -46,12 +46,16 @@ namespace Ombi.Schedule.Jobs.Radarr
|
||||||
var movies = await RadarrApi.GetMovies(settings.ApiKey, settings.FullUri);
|
var movies = await RadarrApi.GetMovies(settings.ApiKey, settings.FullUri);
|
||||||
if (movies != null)
|
if (movies != null)
|
||||||
{
|
{
|
||||||
// Let's remove the old cached data
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM RadarrCache");
|
// Let's remove the old cached data
|
||||||
tran.Commit();
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
}
|
{
|
||||||
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM RadarrCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var movieIds = new List<RadarrCache>();
|
var movieIds = new List<RadarrCache>();
|
||||||
foreach (var m in movies)
|
foreach (var m in movies)
|
||||||
|
@ -72,14 +76,17 @@ namespace Ombi.Schedule.Jobs.Radarr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.RadarrCache.AddRangeAsync(movieIds);
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
|
{
|
||||||
|
await _ctx.RadarrCache.AddRangeAsync(movieIds);
|
||||||
|
|
||||||
await _ctx.SaveChangesAsync();
|
await _ctx.SaveChangesAsync();
|
||||||
tran.Commit();
|
tran.Commit();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await OmbiQuartz.TriggerJob(nameof(IArrAvailabilityChecker), "DVR");
|
await OmbiQuartz.TriggerJob(nameof(IArrAvailabilityChecker), "DVR");
|
||||||
|
|
|
@ -45,12 +45,16 @@ namespace Ombi.Schedule.Jobs.SickRage
|
||||||
if (shows != null)
|
if (shows != null)
|
||||||
{
|
{
|
||||||
var srShows = shows.data.Values;
|
var srShows = shows.data.Values;
|
||||||
var ids = srShows.Select(x => x.tvdbid);
|
var ids = srShows.Select(x => x.tvdbid);
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM SickRageCache");
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
tran.Commit();
|
{
|
||||||
}
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM SickRageCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var entites = ids.Select(id => new SickRageCache { TvDbId = id }).ToList();
|
var entites = ids.Select(id => new SickRageCache { TvDbId = id }).ToList();
|
||||||
|
|
||||||
|
@ -77,13 +81,16 @@ namespace Ombi.Schedule.Jobs.SickRage
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.SickRageEpisodeCache.AddRangeAsync(episodesToAdd);
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
await _ctx.SaveChangesAsync();
|
{
|
||||||
tran.Commit();
|
await _ctx.SickRageEpisodeCache.AddRangeAsync(episodesToAdd);
|
||||||
}
|
await _ctx.SaveChangesAsync();
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -48,12 +48,16 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
||||||
if (series != null)
|
if (series != null)
|
||||||
{
|
{
|
||||||
var sonarrSeries = series as ImmutableHashSet<SonarrSeries> ?? series.ToImmutableHashSet();
|
var sonarrSeries = series as ImmutableHashSet<SonarrSeries> ?? series.ToImmutableHashSet();
|
||||||
var ids = sonarrSeries.Select(x => x.tvdbId);
|
var ids = sonarrSeries.Select(x => x.tvdbId);
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
var strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM SonarrCache");
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
tran.Commit();
|
{
|
||||||
}
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM SonarrCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var existingSeries = await _ctx.SonarrCache.Select(x => x.TvDbId).ToListAsync();
|
var existingSeries = await _ctx.SonarrCache.Select(x => x.TvDbId).ToListAsync();
|
||||||
|
|
||||||
|
@ -62,11 +66,15 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
||||||
|
|
||||||
await _ctx.SonarrCache.AddRangeAsync(entites);
|
await _ctx.SonarrCache.AddRangeAsync(entites);
|
||||||
entites.Clear();
|
entites.Clear();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM SonarrEpisodeCache");
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
tran.Commit();
|
{
|
||||||
}
|
await _ctx.Database.ExecuteSqlRawAsync("DELETE FROM SonarrEpisodeCache");
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
foreach (var s in sonarrSeries)
|
foreach (var s in sonarrSeries)
|
||||||
{
|
{
|
||||||
|
@ -116,14 +124,17 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
strat = _ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await _ctx.SonarrEpisodeCache.AddRangeAsync(episodesToAdd);
|
using (var tran = await _ctx.Database.BeginTransactionAsync())
|
||||||
_log.LogDebug("Commiting the transaction");
|
{
|
||||||
await _ctx.SaveChangesAsync();
|
await _ctx.SonarrEpisodeCache.AddRangeAsync(episodesToAdd);
|
||||||
tran.Commit();
|
_log.LogDebug("Commiting the transaction");
|
||||||
}
|
await _ctx.SaveChangesAsync();
|
||||||
|
tran.Commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,20 +24,16 @@ namespace Ombi.Store.Repository
|
||||||
|
|
||||||
public async Task Record(AuditType type, AuditArea area, string description, string user)
|
public async Task Record(AuditType type, AuditArea area, string description, string user)
|
||||||
{
|
{
|
||||||
using (var tran = await Ctx.Database.BeginTransactionAsync())
|
await Ctx.Audit.AddAsync(new Audit
|
||||||
{
|
{
|
||||||
await Ctx.Audit.AddAsync(new Audit
|
User = user,
|
||||||
{
|
AuditArea = area,
|
||||||
User = user,
|
AuditType = type,
|
||||||
AuditArea = area,
|
DateTime = DateTime.UtcNow,
|
||||||
AuditType = type,
|
Description = description
|
||||||
DateTime = DateTime.UtcNow,
|
});
|
||||||
Description = description
|
|
||||||
});
|
|
||||||
|
|
||||||
await Ctx.SaveChangesAsync();
|
await Ctx.SaveChangesAsync();
|
||||||
tran.Commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Ombi
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine(HelpOutput(result));
|
Console.WriteLine(HelpOutput(result));
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace Ombi
|
||||||
if (migrate)
|
if (migrate)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Migrate in progress...");
|
Console.WriteLine("Migrate in progress...");
|
||||||
|
|
||||||
var migrationTasks = new List<Task>();
|
var migrationTasks = new List<Task>();
|
||||||
var externalDb = provider.GetRequiredService<ExternalContext>();
|
var externalDb = provider.GetRequiredService<ExternalContext>();
|
||||||
var ombiDb = provider.GetRequiredService<OmbiContext>();
|
var ombiDb = provider.GetRequiredService<OmbiContext>();
|
||||||
|
@ -93,12 +93,16 @@ namespace Ombi
|
||||||
Type = ConfigurationTypes.Url,
|
Type = ConfigurationTypes.Url,
|
||||||
Value = "http://*:5000"
|
Value = "http://*:5000"
|
||||||
};
|
};
|
||||||
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
||||||
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
settingsDb.ApplicationConfigurations.Add(url);
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
||||||
await settingsDb.SaveChangesAsync();
|
{
|
||||||
await tran.CommitAsync();
|
settingsDb.ApplicationConfigurations.Add(url);
|
||||||
}
|
await settingsDb.SaveChangesAsync();
|
||||||
|
await tran.CommitAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
urlValue = url.Value;
|
urlValue = url.Value;
|
||||||
}
|
}
|
||||||
|
@ -106,12 +110,15 @@ namespace Ombi
|
||||||
if (!url.Value.Equals(host))
|
if (!url.Value.Equals(host))
|
||||||
{
|
{
|
||||||
url.Value = UrlArgs;
|
url.Value = UrlArgs;
|
||||||
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await settingsDb.SaveChangesAsync();
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
||||||
await tran.CommitAsync();
|
{
|
||||||
}
|
await settingsDb.SaveChangesAsync();
|
||||||
|
await tran.CommitAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
urlValue = url.Value;
|
urlValue = url.Value;
|
||||||
}
|
}
|
||||||
|
@ -129,24 +136,30 @@ namespace Ombi
|
||||||
Type = ConfigurationTypes.BaseUrl,
|
Type = ConfigurationTypes.BaseUrl,
|
||||||
Value = baseUrl
|
Value = baseUrl
|
||||||
};
|
};
|
||||||
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
settingsDb.ApplicationConfigurations.Add(dbBaseUrl);
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
||||||
await settingsDb.SaveChangesAsync();
|
{
|
||||||
await tran.CommitAsync();
|
settingsDb.ApplicationConfigurations.Add(dbBaseUrl);
|
||||||
}
|
await settingsDb.SaveChangesAsync();
|
||||||
|
await tran.CommitAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
|
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
|
||||||
{
|
{
|
||||||
dbBaseUrl.Value = baseUrl;
|
dbBaseUrl.Value = baseUrl;
|
||||||
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
await settingsDb.SaveChangesAsync();
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
||||||
await tran.CommitAsync();
|
{
|
||||||
}
|
await settingsDb.SaveChangesAsync();
|
||||||
|
await tran.CommitAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"We are running on {urlValue}");
|
Console.WriteLine($"We are running on {urlValue}");
|
||||||
|
@ -164,13 +177,16 @@ namespace Ombi
|
||||||
Type = ConfigurationTypes.SecurityToken,
|
Type = ConfigurationTypes.SecurityToken,
|
||||||
Value = Guid.NewGuid().ToString("N")
|
Value = Guid.NewGuid().ToString("N")
|
||||||
};
|
};
|
||||||
|
var strat = ctx.Database.CreateExecutionStrategy();
|
||||||
using (var tran = await ctx.Database.BeginTransactionAsync())
|
await strat.ExecuteAsync(async () =>
|
||||||
{
|
{
|
||||||
ctx.ApplicationConfigurations.Add(securityToken);
|
using (var tran = await ctx.Database.BeginTransactionAsync())
|
||||||
await ctx.SaveChangesAsync();
|
{
|
||||||
await tran.CommitAsync();
|
ctx.ApplicationConfigurations.Add(securityToken);
|
||||||
}
|
await ctx.SaveChangesAsync();
|
||||||
|
await tran.CommitAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.SecurityKey = securityToken.Value;
|
instance.SecurityKey = securityToken.Value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue