Skip to content

Commit

Permalink
Fast-forward client session trivially to the current system state, if…
Browse files Browse the repository at this point in the history
… the current system state were not associated with any state machine (null currentSyncStateMachine implies a trivial state machine). This can happen after recovery. (#273)
  • Loading branch information
badrishc authored Jun 4, 2020
1 parent b073aa7 commit 3fc5429
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cs/src/core/Index/Recovery/Recovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ private void InternalRecover(Guid indexToken, Guid hybridLogToken)
Debug.WriteLine("Index Checkpoint: {0}", indexToken);
Debug.WriteLine("HybridLog Checkpoint: {0}", hybridLogToken);

// Ensure active state machine to null
currentSyncStateMachine = null;

// Recovery appropriate context information
var recoveredICInfo = new IndexCheckpointInfo();
recoveredICInfo.Recover(indexToken, checkpointManager);
Expand Down
12 changes: 12 additions & 0 deletions cs/src/core/Index/Synchronization/FasterStateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ private async ValueTask ThreadStateMachineStep(FasterExecutionContext ctx,
// Target state is the current (non-intermediate state) system state thread needs to catch up to
var (currentTask, targetState) = CaptureTaskAndTargetState();

// No state machine associated with target, we can
// directly fast forward session to target state
if (currentTask == null)
{
if (ctx != null)
{
ctx.phase = targetState.phase;
ctx.version = targetState.version;
}
return;
}

// the current thread state is what the thread remembers, or simply what the current system
// is if we are calling from somewhere other than an execution thread (e.g. waiting on
// a checkpoint to complete on a client app thread)
Expand Down

0 comments on commit 3fc5429

Please sign in to comment.