Skip to content

Commit

Permalink
Fix ContinuePending RI, mark source RI correctly on lock transfer (#787)
Browse files Browse the repository at this point in the history
* Fix ContinuePending RI bits

* Fix inaccurate skipping of "marking source record invalid"
  • Loading branch information
badrishc authored Jan 21, 2023
1 parent 6e0bea0 commit 53297ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions cs/src/core/Index/FASTER/Implementation/ContinuePending.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ internal OperationStatus InternalContinuePendingRead<Input, Output, Context, Fas
where FasterSession : IFasterSession<Key, Value, Input, Output, Context>
{
ref RecordInfo srcRecordInfo = ref hlog.GetInfoFromBytePointer(request.record.GetValidPointer());
Debug.Assert(!srcRecordInfo.IsIntermediate, "Should always retrieve a non-Tentative, non-Sealed record from disk");
// We ignore locks and temp bits for disk images
srcRecordInfo.ClearLocks();
srcRecordInfo.Tentative = false;
srcRecordInfo.Unseal();
// Debug.Assert(!srcRecordInfo.IsIntermediate, "Should always retrieve a non-Tentative, non-Sealed record from disk");

if (request.logicalAddress >= hlog.BeginAddress)
{
Expand Down Expand Up @@ -170,8 +174,13 @@ internal OperationStatus InternalContinuePendingRMW<Input, Output, Context, Fast
SpinWaitUntilClosed(request.logicalAddress);

byte* recordPointer = request.record.GetValidPointer();
RecordInfo inputRecordInfo = hlog.GetInfoFromBytePointer(recordPointer); // Not ref, as we don't want to write into request.record
Debug.Assert(!inputRecordInfo.IsIntermediate, "Should always retrieve a non-Tentative, non-Sealed record from disk");
ref var inputRIRef = ref hlog.GetInfoFromBytePointer(recordPointer);
// We ignore locks and temp bits for disk images
inputRIRef.ClearLocks();
inputRIRef.Tentative = false;
inputRIRef.Unseal();
RecordInfo inputRecordInfo = inputRIRef; // Not ref, as we don't want to write into request.record
// Debug.Assert(!inputRecordInfo.IsIntermediate, "Should always retrieve a non-Tentative, non-Sealed record from disk");

OperationStackContext<Key, Value> stackCtx = new(comparer.GetHashCode64(ref key));
OperationStatus status;
Expand Down
3 changes: 2 additions & 1 deletion cs/src/core/Index/FASTER/Implementation/RecordSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ internal void Set(long latestLogicalAddress, AllocatorBase<Key, Value> srcLog)
internal void MarkSourceRecordAfterSuccessfulCopyUpdate<Input, Output, Context, FasterSession>(FasterSession fasterSession, ref RecordInfo srcRecordInfo)
where FasterSession : IFasterSession<Key, Value, Input, Output, Context>
{
if (this.HasInMemorySrc && this.LogicalAddress >= this.Log.HeadAddress)
if (this.HasInMemorySrc)
{
// Record is guaranteed to be in memory at this point, regardless of HeadAddress
if (this.HasReadCacheSrc)
{
// If the record was evicted, it won't be accessed, so we do not need to worry about setting it invalid.
Expand Down

0 comments on commit 53297ce

Please sign in to comment.