Skip to content

Commit

Permalink
Merge branch 'master' into async-support
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc authored Aug 20, 2019
2 parents 9e84d63 + 84e7595 commit 7e80b07
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cs/src/core/Allocator/AllocatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,8 @@ private bool MonotonicUpdate(ref long variable, long newValue, out long oldValue
/// </summary>
/// <param name="tailAddress"></param>
/// <param name="headAddress"></param>
public void RecoveryReset(long tailAddress, long headAddress)
/// <param name="beginAddress"></param>
public void RecoveryReset(long tailAddress, long headAddress, long beginAddress)
{
long tailPage = GetPage(tailAddress);
long offsetInPage = GetOffsetInPage(tailAddress);
Expand All @@ -1168,7 +1169,8 @@ public void RecoveryReset(long tailAddress, long headAddress)
var nextPageIndex = (pageIndex + 1) % BufferSize;
if (tailAddress > 0)
AllocatePage(nextPageIndex);


BeginAddress = beginAddress;
HeadAddress = headAddress;
SafeHeadAddress = headAddress;
FlushedUntilAddress = tailAddress;
Expand Down
11 changes: 10 additions & 1 deletion cs/src/core/Index/Common/Contexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public struct HybridLogRecoveryInfo
/// </summary>
public long headAddress;
/// <summary>
/// Begin address
/// </summary>
public long beginAddress;
/// <summary>
/// Guid array
/// </summary>
public Guid[] guids;
Expand Down Expand Up @@ -215,6 +219,9 @@ public void Initialize(StreamReader reader)
value = reader.ReadLine();
headAddress = long.Parse(value);

value = reader.ReadLine();
beginAddress = long.Parse(value);

value = reader.ReadLine();
numThreads = int.Parse(value);

Expand Down Expand Up @@ -281,8 +288,9 @@ public byte[] ToByteArray()
writer.WriteLine(startLogicalAddress);
writer.WriteLine(finalLogicalAddress);
writer.WriteLine(headAddress);
writer.WriteLine(checkpointTokens.Count);
writer.WriteLine(beginAddress);

writer.WriteLine(checkpointTokens.Count);
foreach (var kvp in checkpointTokens)
{
writer.WriteLine(kvp.Key);
Expand Down Expand Up @@ -315,6 +323,7 @@ public void DebugPrint()
Debug.WriteLine("Start Logical Address: {0}", startLogicalAddress);
Debug.WriteLine("Final Logical Address: {0}", finalLogicalAddress);
Debug.WriteLine("Head Address: {0}", headAddress);
Debug.WriteLine("Begin Address: {0}", beginAddress);
Debug.WriteLine("Num sessions recovered: {0}", numThreads);
Debug.WriteLine("Recovered sessions: ");
foreach (var sessionInfo in continueTokens)
Expand Down
1 change: 1 addition & 0 deletions cs/src/core/Index/Recovery/Checkpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ private bool GlobalMoveToNextState(SystemState currentState, SystemState nextSta
}

_hybridLogCheckpoint.info.headAddress = hlog.HeadAddress;
_hybridLogCheckpoint.info.beginAddress = hlog.BeginAddress;

if (FoldOverSnapshot)
{
Expand Down
16 changes: 11 additions & 5 deletions cs/src/core/Index/Recovery/Recovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,22 @@ private void InternalRecover(Guid indexToken, Guid hybridLogToken)


// Read appropriate hybrid log pages into memory
RestoreHybridLog(recoveredHLCInfo.info.finalLogicalAddress, recoveredHLCInfo.info.headAddress);
RestoreHybridLog(recoveredHLCInfo.info.finalLogicalAddress, recoveredHLCInfo.info.headAddress, recoveredHLCInfo.info.beginAddress);

// Recover session information
_recoveredSessions = recoveredHLCInfo.info.continueTokens;
}

private void RestoreHybridLog(long untilAddress, long headAddress)
private void RestoreHybridLog(long untilAddress, long headAddress, long beginAddress)
{
// Special case: we do not load any records into memory
if (headAddress == untilAddress)
Debug.Assert(beginAddress <= headAddress);
Debug.Assert(headAddress <= untilAddress);

// Special cases: we do not load any records into memory
if (
(beginAddress == untilAddress) || // Empty log
((headAddress == untilAddress) && (hlog.GetOffsetInPage(headAddress) == 0)) // Empty in-memory page
)
{
hlog.AllocatePage(hlog.GetPageIndexForAddress(headAddress));
}
Expand Down Expand Up @@ -171,7 +177,7 @@ private void RestoreHybridLog(long untilAddress, long headAddress)
}
}

hlog.RecoveryReset(untilAddress, headAddress);
hlog.RecoveryReset(untilAddress, headAddress, beginAddress);
}


Expand Down

0 comments on commit 7e80b07

Please sign in to comment.