Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] Recovery testcase fixing #513

Merged
merged 5 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions cs/remote/src/FASTER.client/ClientSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,17 @@ private bool HandleReceiveCompletion(SocketAsyncEventArgs e)

private void RecvEventArg_Completed(object sender, SocketAsyncEventArgs e)
{
var connState = (ClientNetworkSession<Key, Value, Input, Output, Context, Functions, ParameterSerializer>)e.UserToken;
do
try
{
// No more things to receive
if (!HandleReceiveCompletion(e)) break;
} while (!connState.socket.ReceiveAsync(e));
var connState = (ClientNetworkSession<Key, Value, Input, Output, Context, Functions, ParameterSerializer>)e.UserToken;
do
{
// No more things to receive
if (!HandleReceiveCompletion(e)) break;
} while (!connState.socket.ReceiveAsync(e));
}
// ignore session socket disposed due to client session dispose
catch (ObjectDisposedException) { }
}
}
}
15 changes: 10 additions & 5 deletions cs/remote/src/FASTER.server/FasterServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,17 @@ private void DisposeConnectionSession(SocketAsyncEventArgs e)

private void RecvEventArg_Completed(object sender, SocketAsyncEventArgs e)
{
var connArgs = (ConnectionArgs) e.UserToken;
do
try
{
// No more things to receive
if (!HandleReceiveCompletion(e)) break;
} while (!connArgs.socket.ReceiveAsync(e));
var connArgs = (ConnectionArgs)e.UserToken;
do
{
// No more things to receive
if (!HandleReceiveCompletion(e)) break;
} while (!connArgs.socket.ReceiveAsync(e));
}
// ignore session socket disposed due to server dispose
catch (ObjectDisposedException) { }
}
}
}
72 changes: 36 additions & 36 deletions cs/test/RecoveryChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ public async ValueTask RecoveryCheck1([Values] CheckpointType checkpointType, [V

if (isAsync)
{
await task;
await fht2.RecoverAsync();
var (status, token) = await task;
await fht2.RecoverAsync(default, token);
}
else
{
task.GetAwaiter().GetResult();
fht2.Recover();
var (status, token) = task.GetAwaiter().GetResult();
fht2.Recover(default, token);
}

Assert.IsTrue(fht1.Log.HeadAddress == fht2.Log.HeadAddress);
Assert.IsTrue(fht1.Log.ReadOnlyAddress == fht2.Log.ReadOnlyAddress);
Assert.IsTrue(fht1.Log.TailAddress == fht2.Log.TailAddress);
Assert.AreEqual(fht1.Log.HeadAddress, fht2.Log.HeadAddress);
Assert.AreEqual(fht1.Log.ReadOnlyAddress, fht2.Log.ReadOnlyAddress);
Assert.AreEqual(fht1.Log.TailAddress, fht2.Log.TailAddress);

using var s2 = fht2.NewSession(new MyFunctions());
for (long key = 0; key < 1000; key++)
Expand Down Expand Up @@ -172,18 +172,18 @@ public async ValueTask RecoveryCheck2([Values] CheckpointType checkpointType, [V

if (isAsync)
{
await task;
await fht2.RecoverAsync();
var (status, token) = await task;
await fht2.RecoverAsync(default, token);
}
else
{
task.GetAwaiter().GetResult();
fht2.Recover();
var(status, token) = task.GetAwaiter().GetResult();
fht2.Recover(default, token);
}

Assert.IsTrue(fht1.Log.HeadAddress == fht2.Log.HeadAddress);
Assert.IsTrue(fht1.Log.ReadOnlyAddress == fht2.Log.ReadOnlyAddress);
Assert.IsTrue(fht1.Log.TailAddress == fht2.Log.TailAddress);
Assert.AreEqual(fht1.Log.HeadAddress, fht2.Log.HeadAddress);
Assert.AreEqual(fht1.Log.ReadOnlyAddress, fht2.Log.ReadOnlyAddress);
Assert.AreEqual(fht1.Log.TailAddress, fht2.Log.TailAddress);

using var s2 = fht2.NewSession(new SimpleFunctions<long, long>());
for (long key = 0; key < 1000 * i + 1000; key++)
Expand Down Expand Up @@ -239,18 +239,18 @@ public async ValueTask RecoveryCheck3([Values] CheckpointType checkpointType, [V

if (isAsync)
{
await task;
await fht2.RecoverAsync();
var (status, token) = await task;
await fht2.RecoverAsync(default, token);
}
else
{
task.GetAwaiter().GetResult();
fht2.Recover();
var (status, token) = task.GetAwaiter().GetResult();
fht2.Recover(default, token);
}

Assert.IsTrue(fht1.Log.HeadAddress == fht2.Log.HeadAddress);
Assert.IsTrue(fht1.Log.ReadOnlyAddress == fht2.Log.ReadOnlyAddress);
Assert.IsTrue(fht1.Log.TailAddress == fht2.Log.TailAddress);
Assert.AreEqual(fht1.Log.HeadAddress, fht2.Log.HeadAddress);
Assert.AreEqual(fht1.Log.ReadOnlyAddress, fht2.Log.ReadOnlyAddress);
Assert.AreEqual(fht1.Log.TailAddress, fht2.Log.TailAddress);

using var s2 = fht2.NewSession(new SimpleFunctions<long, long>());
for (long key = 0; key < 1000 * i + 1000; key++)
Expand Down Expand Up @@ -309,18 +309,18 @@ public async ValueTask RecoveryCheck4([Values] CheckpointType checkpointType, [V

if (isAsync)
{
await task;
await fht2.RecoverAsync();
var (status, token) = await task;
await fht2.RecoverAsync(default, token);
}
else
{
task.GetAwaiter().GetResult();
fht2.Recover();
var (status, token) = task.GetAwaiter().GetResult();
fht2.Recover(default, token);
}

Assert.IsTrue(fht1.Log.HeadAddress == fht2.Log.HeadAddress);
Assert.IsTrue(fht1.Log.ReadOnlyAddress == fht2.Log.ReadOnlyAddress);
Assert.IsTrue(fht1.Log.TailAddress == fht2.Log.TailAddress);
Assert.AreEqual(fht1.Log.HeadAddress, fht2.Log.HeadAddress);
Assert.AreEqual(fht1.Log.ReadOnlyAddress, fht2.Log.ReadOnlyAddress);
Assert.AreEqual(fht1.Log.TailAddress, fht2.Log.TailAddress);

using var s2 = fht2.NewSession(new SimpleFunctions<long, long>());
for (long key = 0; key < 1000 * i + 1000; key++)
Expand Down Expand Up @@ -384,18 +384,18 @@ public async ValueTask RecoveryCheck5([Values] CheckpointType checkpointType, [V

if (isAsync)
{
await task;
await fht2.RecoverAsync();
var (status, token) = await task;
await fht2.RecoverAsync(default, token);
}
else
{
task.GetAwaiter().GetResult();
fht2.Recover();
var (status, token) = task.GetAwaiter().GetResult();
fht2.Recover(default, token);
}

Assert.IsTrue(fht1.Log.HeadAddress == fht2.Log.HeadAddress);
Assert.IsTrue(fht1.Log.ReadOnlyAddress == fht2.Log.ReadOnlyAddress);
Assert.IsTrue(fht1.Log.TailAddress == fht2.Log.TailAddress);
Assert.AreEqual(fht1.Log.HeadAddress, fht2.Log.HeadAddress);
Assert.AreEqual(fht1.Log.ReadOnlyAddress, fht2.Log.ReadOnlyAddress);
Assert.AreEqual(fht1.Log.TailAddress, fht2.Log.TailAddress);

using var s2 = fht2.NewSession(new MyFunctions());
for (long key = 0; key < 1000; key++)
Expand Down Expand Up @@ -482,7 +482,7 @@ public async ValueTask IncrSnapshotRecoveryCheck(ICheckpointManager checkpointMa
checkpointSettings: new CheckpointSettings { CheckpointManager = checkpointManager }
);

await fht2.RecoverAsync();
await fht2.RecoverAsync(default, _token2);

Assert.IsTrue(fht1.Log.TailAddress == fht2.Log.TailAddress, $"fht1 tail = {fht1.Log.TailAddress}; fht2 tail = {fht2.Log.TailAddress}");

Expand Down