Files
kv/tests/unit/io-threads.tcl
zeekay 5b2e5fe98e fix: revert the -X ours upstream merge, which left the tree uncompilable
`merge: upstream/unstable (-X ours, brand preserved)` resolved every conflicting
hunk in our favour. That is right for brand strings and wrong for code: it kept
our old server.h beside their new module.c, so module.c calls
commandResultSuccessListeners and reads from_call_argv off a struct that has
neither, and zslFreeLexRange lost the declarations it still has call sites for.
kvReaderFeed got a newer body calling kvReaderGetReadBuf/CommitRead grafted onto
older locals — an sds newbuf and an oom: label the new body never uses. Across
398 files nothing downstream noticed, because main has not compiled since.

That is what the Dockerfile was working around. Pulling valkey/valkey and copying
binaries out of it produced an image no matter what the source did, so a tree
that cannot build looked like a tree that builds. Now the image compiles this
source, so the build breaking is visible the moment it breaks.

src, deps and tests return to the last coherent commit. Carried forward on top:

  - Two identical rdbIsVersionAccepted definitions, differing only in a
    parameter name. The rename pass copied the function instead of editing it,
    so this never compiled either.
  - kv_strtod.h lost the #ifdef USE_FAST_FLOAT that separated its two
    implementations, leaving both definitions and a stray #endif.
  - extended-redis-compatibility is deleted, not defaulted off. It made the
    server answer HELLO with "redis" and name itself Redis in five error
    strings. A server that can be configured to lie about what it is has one
    setting too many. HELLO now reports kv unconditionally.
  - The redis-server and redis-cli install symlinks, on by default via
    USE_REDIS_SYMLINKS?=yes. This is why a running instance answered to
    redis-cli at all.
  - valkeymodule.h and redismodule.h, 3094 lines of adapters mapping old
    prefixes onto KVMODULE_*, included by nothing. kvmodule.h is the header.
  - deps/libvalkey, one documentation file the rename stranded.

Wire contract is untouched. INFO still reports redis_version, redis_git_sha1,
redis_git_dirty and redis_build_id, and the Lua sandbox still exports
REDIS_VERSION — clients parse those field names, so they are protocol, not
branding. What we choose is what the server calls itself, and it calls itself kv.

Verified: builds clean, and a live instance answers HELLO with "server kv",
reports server_name:kv, has no extended-redis-compatibility directive, and
serves strings and lists.
2026-07-26 15:04:44 -07:00

101 lines
3.8 KiB
Tcl

proc activate_io_threads_and_wait {} {
set server_pid [s process_id]
# Create 16 clients
for {set i 0} {$i < 16} {incr i} {
set rd($i) [kv_deferring_client]
}
r set a 0
# Create a batch of commands by suspending the server for a while
# before responding to the first command
pause_process $server_pid
# Send set commands for all clients except the first
for {set i 1} {$i < 16} {incr i} {
$rd($i) incr a
$rd($i) flush
}
# Resume the server
resume_process $server_pid
# Wait until all the client commands have executed
wait_for_condition 1000 50 {
[r get a] eq 15
} else {
fail "Failed to apply the incr command for all clients"
}
# Wait until active io_threads are no longer active
wait_for_condition 1000 50 {
[getInfoProperty [r info server] io_threads_active] eq 0
} else {
fail "Failed to wait until no io_threads are active"
}
for {set i 0} {$i < 16} {incr i} {
$rd($i) close
}
}
start_server {config "minimal.conf" tags {"external:skip" "valgrind:skip"} overrides {enable-debug-command {yes} io-threads 5}} {
# Skip if non io-threads mode - as it is relevant only for io-threads mode
assert_equal {io-threads 5} [r config get io-threads]
test {Force the use of IO threads and assert active IO thread usage} {
activate_io_threads_and_wait
set info [r info]
set io_threads_count [dict get [r config get io-threads] io-threads]
array set initial_active_times {}
for {set i 1} {$i <= $io_threads_count} {incr i} {
set used_active_time [getInfoProperty $info used_active_time_io_thread_$i]
if {$i < $io_threads_count} {
assert_morethan $used_active_time 0
set initial_active_times($i) $used_active_time
} else {
assert_equal $used_active_time {}
}
}
# Adjust io-threads to a lower value and assert that active io_threads fields are >= values found initially
assert_equal {OK} [r config set io-threads 1]
set info [r info]
wait_for_condition 1000 50 {
[getInfoProperty [r info server] io_threads_active] eq 0
} else {
fail "Failed to wait until no io_threads are active"
}
set used_active_time_1 [getInfoProperty $info used_active_time_io_thread_1]
assert_equal $used_active_time_1 {}
# Re-adjust io-threads to the previous value.
assert_equal {OK} [r config set io-threads 5]
set info [r info]
for {set i 1} {$i <= $io_threads_count} {incr i} {
set used_active_time [getInfoProperty $info used_active_time_io_thread_$i]
if {$i < $io_threads_count} {
# Assert active thread usage isn't reset to 0.
assert_morethan $used_active_time 0
} else {
assert_equal $used_active_time {}
}
}
# Sleep for a time duration that is significantly longer than how much
# time each of the io_threads would be active again when reactivated.
set sleep_time_ms 1000
after $sleep_time_ms
# Reactivate io-threads and wait for execution
activate_io_threads_and_wait
set info [r info]
for {set i 1} {$i <= $io_threads_count} {incr i} {
set used_active_time [getInfoProperty $info used_active_time_io_thread_$i]
if {$i < $io_threads_count} {
assert {($used_active_time - $initial_active_times($i)) < ($sleep_time_ms/1000)}
# Assert that total active time is lower than the sleep duration assumed
assert {$used_active_time < ($sleep_time_ms/1000)}
} else {
assert_equal $used_active_time {}
}
}
}
}