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

Checkpoint Recovery Bug #144

Merged
merged 4 commits into from
Jun 26, 2019
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
27 changes: 9 additions & 18 deletions cs/src/core/Allocator/AllocatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
using System.Runtime.CompilerServices;
using System.Threading;
using System.Runtime.InteropServices;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.IO;
using System.Diagnostics;

namespace FASTER.core
Expand Down Expand Up @@ -121,6 +117,11 @@ public unsafe abstract class AllocatorBase<Key, Value> : IDisposable
/// HeadOffset lag (from tail)
/// </summary>
protected const int HeadOffsetLagNumPages = 4;

/// <summary>
/// HeadOffset lag (from tail) for ReadCache
/// </summary>
protected const int ReadCacheHeadOffsetLagNumPages = 1;
/// <summary>
/// HeadOffset lag size
/// </summary>
Expand Down Expand Up @@ -462,30 +463,20 @@ public unsafe abstract class AllocatorBase<Key, Value> : IDisposable


/// <summary>
///
/// Instantiate base allocator
/// </summary>
/// <param name="settings"></param>
/// <param name="comparer"></param>
/// <param name="evictCallback"></param>
/// <param name="epoch"></param>
public AllocatorBase(LogSettings settings, IFasterEqualityComparer<Key> comparer, Action<long, long> evictCallback, LightEpoch epoch)
: this(settings, comparer, epoch)
{
if (evictCallback != null)
{
ReadCache = true;
EvictCallback = evictCallback;
}
}

/// <summary>
/// Instantiate base allocator
/// </summary>
/// <param name="settings"></param>
/// <param name="comparer"></param>
/// <param name="epoch"></param>
public AllocatorBase(LogSettings settings, IFasterEqualityComparer<Key> comparer, LightEpoch epoch)
{
this.comparer = comparer;
if (epoch == null)
{
Expand All @@ -509,8 +500,8 @@ public AllocatorBase(LogSettings settings, IFasterEqualityComparer<Key> comparer
BufferSize = (int)(LogTotalSizeBytes / (1L << LogPageSizeBits));
BufferSizeMask = BufferSize - 1;

// HeadOffset lag (from tail)
HeadOffsetLagSize = BufferSize - HeadOffsetLagNumPages;
// HeadOffset lag (from tail).
HeadOffsetLagSize = BufferSize - (ReadCache ? ReadCacheHeadOffsetLagNumPages : HeadOffsetLagNumPages);
HeadOffsetLagAddress = (long)HeadOffsetLagSize << LogPageSizeBits;

// ReadOnlyOffset lag (from tail). This should not exceed HeadOffset lag.
Expand Down Expand Up @@ -1163,7 +1154,7 @@ public void RecoveryReset(long tailAddress, long headAddress)

HeadAddress = headAddress;
SafeHeadAddress = headAddress;
FlushedUntilAddress = headAddress;
FlushedUntilAddress = tailAddress;
ReadOnlyAddress = tailAddress;
SafeReadOnlyAddress = tailAddress;

Expand Down
3 changes: 1 addition & 2 deletions cs/src/core/Allocator/GenericAllocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ private void WriteAsync<TContext>(long flushPage, ulong alignedDestinationAddres
List<long> addr = new List<long>();
asyncResult.freeBuffer1 = buffer;

addr = new List<long>();
MemoryStream ms = new MemoryStream();
IObjectSerializer<Key> keySerializer = null;
IObjectSerializer<Value> valueSerializer = null;
Expand Down Expand Up @@ -417,7 +416,7 @@ private void WriteAsync<TContext>(long flushPage, ulong alignedDestinationAddres
else
{
// need to write both page and object cache
asyncResult.count++;
Interlocked.Increment(ref asyncResult.count);

asyncResult.freeBuffer2 = _objBuffer;
objlogDevice.WriteAsync(
Expand Down
14 changes: 7 additions & 7 deletions cs/src/core/Device/LocalStorageDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,17 @@ public override void Close()
logHandle.Dispose();
}


private string GetSegmentName(int segmentId)
protected string GetSegmentName(int segmentId)
{
return FileName + "." + segmentId;
}

// Can be used to pre-load handles, e.g., after a checkpoint
protected SafeFileHandle GetOrAddHandle(int _segmentId)
{
return logHandles.GetOrAdd(_segmentId, segmentId => CreateHandle(segmentId));
}

private static uint GetSectorSize(string filename)
{
if (!Native32.GetDiskFreeSpace(filename.Substring(0, 3),
Expand Down Expand Up @@ -216,11 +221,6 @@ private SafeFileHandle CreateHandle(int segmentId)
return logHandle;
}

private SafeFileHandle GetOrAddHandle(int _segmentId)
{
return logHandles.GetOrAdd(_segmentId, segmentId => CreateHandle(segmentId));
}

/// Sets file size to the specified value.
/// Does not reset file seek pointer to original location.
private bool SetFileSize(string filename, SafeFileHandle logHandle, long size)
Expand Down