From 70a8edf165929763060de7b0453d60467f029bbe Mon Sep 17 00:00:00 2001 From: sakno Date: Fri, 5 Jul 2024 12:23:20 +0300 Subject: [PATCH] Fill metadata table with stub entries if they are zeroed on the disk (#244) --- .../Cluster/Consensus/Raft/PersistentState.Partition.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/PersistentState.Partition.cs b/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/PersistentState.Partition.cs index 4ab08dfb8..a711c4aec 100644 --- a/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/PersistentState.Partition.cs +++ b/src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/PersistentState.Partition.cs @@ -473,9 +473,14 @@ internal void Initialize(long lastIndexHint) if (count < LogEntryMetadata.Size) break; + var previousEnd = fileOffset; fileOffset = LogEntryMetadata.GetEndOfLogEntry(metadataBuffer); if (fileOffset <= 0L) - break; + { + var stub = new LogEntryMetadata(default, 0L, previousEnd + LogEntryMetadata.Size, 0L); + stub.Format(metadataBuffer); + fileOffset = stub.End; + } writer.FilePosition = fileOffset; metadataBuffer.CopyTo(metadataTable.Slice(footerOffset, LogEntryMetadata.Size));