From 4c9fc68ef752e6d0168cec7726cbb93d0b25b66a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 10 Sep 2022 22:14:00 +0000 Subject: [PATCH] --- devdocs/todo.txt | 6 +++++- server/AyaNova/util/DbUtil.cs | 16 +++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 2b49b1df..e79ad5c8 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -9,7 +9,7 @@ Problem: potential fixes: TODO HERE: Detect postgres is unreachable and stop digging a hole, wait to resolve it before continuing on again - + Don't log same message repeatedly actually this is not necessary if just stop running jobs when can't reach sql server FIXED don't dual log to system journal logs and ayanova log @@ -40,6 +40,10 @@ Npgsql.NpgsqlException (0x80004005): Failed to connect to 127.0.0.1:5432 System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host. System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it. +ex.source "Npgsql.EntityFrameworkCore.PostgreSQL","Npgsql" +ex.message "An exception has been raised that is likely due to a transient failure.","Exception while writing to stream","Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.." + + Boot exception when db is not up: {Npgsql.NpgsqlException (0x80004005): Failed to connect to 127.0.0.1:5432 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it. diff --git a/server/AyaNova/util/DbUtil.cs b/server/AyaNova/util/DbUtil.cs index 616a5620..66370bb5 100644 --- a/server/AyaNova/util/DbUtil.cs +++ b/server/AyaNova/util/DbUtil.cs @@ -239,20 +239,10 @@ namespace AyaNova.Util internal static void HandleIfDatabaseUnavailableTypeException(Exception ex) { if (ex == null) return; - //System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host. - //System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it. - - do - { - if (ex.Message.Contains("SOMESTRING")) - { - ServerGlobalOpsSettingsCache.DBAVAILABLE = true; - return; - } - ex = ex.InnerException; - //ServerGlobalOpsSettingsCache.DBAVAILABLE = true; - } while (ex != null); + if (ex.Message.Contains("transient failure") && ex.Source.Contains("PostgreSQL")) + ServerGlobalOpsSettingsCache.DBAVAILABLE = false; } + /////////////////////////////////////////// //Verify that database exists, if not, then create it