@@ -7,7 +7,7 @@ use qdrant_client::qdrant::{
77} ;
88use rand:: Rng ;
99use std:: sync:: Arc ;
10- use std:: sync:: atomic:: { AtomicBool , AtomicU64 , Ordering } ;
10+ use std:: sync:: atomic:: { AtomicBool , AtomicI64 , Ordering } ;
1111use std:: time:: { Duration , Instant } ;
1212use tokio:: task:: JoinHandle ;
1313use tokio:: time:: sleep;
@@ -42,7 +42,7 @@ pub struct Workload {
4242 rng_seed : u64 ,
4343 // Largest point id written and confirmed by Qdrant
4444 // Confirmation means, that API responded with `Completed` status for upsert request
45- max_confirmed_point_id : Arc < AtomicU64 > ,
45+ max_confirmed_point_id : Arc < AtomicI64 > ,
4646}
4747
4848impl Workload {
@@ -70,21 +70,26 @@ impl Workload {
7070 stopped,
7171 crash_lock,
7272 rng_seed,
73- max_confirmed_point_id : Arc :: new ( AtomicU64 :: new ( 0 ) ) ,
73+ max_confirmed_point_id : Arc :: new ( AtomicI64 :: new ( - 1 ) ) ,
7474 }
7575 }
7676
7777 fn reset_max_confirmed_point_id ( & self ) {
78- self . max_confirmed_point_id . store ( 0 , Ordering :: Relaxed ) ;
78+ self . max_confirmed_point_id . store ( - 1 , Ordering :: Relaxed ) ;
7979 }
8080
81- fn get_max_confirmed_point_id ( & self ) -> u64 {
82- self . max_confirmed_point_id . load ( Ordering :: Relaxed )
81+ fn get_max_confirmed_point_id ( & self ) -> Option < u64 > {
82+ let max_confirmed_id = self . max_confirmed_point_id . load ( Ordering :: Relaxed ) ;
83+ if max_confirmed_id < 0 {
84+ None
85+ } else {
86+ Some ( max_confirmed_id as u64 )
87+ }
8388 }
8489
8590 fn set_max_confirmed_point_id ( & self , point_id : u64 ) {
8691 self . max_confirmed_point_id
87- . store ( point_id, Ordering :: Relaxed ) ;
92+ . store ( point_id as i64 , Ordering :: Relaxed ) ;
8893 }
8994}
9095
@@ -282,8 +287,10 @@ impl Workload {
282287
283288 // Validate and clean up existing data
284289 let current_count = get_exact_points_count ( client, & self . collection_name ) . await ?;
285- let confirmed_point_id = self . get_max_confirmed_point_id ( ) ;
286- let confirmed_point_count = confirmed_point_id + 1 ; // Starts from zero
290+ let confirmed_point_count = match self . get_max_confirmed_point_id ( ) {
291+ None => 0 ,
292+ Some ( point_id) => point_id + 1 ,
293+ } ;
287294 let checkable_points = std:: cmp:: min ( current_count as u64 , confirmed_point_count) as usize ;
288295 if current_count != 0 {
289296 log:: info!(
0 commit comments