@@ -91,7 +91,7 @@ public async Task Run(RunConfig runConfig)
9191 intervalMilliseconds : runConfig . ReportPeriod ) ;
9292 prometheus . Start ( ) ;
9393
94- _maxId = await SelectCount ( $ "SELECT MAX(id) as max_id FROM ` { SloTable . Name } `;" ) ;
94+ _maxId = await SelectCount ( ) + 1 ;
9595
9696 Logger . LogInformation ( "Init row count: {MaxId}" , _maxId ) ;
9797
@@ -110,7 +110,7 @@ public async Task Run(RunConfig runConfig)
110110 var writeTask = ShootingTask ( writeLimiter , "write" , Save ) ;
111111 var readTask = ShootingTask ( readLimiter , "read" , Select ) ;
112112
113- Logger . LogInformation ( "Started write / read shooting.." ) ;
113+ Logger . LogInformation ( "Started write / read shooting... " ) ;
114114
115115 try
116116 {
@@ -210,25 +210,32 @@ Task ShootingTask(RateLimiter rateLimitPolicy, string operationType,
210210
211211 _ = Task . Run ( async ( ) =>
212212 {
213- pendingOperations . Inc ( ) ;
214- var sw = Stopwatch . StartNew ( ) ;
215- var ( attempts , statusCode ) = await action ( runConfig , errorsTotal ) ;
216- sw . Stop ( ) ;
217-
218- retryAttempts . Set ( attempts ) ;
219- operationsTotal . Inc ( ) ;
220- pendingOperations . Dec ( ) ;
221-
222- if ( statusCode != StatusCode . Success )
213+ try
223214 {
224- errorsTotal . WithLabels ( statusCode . StatusName ( ) ) . Inc ( ) ;
225- operationsFailureTotal . Inc ( ) ;
226- operationLatencySeconds . WithLabels ( "err" ) . Observe ( sw . Elapsed . TotalSeconds ) ;
215+ pendingOperations . Inc ( ) ;
216+ var sw = Stopwatch . StartNew ( ) ;
217+ var ( attempts , statusCode ) = await action ( runConfig , errorsTotal ) ;
218+ sw . Stop ( ) ;
219+
220+ retryAttempts . Set ( attempts ) ;
221+ operationsTotal . Inc ( ) ;
222+ pendingOperations . Dec ( ) ;
223+
224+ if ( statusCode != StatusCode . Success )
225+ {
226+ errorsTotal . WithLabels ( statusCode . StatusName ( ) ) . Inc ( ) ;
227+ operationsFailureTotal . Inc ( ) ;
228+ operationLatencySeconds . WithLabels ( "err" ) . Observe ( sw . Elapsed . TotalSeconds ) ;
229+ }
230+ else
231+ {
232+ operationsSuccessTotal . Inc ( ) ;
233+ operationLatencySeconds . WithLabels ( "success" ) . Observe ( sw . Elapsed . TotalSeconds ) ;
234+ }
227235 }
228- else
236+ catch ( Exception e )
229237 {
230- operationsSuccessTotal . Inc ( ) ;
231- operationLatencySeconds . WithLabels ( "success" ) . Observe ( sw . Elapsed . TotalSeconds ) ;
238+ Console . WriteLine ( e ) ;
232239 }
233240 } , cancellationTokenSource . Token ) ;
234241 }
@@ -242,10 +249,10 @@ Task ShootingTask(RateLimiter rateLimitPolicy, string operationType,
242249 protected abstract Task < ( int , StatusCode ) > Save ( SloTable sloTable , int writeTimeout ,
243250 Counter ? errorsTotal = null ) ;
244251
245- protected abstract Task < ( int , StatusCode , object ? ) > Select ( dynamic select , int readTimeout ,
252+ protected abstract Task < ( int , StatusCode , object ? ) > Select ( ( Guid Guid , int Id ) select , int readTimeout ,
246253 Counter ? errorsTotal = null ) ;
247254
248- protected abstract Task < int > SelectCount ( string sql ) ;
255+ protected abstract Task < int > SelectCount ( ) ;
249256
250257 private Task < ( int , StatusCode ) > Save ( Config config , Counter ? errorsTotal = null )
251258 {
@@ -271,7 +278,7 @@ Task ShootingTask(RateLimiter rateLimitPolicy, string operationType,
271278 {
272279 var id = Random . Shared . Next ( _maxId ) ;
273280 var ( attempts , code , _) =
274- await Select ( new { Guid = GuidFromInt ( id ) , Id = id } , config . ReadTimeout , errorsTotal ) ;
281+ await Select ( new ValueTuple < Guid , int > ( GuidFromInt ( id ) , id ) , config . ReadTimeout , errorsTotal ) ;
275282
276283 return ( attempts , code ) ;
277284 }
0 commit comments