Skip to content

Commit

Permalink
[C#] Recovery testcase fixing (#513)
Browse files Browse the repository at this point in the history
* make error more detailed

* try sorting by creation time for linux compat

* change test to use specific token, as workaround for linux timestamp sorting granularity issue.

* Ignore socket disposal exception in RecvEventArg_Completed

* Restore full Azure pipeline
  • Loading branch information
badrishc authored Jun 27, 2021
1 parent 6766012 commit 0c23a47
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 46 deletions.
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

0 comments on commit 0c23a47

Please sign in to comment.