[8.2] [MOD-12694] [MOD-12069] Add active_worker_threads metric#7564
[8.2] [MOD-12694] [MOD-12069] Add active_worker_threads metric#7564redisearch-backport-pull-request[bot] merged 7 commits into8.2from
Conversation
* add "active_worker_threads" metric * fix declartion * remove coord threads * make the tests run... * introduce workersThreadPool_isInitialized assert is initizlied in GlobalStats_GetMultiThreadingStats * cleanup * rename workersThreadPool_isCreated * Unskip test_active_io_threads_stats Removed skip decorator from test_active_io_threads_stats. (cherry picked from commit d9574d8)
| MultiThreadingStats stats; | ||
| stats.active_io_threads = READ(RSGlobalStats.totalStats.multi_threading.active_io_threads); | ||
| RS_ASSERT(workersThreadPool_isCreated()); // In production workers threadpool is created at startup. | ||
| stats.active_worker_threads = workersThreadPool_WorkingThreadCount(); |
There was a problem hiding this comment.
Bug: RS_ASSERT is NOP in production causing potential NULL dereference
The RS_ASSERT(workersThreadPool_isCreated()) call provides no protection in production builds because RS_ASSERT is defined as a no-op when ENABLE_ASSERT is not defined. If _workers_thpool is NULL when workersThreadPool_WorkingThreadCount() is called, redisearch_thpool_num_jobs_in_progress will dereference a NULL pointer and crash. Other functions in workers.c like workersThreadPool_getStats() use proper null checks with fallback values rather than relying on assertions.
There was a problem hiding this comment.
Bug: Removed function still referenced in test file
The countFlatElements function was removed from common.py but is still being used in tests/pytests/test_debug_commands.py (lines 1367-1368). The test file imports from common import *, so when those tests execute, they will fail with a NameError because countFlatElements no longer exists. This appears to be an incomplete cleanup where the function was removed without updating all references.
tests/pytests/common.py#L139-L140
RediSearch/tests/pytests/common.py
Lines 139 to 140 in a0ac89a
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.2 #7564 +/- ##
==========================================
- Coverage 89.54% 89.48% -0.06%
==========================================
Files 253 253
Lines 41197 41202 +5
Branches 3725 3725
==========================================
- Hits 36889 36870 -19
- Misses 4259 4283 +24
Partials 49 49
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| import signal | ||
| import platform | ||
| import itertools | ||
| import threading |
There was a problem hiding this comment.
why do we need this import?
There was a problem hiding this comment.
it is used in test_info_modules for the bg queries
i include it here to align with master and avoid future conflicts
Description
Backport of #7538 to
8.2.Note
Adds
active_worker_threadsto multi-threading stats and INFO output, sourcing from the workers thread pool, with supporting API and tests.active_worker_threadstoMultiThreadingStatsand export it inINFO MODULESundersearch_multi_threading.workersThreadPool_WorkingThreadCount()inGlobalStats_GetMultiThreadingStats(); assert pool exists.workersThreadPool_isCreated()inutil/workers.{h,c}.util/workers.hinsrc/info/global_stats.c.call_and_storeintests/pytests/common.py.search_active_worker_threadsin standalone and cluster (test_active_worker_threads_SA,test_active_worker_threads_cluster).Written by Cursor Bugbot for commit eb09a94. This will update automatically on new commits. Configure here.