diff --git a/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs b/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs index f90285b3fbd..5eb948acc03 100644 --- a/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs +++ b/libs/cluster/Server/Replication/ReplicaOps/ReplicationReplicaAofSync.cs @@ -67,10 +67,11 @@ public unsafe void ProcessPrimaryStream(byte* record, int recordLength, long pre var tail = storeWrapper.appendOnlyFile.TailAddress; var nextPageBeginAddress = ((tail >> pageSizeBits) + 1) << pageSizeBits; - if (tail + recordLength > nextPageBeginAddress && nextPageBeginAddress != currentAddress) + if ((tail + recordLength <= nextPageBeginAddress && tail != currentAddress) || + (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); - throw new GarnetException($"Divergent AOF Stream recordLength:{recordLength}; previousAddress:{previousAddress}; currentAddress:{currentAddress}; nextAddress:{nextAddress}; tailAddress{tail}", LogLevel.Warning, clientResponse: false); + logger?.LogError("Divergent AOF Stream recordLength:{recordLength}; previousAddress:{previousAddress}; currentAddress:{currentAddress}; nextAddress:{nextAddress}; tailAddress:{tail}", recordLength, previousAddress, currentAddress, nextAddress, tail); + throw new GarnetException($"Divergent AOF Stream recordLength:{recordLength}; previousAddress:{previousAddress}; currentAddress:{currentAddress}; nextAddress:{nextAddress}; tailAddress:{tail}", LogLevel.Warning, clientResponse: false); } // Address check only if synchronous replication is enabled