@@ -104,9 +104,9 @@ internal static unsafe bool DoInternalTryLock<FasterSession, TLockableKey>(Faste
104104 {
105105 ref var key = ref keys [ keyIdx ] ;
106106 if ( keyIdx == start || clientSession . fht . LockTable . GetBucketIndex ( key . KeyHash ) != clientSession . fht . LockTable . GetBucketIndex ( keys [ keyIdx - 1 ] . KeyHash ) )
107- {
107+ {
108108 for ( int numRetriesForKey = 0 ; ; )
109- {
109+ {
110110 OperationStatus status = clientSession . fht . InternalLock ( key . KeyHash , new ( LockOperationType . Lock , key . LockType ) ) ;
111111 bool fail = false ;
112112 if ( status == OperationStatus . SUCCESS )
@@ -125,8 +125,13 @@ internal static unsafe bool DoInternalTryLock<FasterSession, TLockableKey>(Faste
125125 // CancellationToken can accompany either of the other two mechanisms
126126 fail |= timeout . Ticks > 0 && DateTime . UtcNow . Ticks - startTime . Ticks > timeout . Ticks ;
127127 fail |= cancellationToken . IsCancellationRequested ;
128- if ( ! fail && status == OperationStatus . SUCCESS )
129- break ; // out of the retry loop
128+ if ( ! fail )
129+ {
130+ if ( status == OperationStatus . SUCCESS )
131+ break ; // Out of the retry loop
132+
133+ continue ; // Retry in next iteration
134+ }
130135
131136 clientSession . fht . HandleImmediateNonPendingRetryStatus < Input , Output , Context , FasterSession > ( status , fasterSession ) ;
132137
@@ -202,7 +207,7 @@ private static unsafe LockType DoLockOp<FasterSession, TLockableKey>(FasterSessi
202207
203208 /// <inheritdoc/>
204209 public void Lock < TLockableKey > ( TLockableKey [ ] keys ) where TLockableKey : ILockableKey => Lock ( keys , 0 , keys . Length ) ;
205-
210+
206211 /// <inheritdoc/>
207212 public void Lock < TLockableKey > ( TLockableKey [ ] keys , int start , int count )
208213 where TLockableKey : ILockableKey
@@ -222,8 +227,8 @@ public void Lock<TLockableKey>(TLockableKey[] keys, int start, int count)
222227 }
223228
224229 /// <inheritdoc/>
225- public bool TryLock < TLockableKey > ( TLockableKey [ ] keys , int maxRetriesPerKey , CancellationToken cancellationToken = default )
226- where TLockableKey : ILockableKey
230+ public bool TryLock < TLockableKey > ( TLockableKey [ ] keys , int maxRetriesPerKey , CancellationToken cancellationToken = default )
231+ where TLockableKey : ILockableKey
227232 => TryLock ( keys , 0 , keys . Length , maxRetriesPerKey , default , cancellationToken ) ;
228233
229234 /// <inheritdoc/>
@@ -233,7 +238,7 @@ public bool TryLock<TLockableKey>(TLockableKey[] keys, int start, int count, int
233238
234239 /// <inheritdoc/>
235240 public bool TryLock < TLockableKey > ( TLockableKey [ ] keys , TimeSpan timeout , CancellationToken cancellationToken = default )
236- where TLockableKey : ILockableKey
241+ where TLockableKey : ILockableKey
237242 => TryLock ( keys , 0 , keys . Length , - 1 , timeout , cancellationToken ) ;
238243
239244 /// <inheritdoc/>
@@ -392,7 +397,7 @@ public Status Read(ref Key key, ref Input input, ref Output output, Context user
392397
393398 /// <inheritdoc/>
394399 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
395- public Status Read ( ref Key key , ref Input input , ref Output output , ref ReadOptions readOptions , Context userContext = default , long serialNo = 0 )
400+ public Status Read ( ref Key key , ref Input input , ref Output output , ref ReadOptions readOptions , Context userContext = default , long serialNo = 0 )
396401 => Read ( ref key , ref input , ref output , ref readOptions , out _ , userContext , serialNo ) ;
397402
398403 /// <inheritdoc/>
@@ -521,7 +526,7 @@ public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> R
521526
522527 /// <inheritdoc/>
523528 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
524- public ValueTask < FasterKV < Key , Value > . ReadAsyncResult < Input , Output , Context > > ReadAsync ( Key key , Input input , ref ReadOptions readOptions , Context context = default , long serialNo = 0 , CancellationToken token = default )
529+ public ValueTask < FasterKV < Key , Value > . ReadAsyncResult < Input , Output , Context > > ReadAsync ( Key key , Input input , ref ReadOptions readOptions , Context context = default , long serialNo = 0 , CancellationToken token = default )
525530 => ReadAsync ( ref key , ref input , ref readOptions , context , serialNo , token ) ;
526531
527532 /// <inheritdoc/>
@@ -543,7 +548,7 @@ public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> R
543548
544549 /// <inheritdoc/>
545550 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
546- public ValueTask < FasterKV < Key , Value > . ReadAsyncResult < Input , Output , Context > > ReadAsync ( Key key , Context context = default , long serialNo = 0 , CancellationToken token = default )
551+ public ValueTask < FasterKV < Key , Value > . ReadAsyncResult < Input , Output , Context > > ReadAsync ( Key key , Context context = default , long serialNo = 0 , CancellationToken token = default )
547552 => ReadAsync ( ref key , context , serialNo , token ) ;
548553
549554 /// <inheritdoc/>
@@ -720,7 +725,7 @@ public Status RMW(ref Key key, ref Input input, ref Output output, out RecordMet
720725
721726 /// <inheritdoc/>
722727 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
723- public Status RMW ( ref Key key , ref Input input , ref Output output , ref RMWOptions rmwOptions , out RecordMetadata recordMetadata , Context userContext = default , long serialNo = 0 )
728+ public Status RMW ( ref Key key , ref Input input , ref Output output , ref RMWOptions rmwOptions , out RecordMetadata recordMetadata , Context userContext = default , long serialNo = 0 )
724729 => RMW ( ref key , rmwOptions . KeyHash ?? clientSession . fht . comparer . GetHashCode64 ( ref key ) , ref input , ref output , out recordMetadata , userContext , serialNo ) ;
725730
726731 /// <inheritdoc/>
@@ -821,7 +826,7 @@ public Status Delete(ref Key key, Context userContext = default, long serialNo =
821826 /// <inheritdoc/>
822827 /// <inheritdoc/>
823828 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
824- public Status Delete ( ref Key key , ref DeleteOptions deleteOptions , Context userContext = default , long serialNo = 0 )
829+ public Status Delete ( ref Key key , ref DeleteOptions deleteOptions , Context userContext = default , long serialNo = 0 )
825830 => Delete ( ref key , deleteOptions . KeyHash ?? clientSession . fht . comparer . GetHashCode64 ( ref key ) , userContext , serialNo ) ;
826831
827832 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -985,7 +990,7 @@ public bool CopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Va
985990 => _clientSession . functions . CopyUpdater ( ref key , ref input , ref oldValue , ref newValue , ref output , ref rmwInfo ) ;
986991
987992 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
988- public void PostCopyUpdater ( ref Key key , ref Input input , ref Value oldValue , ref Value newValue , ref Output output , ref RecordInfo recordInfo , ref RMWInfo rmwInfo )
993+ public void PostCopyUpdater ( ref Key key , ref Input input , ref Value oldValue , ref Value newValue , ref Output output , ref RecordInfo recordInfo , ref RMWInfo rmwInfo )
989994 {
990995 recordInfo . SetDirtyAndModified ( ) ;
991996 _clientSession . functions . PostCopyUpdater ( ref key , ref input , ref oldValue , ref newValue , ref output , ref rmwInfo ) ;
@@ -1015,7 +1020,7 @@ public bool SingleDeleter(ref Key key, ref Value value, ref RecordInfo recordInf
10151020 => _clientSession . functions . SingleDeleter ( ref key , ref value , ref deleteInfo ) ;
10161021
10171022 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
1018- public void PostSingleDeleter ( ref Key key , ref RecordInfo recordInfo , ref DeleteInfo deleteInfo )
1023+ public void PostSingleDeleter ( ref Key key , ref RecordInfo recordInfo , ref DeleteInfo deleteInfo )
10191024 {
10201025 recordInfo . SetDirtyAndModified ( ) ;
10211026 _clientSession . functions . PostSingleDeleter ( ref key , ref deleteInfo ) ;
@@ -1116,4 +1121,4 @@ public bool CompletePendingWithOutputs(out CompletedOutputIterator<Key, Value, I
11161121 }
11171122 #endregion IFasterSession
11181123 }
1119- }
1124+ }
0 commit comments