From 4697db9a829d245bfae4c53f622a8b27b64f3a1e Mon Sep 17 00:00:00 2001 From: Vasileios Zois Date: Fri, 15 Nov 2024 17:30:48 -0800 Subject: [PATCH] pageSizeBits instance variable for use with process AOF stream --- .../Replication/ReplicaOps/ReplicationReplicaAofSync.cs | 5 ++--- libs/cluster/Server/Replication/ReplicationManager.cs | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs b/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs index 5afc81691a8..f90285b3fbd 100644 --- a/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs +++ b/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs @@ -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 ) { @@ -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); diff --git a/libs/cluster/Server/Replication/ReplicationManager.cs b/libs/cluster/Server/Replication/ReplicationManager.cs index 7ba96560867..2f418f4369c 100644 --- a/libs/cluster/Server/Replication/ReplicationManager.cs +++ b/libs/cluster/Server/Replication/ReplicationManager.cs @@ -22,6 +22,8 @@ internal sealed partial class ReplicationManager : IDisposable readonly CancellationTokenSource ctsRepManager = new(); + readonly int pageSizeBits; + readonly ILogger logger; bool _disposed; @@ -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();