Skip to content

Commit

Permalink
Fix bug in truncating process history
Browse files Browse the repository at this point in the 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.
  • Loading branch information
Viir committed Jul 24, 2021
1 parent 0ec7fa3 commit 5bcec4e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion implement/elm-fullstack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,9 @@ static public (IImmutableDictionary<IImmutableList<string>, IReadOnlyList<byte>>
{
var filesForProcessRestore = new ConcurrentDictionary<IImmutableList<string>, IReadOnlyList<byte>>(EnumerableExtension.EqualityComparer<string>());

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);
Expand Down
8 changes: 7 additions & 1 deletion implement/elm-fullstack/WebHost/StartupAdminInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura
var numbersOfThreadsToDeleteFiles = 4;

var filePathsInProcessStorePartitions =
processStoreFileStore.ListFilesInDirectory(ImmutableList<string>.Empty)
processStoreFileStore.ListFiles()
.Select((s, i) => (s, i))
.GroupBy(x => x.i % numbersOfThreadsToDeleteFiles)
.Select(g => g.Select(x => x.s).ToImmutableList())
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -871,6 +873,10 @@ public class TruncateProcessHistoryReport
{
public string beginTime;

public int filesForRestoreCount;

public int discoveredFilesCount;

public int deletedFilesCount;

public int lockedTimeSpentMilli;
Expand Down
4 changes: 2 additions & 2 deletions implement/elm-fullstack/elm-fullstack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>elm_fullstack</RootNamespace>
<AssemblyName>elm-fs</AssemblyName>
<AssemblyVersion>2021.0714.0.0</AssemblyVersion>
<FileVersion>2021.0714.0.0</FileVersion>
<AssemblyVersion>2021.0724.0.0</AssemblyVersion>
<FileVersion>2021.0724.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 5bcec4e

Please sign in to comment.