From 5bcec4eae61112ed81df97cce32e0c1b5df2148b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=A4tzel?= Date: Sat, 24 Jul 2021 17:34:10 +0000 Subject: [PATCH] Fix bug in truncating process history Fix implementation to get the subset of files necessary to replicate the process state in `GetFilesForRestoreProcess`: Avoid all files under the composition log directory being included due to the command to list the file paths. Also, expand the report on the truncate operation to include file counts. --- implement/elm-fullstack/Program.cs | 2 +- .../PersistentProcessVolatileRepresentation.cs | 15 +-------------- .../WebHost/StartupAdminInterface.cs | 8 +++++++- implement/elm-fullstack/elm-fullstack.csproj | 4 ++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/implement/elm-fullstack/Program.cs b/implement/elm-fullstack/Program.cs index 088122dc..8b0278a5 100644 --- a/implement/elm-fullstack/Program.cs +++ b/implement/elm-fullstack/Program.cs @@ -14,7 +14,7 @@ namespace elm_fullstack { public class Program { - static public string AppVersionId => "2021-07-14"; + static public string AppVersionId => "2021-07-24"; static int AdminInterfaceDefaultPort => 4000; diff --git a/implement/elm-fullstack/WebHost/PersistentProcessVolatileRepresentation.cs b/implement/elm-fullstack/WebHost/PersistentProcessVolatileRepresentation.cs index 97e09117..dd3128c2 100644 --- a/implement/elm-fullstack/WebHost/PersistentProcessVolatileRepresentation.cs +++ b/implement/elm-fullstack/WebHost/PersistentProcessVolatileRepresentation.cs @@ -118,22 +118,9 @@ static public (IImmutableDictionary, IReadOnlyList> { var filesForProcessRestore = new ConcurrentDictionary, IReadOnlyList>(EnumerableExtension.EqualityComparer()); - var listFilePlaceholderContent = Encoding.UTF8.GetBytes("Placeholder only to make file path appear in list files API"); - var recordingReader = new DelegatingFileStoreReader { - ListFilesInDirectoryDelegate = directoryPath => - { - var filesPaths = fileStoreReader.ListFilesInDirectory(directoryPath); - - foreach (var filePath in filesPaths) - filesForProcessRestore.AddOrUpdate( - filePath, - addValue: listFilePlaceholderContent, - updateValueFactory: (_, fileContent) => fileContent); - - return filesPaths; - }, + ListFilesInDirectoryDelegate = fileStoreReader.ListFilesInDirectory, GetFileContentDelegate = filePath => { var fileContent = fileStoreReader.GetFileContent(filePath); diff --git a/implement/elm-fullstack/WebHost/StartupAdminInterface.cs b/implement/elm-fullstack/WebHost/StartupAdminInterface.cs index e6f4dcb9..b15fee37 100644 --- a/implement/elm-fullstack/WebHost/StartupAdminInterface.cs +++ b/implement/elm-fullstack/WebHost/StartupAdminInterface.cs @@ -580,7 +580,7 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura var numbersOfThreadsToDeleteFiles = 4; var filePathsInProcessStorePartitions = - processStoreFileStore.ListFilesInDirectory(ImmutableList.Empty) + processStoreFileStore.ListFiles() .Select((s, i) => (s, i)) .GroupBy(x => x.i % numbersOfThreadsToDeleteFiles) .Select(g => g.Select(x => x.s).ToImmutableList()) @@ -638,6 +638,8 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura return new TruncateProcessHistoryReport { beginTime = beginTime, + filesForRestoreCount = filesForRestore.Count, + discoveredFilesCount = filePathsInProcessStorePartitions.Sum(partition => partition.Count), deletedFilesCount = totalDeletedFilesCount, storeReductionTimeSpentMilli = (int)storeReductionStopwatch.ElapsedMilliseconds, storeReductionReport = storeReductionReport, @@ -871,6 +873,10 @@ public class TruncateProcessHistoryReport { public string beginTime; + public int filesForRestoreCount; + + public int discoveredFilesCount; + public int deletedFilesCount; public int lockedTimeSpentMilli; diff --git a/implement/elm-fullstack/elm-fullstack.csproj b/implement/elm-fullstack/elm-fullstack.csproj index 2de5162a..432ae370 100644 --- a/implement/elm-fullstack/elm-fullstack.csproj +++ b/implement/elm-fullstack/elm-fullstack.csproj @@ -5,8 +5,8 @@ netcoreapp3.1 elm_fullstack elm-fs - 2021.0714.0.0 - 2021.0714.0.0 + 2021.0724.0.0 + 2021.0724.0.0