Skip to content

Commit

Permalink
pageSizeBits instance variable for use with process AOF stream
Browse files Browse the repository at this point in the history
  • Loading branch information
vazois committed Nov 18, 2024
1 parent 838073b commit 4697db9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public unsafe void ProcessPrimaryStream(byte* record, int recordLength, long pre
if (currentAddress > previousAddress)
{
if (
(currentAddress % (1 << storeWrapper.appendOnlyFile.UnsafeGetLogPageSizeBits()) != 0) || // the skip was to a non-page-boundary
(currentAddress % (1 << pageSizeBits) != 0) || // the skip was to a non-page-boundary
(currentAddress >= previousAddress + recordLength) // the skip will not be auto-handled by the AOF enqueue
)
{
Expand All @@ -66,8 +66,7 @@ public unsafe void ProcessPrimaryStream(byte* record, int recordLength, long pre
}

var tail = storeWrapper.appendOnlyFile.TailAddress;
var pageBits = storeWrapper.appendOnlyFile.UnsafeGetLogPageSizeBits();
var nextPageBeginAddress = ((tail >> pageBits) + 1) << pageBits;
var nextPageBeginAddress = ((tail >> pageSizeBits) + 1) << pageSizeBits;
if (tail + recordLength > nextPageBeginAddress && nextPageBeginAddress != currentAddress)
{
logger?.LogError("Divergent AOF Stream recordLength:{recordLength}; previousAddress:{previousAddress}; currentAddress:{currentAddress}; nextAddress:{nextAddress}; tailAddress{tail}", recordLength, previousAddress, currentAddress, nextAddress, tail);
Expand Down
3 changes: 3 additions & 0 deletions libs/cluster/Server/Replication/ReplicationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ internal sealed partial class ReplicationManager : IDisposable

readonly CancellationTokenSource ctsRepManager = new();

readonly int pageSizeBits;

readonly ILogger logger;
bool _disposed;

Expand Down Expand Up @@ -92,6 +94,7 @@ public ReplicationManager(ClusterProvider clusterProvider, ILogger logger = null
this.logger = logger;
this.clusterProvider = clusterProvider;
this.storeWrapper = clusterProvider.storeWrapper;
this.pageSizeBits = storeWrapper.appendOnlyFile == null ? 0 : storeWrapper.appendOnlyFile.UnsafeGetLogPageSizeBits();

this.networkPool = networkBufferSettings.CreateBufferPool(logger: logger);
ValidateNetworkBufferSettings();
Expand Down

0 comments on commit 4697db9

Please sign in to comment.