Repository navigation
MOD-13142 Allow changing number of threads, while pool hasn't started - #1928
Conversation
Also allow PYTHON override for flow tests, and add a regression test for ts-num-threads module args.
Skip RLEC explicitly without redundant skip_on_rlec(), and assert CONFIG SET is rejected since ts-num-threads is immutable.
Remove redundant is_rlec() check (env.isCluster() already covers RLEC) and verify CONFIG GET returns unchanged value after rejected CONFIG SET. Made-with: Cursor
Made-with: Cursor
Extract ParseNumThreadsArg() to eliminate duplicated parsing and validation between ts-num-threads and NUM_THREADS load-time args. Add get_worker_thread_names() utility that reads /proc/<pid>/task/ to discover LibMR worker threads by name, and use it to assert the configured thread count actually took effect. Made-with: Cursor
Consolidate into a single cluster-mode test that verifies the config value is accepted, CONFIG SET is rejected (immutable), and the configured number of LibMR worker threads is actually spawned after triggering TS.MRANGE. Worker threads are created lazily (on first mr_thpool_add_work), which only happens in cluster mode, so standalone is skipped. Made-with: Cursor
| if (!strcasecmp("ts-num-threads", name)) { | ||
| if (LibMR_IsInitialized()) { | ||
| if (LibMR_ResizeExecutionThreadPoolIfUnstarted(value) != REDISMODULE_OK) { | ||
| *err = RedisModule_CreateStringPrintf( |
There was a problem hiding this comment.
Don't we want an error for when libmr is not initialized yet?
There was a problem hiding this comment.
Yeah, but:
| names.append(name) | ||
| return names | ||
|
|
||
| def _get_worker_thread_names_darwin_sample(pid, prefix): |
There was a problem hiding this comment.
any objection? its a profiling tool bundled with Xcode.
There was a problem hiding this comment.
This is the textbook solution for fetching thread names on macs?
There was a problem hiding this comment.
AFAIU i can use other external processes such as libproc + proc_pidinfo or use a c api(bah)
I think this is the most easiest
There was a problem hiding this comment.
Will it work under a non-root user that's running the test on darwin? If not, just skip it there (i.e., return None).
There was a problem hiding this comment.
anyway we return None if we fail to sample:
if r.returncode != 0: return None
|
|
||
| names = get_worker_thread_names(conn) | ||
| # Worker threads are named timeseries-0 … timeseries-[n-1]; | ||
| env.assertEqual(len(names), 6, |
There was a problem hiding this comment.
Cursor is right. len(None) will explode with a TypeError: object of type 'NoneType' has no len()
There was a problem hiding this comment.
Anyway test should fail if no names..
There was a problem hiding this comment.
Yes, but not like this. Simply return an empty list instead of None.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7f046fd. Configure here.
| def _get_worker_thread_names_linux(pid, prefix): | ||
| task_dir = f"/proc/{pid}/task" | ||
| if not os.path.isdir(task_dir): | ||
| return None |
There was a problem hiding this comment.
Helper functions return None instead of empty list
Low Severity
_get_worker_thread_names_linux, _get_worker_thread_names_darwin_sample, and get_worker_thread_names return None on failure instead of []. While the current test caller has an explicit None guard, any future caller that directly uses len() or iterates over the result will crash with a TypeError. Returning an empty list consistently makes the API safe for all callers without losing semantics — zero matching threads is the correct representation of a failed lookup in test assertions.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 7f046fd. Configure here.
…#1928) * config: accept ts-num-threads as load-time arg Also allow PYTHON override for flow tests, and add a regression test for ts-num-threads module args. * config: log load-time parse failures as error * tests: refine ts-num-threads module-arg coverage Skip RLEC explicitly without redundant skip_on_rlec(), and assert CONFIG SET is rejected since ts-num-threads is immutable. * format: clang-format config.c * tests: address review feedback on ts-num-threads test Remove redundant is_rlec() check (env.isCluster() already covers RLEC) and verify CONFIG GET returns unchanged value after rejected CONFIG SET. Made-with: Cursor * tests: fix indentation in else branch of tests.sh Made-with: Cursor * config: deduplicate num-threads parsing; verify threads in test Extract ParseNumThreadsArg() to eliminate duplicated parsing and validation between ts-num-threads and NUM_THREADS load-time args. Add get_worker_thread_names() utility that reads /proc/<pid>/task/ to discover LibMR worker threads by name, and use it to assert the configured thread count actually took effect. Made-with: Cursor * tests: verify ts-num-threads in cluster mode Consolidate into a single cluster-mode test that verifies the config value is accepted, CONFIG SET is rejected (immutable), and the configured number of LibMR worker threads is actually spawned after triggering TS.MRANGE. Worker threads are created lazily (on first mr_thpool_add_work), which only happens in cluster mode, so standalone is skipped. Made-with: Cursor * . * . * MOD-13142 Allow changing number of threads, while pool hasn't started yet * guard call for LibMR_ResizeExecutionThreadPoolIfUnstarted * fix linux thread names regex * test --------- Co-authored-by: Tom Gabsow <[email protected]>
…#1928) (#1934) * config: accept ts-num-threads as load-time arg Also allow PYTHON override for flow tests, and add a regression test for ts-num-threads module args. * config: log load-time parse failures as error * tests: refine ts-num-threads module-arg coverage Skip RLEC explicitly without redundant skip_on_rlec(), and assert CONFIG SET is rejected since ts-num-threads is immutable. * format: clang-format config.c * tests: address review feedback on ts-num-threads test Remove redundant is_rlec() check (env.isCluster() already covers RLEC) and verify CONFIG GET returns unchanged value after rejected CONFIG SET. Made-with: Cursor * tests: fix indentation in else branch of tests.sh Made-with: Cursor * config: deduplicate num-threads parsing; verify threads in test Extract ParseNumThreadsArg() to eliminate duplicated parsing and validation between ts-num-threads and NUM_THREADS load-time args. Add get_worker_thread_names() utility that reads /proc/<pid>/task/ to discover LibMR worker threads by name, and use it to assert the configured thread count actually took effect. Made-with: Cursor * tests: verify ts-num-threads in cluster mode Consolidate into a single cluster-mode test that verifies the config value is accepted, CONFIG SET is rejected (immutable), and the configured number of LibMR worker threads is actually spawned after triggering TS.MRANGE. Worker threads are created lazily (on first mr_thpool_add_work), which only happens in cluster mode, so standalone is skipped. Made-with: Cursor * . * . * MOD-13142 Allow changing number of threads, while pool hasn't started yet * guard call for LibMR_ResizeExecutionThreadPoolIfUnstarted * fix linux thread names regex * test --------- Co-authored-by: Tom Gabsow <[email protected]>
## Summary Bumps the pinned `MODULE_VERSION` for **RedisTimeSeries** from `v8.8.0` to `v8.9.80`. RedisBloom and RedisJSON are unchanged. | Module | From | To | |-----------------|---------|----------| | RedisTimeSeries | v8.8.0 | v8.9.80 | > **Note:** `v8.9.80` is the **8.10 LTS branch cut** (targets Redis 8.10) and has diverged from `v8.8.0`. The `v8.8.0...v8.9.80` ancestry diff contains 37 commits, but **7 are backports already shipped in `v8.8.0`** (verified with `git cherry`, see below); the **30 genuinely new** changes are listed here. ## Module changes ([v8.8.0 → v8.9.80](RedisTimeSeries/RedisTimeSeries@v8.8.0...v8.9.80)) - MOD-14124 — m commands acl ([#1913](RedisTimeSeries/RedisTimeSeries#1913)) - MOD-14250 — missing artifacts logs fix ([#1932](RedisTimeSeries/RedisTimeSeries#1932)) - MOD-14289 — Increase LibMR execution timeout for Valgrind builds ([#1933](RedisTimeSeries/RedisTimeSeries#1933)) - MOD-12726 — unique snapshot name + new output params for nighly event ([#1937](RedisTimeSeries/RedisTimeSeries#1937)) - MOD-14674 — oss refresh list ([#1935](RedisTimeSeries/RedisTimeSeries#1935)) - nightly build, upload snapshot artifact ([#1954](RedisTimeSeries/RedisTimeSeries#1954)) - MOD-14902 — existence check to prevent Timeseries crash when Redis is not aligned with new redis-core changes ([#1940](RedisTimeSeries/RedisTimeSeries#1940)) - MOD-14850 — Bump libmr ([#1962](RedisTimeSeries/RedisTimeSeries#1962)) - MOD-14715 — add apt retries/timeouts to Debian/Ubuntu Dockerfiles ([#1965](RedisTimeSeries/RedisTimeSeries#1965)) - MOD-15262 — Align TimeSeries with the RedisModule_GetUserUserName API changes ([#1975](RedisTimeSeries/RedisTimeSeries#1975)) - RED-180951 RED-180027 — fixing bugs and improving the code ([#2004](RedisTimeSeries/RedisTimeSeries#2004)) - MOD-14239 — Ignore known init-rdbchannel migration timeout under sanitizer ([#1979](RedisTimeSeries/RedisTimeSeries#1979)) - MOD-15105 — make one generic getUser function ([#1981](RedisTimeSeries/RedisTimeSeries#1981)) - MOD-15741 MOD-14091 — add dont-cache command tip to non-cacheable read commands ([#2031](RedisTimeSeries/RedisTimeSeries#2031)) - MOD-15731 — modules modernization alignment ([#2027](RedisTimeSeries/RedisTimeSeries#2027)) - MOD-15728 — Tal.ba/feat/blocking get ([#2028](RedisTimeSeries/RedisTimeSeries#2028)) - MOD-8187 — fix the aggregation bugs (fix reverse iterator) ([#2036](RedisTimeSeries/RedisTimeSeries#2036)) - MOD-15749 — Link to new version of LibMR with short-form CLUSTERSET and add tests ([#2034](RedisTimeSeries/RedisTimeSeries#2034)) - Fix REDISMODULE_MAIN typo + drop common.h forward-decl workarounds ([#2044](RedisTimeSeries/RedisTimeSeries#2044)) - CI: switch flow-linux arm64 runner to standard ubuntu-24.04-arm ([#2048](RedisTimeSeries/RedisTimeSeries#2048)) - MOD-15999 — Centralize Redis ref into a single source-of-truth file for CI ([#2045](RedisTimeSeries/RedisTimeSeries#2045)) - CI: trigger OSS cluster (multi-shard) benchmarks on demand ([#2050](RedisTimeSeries/RedisTimeSeries#2050)) - MOD-15899 — oom try calloc ([#2051](RedisTimeSeries/RedisTimeSeries#2051)) - MOD-8187 — fix non twa aggregation ([#2053](RedisTimeSeries/RedisTimeSeries#2053)) - MOD-16224 — Fix filter-blind neighbor lookups in EMPTY aggregation ([#2056](RedisTimeSeries/RedisTimeSeries#2056)) - MOD-15893 — Nrange new command ([#2052](RedisTimeSeries/RedisTimeSeries#2052)) - MOD-16160 — update blocking get syntax ([#2054](RedisTimeSeries/RedisTimeSeries#2054)) - MOD-16160 — Fix client-side cache tips for TS.BGET and TS.NRANGE/TS.NREVRANGE ([#2057](RedisTimeSeries/RedisTimeSeries#2057)) - Cut 8.10 LTS branch: bump version to 8.9.80, target Redis 8.10 ([27484f7](RedisTimeSeries/RedisTimeSeries@27484f7)) - Fix event-nightly CI on 8.10: read Redis ref from dedicated redis_ref field ([#2058](RedisTimeSeries/RedisTimeSeries#2058)) <details> <summary>7 commits excluded — already shipped in v8.8.0 as backports</summary> These show up in the `v8.8.0...v8.9.80` ancestry diff with different SHAs, but `git cherry` confirms their patch content is already in `v8.8.0`: they were backported to the 8.8 release branch (the "in 8.8 via" PR below), so they are **not** new in this bump. - MOD-9320 — Multiple aggregators single command ([#1916](RedisTimeSeries/RedisTimeSeries#1916)) → in 8.8 via [#1921](RedisTimeSeries/RedisTimeSeries#1921) - MOD-9320 — rename AGGREGATION token in m commands ([#1926](RedisTimeSeries/RedisTimeSeries#1926)) → in 8.8 via [#1927](RedisTimeSeries/RedisTimeSeries#1927) - MOD-13142 — Allow changing number of threads while pool hasn't started ([#1928](RedisTimeSeries/RedisTimeSeries#1928)) → in 8.8 via [#1934](RedisTimeSeries/RedisTimeSeries#1934) - MOD-14439 — Detect cluster topology changes during a multi-shard command ([#1930](RedisTimeSeries/RedisTimeSeries#1930)) → in 8.8 under the same PR - ci: skip Event CI when PR only changes src/version.h ([#1984](RedisTimeSeries/RedisTimeSeries#1984)) → in 8.8 via [#1986](RedisTimeSeries/RedisTimeSeries#1986) - MOD-15020 — remove bionic os support ([#1983](RedisTimeSeries/RedisTimeSeries#1983)) → in 8.8 via [#1996](RedisTimeSeries/RedisTimeSeries#1996) - MOD-14420 — fix count reducers return wrong NaN ([#2013](RedisTimeSeries/RedisTimeSeries#2013)) → in 8.8 via [#2016](RedisTimeSeries/RedisTimeSeries#2016) </details> ## Test plan - [ ] CI passes for RedisTimeSeries at the new pinned version - [ ] `make all` builds RedisTimeSeries cleanly against `unstable` - [ ] Module tests run under `make test` Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>





Note
Medium Risk
Changes thread-pool sizing behavior for
ts-num-threadsand ties it to LibMR initialization state; mis-ordering or unexpected pool start timing could cause runtime errors or performance regressions.Overview
Allows
ts-num-threadsto be changed viaCONFIG SETuntil the LibMR worker pool starts, and returns an error if updated after startup.Makes
ts-num-threadsnon-immutable, adds LibMR integration helpers (LibMR_IsInitialized,LibMR_ResizeExecutionThreadPoolIfUnstarted), and acceptsts-num-threadsas a module-load argument (with precedence over legacyNUM_THREADS, including range validation and clearer warnings).Extends flow tests to cover the new behavior, including verifying actual worker thread count on Linux/macOS and updating existing config tests to expect
ts-num-threadsto be settable.Reviewed by Cursor Bugbot for commit 7f046fd. Bugbot is set up for automated code reviews on this repo. Configure here.