diff --git a/fhem/CHANGED b/fhem/CHANGED index 07858a65c..96fd52004 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 93_DbLog: write cachefile while Server shutdown if database isn't + available, Forum: #133599 - change: 00_KNXIO: multiple changes, see Forum #127792 - change: 10_KNX: multiple changes, see Forum #122582 - change: 74_AutomowerConnect: Common.pm, automowerconnect.js diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index 7257e306e..f7b8bb897 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -39,9 +39,11 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # Version History intern by DS_Starter: my %DbLog_vNotesIntern = ( + "5.9.0" => "16.05.2023 Server shutdown -> write cachefile if database connect can't be done during delayed shutdown ". + "Forum: https://forum.fhem.de/index.php?topic=133599.0 ", "5.8.8" => "11.05.2023 _DbLog_ParseEvent changed default splitting, Forum: https://forum.fhem.de/index.php?topic=133537.0 ", "5.8.7" => "01.05.2023 new Events FRAME_INITIALIZED, SUBPROC_INITIALIZED, SUBPROC_DISCONNECTED, SUBPROC_STOPPED ". - "Forum: https://forum.fhem.de/index.php?topic=133403.0, minor fixes ", + "Forum: https://forum.fhem.de/index.php?topic=133403.0, minor fixes ", "5.8.6" => "25.03.2023 change _DbLog_plotData (intx), Plot Editor: include functions delta-h, delta-h, ...". "remove setter deleteOldDaysNbl, reduceLogNbl ", "5.8.5" => "16.03.2023 fix using https in configCheck after SVN server change ", @@ -1025,7 +1027,7 @@ sub _DbLog_setexportCache { ## no critic "not used" my $logsref = $paref->{logsref}; my $dir = $paref->{dir}; - return "Device is not in asynch working mode" if(!AttrVal($name, 'asyncMode', 0)); + # return "Device is not in asynch working mode" if(!AttrVal($name, 'asyncMode', 0)); my $cln; my $crows = 0; @@ -5467,15 +5469,25 @@ sub DbLog_SBP_Read { if ($oper =~ /log_/xs) { my $rowlback = $ret->{rowlback}; - if($rowlback) { # one Transaction + if($rowlback) { my $memcount; - eval { + eval { # one Transaction for my $key (sort {$a <=>$b} keys %{$rowlback}) { - $memcount = DbLog_addMemCacheRow ($name, $rowlback->{$key}); # Datensatz zum Memory Cache hinzufügen + $memcount = DbLog_addMemCacheRow ($name, $rowlback->{$key}); # Datensatz zum Memory Cache hinzufügen Log3 ($name, 5, "DbLog $name - row back to Cache: $key -> ".$rowlback->{$key}); } + + if ($hash->{HELPER}{SHUTDOWNSEQ} && $memcount) { + Log3 ($name, 2, "DbLog $name - an error occurred during the last write cycle to the database, the data is exported to a file instead ... ......"); + + my $error = CommandSet (undef, qq{$name exportCache purgecache}); + + if ($error) { # Fehler beim Export Cachefile + Log3 ($name, 1, "DbLog $name - ERROR - while exporting Cache file: $error"); + } + } }; readingsSingleUpdate ($hash, 'CacheUsage', $memcount, ($ce == 1 ? 1 : 0));