mirror of https://github.com/lidarr/Lidarr
New: Retry Postgres connection 3 times (with 5 second sleep) on Startup
(cherry picked from commit 3e700b63c26b247fcac83428ba79e53c88f797ff) (cherry picked from commit dbca393772d7f558b45a780a6767187bf5900a23)
This commit is contained in:
parent
977fb31a91
commit
3c8d3b00f8
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
|
using System.Net.Sockets;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
@ -113,6 +114,37 @@ namespace NzbDrone.Core.Datastore
|
||||||
|
|
||||||
throw new CorruptDatabaseException("Database file: {0} is corrupt, restore from backup if available. See: https://wiki.servarr.com/lidarr/faq#i-am-getting-an-error-database-disk-image-is-malformed", e, fileName);
|
throw new CorruptDatabaseException("Database file: {0} is corrupt, restore from backup if available. See: https://wiki.servarr.com/lidarr/faq#i-am-getting-an-error-database-disk-image-is-malformed", e, fileName);
|
||||||
}
|
}
|
||||||
|
catch (NpgsqlException e)
|
||||||
|
{
|
||||||
|
if (e.InnerException is SocketException)
|
||||||
|
{
|
||||||
|
var retryCount = 3;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Logger.Error(e, "Failure to connect to Postgres DB, {0} retries remaining", retryCount);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_migrationController.Migrate(connectionString, migrationContext);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (--retryCount > 0)
|
||||||
|
{
|
||||||
|
System.Threading.Thread.Sleep(5000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RadarrStartupException(ex, "Error creating main database");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new RadarrStartupException(e, "Error creating main database");
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new LidarrStartupException(e, "Error creating main database");
|
throw new LidarrStartupException(e, "Error creating main database");
|
||||||
|
|
Loading…
Reference in New Issue