Files
redis/runtest-moduleapi
Tom Gabsow 559d143b4e RED-220725: Preserve BLESS across module value replacement (#15995)
Fixes RED-220725 by preserving BLESS `NO-EVICT` when
`RM_ModuleTypeSetValue` replaces a module value.

The API deletes the old key before installing the replacement, which
clears its BLESS state. The change captures the old flag, installs the
replacement, then looks up the live key after keyspace notifications and
restores the flag only if that key still contains the module value being
installed. This also covers module commands such as `TDIGEST.MERGE`,
which use `RM_ModuleTypeSetValue` for their destination.

Regression tests cover flag preservation and eviction protection,
including a notification callback that attaches metadata and reallocates
the new key. The suite is registered in `runtest-moduleapi`.

`make -j8` passed. The focused Tcl suite could not run locally because
the test harness reported all candidate ports busy; CI will validate the
registered suite.

`MIGRATE` flag transfer and the expired-key difference between `INFO`
and `BLESS SCAN` remain unchanged, consistent with the design
discussion.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes module key replacement and BLESS/eviction behavior for module
types; scoped fix with regression tests but affects memory policy
semantics.
> 
> **Overview**
> **`RM_ModuleTypeSetValue`** used to drop **BLESS `NO-EVICT`** because
it deletes the key before installing the new module value. The
implementation now reads the no-evict flag on the existing key, performs
the replace, and reapplies **`blessSetNoEvict`** on the new value when
needed (e.g. module commands that update in place via
**`TDIGEST.MERGE`**).
> 
> A new **`bless_datatype`** module API suite checks that **`NO-EVICT`**
survives **`datatype.set`** on a blessed key and that the key is not
evicted under **`allkeys-lru`** after the value is replaced. The suite
is wired into **`runtest-moduleapi`**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2eb39e07d3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-10-20 09:06:36 +03:00

73 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
# Raise open files limit (macOS default 256 is too low for tests).
OPEN_FILE_LIMIT=$(ulimit -n 2>/dev/null)
if [ -n "$OPEN_FILE_LIMIT" ] && [ "$OPEN_FILE_LIMIT" != "unlimited" ] && [ "$OPEN_FILE_LIMIT" -lt 1024 ]; then
ulimit -n 1024 2>/dev/null || true
fi
TCL_VERSIONS="8.5 8.6 8.7 9.0"
TCLSH=""
[ -z "$MAKE" ] && MAKE=make
for VERSION in $TCL_VERSIONS; do
TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
done
if [ -z $TCLSH ]
then
echo "You need tcl 8.5 or newer in order to run the Redis ModuleApi test"
exit 1
fi
$MAKE -C tests/modules && \
$TCLSH tests/test_helper.tcl \
--single unit/moduleapi/commandfilter \
--single unit/moduleapi/basics \
--single unit/moduleapi/fork \
--single unit/moduleapi/testrdb \
--single unit/moduleapi/infotest \
--single unit/moduleapi/moduleconfigs \
--single unit/moduleapi/infra \
--single unit/moduleapi/propagate \
--single unit/moduleapi/hooks \
--single unit/moduleapi/misc \
--single unit/moduleapi/blockonkeys \
--single unit/moduleapi/blockonbackground \
--single unit/moduleapi/scan \
--single unit/moduleapi/datatype \
--single unit/moduleapi/auth \
--single unit/moduleapi/keyspace_events \
--single unit/moduleapi/blockedclient \
--single unit/moduleapi/getchannels \
--single unit/moduleapi/getkeys \
--single unit/moduleapi/test_lazyfree \
--single unit/moduleapi/defrag \
--single unit/moduleapi/keyspecs \
--single unit/moduleapi/hash \
--single unit/moduleapi/zset \
--single unit/moduleapi/list \
--single unit/moduleapi/stream \
--single unit/moduleapi/mallocsize \
--single unit/moduleapi/datatype2 \
--single unit/moduleapi/cluster \
--single unit/moduleapi/aclcheck \
--single unit/moduleapi/subcommands \
--single unit/moduleapi/reply \
--single unit/moduleapi/cmdintrospection \
--single unit/moduleapi/eventloop \
--single unit/moduleapi/timer \
--single unit/moduleapi/publish \
--single unit/moduleapi/usercall \
--single unit/moduleapi/aofduration \
--single unit/moduleapi/postnotifications \
--single unit/moduleapi/postnotifications_perkey \
--single unit/moduleapi/async_rm_call \
--single unit/moduleapi/moduleauth \
--single unit/moduleapi/rdbloadsave \
--single unit/moduleapi/crash \
--single unit/moduleapi/internalsecret \
--single unit/moduleapi/configaccess \
--single unit/moduleapi/keymeta \
--single unit/moduleapi/ksn_notify_side_effect \
--single unit/moduleapi/bless_datatype \
"${@}"