Skip to content

Commit c81a236

Browse files
authored
cherry-pick AOF fix (#1742)
1 parent 4ddd785 commit c81a236

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

libs/host/Configuration/Options.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,12 @@ endpoint is IPEndPoint listenEp && clusterAnnounceEndpoint[0] is IPEndPoint anno
831831
throw new Exception("SlowLogThreshold must be at least 100 microseconds.");
832832
}
833833

834+
if (!EnableAOF.GetValueOrDefault())
835+
{
836+
if (!string.IsNullOrEmpty(AofSizeLimit))
837+
throw new GarnetException("AofSizeLimit cannot be enforced with disabled AOF!");
838+
}
839+
834840
Func<INamedDeviceFactoryCreator> azureFactoryCreator = () =>
835841
{
836842
if (!string.IsNullOrEmpty(AzureStorageConnectionString))

test/Garnet.test/GarnetServerConfigTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,5 +1312,24 @@ public void RevivificationFlagOrderingIndependence()
13121312
Assert.Throws<Exception>(() => options.GetServerOptions(), $"Should throw for args: {string.Join(" ", args)}");
13131313
}
13141314
}
1315+
1316+
[Test]
1317+
public void AofSizeLimitWithoutAofEnabled()
1318+
{
1319+
// Setting --aof-size-limit without --aof should throw
1320+
var args = new[] { "--aof-size-limit", "64m" };
1321+
var parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out var options, out var invalidOptions, out _, out _, silentMode: true);
1322+
ClassicAssert.IsTrue(parseSuccessful);
1323+
ClassicAssert.AreEqual(0, invalidOptions.Count);
1324+
var ex = Assert.Throws<GarnetException>(() => options.GetServerOptions());
1325+
ClassicAssert.IsTrue(ex.Message.Contains("AofSizeLimit"));
1326+
1327+
// Setting --aof-size-limit with --aof enabled should succeed
1328+
args = ["--aof", "--aof-size-limit", "64m"];
1329+
parseSuccessful = ServerSettingsManager.TryParseCommandLineArguments(args, out options, out invalidOptions, out _, out _, silentMode: true);
1330+
ClassicAssert.IsTrue(parseSuccessful);
1331+
ClassicAssert.AreEqual(0, invalidOptions.Count);
1332+
Assert.DoesNotThrow(() => options.GetServerOptions());
1333+
}
13151334
}
13161335
}

0 commit comments

Comments
 (0)