@@ -325,10 +325,11 @@ void Indexes_SetTempSpecsTimers(TimerOp op) {
325325
326326//---------------------------------------------------------------------------------------------
327327
328- double IndexesScanner_IndexedPercent (IndexesScanner * scanner , IndexSpec * sp ) {
328+ double IndexesScanner_IndexedPercent (RedisModuleCtx * ctx , IndexesScanner * scanner , IndexSpec * sp ) {
329329 if (scanner || sp -> scan_in_progress ) {
330330 if (scanner ) {
331- return scanner -> totalKeys > 0 ? (double )scanner -> scannedKeys / scanner -> totalKeys : 0 ;
331+ size_t totalKeys = RedisModule_DbSize (ctx );
332+ return totalKeys > 0 ? (double )scanner -> scannedKeys / totalKeys : 0 ;
332333 } else {
333334 return 0 ;
334335 }
@@ -2068,7 +2069,6 @@ static IndexesScanner *IndexesScanner_NewGlobal() {
20682069 IndexesScanner * scanner = rm_calloc (1 , sizeof (IndexesScanner ));
20692070 scanner -> global = true;
20702071 scanner -> scannedKeys = 0 ;
2071- scanner -> totalKeys = RedisModule_DbSize (RSDummyContext );
20722072
20732073 global_spec_scanner = scanner ;
20742074 RedisModule_Log (RSDummyContext , "notice" , "Global scanner created" );
@@ -2079,7 +2079,6 @@ static IndexesScanner *IndexesScanner_NewGlobal() {
20792079static IndexesScanner * IndexesScanner_New (StrongRef global_ref ) {
20802080
20812081 IndexesScanner * scanner = rm_calloc (1 , sizeof (IndexesScanner ));
2082- scanner -> totalKeys = RedisModule_DbSize (RSDummyContext );
20832082
20842083 scanner -> spec_ref = StrongRef_Demote (global_ref );
20852084 IndexSpec * spec = StrongRef_Get (global_ref );
@@ -2377,7 +2376,7 @@ void IndexSpec_AddToInfo(RedisModuleInfoCtx *ctx, IndexSpec *sp) {
23772376 RedisModule_InfoAddFieldLongLong (ctx , "hash_indexing_failures" , sp -> stats .indexingFailures );
23782377 RedisModule_InfoAddFieldLongLong (ctx , "indexing" , !!global_spec_scanner || sp -> scan_in_progress );
23792378 IndexesScanner * scanner = global_spec_scanner ? global_spec_scanner : sp -> scanner ;
2380- double percent_indexed = IndexesScanner_IndexedPercent (scanner , sp );
2379+ double percent_indexed = IndexesScanner_IndexedPercent (ctx , scanner , sp );
23812380 RedisModule_InfoAddFieldDouble (ctx , "percent_indexed" , percent_indexed );
23822381 RedisModule_InfoEndDictField (ctx );
23832382
0 commit comments