@@ -104,9 +104,9 @@ internal static unsafe bool DoInternalTryLock<FasterSession, TLockableKey>(Faste
104
104
{
105
105
ref var key = ref keys [ keyIdx ] ;
106
106
if ( keyIdx == start || clientSession . fht . LockTable . GetBucketIndex ( key . KeyHash ) != clientSession . fht . LockTable . GetBucketIndex ( keys [ keyIdx - 1 ] . KeyHash ) )
107
- {
107
+ {
108
108
for ( int numRetriesForKey = 0 ; ; )
109
- {
109
+ {
110
110
OperationStatus status = clientSession . fht . InternalLock ( key . KeyHash , new ( LockOperationType . Lock , key . LockType ) ) ;
111
111
bool fail = false ;
112
112
if ( status == OperationStatus . SUCCESS )
@@ -125,8 +125,13 @@ internal static unsafe bool DoInternalTryLock<FasterSession, TLockableKey>(Faste
125
125
// CancellationToken can accompany either of the other two mechanisms
126
126
fail |= timeout . Ticks > 0 && DateTime . UtcNow . Ticks - startTime . Ticks > timeout . Ticks ;
127
127
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
+ }
130
135
131
136
clientSession . fht . HandleImmediateNonPendingRetryStatus < Input , Output , Context , FasterSession > ( status , fasterSession ) ;
132
137
@@ -202,7 +207,7 @@ private static unsafe LockType DoLockOp<FasterSession, TLockableKey>(FasterSessi
202
207
203
208
/// <inheritdoc/>
204
209
public void Lock < TLockableKey > ( TLockableKey [ ] keys ) where TLockableKey : ILockableKey => Lock ( keys , 0 , keys . Length ) ;
205
-
210
+
206
211
/// <inheritdoc/>
207
212
public void Lock < TLockableKey > ( TLockableKey [ ] keys , int start , int count )
208
213
where TLockableKey : ILockableKey
@@ -222,8 +227,8 @@ public void Lock<TLockableKey>(TLockableKey[] keys, int start, int count)
222
227
}
223
228
224
229
/// <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
227
232
=> TryLock ( keys , 0 , keys . Length , maxRetriesPerKey , default , cancellationToken ) ;
228
233
229
234
/// <inheritdoc/>
@@ -233,7 +238,7 @@ public bool TryLock<TLockableKey>(TLockableKey[] keys, int start, int count, int
233
238
234
239
/// <inheritdoc/>
235
240
public bool TryLock < TLockableKey > ( TLockableKey [ ] keys , TimeSpan timeout , CancellationToken cancellationToken = default )
236
- where TLockableKey : ILockableKey
241
+ where TLockableKey : ILockableKey
237
242
=> TryLock ( keys , 0 , keys . Length , - 1 , timeout , cancellationToken ) ;
238
243
239
244
/// <inheritdoc/>
@@ -392,7 +397,7 @@ public Status Read(ref Key key, ref Input input, ref Output output, Context user
392
397
393
398
/// <inheritdoc/>
394
399
[ 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 )
396
401
=> Read ( ref key , ref input , ref output , ref readOptions , out _ , userContext , serialNo ) ;
397
402
398
403
/// <inheritdoc/>
@@ -521,7 +526,7 @@ public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> R
521
526
522
527
/// <inheritdoc/>
523
528
[ 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 )
525
530
=> ReadAsync ( ref key , ref input , ref readOptions , context , serialNo , token ) ;
526
531
527
532
/// <inheritdoc/>
@@ -543,7 +548,7 @@ public ValueTask<FasterKV<Key, Value>.ReadAsyncResult<Input, Output, Context>> R
543
548
544
549
/// <inheritdoc/>
545
550
[ 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 )
547
552
=> ReadAsync ( ref key , context , serialNo , token ) ;
548
553
549
554
/// <inheritdoc/>
@@ -720,7 +725,7 @@ public Status RMW(ref Key key, ref Input input, ref Output output, out RecordMet
720
725
721
726
/// <inheritdoc/>
722
727
[ 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 )
724
729
=> RMW ( ref key , rmwOptions . KeyHash ?? clientSession . fht . comparer . GetHashCode64 ( ref key ) , ref input , ref output , out recordMetadata , userContext , serialNo ) ;
725
730
726
731
/// <inheritdoc/>
@@ -821,7 +826,7 @@ public Status Delete(ref Key key, Context userContext = default, long serialNo =
821
826
/// <inheritdoc/>
822
827
/// <inheritdoc/>
823
828
[ 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 )
825
830
=> Delete ( ref key , deleteOptions . KeyHash ?? clientSession . fht . comparer . GetHashCode64 ( ref key ) , userContext , serialNo ) ;
826
831
827
832
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -985,7 +990,7 @@ public bool CopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Va
985
990
=> _clientSession . functions . CopyUpdater ( ref key , ref input , ref oldValue , ref newValue , ref output , ref rmwInfo ) ;
986
991
987
992
[ 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 )
989
994
{
990
995
recordInfo . SetDirtyAndModified ( ) ;
991
996
_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
1015
1020
=> _clientSession . functions . SingleDeleter ( ref key , ref value , ref deleteInfo ) ;
1016
1021
1017
1022
[ 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 )
1019
1024
{
1020
1025
recordInfo . SetDirtyAndModified ( ) ;
1021
1026
_clientSession . functions . PostSingleDeleter ( ref key , ref deleteInfo ) ;
@@ -1116,4 +1121,4 @@ public bool CompletePendingWithOutputs(out CompletedOutputIterator<Key, Value, I
1116
1121
}
1117
1122
#endregion IFasterSession
1118
1123
}
1119
- }
1124
+ }
0 commit comments