Skip to content

Commit

Permalink
rename replay max lag parameter and added stats info
Browse files Browse the repository at this point in the history
  • Loading branch information
vazois committed Nov 13, 2024
1 parent f715ec4 commit c216e21
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions libs/cluster/Server/ClusterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public MetricsItem[] GetReplicationInfo()
{
var (address, port) = config.GetLocalNodePrimaryAddress();
var primaryLinkStatus = clusterManager.GetPrimaryLinkStatus(config);
var replicationOffsetLag = storeWrapper.appendOnlyFile.TailAddress - replicationManager.ReplicationOffset;
replicationInfo.Add(new("master_host", address));
replicationInfo.Add(new("master_port", port.ToString()));
replicationInfo.Add(primaryLinkStatus[0]);
Expand All @@ -241,6 +242,8 @@ public MetricsItem[] GetReplicationInfo()
replicationInfo.Add(new("slave_read_only", "1"));
replicationInfo.Add(new("replica_announced", "1"));
replicationInfo.Add(new("master_sync_last_io_seconds_ago", replicationManager.LastPrimarySyncSeconds.ToString()));
replicationInfo.Add(new("replication_offset_lag", replicationOffsetLag.ToString()));
replicationInfo.Add(new("replication_offset_max_lag", storeWrapper.serverOptions.ReplicationOffsetMaxLag.ToString()));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal sealed partial class ReplicationManager : IDisposable
{
void ThrottlePrimary()
{
while (replayIterator != null && storeWrapper.appendOnlyFile.TailAddress - ReplicationOffset > storeWrapper.serverOptions.ReplicaMaxLag)
while (replayIterator != null && storeWrapper.appendOnlyFile.TailAddress - ReplicationOffset > storeWrapper.serverOptions.ReplicationOffsetMaxLag)
{
replicaReplayTaskCts.Token.ThrowIfCancellationRequested();
Thread.Yield();
Expand Down
6 changes: 3 additions & 3 deletions libs/host/Configuration/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ internal sealed class Options
public int ReplicaSyncDelayMs { get; set; }

[IntRangeValidation(-1, int.MaxValue)]
[Option("replica-max-lag", Required = false, HelpText = "Upper bound on the lag (i.e. throttle replicaAOF append if AOF.TailAddress - ReplicationOffset > ReplicaMaxLag) between primary and replica. -1 - Synchronous replay, >= 0 - background replay with specified lag")]
public int ReplicaMaxLag { get; set; }
[Option("replica-offset-max-lag", Required = false, HelpText = "Upper bound on the lag (i.e. throttle replicaAOF append if AOF.TailAddress - ReplicationOffset > ReplicaMaxLag) between primary and replica. -1 - Synchronous replay, >= 0 - background replay with specified lag")]
public int ReplicationOffsetMaxLag { get; set; }

[OptionValidation]
[Option("main-memory-replication", Required = false, HelpText = "Use main-memory replication model.")]
Expand Down Expand Up @@ -643,7 +643,7 @@ public GarnetServerOptions GetServerOptions(ILogger logger = null)
CheckpointThrottleFlushDelayMs = CheckpointThrottleFlushDelayMs,
EnableScatterGatherGet = EnableScatterGatherGet.GetValueOrDefault(),
ReplicaSyncDelayMs = ReplicaSyncDelayMs,
ReplicaMaxLag = ReplicaMaxLag,
ReplicationOffsetMaxLag = ReplicationOffsetMaxLag,
MainMemoryReplication = MainMemoryReplication.GetValueOrDefault(),
OnDemandCheckpoint = OnDemandCheckpoint.GetValueOrDefault(),
UseAofNullDevice = UseAofNullDevice.GetValueOrDefault(),
Expand Down
2 changes: 1 addition & 1 deletion libs/host/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
"ReplicaSyncDelayMs" : 5,

/* Upper bound on the lag (i.e. throttle replicaAOF append if AOF.TailAddress - ReplicationOffset > ReplicaMaxLag) between primary and replica. -1 - Synchronous replay, >= 0 - background replay with specified lag*/
"ReplicaMaxLag" : 32768,
"ReplicationOffsetMaxLag" : -1,

/* Use main-memory replication model. */
"MainMemoryReplication" : false,
Expand Down
4 changes: 1 addition & 3 deletions libs/server/Servers/GarnetServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public class GarnetServerOptions : ServerOptions
/// <summary>
/// Upper bound on the lag (i.e. throttle replicaAOF append if AOF.TailAddress - ReplicationOffset > ReplicaMaxLag) between primary and replica. -1 - Synchronous replay, >= 0 - background replay with specified lag
/// </summary>
public int ReplicaMaxLag = 32768;
public int ReplicationOffsetMaxLag = -1;

/// <summary>
/// Whether we truncate AOF as soon as replicas are fed (not just after checkpoints)
Expand All @@ -309,8 +309,6 @@ public class GarnetServerOptions : ServerOptions
/// </summary>
public bool UseNativeDeviceLinux = false;



/// <summary>
/// Limit of items to return in one iteration of *SCAN command
/// </summary>
Expand Down

0 comments on commit c216e21

Please sign in to comment.