Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23828d6b34 | ||
|
|
7b171abce7 | ||
|
|
461c529ea6 | ||
|
|
18a88dcae5 | ||
|
|
ce7b03a297 | ||
|
|
0221ecc5ec | ||
|
|
f630e56e10 | ||
|
|
a129ac30c4 | ||
|
|
1b36f39759 | ||
|
|
edc059db65 | ||
|
|
d272828706 | ||
|
|
4d7dcf2103 | ||
|
|
0e5e12e353 | ||
|
|
0b32fa00e7 | ||
|
|
192086838d | ||
|
|
08e94adea9 | ||
|
|
96a63b3fac | ||
|
|
e2867a879f | ||
|
|
8d6fbe827f | ||
|
|
0f184975e4 | ||
|
|
bcea2da0e4 | ||
|
|
f983fc31a2 | ||
|
|
85e25ebc9b | ||
|
|
7bb645ef14 | ||
|
|
d48f885bf9 | ||
|
|
ffcb4e222b | ||
|
|
6a5f8eaf1b | ||
|
|
75c2746c95 | ||
|
|
25486f1647 | ||
|
|
573579acfa | ||
|
|
78a168a538 | ||
|
|
8c7484d9bf | ||
|
|
b61785fc37 | ||
|
|
babf19e1f1 | ||
|
|
4fcde04dcc | ||
|
|
94fcf4318e | ||
|
|
fb75e2f9df | ||
|
|
d27f439e67 | ||
|
|
885f969d50 | ||
|
|
13332e28c3 | ||
|
|
b3d4653ccb | ||
|
|
af5784c031 | ||
|
|
f5d8b9f536 | ||
|
|
3cfeaea24c | ||
|
|
f598645e7e | ||
|
|
b2ff9407e2 | ||
|
|
2872565dd1 | ||
|
|
1ba9929633 | ||
|
|
d3972ad5a8 | ||
|
|
bacdcbe18b | ||
|
|
8da5b6333f | ||
|
|
ef746b0dff | ||
|
|
04c2d0dfe9 | ||
|
|
c79091d72e | ||
|
|
f30986f299 | ||
|
|
1abedeeb7e | ||
|
|
9c4237c17e | ||
|
|
3a9009d3bd | ||
|
|
20339015f0 | ||
|
|
2c9af0f00d | ||
|
|
122e375eeb | ||
|
|
d70a9d1653 | ||
|
|
e52f3bfdd1 | ||
|
|
94b5ec459a | ||
|
|
802a70e3ad | ||
|
|
22c9e05439 | ||
|
|
44eff3aad4 | ||
|
|
8e5683fb1c | ||
|
|
bb9130d9c6 | ||
|
|
9d1150494b | ||
|
|
19d6702358 | ||
|
|
629b757cc4 | ||
|
|
708a7e9ea1 | ||
|
|
67bb61fa5c | ||
|
|
93fee40390 | ||
|
|
64aa4537ba | ||
|
|
5bcce7a39d | ||
|
|
20b20d404c | ||
|
|
139d93266d | ||
|
|
4d78a6061f | ||
|
|
c2ebbd0668 | ||
|
|
68d6dffe50 | ||
|
|
22087fc2b4 | ||
|
|
b3d6f4bbf2 | ||
|
|
d5f5378d47 | ||
|
|
93784e2ee3 | ||
|
|
41275dd3d3 | ||
|
|
42d7d976ed | ||
|
|
606f3502c9 | ||
|
|
146644355e | ||
|
|
ff1c49d07b | ||
|
|
cd05870817 | ||
|
|
1bc735bf30 | ||
|
|
b1fe900842 | ||
|
|
df68e754a7 | ||
|
|
f4ba22d9b6 | ||
|
|
45f46a1a5a |
@@ -18,4 +18,5 @@ statics
|
||||
filetest
|
||||
ro
|
||||
exat
|
||||
clen
|
||||
clen
|
||||
parth
|
||||
|
||||
+10
-10
@@ -11,7 +11,7 @@ jobs:
|
||||
- name: make
|
||||
# Fail build if there are warnings
|
||||
# build with TLS just for compilation coverage
|
||||
run: make REDIS_CFLAGS='-Werror' BUILD_TLS=yes
|
||||
run: make SERVER_CFLAGS='-Werror' BUILD_TLS=yes
|
||||
- name: test
|
||||
run: |
|
||||
sudo apt-get install tcl8.6 tclx
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make
|
||||
# build with TLS module just for compilation coverage
|
||||
run: make SANITIZER=address REDIS_CFLAGS='-Werror' BUILD_TLS=module
|
||||
run: make SANITIZER=address SERVER_CFLAGS='-Werror' BUILD_TLS=module
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx -y
|
||||
- name: test
|
||||
@@ -47,14 +47,14 @@ jobs:
|
||||
- name: make
|
||||
run: |
|
||||
apt-get update && apt-get install -y build-essential
|
||||
make REDIS_CFLAGS='-Werror'
|
||||
make SERVER_CFLAGS='-Werror'
|
||||
|
||||
build-macos-latest:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror'
|
||||
run: make SERVER_CFLAGS='-Werror'
|
||||
|
||||
build-32bit:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -63,22 +63,22 @@ jobs:
|
||||
- name: make
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install libc6-dev-i386
|
||||
make REDIS_CFLAGS='-Werror' 32bit
|
||||
make SERVER_CFLAGS='-Werror' 32bit
|
||||
|
||||
build-libc-malloc:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror' MALLOC=libc
|
||||
run: make SERVER_CFLAGS='-Werror' MALLOC=libc
|
||||
|
||||
build-centos7-jemalloc:
|
||||
build-almalinux8-jemalloc:
|
||||
runs-on: ubuntu-latest
|
||||
container: centos:7
|
||||
container: almalinux:8
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: make
|
||||
run: |
|
||||
yum -y install gcc make
|
||||
make REDIS_CFLAGS='-Werror'
|
||||
dnf -y install epel-release gcc make procps-ng which
|
||||
make -j SERVER_CFLAGS='-Werror'
|
||||
|
||||
|
||||
+169
-166
@@ -11,7 +11,7 @@ on:
|
||||
inputs:
|
||||
skipjobs:
|
||||
description: 'jobs to skip (delete the ones you wanna keep, do not leave empty)'
|
||||
default: 'valgrind,sanitizer,tls,freebsd,macos,alpine,32bit,iothreads,ubuntu,centos,malloc,specific,fortify,reply-schema'
|
||||
default: 'valgrind,sanitizer,tls,freebsd,macos,alpine,32bit,iothreads,ubuntu,rpm-distros,malloc,specific,fortify,reply-schema'
|
||||
skiptests:
|
||||
description: 'tests to skip (delete the ones you wanna keep, do not leave empty)'
|
||||
default: 'redis,modules,sentinel,cluster,unittest'
|
||||
@@ -23,7 +23,7 @@ on:
|
||||
default: ''
|
||||
use_repo:
|
||||
description: 'repo owner and name'
|
||||
default: 'redis/redis'
|
||||
default: 'valkey-io/valkey'
|
||||
use_git_ref:
|
||||
description: 'git branch or sha to use'
|
||||
default: 'unstable'
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
test-ubuntu-jemalloc:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'ubuntu')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror -DREDIS_TEST'
|
||||
run: make SERVER_CFLAGS='-Werror -DREDIS_TEST'
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx
|
||||
- name: test
|
||||
@@ -69,12 +69,12 @@ jobs:
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all --accurate
|
||||
run: ./src/valkey-server test all --accurate
|
||||
|
||||
test-ubuntu-jemalloc-fortify:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'fortify')
|
||||
container: ubuntu:lunar
|
||||
timeout-minutes: 14400
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
run: |
|
||||
apt-get update && apt-get install -y make gcc-13
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100
|
||||
make CC=gcc REDIS_CFLAGS='-Werror -DREDIS_TEST -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3'
|
||||
make CC=gcc SERVER_CFLAGS='-Werror -DREDIS_TEST -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3'
|
||||
- name: testprep
|
||||
run: apt-get install -y tcl8.6 tclx procps
|
||||
- name: test
|
||||
@@ -113,12 +113,12 @@ jobs:
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all --accurate
|
||||
run: ./src/valkey-server test all --accurate
|
||||
|
||||
test-ubuntu-libc-malloc:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'malloc')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -136,7 +136,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make MALLOC=libc REDIS_CFLAGS='-Werror'
|
||||
run: make MALLOC=libc SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx
|
||||
- name: test
|
||||
@@ -155,7 +155,7 @@ jobs:
|
||||
test-ubuntu-no-malloc-usable-size:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'malloc')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -173,7 +173,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make MALLOC=libc CFLAGS=-DNO_MALLOC_USABLE_SIZE REDIS_CFLAGS='-Werror'
|
||||
run: make MALLOC=libc CFLAGS=-DNO_MALLOC_USABLE_SIZE SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx
|
||||
- name: test
|
||||
@@ -192,7 +192,7 @@ jobs:
|
||||
test-ubuntu-32bit:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, '32bit')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -212,7 +212,7 @@ jobs:
|
||||
- name: make
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install libc6-dev-i386
|
||||
make 32bit REDIS_CFLAGS='-Werror -DREDIS_TEST'
|
||||
make 32bit SERVER_CFLAGS='-Werror -DREDIS_TEST'
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx
|
||||
- name: test
|
||||
@@ -231,12 +231,12 @@ jobs:
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all --accurate
|
||||
run: ./src/valkey-server test all --accurate
|
||||
|
||||
test-ubuntu-tls:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'tls')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -255,7 +255,7 @@ jobs:
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: |
|
||||
make BUILD_TLS=yes REDIS_CFLAGS='-Werror'
|
||||
make BUILD_TLS=yes SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get install tcl8.6 tclx tcl-tls
|
||||
@@ -280,7 +280,7 @@ jobs:
|
||||
test-ubuntu-tls-no-tls:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'tls')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -299,7 +299,7 @@ jobs:
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: |
|
||||
make BUILD_TLS=yes REDIS_CFLAGS='-Werror'
|
||||
make BUILD_TLS=yes SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get install tcl8.6 tclx tcl-tls
|
||||
@@ -324,7 +324,7 @@ jobs:
|
||||
test-ubuntu-io-threads:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'iothreads')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -343,7 +343,7 @@ jobs:
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: |
|
||||
make REDIS_CFLAGS='-Werror'
|
||||
make SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx
|
||||
- name: test
|
||||
@@ -356,7 +356,7 @@ jobs:
|
||||
test-ubuntu-reclaim-cache:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'specific')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -375,7 +375,7 @@ jobs:
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: |
|
||||
make REDIS_CFLAGS='-Werror'
|
||||
make SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get install vmtouch
|
||||
@@ -383,19 +383,19 @@ jobs:
|
||||
mkdir /tmp/slave
|
||||
- name: warm up
|
||||
run: |
|
||||
./src/redis-server --daemonize yes --logfile /dev/null
|
||||
./src/redis-benchmark -n 1 > /dev/null
|
||||
./src/redis-cli save | grep OK > /dev/null
|
||||
./src/valkey-server --daemonize yes --logfile /dev/null
|
||||
./src/valkey-benchmark -n 1 > /dev/null
|
||||
./src/valkey-cli save | grep OK > /dev/null
|
||||
vmtouch -v ./dump.rdb > /dev/null
|
||||
- name: test
|
||||
run: |
|
||||
echo "test SAVE doesn't increase cache"
|
||||
CACHE0=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')
|
||||
echo "$CACHE0"
|
||||
./src/redis-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080 --repl-diskless-sync no --pidfile /tmp/master/redis.pid --rdbcompression no --enable-debug-command yes
|
||||
./src/redis-cli -p 8080 debug populate 10000 k 102400
|
||||
./src/redis-server --daemonize yes --logfile /dev/null --dir /tmp/slave --port 8081 --repl-diskless-load disabled --rdbcompression no
|
||||
./src/redis-cli -p 8080 save > /dev/null
|
||||
./src/valkey-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080 --repl-diskless-sync no --pidfile /tmp/master/redis.pid --rdbcompression no --enable-debug-command yes
|
||||
./src/valkey-cli -p 8080 debug populate 10000 k 102400
|
||||
./src/valkey-server --daemonize yes --logfile /dev/null --dir /tmp/slave --port 8081 --repl-diskless-load disabled --rdbcompression no
|
||||
./src/valkey-cli -p 8080 save > /dev/null
|
||||
VMOUT=$(vmtouch -v /tmp/master/dump.rdb)
|
||||
echo $VMOUT
|
||||
grep -q " 0%" <<< $VMOUT
|
||||
@@ -404,8 +404,8 @@ jobs:
|
||||
if [ "$(( $CACHE-$CACHE0 ))" -gt "8000000" ]; then exit 1; fi
|
||||
|
||||
echo "test replication doesn't increase cache"
|
||||
./src/redis-cli -p 8081 REPLICAOF 127.0.0.1 8080 > /dev/null
|
||||
while [ $(./src/redis-cli -p 8081 info replication | grep "master_link_status:down") ]; do sleep 1; done;
|
||||
./src/valkey-cli -p 8081 REPLICAOF 127.0.0.1 8080 > /dev/null
|
||||
while [ $(./src/valkey-cli -p 8081 info replication | grep "master_link_status:down") ]; do sleep 1; done;
|
||||
sleep 1 # wait for the completion of cache reclaim bio
|
||||
VMOUT=$(vmtouch -v /tmp/master/dump.rdb)
|
||||
echo $VMOUT
|
||||
@@ -421,8 +421,8 @@ jobs:
|
||||
PID=$(cat /tmp/master/redis.pid)
|
||||
kill -15 $PID
|
||||
while [ -x /proc/${PID} ]; do sleep 1; done
|
||||
./src/redis-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080
|
||||
while [ $(./src/redis-cli -p 8080 info persistence | grep "loading:1") ]; do sleep 1; done;
|
||||
./src/valkey-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080
|
||||
while [ $(./src/valkey-cli -p 8080 info persistence | grep "loading:1") ]; do sleep 1; done;
|
||||
sleep 1 # wait for the completion of cache reclaim bio
|
||||
VMOUT=$(vmtouch -v /tmp/master/dump.rdb)
|
||||
echo $VMOUT
|
||||
@@ -434,7 +434,7 @@ jobs:
|
||||
test-valgrind-test:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'valgrind') && !contains(github.event.inputs.skiptests, 'redis')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -452,7 +452,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make valgrind REDIS_CFLAGS='-Werror -DREDIS_TEST'
|
||||
run: make valgrind SERVER_CFLAGS='-Werror -DREDIS_TEST'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -464,7 +464,7 @@ jobs:
|
||||
test-valgrind-misc:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'valgrind') && !(contains(github.event.inputs.skiptests, 'modules') && contains(github.event.inputs.skiptests, 'unittest'))
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -482,7 +482,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make valgrind REDIS_CFLAGS='-Werror -DREDIS_TEST'
|
||||
run: make valgrind SERVER_CFLAGS='-Werror -DREDIS_TEST'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -493,13 +493,13 @@ jobs:
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: |
|
||||
valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/redis-server test all --valgrind
|
||||
valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/valkey-server test all --valgrind
|
||||
if grep -q 0x err.txt; then cat err.txt; exit 1; fi
|
||||
|
||||
test-valgrind-no-malloc-usable-size-test:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'valgrind') && !contains(github.event.inputs.skiptests, 'redis')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -517,7 +517,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE -DREDIS_TEST" REDIS_CFLAGS='-Werror'
|
||||
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE -DREDIS_TEST" SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -529,7 +529,7 @@ jobs:
|
||||
test-valgrind-no-malloc-usable-size-misc:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'valgrind') && !(contains(github.event.inputs.skiptests, 'modules') && contains(github.event.inputs.skiptests, 'unittest'))
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -547,7 +547,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE -DREDIS_TEST" REDIS_CFLAGS='-Werror'
|
||||
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE -DREDIS_TEST" SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -558,13 +558,13 @@ jobs:
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: |
|
||||
valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/redis-server test all --valgrind
|
||||
valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/valkey-server test all --valgrind
|
||||
if grep -q 0x err.txt; then cat err.txt; exit 1; fi
|
||||
|
||||
test-sanitizer-address:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'sanitizer')
|
||||
timeout-minutes: 14400
|
||||
strategy:
|
||||
@@ -587,7 +587,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make SANITIZER=address REDIS_CFLAGS='-DREDIS_TEST -Werror'
|
||||
run: make SANITIZER=address SERVER_CFLAGS='-DREDIS_TEST -Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -606,12 +606,12 @@ jobs:
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all
|
||||
run: ./src/valkey-server test all
|
||||
|
||||
test-sanitizer-undefined:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'sanitizer')
|
||||
timeout-minutes: 14400
|
||||
strategy:
|
||||
@@ -634,7 +634,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make SANITIZER=undefined REDIS_CFLAGS='-DREDIS_TEST -Werror' LUA_DEBUG=yes # we (ab)use this flow to also check Lua C API violations
|
||||
run: make SANITIZER=undefined SERVER_CFLAGS='-DREDIS_TEST -Werror' LUA_DEBUG=yes # we (ab)use this flow to also check Lua C API violations
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -653,15 +653,36 @@ jobs:
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all --accurate
|
||||
run: ./src/valkey-server test all --accurate
|
||||
|
||||
test-centos7-jemalloc:
|
||||
runs-on: ubuntu-latest
|
||||
test-rpm-distros-jemalloc:
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'centos')
|
||||
container: centos:7
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'rpm-distros')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: test-almalinux8-jemalloc
|
||||
container: almalinux:8
|
||||
install_epel: true
|
||||
- name: test-almalinux9-jemalloc
|
||||
container: almalinux:8
|
||||
install_epel: true
|
||||
- name: test-centosstream9-jemalloc
|
||||
container: quay.io/centos/centos:stream9
|
||||
install_epel: true
|
||||
- name: test-fedoralatest-jemalloc
|
||||
container: fedora:latest
|
||||
- name: test-fedorarawhide-jemalloc
|
||||
container: fedora:rawhide
|
||||
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: ${{ matrix.container }}
|
||||
timeout-minutes: 14400
|
||||
|
||||
steps:
|
||||
- name: prep
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
@@ -676,12 +697,15 @@ jobs:
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: Install EPEL
|
||||
if: matrix.install_epel
|
||||
run: dnf -y install epel-release
|
||||
- name: make
|
||||
run: |
|
||||
yum -y install gcc make
|
||||
make REDIS_CFLAGS='-Werror'
|
||||
dnf -y install gcc make procps-ng which /usr/bin/kill
|
||||
make -j SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: yum -y install which tcl tclx
|
||||
run: dnf -y install tcl tcltls
|
||||
- name: test
|
||||
if: true && !contains(github.event.inputs.skiptests, 'redis')
|
||||
run: ./runtest --accurate --verbose --dump-logs ${{github.event.inputs.test_args}}
|
||||
@@ -695,13 +719,34 @@ jobs:
|
||||
if: true && !contains(github.event.inputs.skiptests, 'cluster')
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
|
||||
test-centos7-tls-module:
|
||||
runs-on: ubuntu-latest
|
||||
test-rpm-distros-tls-module:
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'tls')
|
||||
container: centos:7
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'tls')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: test-almalinux8-tls-module
|
||||
container: almalinux:8
|
||||
install_epel: true
|
||||
- name: test-almalinux9-tls-module
|
||||
container: almalinux:8
|
||||
install_epel: true
|
||||
- name: test-centosstream9-tls-module
|
||||
container: quay.io/centos/centos:stream9
|
||||
install_epel: true
|
||||
- name: test-fedoralatest-tls-module
|
||||
container: fedora:latest
|
||||
- name: test-fedorarawhide-tls-module
|
||||
container: fedora:rawhide
|
||||
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: ${{ matrix.container }}
|
||||
timeout-minutes: 14400
|
||||
|
||||
steps:
|
||||
- name: prep
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
@@ -716,14 +761,16 @@ jobs:
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: Install EPEL
|
||||
if: matrix.install_epel
|
||||
run: dnf -y install epel-release
|
||||
- name: make
|
||||
run: |
|
||||
yum -y install centos-release-scl epel-release
|
||||
yum -y install devtoolset-7 openssl-devel openssl
|
||||
scl enable devtoolset-7 "make BUILD_TLS=module REDIS_CFLAGS='-Werror'"
|
||||
dnf -y install make gcc openssl-devel openssl procps-ng which /usr/bin/kill
|
||||
make -j BUILD_TLS=module SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
yum -y install tcl tcltls tclx
|
||||
dnf -y install tcl tcltls
|
||||
./utils/gen-test-certs.sh
|
||||
- name: test
|
||||
if: true && !contains(github.event.inputs.skiptests, 'redis')
|
||||
@@ -742,13 +789,34 @@ jobs:
|
||||
run: |
|
||||
./runtest-cluster --tls-module ${{github.event.inputs.cluster_test_args}}
|
||||
|
||||
test-centos7-tls-module-no-tls:
|
||||
runs-on: ubuntu-latest
|
||||
test-rpm-distros-tls-module-no-tls:
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'tls')
|
||||
container: centos:7
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'tls')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: test-almalinux8-tls-module-no-tls
|
||||
container: almalinux:8
|
||||
install_epel: true
|
||||
- name: test-almalinux9-tls-module-no-tls
|
||||
container: almalinux:8
|
||||
install_epel: true
|
||||
- name: test-centosstream9-tls-module-no-tls
|
||||
container: quay.io/centos/centos:stream9
|
||||
install_epel: true
|
||||
- name: test-fedoralatest-tls-module-no-tls
|
||||
container: fedora:latest
|
||||
- name: test-fedorarawhide-tls-module-no-tls
|
||||
container: fedora:rawhide
|
||||
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: ${{ matrix.container }}
|
||||
timeout-minutes: 14400
|
||||
|
||||
steps:
|
||||
- name: prep
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
@@ -763,14 +831,16 @@ jobs:
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: Install EPEL
|
||||
if: matrix.install_epel
|
||||
run: dnf -y install epel-release
|
||||
- name: make
|
||||
run: |
|
||||
yum -y install centos-release-scl epel-release
|
||||
yum -y install devtoolset-7 openssl-devel openssl
|
||||
scl enable devtoolset-7 "make BUILD_TLS=module REDIS_CFLAGS='-Werror'"
|
||||
dnf -y install make gcc openssl-devel openssl procps-ng which /usr/bin/kill
|
||||
make -j BUILD_TLS=module SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: |
|
||||
yum -y install tcl tcltls tclx
|
||||
dnf -y install tcl tcltls
|
||||
./utils/gen-test-certs.sh
|
||||
- name: test
|
||||
if: true && !contains(github.event.inputs.skiptests, 'redis')
|
||||
@@ -792,7 +862,7 @@ jobs:
|
||||
test-macos-latest:
|
||||
runs-on: macos-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'macos') && !(contains(github.event.inputs.skiptests, 'redis') && contains(github.event.inputs.skiptests, 'modules'))
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -810,7 +880,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror'
|
||||
run: make SERVER_CFLAGS='-Werror'
|
||||
- name: test
|
||||
if: true && !contains(github.event.inputs.skiptests, 'redis')
|
||||
run: ./runtest --accurate --verbose --verbose --clients 1 --no-latency --dump-logs ${{github.event.inputs.test_args}}
|
||||
@@ -821,7 +891,7 @@ jobs:
|
||||
test-macos-latest-sentinel:
|
||||
runs-on: macos-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'macos') && !contains(github.event.inputs.skiptests, 'sentinel')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -839,7 +909,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror'
|
||||
run: make SERVER_CFLAGS='-Werror'
|
||||
- name: sentinel tests
|
||||
if: true && !contains(github.event.inputs.skiptests, 'sentinel')
|
||||
run: ./runtest-sentinel ${{github.event.inputs.cluster_test_args}}
|
||||
@@ -847,7 +917,7 @@ jobs:
|
||||
test-macos-latest-cluster:
|
||||
runs-on: macos-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'macos') && !contains(github.event.inputs.skiptests, 'cluster')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
@@ -865,7 +935,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror'
|
||||
run: make SERVER_CFLAGS='-Werror'
|
||||
- name: cluster tests
|
||||
if: true && !contains(github.event.inputs.skiptests, 'cluster')
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
@@ -873,8 +943,8 @@ jobs:
|
||||
test-freebsd:
|
||||
runs-on: macos-12
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'freebsd') && !(contains(github.event.inputs.skiptests, 'redis') && contains(github.event.inputs.skiptests, 'modules'))
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'freebsd')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
- name: prep
|
||||
@@ -882,92 +952,26 @@ jobs:
|
||||
run: |
|
||||
echo "GITHUB_REPOSITORY=${{github.event.inputs.use_repo}}" >> $GITHUB_ENV
|
||||
echo "GITHUB_HEAD_REF=${{github.event.inputs.use_git_ref}}" >> $GITHUB_ENV
|
||||
echo "skipjobs: ${{github.event.inputs.skipjobs}}"
|
||||
echo "skiptests: ${{github.event.inputs.skiptests}}"
|
||||
echo "test_args: ${{github.event.inputs.test_args}}"
|
||||
echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}"
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: test
|
||||
uses: vmactions/freebsd-vm@v0.3.1
|
||||
uses: cross-platform-actions/action@v0.21.1
|
||||
with:
|
||||
usesh: true
|
||||
sync: rsync
|
||||
copyback: false
|
||||
prepare: pkg install -y bash gmake lang/tcl86 lang/tclx
|
||||
run: >
|
||||
gmake || exit 1 ;
|
||||
if echo "${{github.event.inputs.skiptests}}" | grep -vq redis ; then ./runtest --verbose --timeout 2400 --no-latency --dump-logs ${{github.event.inputs.test_args}} || exit 1 ; fi ;
|
||||
if echo "${{github.event.inputs.skiptests}}" | grep -vq modules ; then MAKE=gmake ./runtest-moduleapi --verbose --timeout 2400 --no-latency --dump-logs ${{github.event.inputs.test_args}} || exit 1 ; fi ;
|
||||
|
||||
test-freebsd-sentinel:
|
||||
runs-on: macos-12
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'freebsd') && !contains(github.event.inputs.skiptests, 'sentinel')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
- name: prep
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
echo "GITHUB_REPOSITORY=${{github.event.inputs.use_repo}}" >> $GITHUB_ENV
|
||||
echo "GITHUB_HEAD_REF=${{github.event.inputs.use_git_ref}}" >> $GITHUB_ENV
|
||||
echo "skipjobs: ${{github.event.inputs.skipjobs}}"
|
||||
echo "skiptests: ${{github.event.inputs.skiptests}}"
|
||||
echo "test_args: ${{github.event.inputs.test_args}}"
|
||||
echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}"
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: test
|
||||
uses: vmactions/freebsd-vm@v0.3.1
|
||||
with:
|
||||
usesh: true
|
||||
sync: rsync
|
||||
copyback: false
|
||||
prepare: pkg install -y bash gmake lang/tcl86 lang/tclx
|
||||
run: >
|
||||
gmake || exit 1 ;
|
||||
if echo "${{github.event.inputs.skiptests}}" | grep -vq sentinel ; then ./runtest-sentinel ${{github.event.inputs.cluster_test_args}} || exit 1 ; fi ;
|
||||
|
||||
test-freebsd-cluster:
|
||||
runs-on: macos-12
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'freebsd') && !contains(github.event.inputs.skiptests, 'cluster')
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
- name: prep
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
echo "GITHUB_REPOSITORY=${{github.event.inputs.use_repo}}" >> $GITHUB_ENV
|
||||
echo "GITHUB_HEAD_REF=${{github.event.inputs.use_git_ref}}" >> $GITHUB_ENV
|
||||
echo "skipjobs: ${{github.event.inputs.skipjobs}}"
|
||||
echo "skiptests: ${{github.event.inputs.skiptests}}"
|
||||
echo "test_args: ${{github.event.inputs.test_args}}"
|
||||
echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}"
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: test
|
||||
uses: vmactions/freebsd-vm@v0.3.1
|
||||
with:
|
||||
usesh: true
|
||||
sync: rsync
|
||||
copyback: false
|
||||
prepare: pkg install -y bash gmake lang/tcl86 lang/tclx
|
||||
run: >
|
||||
gmake || exit 1 ;
|
||||
if echo "${{github.event.inputs.skiptests}}" | grep -vq cluster ; then ./runtest-cluster ${{github.event.inputs.cluster_test_args}} || exit 1 ; fi ;
|
||||
operating_system: freebsd
|
||||
environment_variables: MAKE
|
||||
version: 13.2
|
||||
shell: bash
|
||||
run: |
|
||||
sudo pkg install -y bash gmake lang/tcl86 lang/tclx
|
||||
gmake
|
||||
./runtest --single unit/keyspace --single unit/auth --single unit/networking --single unit/protocol
|
||||
|
||||
test-alpine-jemalloc:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'alpine')
|
||||
container: alpine:latest
|
||||
steps:
|
||||
@@ -987,7 +991,7 @@ jobs:
|
||||
- name: make
|
||||
run: |
|
||||
apk add build-base
|
||||
make REDIS_CFLAGS='-Werror'
|
||||
make SERVER_CFLAGS='-Werror'
|
||||
- name: testprep
|
||||
run: apk add tcl procps tclx
|
||||
- name: test
|
||||
@@ -1006,7 +1010,7 @@ jobs:
|
||||
test-alpine-libc-malloc:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'alpine')
|
||||
container: alpine:latest
|
||||
steps:
|
||||
@@ -1026,7 +1030,7 @@ jobs:
|
||||
- name: make
|
||||
run: |
|
||||
apk add build-base
|
||||
make REDIS_CFLAGS='-Werror' USE_JEMALLOC=no CFLAGS=-DUSE_MALLOC_USABLE_SIZE
|
||||
make SERVER_CFLAGS='-Werror' USE_JEMALLOC=no CFLAGS=-DUSE_MALLOC_USABLE_SIZE
|
||||
- name: testprep
|
||||
run: apk add tcl procps tclx
|
||||
- name: test
|
||||
@@ -1046,7 +1050,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 14400
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'valkey-io/valkey')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'reply-schema')
|
||||
steps:
|
||||
- name: prep
|
||||
@@ -1063,7 +1067,7 @@ jobs:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make REDIS_CFLAGS='-Werror -DLOG_REQ_RES'
|
||||
run: make SERVER_CFLAGS='-Werror -DLOG_REQ_RES'
|
||||
- name: testprep
|
||||
run: sudo apt-get install tcl8.6 tclx
|
||||
- name: test
|
||||
@@ -1084,4 +1088,3 @@ jobs:
|
||||
path: "./utils/req-res-validator/requirements.txt"
|
||||
- name: validator
|
||||
run: ./utils/req-res-log-validator.py --verbose --fail-missing-reply-schemas ${{ (!contains(github.event.inputs.skiptests, 'redis') && !contains(github.event.inputs.skiptests, 'module') && !contains(github.event.inputs.sentinel, 'redis') && !contains(github.event.inputs.skiptests, 'cluster')) && github.event.inputs.test_args == '' && github.event.inputs.cluster_test_args == '' && '--fail-commands-not-all-hit' || '' }}
|
||||
|
||||
|
||||
@@ -1,82 +1,85 @@
|
||||
name: External Server Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
pull_request:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
test-external-standalone:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'schedule' || github.repository == 'redis/redis'
|
||||
if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey'
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: make REDIS_CFLAGS=-Werror
|
||||
- name: Start redis-server
|
||||
run: make SERVER_CFLAGS=-Werror
|
||||
- name: Start valkey-server
|
||||
run: |
|
||||
./src/redis-server --daemonize yes --save "" --logfile external-redis.log \
|
||||
./src/valkey-server --daemonize yes --save "" --logfile external-server.log \
|
||||
--enable-protected-configs yes --enable-debug-command yes --enable-module-command yes
|
||||
- name: Run external test
|
||||
run: |
|
||||
./runtest \
|
||||
--host 127.0.0.1 --port 6379 \
|
||||
--verbose \
|
||||
--tags -slow
|
||||
- name: Archive redis log
|
||||
- name: Archive server log
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-external-redis-log
|
||||
path: external-redis.log
|
||||
name: test-external-server-log
|
||||
path: external-server.log
|
||||
|
||||
test-external-cluster:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'schedule' || github.repository == 'redis/redis'
|
||||
if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey'
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: make REDIS_CFLAGS=-Werror
|
||||
- name: Start redis-server
|
||||
run: make SERVER_CFLAGS=-Werror
|
||||
- name: Start valkey-server
|
||||
run: |
|
||||
./src/redis-server --cluster-enabled yes --daemonize yes --save "" --logfile external-redis.log \
|
||||
./src/valkey-server --cluster-enabled yes --daemonize yes --save "" --logfile external-server.log \
|
||||
--enable-protected-configs yes --enable-debug-command yes --enable-module-command yes
|
||||
- name: Create a single node cluster
|
||||
run: ./src/redis-cli cluster addslots $(for slot in {0..16383}; do echo $slot; done); sleep 5
|
||||
run: ./src/valkey-cli cluster addslots $(for slot in {0..16383}; do echo $slot; done); sleep 5
|
||||
- name: Run external test
|
||||
run: |
|
||||
./runtest \
|
||||
--host 127.0.0.1 --port 6379 \
|
||||
--verbose \
|
||||
--cluster-mode \
|
||||
--tags -slow
|
||||
- name: Archive redis log
|
||||
- name: Archive server log
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-external-cluster-log
|
||||
path: external-redis.log
|
||||
path: external-server.log
|
||||
|
||||
test-external-nodebug:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'schedule' || github.repository == 'redis/redis'
|
||||
if: github.event_name != 'schedule' || github.repository == 'valkey-io/valkey'
|
||||
timeout-minutes: 14400
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: make REDIS_CFLAGS=-Werror
|
||||
- name: Start redis-server
|
||||
run: make SERVER_CFLAGS=-Werror
|
||||
- name: Start valkey-server
|
||||
run: |
|
||||
./src/redis-server --daemonize yes --save "" --logfile external-redis.log
|
||||
./src/valkey-server --daemonize yes --save "" --logfile external-server.log
|
||||
- name: Run external test
|
||||
run: |
|
||||
./runtest \
|
||||
--host 127.0.0.1 --port 6379 \
|
||||
--verbose \
|
||||
--tags "-slow -needs:debug"
|
||||
- name: Archive redis log
|
||||
- name: Archive server log
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-external-redis-log
|
||||
path: external-redis.log
|
||||
name: test-external-server-log
|
||||
path: external-server.log
|
||||
+15
-9
@@ -1,17 +1,19 @@
|
||||
.*.swp
|
||||
*.o
|
||||
*.a
|
||||
*.xo
|
||||
*.so
|
||||
*.d
|
||||
*.log
|
||||
dump.rdb
|
||||
redis-benchmark
|
||||
redis-check-aof
|
||||
redis-check-rdb
|
||||
redis-check-dump
|
||||
redis-cli
|
||||
redis-sentinel
|
||||
redis-server
|
||||
*-benchmark
|
||||
*-check-aof
|
||||
*-check-rdb
|
||||
*-check-dump
|
||||
*-cli
|
||||
*-sentinel
|
||||
*-server
|
||||
*-unit-tests
|
||||
doc-tools
|
||||
release
|
||||
misc/*
|
||||
@@ -23,8 +25,7 @@ release.h
|
||||
src/transfer.sh
|
||||
src/configs
|
||||
redis.ds
|
||||
src/redis.conf
|
||||
src/nodes.conf
|
||||
src/*.conf
|
||||
deps/lua/src/lua
|
||||
deps/lua/src/luac
|
||||
deps/lua/src/liblua.a
|
||||
@@ -41,3 +42,8 @@ Makefile.dep
|
||||
.ccls-cache/*
|
||||
compile_commands.json
|
||||
redis.code-workspace
|
||||
.cache
|
||||
.cscope*
|
||||
.swp
|
||||
nodes.conf
|
||||
tests/cluster/tmp/*
|
||||
|
||||
+149
-11
@@ -1,16 +1,154 @@
|
||||
Hello! This file is just a placeholder, since this is the "unstable" branch
|
||||
of Redis, the place where all the development happens.
|
||||
Valkey 7.2 release notes
|
||||
========================
|
||||
|
||||
There is no release notes for this branch, it gets forked into another branch
|
||||
every time there is a partial feature freeze in order to eventually create
|
||||
a new stable release.
|
||||
--------------------------------------------------------------------------------
|
||||
Upgrade urgency levels:
|
||||
|
||||
Usually "unstable" is stable enough for you to use it in development environments
|
||||
however you should never use it in production environments. It is possible
|
||||
to download the latest stable release here:
|
||||
LOW: No need to upgrade unless there are new features you want to use.
|
||||
MODERATE: Program an upgrade of the server, but it's not urgent.
|
||||
HIGH: There is a critical bug that may affect a subset of users. Upgrade!
|
||||
CRITICAL: There is a critical bug affecting MOST USERS. Upgrade ASAP.
|
||||
SECURITY: There are security fixes in the release.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
https://download.redis.io/redis-stable.tar.gz
|
||||
================================================================================
|
||||
Valkey 7.2.6 GA - Released Tue 30 July 2024
|
||||
================================================================================
|
||||
|
||||
More information is available at https://redis.io
|
||||
Upgrade urgency MODERATE: This release fixes an incompatibility issue with modules
|
||||
compiled for Redis. For other users, it primarily fixes uncommon bugs.
|
||||
|
||||
Happy hacking!
|
||||
Bug fixes - Core
|
||||
================
|
||||
* Fix typo in REGISTER_API macro to prevent segfaults when loading Redis
|
||||
modules (#608)
|
||||
* Fix the command duration reset issue when clients are blocked and commands
|
||||
are reprocessed (#526)
|
||||
* Fix the data type conversion error in zrangeResultBeginStore (Redis#13148)
|
||||
* Fix a crash caused by quicklist node merges (Redis#13040)
|
||||
* Fix crashes in module blocking client timeout cases (Redis#13011)
|
||||
* Fix conversion of numbers in Lua args to Redis args
|
||||
(Redis#13115, Fixes Redis#13113)
|
||||
* Fix crash in LSET command when replacing small list items with larger ones,
|
||||
creating listpacks larger than 4GB (Redis#12955, Fixes Redis#12864)
|
||||
* Fix blocking command timeout reset issue during reprocessing (Redis#13004)
|
||||
|
||||
Bug fixes - Cluster
|
||||
===================
|
||||
* Fix the CLUSTER SHARDS command to display accurate slot information even
|
||||
if a primary node fails (#790, Fixes #784)
|
||||
* Fix an issue where module authentication failed when the cluster was down
|
||||
(#693, Fixes #619)
|
||||
* Ensure only primary nodes with slots can mark another node as failed (#634)
|
||||
* Improve MEET command reliability under link failures to maintain cluster
|
||||
membership symmetry (#461)
|
||||
* Allow single primary node to mark potentially failed replica as FAIL in
|
||||
single-shard cluster (Redis#12824)
|
||||
|
||||
Bug fixes - Sentinel
|
||||
====================
|
||||
* Accept redis-sentinel to start Valkey in sentinel mode (#731, Fixes #719)
|
||||
|
||||
Bug fixes - CLI
|
||||
===============
|
||||
* Ensure the `--count` option in redis-cli works correctly even without
|
||||
`--pattern` (Redis#13092)
|
||||
* Fix redis-check-aof misidentifying data in manifest format as MP-AOF
|
||||
(Redis#12951)
|
||||
* Update redis-check-rdb types to replace stream-v2 with stream-v3
|
||||
(Redis#12969)
|
||||
|
||||
================================================================================
|
||||
Valkey 7.2.5 GA - Released Tue 16 Apr 2024
|
||||
================================================================================
|
||||
|
||||
Upgrade urgency LOW: This is the first stable release of Valkey 7.2.5.
|
||||
|
||||
Changes to support Valkey branding
|
||||
=========
|
||||
* Update template config files to remove references of redis.io and replace them
|
||||
with valkey.io. (#320)
|
||||
|
||||
================================================================================
|
||||
Valkey 7.2.5 RC1 - Released Fri 12 Apr 2024
|
||||
================================================================================
|
||||
|
||||
Upgrade urgency LOW: Second release candidate for Valkey with API compatibility
|
||||
for OSS Redis 7.2.4. Moving to a release candidate on 7.2.5, to make it clearer
|
||||
this is a patch iteration as opposed to an exact copy of OSS Redis. Also includes
|
||||
fixes to minor bugs present in 7.2.4 RC1 and more compatibility changes.
|
||||
|
||||
Changes to support Valkey branding
|
||||
=========
|
||||
* Update README to remove Redis references.
|
||||
* Update valkey-server and valkey-cli help info to show only Valkey (#222)
|
||||
* Add compatibility for lua debugger to use 'server' instead of redis. (#303)
|
||||
|
||||
Bug fixes
|
||||
=========
|
||||
* Fix module event name to maintain Redis compatibility. (#289)
|
||||
* Fix issue where Redis symlinks were created with the wrong name. (#282)
|
||||
|
||||
================================================================================
|
||||
Valkey 7.2.4 RC1 - Released Tue 09 Apr 2024
|
||||
================================================================================
|
||||
|
||||
Upgrade urgency LOW: Initial release of Valkey with API compatibility for OSS
|
||||
Redis 7.2.4. This release is based off of OSS Redis 7.2.4, with additional
|
||||
functionality to better brand the server as Valkey instead of Redis. All APIs
|
||||
are fully backwards compatible and care was taken to minimize the number of
|
||||
log lines that were changed to best support existing tooling around log parsing.
|
||||
|
||||
Changes to support Valkey branding
|
||||
=========
|
||||
|
||||
* Rename the 6 Redis binaries to ones with `valkey` prefixes: `valkey-server`,
|
||||
`valkey-cli`, `valkey-benchmark`, `valkey-check-aof`, `valkey-check-rdb` and
|
||||
`valkey-sentinel`. (#62)
|
||||
* During install, create symlinks mapping the corresponding Redis binary names
|
||||
to the new Valkey binaries. (#193)
|
||||
* INFO fields: Introduce `valkey_version` and `server_name` fields. The
|
||||
`redis_version` will continue to be present and will indicate the Redis OSS
|
||||
version that the server is compatible with. (#47, #232)
|
||||
* RDB file format: Introduce a `valkey-ver` RDB field to indicate an RDB file
|
||||
was produced by a Valkey server. This field is ignored when the file is
|
||||
loaded by Redis OSS. (#47)
|
||||
* Module API changes: Introduce Valkey Module API in a new file, valkeymodule.h,
|
||||
with functions and types prefixed by ValkeyModule. Valkey is still fully ABI
|
||||
compatible with the Redis Module API, meaning Valkey supports running modules
|
||||
compiled with either the Redis or Valkey Module APIs. For full source
|
||||
compatibility, the Redis Module API (redismodule.h) is also kept with the
|
||||
RedisModule prefixed functions and types. (#194, #243, #262)
|
||||
* Scripting: Introduce a new top level `server` object for functions and scripts
|
||||
that can be instead of the existing `redis` object. This allows users to
|
||||
replace calls like `redis.call(...)` with `server.call(...)`. (#213)
|
||||
* Makefile: Introduce `SERVER_CFLAGS` and `SERVER_LDFLAGS` as an alternative to
|
||||
`REDIS_CFLAGS` and `REDIS_LDFLAGS`. (#46)
|
||||
* Update template config files to replace references to Redis with Valkey. The
|
||||
file valkey.conf replaces redis.conf. (#29, #171)
|
||||
* Logging: Update startup, shutdown, and help logs to reference Valkey instead of
|
||||
Redis. Valkey server will also show the Valkey logo at startup and show the
|
||||
Valkey repositories when crashing. (#251, #252, #263, #113)
|
||||
|
||||
Bug fixes
|
||||
=========
|
||||
* Cluster: Fix an issue where cluster nodes running on Redis versions earlier
|
||||
than 7.0 would be unable to communicate with nodes running on Valkey 7.2. This
|
||||
change also introduces a slight delay when hostnames are not displayed when a
|
||||
node is first added to the cluster. (#52)
|
||||
|
||||
A special thank you for the amount of work put into this release by:
|
||||
|
||||
- Viktor Söderqvist
|
||||
- Madelyn Olson
|
||||
- Wen Hui
|
||||
- Ping Xie
|
||||
- Parth Patel
|
||||
- Roshan Katri
|
||||
- Zhu Binbin
|
||||
- Zhao Zhao
|
||||
- Bany
|
||||
- Harkrishn Patro
|
||||
- Vitah Lin
|
||||
- Ziyang Zeng (For creating the logo!)
|
||||
- The many other community members who provided their support!
|
||||
|
||||
@@ -1,34 +1,23 @@
|
||||
This README is just a fast *quick start* document. You can find more detailed documentation at [redis.io](https://redis.io).
|
||||
This README is under construction as we work to build a new community driven high performance key-value store.
|
||||
|
||||
What is Redis?
|
||||
This project was forked from the open source Redis project right before the transition to their new source available licenses.
|
||||
|
||||
This README is just a fast *quick start* document. We are currently working on a more permanent documentation page.
|
||||
|
||||
What is Valkey?
|
||||
--------------
|
||||
Valkey is a high-performance data structure server that primarily serves key/value workloads.
|
||||
It supports a wide range of native structures and an extensible plugin system for adding new data structures and access patterns.
|
||||
|
||||
Building Valkey
|
||||
--------------
|
||||
|
||||
Redis is often referred to as a *data structures* server. What this means is that Redis provides access to mutable data structures via a set of commands, which are sent using a *server-client* model with TCP sockets and a simple protocol. So different processes can query and modify the same data structures in a shared way.
|
||||
|
||||
Data structures implemented into Redis have a few special properties:
|
||||
|
||||
* Redis cares to store them on disk, even if they are always served and modified into the server memory. This means that Redis is fast, but that it is also non-volatile.
|
||||
* The implementation of data structures emphasizes memory efficiency, so data structures inside Redis will likely use less memory compared to the same data structure modelled using a high-level programming language.
|
||||
* Redis offers a number of features that are natural to find in a database, like replication, tunable levels of durability, clustering, and high availability.
|
||||
|
||||
Another good example is to think of Redis as a more complex version of memcached, where the operations are not just SETs and GETs, but operations that work with complex data types like Lists, Sets, ordered data structures, and so forth.
|
||||
|
||||
If you want to know more, this is a list of selected starting points:
|
||||
|
||||
* Introduction to Redis data types. https://redis.io/topics/data-types-intro
|
||||
* Try Redis directly inside your browser. https://try.redis.io
|
||||
* The full list of Redis commands. https://redis.io/commands
|
||||
* There is much more inside the official Redis documentation. https://redis.io/documentation
|
||||
|
||||
Building Redis
|
||||
--------------
|
||||
|
||||
Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD.
|
||||
Valkey can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD.
|
||||
We support big endian and little endian architectures, and both 32 bit
|
||||
and 64 bit systems.
|
||||
|
||||
It may compile on Solaris derived systems (for instance SmartOS) but our
|
||||
support for this platform is *best effort* and Redis is not guaranteed to
|
||||
support for this platform is *best effort* and Valkey is not guaranteed to
|
||||
work as well as in Linux, OSX, and \*BSD.
|
||||
|
||||
It is as simple as:
|
||||
@@ -45,15 +34,15 @@ as libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS) and run:
|
||||
|
||||
% make USE_SYSTEMD=yes
|
||||
|
||||
To append a suffix to Redis program names, use:
|
||||
To append a suffix to Valkey program names, use:
|
||||
|
||||
% make PROG_SUFFIX="-alt"
|
||||
|
||||
You can build a 32 bit Redis binary using:
|
||||
You can build a 32 bit Valkey binary using:
|
||||
|
||||
% make 32bit
|
||||
|
||||
After building Redis, it is a good idea to test it using:
|
||||
After building Valkey, it is a good idea to test it using:
|
||||
|
||||
% make test
|
||||
|
||||
@@ -67,7 +56,7 @@ installed):
|
||||
Fixing build problems with dependencies or cached build options
|
||||
---------
|
||||
|
||||
Redis has some dependencies which are included in the `deps` directory.
|
||||
Valkey has some dependencies which are included in the `deps` directory.
|
||||
`make` does not automatically rebuild dependencies even if something in
|
||||
the source code of dependencies changes.
|
||||
|
||||
@@ -87,11 +76,11 @@ command.
|
||||
Fixing problems building 32 bit binaries
|
||||
---------
|
||||
|
||||
If after building Redis with a 32 bit target you need to rebuild it
|
||||
If after building Valkey with a 32 bit target you need to rebuild it
|
||||
with a 64 bit target, or the other way around, you need to perform a
|
||||
`make distclean` in the root directory of the Redis distribution.
|
||||
`make distclean` in the root directory of the Valkey distribution.
|
||||
|
||||
In case of build errors when trying to build a 32 bit binary of Redis, try
|
||||
In case of build errors when trying to build a 32 bit binary of Valkey, try
|
||||
the following steps:
|
||||
|
||||
* Install the package libc6-dev-i386 (also try g++-multilib).
|
||||
@@ -101,8 +90,8 @@ the following steps:
|
||||
Allocator
|
||||
---------
|
||||
|
||||
Selecting a non-default memory allocator when building Redis is done by setting
|
||||
the `MALLOC` environment variable. Redis is compiled and linked against libc
|
||||
Selecting a non-default memory allocator when building Valkey is done by setting
|
||||
the `MALLOC` environment variable. Valkey is compiled and linked against libc
|
||||
malloc by default, with the exception of jemalloc being the default on Linux
|
||||
systems. This default was picked because jemalloc has proven to have fewer
|
||||
fragmentation problems than libc malloc.
|
||||
@@ -118,7 +107,7 @@ To compile against jemalloc on Mac OS X systems, use:
|
||||
Monotonic clock
|
||||
---------------
|
||||
|
||||
By default, Redis will build using the POSIX clock_gettime function as the
|
||||
By default, Valkey will build using the POSIX clock_gettime function as the
|
||||
monotonic clock source. On most modern systems, the internal processor clock
|
||||
can be used to improve performance. Cautions can be found here:
|
||||
http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/
|
||||
@@ -130,75 +119,78 @@ To build with support for the processor's internal instruction clock, use:
|
||||
Verbose build
|
||||
-------------
|
||||
|
||||
Redis will build with a user-friendly colorized output by default.
|
||||
Valkey will build with a user-friendly colorized output by default.
|
||||
If you want to see a more verbose output, use the following:
|
||||
|
||||
% make V=1
|
||||
|
||||
Running Redis
|
||||
Running Valkey
|
||||
-------------
|
||||
|
||||
To run Redis with the default configuration, just type:
|
||||
To run Valkey with the default configuration, just type:
|
||||
|
||||
% cd src
|
||||
% ./redis-server
|
||||
% ./valkey-server
|
||||
|
||||
If you want to provide your redis.conf, you have to run it using an additional
|
||||
If you want to provide your valkey.conf, you have to run it using an additional
|
||||
parameter (the path of the configuration file):
|
||||
|
||||
% cd src
|
||||
% ./redis-server /path/to/redis.conf
|
||||
% ./valkey-server /path/to/valkey.conf
|
||||
|
||||
It is possible to alter the Redis configuration by passing parameters directly
|
||||
It is possible to alter the Valkey configuration by passing parameters directly
|
||||
as options using the command line. Examples:
|
||||
|
||||
% ./redis-server --port 9999 --replicaof 127.0.0.1 6379
|
||||
% ./redis-server /etc/redis/6379.conf --loglevel debug
|
||||
% ./valkey-server --port 9999 --replicaof 127.0.0.1 6379
|
||||
% ./valkey-server /etc/valkey/6379.conf --loglevel debug
|
||||
|
||||
All the options in redis.conf are also supported as options using the command
|
||||
All the options in valkey.conf are also supported as options using the command
|
||||
line, with exactly the same name.
|
||||
|
||||
Running Redis with TLS:
|
||||
Running Valkey with TLS:
|
||||
------------------
|
||||
|
||||
Please consult the [TLS.md](TLS.md) file for more information on
|
||||
how to use Redis with TLS.
|
||||
how to use Valkey with TLS.
|
||||
|
||||
Playing with Redis
|
||||
Playing with Valkey
|
||||
------------------
|
||||
|
||||
You can use redis-cli to play with Redis. Start a redis-server instance,
|
||||
You can use valkey-cli to play with Valkey. Start a valkey-server instance,
|
||||
then in another terminal try the following:
|
||||
|
||||
% cd src
|
||||
% ./redis-cli
|
||||
redis> ping
|
||||
% ./valkey-cli
|
||||
valkey> ping
|
||||
PONG
|
||||
redis> set foo bar
|
||||
valkey> set foo bar
|
||||
OK
|
||||
redis> get foo
|
||||
valkey> get foo
|
||||
"bar"
|
||||
redis> incr mycounter
|
||||
valkey> incr mycounter
|
||||
(integer) 1
|
||||
redis> incr mycounter
|
||||
valkey> incr mycounter
|
||||
(integer) 2
|
||||
redis>
|
||||
valkey>
|
||||
|
||||
You can find the list of all the available commands at https://redis.io/commands.
|
||||
|
||||
Installing Redis
|
||||
Installing Valkey
|
||||
-----------------
|
||||
|
||||
In order to install Redis binaries into /usr/local/bin, just use:
|
||||
In order to install Valkey binaries into /usr/local/bin, just use:
|
||||
|
||||
% make install
|
||||
|
||||
You can use `make PREFIX=/some/other/directory install` if you wish to use a
|
||||
different destination.
|
||||
|
||||
_Note_: For compatibility with Redis, we create symlinks from the Redis names (`redis-server`, `redis-cli`, etc.) to the Valkey binaries installed by `make install`.
|
||||
The symlinks are created in same directory as the Valkey binaries.
|
||||
The symlinks are removed when using `make uninstall`.
|
||||
The creation of the symlinks can be skipped by setting the makefile variable `USE_REDIS_SYMLINKS=no`.
|
||||
|
||||
`make install` will just install binaries in your system, but will not configure
|
||||
init scripts and configuration files in the appropriate place. This is not
|
||||
needed if you just want to play a bit with Redis, but if you are installing
|
||||
needed if you just want to play a bit with Valkey, but if you are installing
|
||||
it the proper way for a production system, we have a script that does this
|
||||
for Ubuntu and Debian systems:
|
||||
|
||||
@@ -208,299 +200,16 @@ for Ubuntu and Debian systems:
|
||||
_Note_: `install_server.sh` will not work on Mac OSX; it is built for Linux only.
|
||||
|
||||
The script will ask you a few questions and will setup everything you need
|
||||
to run Redis properly as a background daemon that will start again on
|
||||
to run Valkey properly as a background daemon that will start again on
|
||||
system reboots.
|
||||
|
||||
You'll be able to stop and start Redis using the script named
|
||||
`/etc/init.d/redis_<portnumber>`, for instance `/etc/init.d/redis_6379`.
|
||||
You'll be able to stop and start Valkey using the script named
|
||||
`/etc/init.d/valkey_<portnumber>`, for instance `/etc/init.d/valkey_6379`.
|
||||
|
||||
Code contributions
|
||||
-----------------
|
||||
Please see the [CONTRIBUTING.md][2]. For security bugs and vulnerabilities, please see [SECURITY.md][3].
|
||||
|
||||
Note: By contributing code to the Redis project in any form, including sending
|
||||
a pull request via Github, a code fragment or patch via private email or
|
||||
public discussion groups, you agree to release your code under the terms
|
||||
of the BSD license that you can find in the [COPYING][1] file included in the Redis
|
||||
source distribution.
|
||||
|
||||
Please see the [CONTRIBUTING.md][2] file in this source distribution for more
|
||||
information. For security bugs and vulnerabilities, please see [SECURITY.md][3].
|
||||
|
||||
[1]: https://github.com/redis/redis/blob/unstable/COPYING
|
||||
[2]: https://github.com/redis/redis/blob/unstable/CONTRIBUTING.md
|
||||
[3]: https://github.com/redis/redis/blob/unstable/SECURITY.md
|
||||
|
||||
Redis internals
|
||||
===
|
||||
|
||||
If you are reading this README you are likely in front of a Github page
|
||||
or you just untarred the Redis distribution tar ball. In both the cases
|
||||
you are basically one step away from the source code, so here we explain
|
||||
the Redis source code layout, what is in each file as a general idea, the
|
||||
most important functions and structures inside the Redis server and so forth.
|
||||
We keep all the discussion at a high level without digging into the details
|
||||
since this document would be huge otherwise and our code base changes
|
||||
continuously, but a general idea should be a good starting point to
|
||||
understand more. Moreover most of the code is heavily commented and easy
|
||||
to follow.
|
||||
|
||||
Source code layout
|
||||
---
|
||||
|
||||
The Redis root directory just contains this README, the Makefile which
|
||||
calls the real Makefile inside the `src` directory and an example
|
||||
configuration for Redis and Sentinel. You can find a few shell
|
||||
scripts that are used in order to execute the Redis, Redis Cluster and
|
||||
Redis Sentinel unit tests, which are implemented inside the `tests`
|
||||
directory.
|
||||
|
||||
Inside the root are the following important directories:
|
||||
|
||||
* `src`: contains the Redis implementation, written in C.
|
||||
* `tests`: contains the unit tests, implemented in Tcl.
|
||||
* `deps`: contains libraries Redis uses. Everything needed to compile Redis is inside this directory; your system just needs to provide `libc`, a POSIX compatible interface and a C compiler. Notably `deps` contains a copy of `jemalloc`, which is the default allocator of Redis under Linux. Note that under `deps` there are also things which started with the Redis project, but for which the main repository is not `redis/redis`.
|
||||
|
||||
There are a few more directories but they are not very important for our goals
|
||||
here. We'll focus mostly on `src`, where the Redis implementation is contained,
|
||||
exploring what there is inside each file. The order in which files are
|
||||
exposed is the logical one to follow in order to disclose different layers
|
||||
of complexity incrementally.
|
||||
|
||||
Note: lately Redis was refactored quite a bit. Function names and file
|
||||
names have been changed, so you may find that this documentation reflects the
|
||||
`unstable` branch more closely. For instance, in Redis 3.0 the `server.c`
|
||||
and `server.h` files were named `redis.c` and `redis.h`. However the overall
|
||||
structure is the same. Keep in mind that all the new developments and pull
|
||||
requests should be performed against the `unstable` branch.
|
||||
|
||||
server.h
|
||||
---
|
||||
|
||||
The simplest way to understand how a program works is to understand the
|
||||
data structures it uses. So we'll start from the main header file of
|
||||
Redis, which is `server.h`.
|
||||
|
||||
All the server configuration and in general all the shared state is
|
||||
defined in a global structure called `server`, of type `struct redisServer`.
|
||||
A few important fields in this structure are:
|
||||
|
||||
* `server.db` is an array of Redis databases, where data is stored.
|
||||
* `server.commands` is the command table.
|
||||
* `server.clients` is a linked list of clients connected to the server.
|
||||
* `server.master` is a special client, the master, if the instance is a replica.
|
||||
|
||||
There are tons of other fields. Most fields are commented directly inside
|
||||
the structure definition.
|
||||
|
||||
Another important Redis data structure is the one defining a client.
|
||||
In the past it was called `redisClient`, now just `client`. The structure
|
||||
has many fields, here we'll just show the main ones:
|
||||
```c
|
||||
struct client {
|
||||
int fd;
|
||||
sds querybuf;
|
||||
int argc;
|
||||
robj **argv;
|
||||
redisDb *db;
|
||||
int flags;
|
||||
list *reply;
|
||||
// ... many other fields ...
|
||||
char buf[PROTO_REPLY_CHUNK_BYTES];
|
||||
}
|
||||
```
|
||||
The client structure defines a *connected client*:
|
||||
|
||||
* The `fd` field is the client socket file descriptor.
|
||||
* `argc` and `argv` are populated with the command the client is executing, so that functions implementing a given Redis command can read the arguments.
|
||||
* `querybuf` accumulates the requests from the client, which are parsed by the Redis server according to the Redis protocol and executed by calling the implementations of the commands the client is executing.
|
||||
* `reply` and `buf` are dynamic and static buffers that accumulate the replies the server sends to the client. These buffers are incrementally written to the socket as soon as the file descriptor is writable.
|
||||
|
||||
As you can see in the client structure above, arguments in a command
|
||||
are described as `robj` structures. The following is the full `robj`
|
||||
structure, which defines a *Redis object*:
|
||||
|
||||
```c
|
||||
struct redisObject {
|
||||
unsigned type:4;
|
||||
unsigned encoding:4;
|
||||
unsigned lru:LRU_BITS; /* LRU time (relative to global lru_clock) or
|
||||
* LFU data (least significant 8 bits frequency
|
||||
* and most significant 16 bits access time). */
|
||||
int refcount;
|
||||
void *ptr;
|
||||
};
|
||||
```
|
||||
|
||||
Basically this structure can represent all the basic Redis data types like
|
||||
strings, lists, sets, sorted sets and so forth. The interesting thing is that
|
||||
it has a `type` field, so that it is possible to know what type a given
|
||||
object has, and a `refcount`, so that the same object can be referenced
|
||||
in multiple places without allocating it multiple times. Finally the `ptr`
|
||||
field points to the actual representation of the object, which might vary
|
||||
even for the same type, depending on the `encoding` used.
|
||||
|
||||
Redis objects are used extensively in the Redis internals, however in order
|
||||
to avoid the overhead of indirect accesses, recently in many places
|
||||
we just use plain dynamic strings not wrapped inside a Redis object.
|
||||
|
||||
server.c
|
||||
---
|
||||
|
||||
This is the entry point of the Redis server, where the `main()` function
|
||||
is defined. The following are the most important steps in order to startup
|
||||
the Redis server.
|
||||
|
||||
* `initServerConfig()` sets up the default values of the `server` structure.
|
||||
* `initServer()` allocates the data structures needed to operate, setup the listening socket, and so forth.
|
||||
* `aeMain()` starts the event loop which listens for new connections.
|
||||
|
||||
There are two special functions called periodically by the event loop:
|
||||
|
||||
1. `serverCron()` is called periodically (according to `server.hz` frequency), and performs tasks that must be performed from time to time, like checking for timed out clients.
|
||||
2. `beforeSleep()` is called every time the event loop fired, Redis served a few requests, and is returning back into the event loop.
|
||||
|
||||
Inside server.c you can find code that handles other vital things of the Redis server:
|
||||
|
||||
* `call()` is used in order to call a given command in the context of a given client.
|
||||
* `activeExpireCycle()` handles eviction of keys with a time to live set via the `EXPIRE` command.
|
||||
* `performEvictions()` is called when a new write command should be performed but Redis is out of memory according to the `maxmemory` directive.
|
||||
* The global variable `redisCommandTable` defines all the Redis commands, specifying the name of the command, the function implementing the command, the number of arguments required, and other properties of each command.
|
||||
|
||||
commands.c
|
||||
---
|
||||
This file is auto generated by utils/generate-command-code.py, the content is based on the JSON files in the src/commands folder.
|
||||
These are meant to be the single source of truth about the Redis commands, and all the metadata about them.
|
||||
These JSON files are not meant to be used by anyone directly, instead that metadata can be obtained via the `COMMAND` command.
|
||||
|
||||
networking.c
|
||||
---
|
||||
|
||||
This file defines all the I/O functions with clients, masters and replicas
|
||||
(which in Redis are just special clients):
|
||||
|
||||
* `createClient()` allocates and initializes a new client.
|
||||
* The `addReply*()` family of functions are used by command implementations in order to append data to the client structure, that will be transmitted to the client as a reply for a given command executed.
|
||||
* `writeToClient()` transmits the data pending in the output buffers to the client and is called by the *writable event handler* `sendReplyToClient()`.
|
||||
* `readQueryFromClient()` is the *readable event handler* and accumulates data read from the client into the query buffer.
|
||||
* `processInputBuffer()` is the entry point in order to parse the client query buffer according to the Redis protocol. Once commands are ready to be processed, it calls `processCommand()` which is defined inside `server.c` in order to actually execute the command.
|
||||
* `freeClient()` deallocates, disconnects and removes a client.
|
||||
|
||||
aof.c and rdb.c
|
||||
---
|
||||
|
||||
As you can guess from the names, these files implement the RDB and AOF
|
||||
persistence for Redis. Redis uses a persistence model based on the `fork()`
|
||||
system call in order to create a process with the same (shared) memory
|
||||
content of the main Redis process. This secondary process dumps the content
|
||||
of the memory on disk. This is used by `rdb.c` to create the snapshots
|
||||
on disk and by `aof.c` in order to perform the AOF rewrite when the
|
||||
append only file gets too big.
|
||||
|
||||
The implementation inside `aof.c` has additional functions in order to
|
||||
implement an API that allows commands to append new commands into the AOF
|
||||
file as clients execute them.
|
||||
|
||||
The `call()` function defined inside `server.c` is responsible for calling
|
||||
the functions that in turn will write the commands into the AOF.
|
||||
|
||||
db.c
|
||||
---
|
||||
|
||||
Certain Redis commands operate on specific data types; others are general.
|
||||
Examples of generic commands are `DEL` and `EXPIRE`. They operate on keys
|
||||
and not on their values specifically. All those generic commands are
|
||||
defined inside `db.c`.
|
||||
|
||||
Moreover `db.c` implements an API in order to perform certain operations
|
||||
on the Redis dataset without directly accessing the internal data structures.
|
||||
|
||||
The most important functions inside `db.c` which are used in many command
|
||||
implementations are the following:
|
||||
|
||||
* `lookupKeyRead()` and `lookupKeyWrite()` are used in order to get a pointer to the value associated to a given key, or `NULL` if the key does not exist.
|
||||
* `dbAdd()` and its higher level counterpart `setKey()` create a new key in a Redis database.
|
||||
* `dbDelete()` removes a key and its associated value.
|
||||
* `emptyDb()` removes an entire single database or all the databases defined.
|
||||
|
||||
The rest of the file implements the generic commands exposed to the client.
|
||||
|
||||
object.c
|
||||
---
|
||||
|
||||
The `robj` structure defining Redis objects was already described. Inside
|
||||
`object.c` there are all the functions that operate with Redis objects at
|
||||
a basic level, like functions to allocate new objects, handle the reference
|
||||
counting and so forth. Notable functions inside this file:
|
||||
|
||||
* `incrRefCount()` and `decrRefCount()` are used in order to increment or decrement an object reference count. When it drops to 0 the object is finally freed.
|
||||
* `createObject()` allocates a new object. There are also specialized functions to allocate string objects having a specific content, like `createStringObjectFromLongLong()` and similar functions.
|
||||
|
||||
This file also implements the `OBJECT` command.
|
||||
|
||||
replication.c
|
||||
---
|
||||
|
||||
This is one of the most complex files inside Redis, it is recommended to
|
||||
approach it only after getting a bit familiar with the rest of the code base.
|
||||
In this file there is the implementation of both the master and replica role
|
||||
of Redis.
|
||||
|
||||
One of the most important functions inside this file is `replicationFeedSlaves()` that writes commands to the clients representing replica instances connected
|
||||
to our master, so that the replicas can get the writes performed by the clients:
|
||||
this way their data set will remain synchronized with the one in the master.
|
||||
|
||||
This file also implements both the `SYNC` and `PSYNC` commands that are
|
||||
used in order to perform the first synchronization between masters and
|
||||
replicas, or to continue the replication after a disconnection.
|
||||
|
||||
Script
|
||||
---
|
||||
|
||||
The script unit is composed of 3 units:
|
||||
* `script.c` - integration of scripts with Redis (commands execution, set replication/resp, ...)
|
||||
* `script_lua.c` - responsible to execute Lua code, uses script.c to interact with Redis from within the Lua code.
|
||||
* `function_lua.c` - contains the Lua engine implementation, uses script_lua.c to execute the Lua code.
|
||||
* `functions.c` - contains Redis Functions implementation (FUNCTION command), uses functions_lua.c if the function it wants to invoke needs the Lua engine.
|
||||
* `eval.c` - contains the `eval` implementation using `script_lua.c` to invoke the Lua code.
|
||||
|
||||
|
||||
Other C files
|
||||
---
|
||||
|
||||
* `t_hash.c`, `t_list.c`, `t_set.c`, `t_string.c`, `t_zset.c` and `t_stream.c` contains the implementation of the Redis data types. They implement both an API to access a given data type, and the client command implementations for these data types.
|
||||
* `ae.c` implements the Redis event loop, it's a self contained library which is simple to read and understand.
|
||||
* `sds.c` is the Redis string library, check https://github.com/antirez/sds for more information.
|
||||
* `anet.c` is a library to use POSIX networking in a simpler way compared to the raw interface exposed by the kernel.
|
||||
* `dict.c` is an implementation of a non-blocking hash table which rehashes incrementally.
|
||||
* `cluster.c` implements the Redis Cluster. Probably a good read only after being very familiar with the rest of the Redis code base. If you want to read `cluster.c` make sure to read the [Redis Cluster specification][4].
|
||||
|
||||
[4]: https://redis.io/topics/cluster-spec
|
||||
|
||||
Anatomy of a Redis command
|
||||
---
|
||||
|
||||
All the Redis commands are defined in the following way:
|
||||
|
||||
```c
|
||||
void foobarCommand(client *c) {
|
||||
printf("%s",c->argv[1]->ptr); /* Do something with the argument. */
|
||||
addReply(c,shared.ok); /* Reply something to the client. */
|
||||
}
|
||||
```
|
||||
|
||||
The command function is referenced by a JSON file, together with its metadata, see `commands.c` described above for details.
|
||||
The command flags are documented in the comment above the `struct redisCommand` in `server.h`.
|
||||
For other details, please refer to the `COMMAND` command. https://redis.io/commands/command/
|
||||
|
||||
After the command operates in some way, it returns a reply to the client,
|
||||
usually using `addReply()` or a similar function defined inside `networking.c`.
|
||||
|
||||
There are tons of command implementations inside the Redis source code
|
||||
that can serve as examples of actual commands implementations (e.g. pingCommand). Writing
|
||||
a few toy commands can be a good exercise to get familiar with the code base.
|
||||
|
||||
There are also many other files not described here, but it is useless to
|
||||
cover everything. We just want to help you with the first steps.
|
||||
Eventually you'll find your way inside the Redis code base :-)
|
||||
|
||||
Enjoy!
|
||||
[1]: https://github.com/valkey-io/valkey/blob/unstable/COPYING
|
||||
[2]: https://github.com/valkey-io/valkey/blob/unstable/CONTRIBUTING.md
|
||||
[3]: https://github.com/valkey-io/valkey/blob/unstable/SECURITY.md
|
||||
|
||||
+4
-41
@@ -1,43 +1,6 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Redis is generally backwards compatible with very few exceptions, so we
|
||||
recommend users to always use the latest version to experience stability,
|
||||
performance and security.
|
||||
|
||||
We generally backport security issues to a single previous major version,
|
||||
unless this is not possible or feasible with a reasonable effort.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 7.0.x | :white_check_mark: |
|
||||
| 6.2.x | :white_check_mark: |
|
||||
| 6.0.x | :white_check_mark: |
|
||||
| < 6.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you believe you’ve discovered a serious vulnerability, please contact the
|
||||
Redis core team at redis@redis.io. We will evaluate your report and if
|
||||
necessary issue a fix and an advisory. If the issue was previously undisclosed,
|
||||
we’ll also mention your name in the credits.
|
||||
|
||||
## Responsible Disclosure
|
||||
|
||||
In some cases, we may apply a responsible disclosure process to reported or
|
||||
otherwise discovered vulnerabilities. We will usually do that for a critical
|
||||
vulnerability, and only if we have a good reason to believe information about
|
||||
it is not yet public.
|
||||
|
||||
This process involves providing an early notification about the vulnerability,
|
||||
its impact and mitigations to a short list of vendors under a time-limited
|
||||
embargo on public disclosure.
|
||||
|
||||
Vendors on the list are individuals or organizations that maintain Redis
|
||||
distributions or provide Redis as a service, who have third party users who
|
||||
will benefit from the vendor’s ability to prepare for a new version or deploy a
|
||||
fix early.
|
||||
|
||||
If you believe you should be on the list, please contact us and we will
|
||||
consider your request based on the above criteria.
|
||||
If you believe you've discovered a security vulnerability, please contact the Valkey team at security@lists.valkey.io.
|
||||
Please *DO NOT* create an issue.
|
||||
We follow a responsible disclore procedure, so depending on the severity of the issue we may notify Valkey vendors about the issue before releasing it publicly.
|
||||
If you would like to be added to our list of vendors, please reach out to the Valkey team at maintainers@lists.valkey.io.
|
||||
|
||||
+27
-30
@@ -9,15 +9,15 @@ protected-mode no
|
||||
# The port that this sentinel instance will run on
|
||||
port 26379
|
||||
|
||||
# By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
|
||||
# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
|
||||
# By default Valkey Sentinel does not run as a daemon. Use 'yes' if you need it.
|
||||
# Note that Valkey will write a pid file in /var/run/valkey-sentinel.pid when
|
||||
# daemonized.
|
||||
daemonize no
|
||||
|
||||
# When running daemonized, Redis Sentinel writes a pid file in
|
||||
# /var/run/redis-sentinel.pid by default. You can specify a custom pid file
|
||||
# When running daemonized, Valkey Sentinel writes a pid file in
|
||||
# /var/run/valkey-sentinel.pid by default. You can specify a custom pid file
|
||||
# location here.
|
||||
pidfile /var/run/redis-sentinel.pid
|
||||
pidfile /var/run/valkey-sentinel.pid
|
||||
|
||||
# Specify the server verbosity level.
|
||||
# This can be one of:
|
||||
@@ -67,12 +67,12 @@ logfile ""
|
||||
|
||||
# dir <working-directory>
|
||||
# Every long running process should have a well-defined working directory.
|
||||
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
|
||||
# For Valkey Sentinel to chdir to /tmp at startup is the simplest thing
|
||||
# for the process to don't interfere with administrative tasks such as
|
||||
# unmounting filesystems.
|
||||
dir /tmp
|
||||
|
||||
# sentinel monitor <master-name> <ip> <redis-port> <quorum>
|
||||
# sentinel monitor <master-name> <ip> <valkey-port> <quorum>
|
||||
#
|
||||
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
|
||||
# (Objectively Down) state only if at least <quorum> sentinels agree.
|
||||
@@ -94,16 +94,16 @@ sentinel monitor mymaster 127.0.0.1 6379 2
|
||||
# sentinel auth-pass <master-name> <password>
|
||||
#
|
||||
# Set the password to use to authenticate with the master and replicas.
|
||||
# Useful if there is a password set in the Redis instances to monitor.
|
||||
# Useful if there is a password set in the Valkey instances to monitor.
|
||||
#
|
||||
# Note that the master password is also used for replicas, so it is not
|
||||
# possible to set a different password in masters and replicas instances
|
||||
# if you want to be able to monitor these instances with Sentinel.
|
||||
#
|
||||
# However you can have Redis instances without the authentication enabled
|
||||
# mixed with Redis instances requiring the authentication (as long as the
|
||||
# However you can have Valkey instances without the authentication enabled
|
||||
# mixed with Valkey instances requiring the authentication (as long as the
|
||||
# password set is the same for all the instances requiring the password) as
|
||||
# the AUTH command will have no effect in Redis instances with authentication
|
||||
# the AUTH command will have no effect in Valkey instances with authentication
|
||||
# switched off.
|
||||
#
|
||||
# Example:
|
||||
@@ -113,10 +113,10 @@ sentinel monitor mymaster 127.0.0.1 6379 2
|
||||
# sentinel auth-user <master-name> <username>
|
||||
#
|
||||
# This is useful in order to authenticate to instances having ACL capabilities,
|
||||
# that is, running Redis 6.0 or greater. When just auth-pass is provided the
|
||||
# Sentinel instance will authenticate to Redis using the old "AUTH <pass>"
|
||||
# that is, running Valkey. When just auth-pass is provided the
|
||||
# Sentinel instance will authenticate to Valkey using the old "AUTH <pass>"
|
||||
# method. When also an username is provided, it will use "AUTH <user> <pass>".
|
||||
# In the Redis servers side, the ACL to provide just minimal access to
|
||||
# In the Valkey servers side, the ACL to provide just minimal access to
|
||||
# Sentinel instances, should be configured along the following lines:
|
||||
#
|
||||
# user sentinel-user >somepassword +client +subscribe +publish \
|
||||
@@ -132,9 +132,6 @@ sentinel monitor mymaster 127.0.0.1 6379 2
|
||||
# Default is 30 seconds.
|
||||
sentinel down-after-milliseconds mymaster 30000
|
||||
|
||||
# IMPORTANT NOTE: starting with Redis 6.2 ACL capability is supported for
|
||||
# Sentinel mode, please refer to the Redis website https://redis.io/topics/acl
|
||||
# for more details.
|
||||
|
||||
# Sentinel's ACL users are defined in the following format:
|
||||
#
|
||||
@@ -145,8 +142,8 @@ sentinel down-after-milliseconds mymaster 30000
|
||||
# user worker +@admin +@connection ~* on >ffa9203c493aa99
|
||||
#
|
||||
# For more information about ACL configuration please refer to the Redis
|
||||
# website at https://redis.io/topics/acl and redis server configuration
|
||||
# template redis.conf.
|
||||
# website at https://valkey.io/topics/acl and valkey server configuration
|
||||
# template valkey.conf.
|
||||
|
||||
# ACL LOG
|
||||
#
|
||||
@@ -164,9 +161,9 @@ acllog-max-len 128
|
||||
# ACL file, the server will refuse to start.
|
||||
#
|
||||
# The format of the external ACL user file is exactly the same as the
|
||||
# format that is used inside redis.conf to describe users.
|
||||
# format that is used inside valkey.conf to describe users.
|
||||
#
|
||||
# aclfile /etc/redis/sentinel-users.acl
|
||||
# aclfile /etc/valkey/sentinel-users.acl
|
||||
|
||||
# requirepass <password>
|
||||
#
|
||||
@@ -174,9 +171,9 @@ acllog-max-len 128
|
||||
# so Sentinel will try to authenticate with the same password to all the
|
||||
# other Sentinels. So you need to configure all your Sentinels in a given
|
||||
# group with the same "requirepass" password. Check the following documentation
|
||||
# for more info: https://redis.io/topics/sentinel
|
||||
# for more info: https://valkey.io/topics/sentinel
|
||||
#
|
||||
# IMPORTANT NOTE: starting with Redis 6.2 "requirepass" is a compatibility
|
||||
# IMPORTANT NOTE: "requirepass" is a compatibility
|
||||
# layer on top of the ACL system. The option effect will be just setting
|
||||
# the password for the default user. Clients will still authenticate using
|
||||
# AUTH <password> as usually, or more explicitly with AUTH default <password>
|
||||
@@ -259,7 +256,7 @@ sentinel failover-timeout mymaster 180000
|
||||
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
|
||||
# This script should notify the system administrator via email, SMS, or any
|
||||
# other messaging system, that there is something wrong with the monitored
|
||||
# Redis systems.
|
||||
# Valkey systems.
|
||||
#
|
||||
# The script is called with just two arguments: the first is the event type
|
||||
# and the second the event description.
|
||||
@@ -269,7 +266,7 @@ sentinel failover-timeout mymaster 180000
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# sentinel notification-script mymaster /var/redis/notify.sh
|
||||
# sentinel notification-script mymaster /var/valkey/notify.sh
|
||||
|
||||
# CLIENTS RECONFIGURATION SCRIPT
|
||||
#
|
||||
@@ -294,7 +291,7 @@ sentinel failover-timeout mymaster 180000
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
|
||||
# sentinel client-reconfig-script mymaster /var/valkey/reconfig.sh
|
||||
|
||||
# SECURITY
|
||||
#
|
||||
@@ -305,13 +302,13 @@ sentinel failover-timeout mymaster 180000
|
||||
|
||||
sentinel deny-scripts-reconfig yes
|
||||
|
||||
# REDIS COMMANDS RENAMING (DEPRECATED)
|
||||
# VALKEY COMMANDS RENAMING (DEPRECATED)
|
||||
#
|
||||
# WARNING: avoid using this option if possible, instead use ACLs.
|
||||
#
|
||||
# Sometimes the Redis server has certain commands, that are needed for Sentinel
|
||||
# Sometimes the Valkey server has certain commands, that are needed for Sentinel
|
||||
# to work correctly, renamed to unguessable strings. This is often the case
|
||||
# of CONFIG and SLAVEOF in the context of providers that provide Redis as
|
||||
# of CONFIG and SLAVEOF in the context of providers that provide Valkey as
|
||||
# a service, and don't want the customers to reconfigure the instances outside
|
||||
# of the administration console.
|
||||
#
|
||||
@@ -335,7 +332,7 @@ sentinel deny-scripts-reconfig yes
|
||||
# HOSTNAMES SUPPORT
|
||||
#
|
||||
# Normally Sentinel uses only IP addresses and requires SENTINEL MONITOR
|
||||
# to specify an IP address. Also, it requires the Redis replica-announce-ip
|
||||
# to specify an IP address. Also, it requires the Valkey replica-announce-ip
|
||||
# keyword to specify only IP addresses.
|
||||
#
|
||||
# You may enable hostnames support by enabling resolve-hostnames. Note
|
||||
|
||||
+76
-33
@@ -1,13 +1,13 @@
|
||||
# Redis Makefile
|
||||
# Valkey Makefile
|
||||
# Copyright (C) 2009 Salvatore Sanfilippo <antirez at gmail dot com>
|
||||
# This file is released under the BSD license, see the COPYING file
|
||||
#
|
||||
# The Makefile composes the final FINAL_CFLAGS and FINAL_LDFLAGS using
|
||||
# what is needed for Redis plus the standard CFLAGS and LDFLAGS passed.
|
||||
# what is needed for Valkey plus the standard CFLAGS and LDFLAGS passed.
|
||||
# However when building the dependencies (Jemalloc, Lua, Hiredis, ...)
|
||||
# CFLAGS and LDFLAGS are propagated to the dependencies, so to pass
|
||||
# flags only to be used when compiling / linking Redis itself REDIS_CFLAGS
|
||||
# and REDIS_LDFLAGS are used instead (this is the case of 'make gcov').
|
||||
# flags only to be used when compiling / linking Valkey itself SERVER_CFLAGS
|
||||
# and SERVER_LDFLAGS are used instead (this is the case of 'make gcov').
|
||||
#
|
||||
# Dependencies are stored in the Makefile.dep file. To rebuild this file
|
||||
# Just use 'make dep', but this is only needed by developers.
|
||||
@@ -19,11 +19,11 @@ CLANG := $(findstring clang,$(shell sh -c '$(CC) --version | head -1'))
|
||||
OPTIMIZATION?=-O3
|
||||
ifeq ($(OPTIMIZATION),-O3)
|
||||
ifeq (clang,$(CLANG))
|
||||
REDIS_CFLAGS+=-flto
|
||||
SERVER_CFLAGS+=-flto
|
||||
else
|
||||
REDIS_CFLAGS+=-flto=auto
|
||||
SERVER_CFLAGS+=-flto=auto
|
||||
endif
|
||||
REDIS_LDFLAGS+=-O3 -flto
|
||||
SERVER_LDFLAGS+=-O3 -flto
|
||||
endif
|
||||
DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram fpconv
|
||||
NODEPS:=clean distclean
|
||||
@@ -70,7 +70,7 @@ ifeq ($(uname_S),Linux)
|
||||
MALLOC=jemalloc
|
||||
endif
|
||||
|
||||
# To get ARM stack traces if Redis crashes we need a special C flag.
|
||||
# To get ARM stack traces if Valkey crashes we need a special C flag.
|
||||
ifneq (,$(filter aarch64 armv%,$(uname_M)))
|
||||
CFLAGS+=-funwind-tables
|
||||
endif
|
||||
@@ -116,8 +116,16 @@ endif
|
||||
# Override default settings if possible
|
||||
-include .make-settings
|
||||
|
||||
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
|
||||
FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
|
||||
# For added compatibility REDIS_CFLAGS and REDIS_LDFLAGS are also supported.
|
||||
ifdef REDIS_CFLAGS
|
||||
SERVER_CFLAGS := $(REDIS_CFLAGS)
|
||||
endif
|
||||
ifdef REDIS_LDFLAGS
|
||||
SERVER_LDFLAGS := $(REDIS_LDFLAGS)
|
||||
endif
|
||||
|
||||
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(SERVER_CFLAGS)
|
||||
FINAL_LDFLAGS=$(LDFLAGS) $(SERVER_LDFLAGS) $(DEBUG)
|
||||
FINAL_LIBS=-lm
|
||||
DEBUG=-g -ggdb
|
||||
|
||||
@@ -297,7 +305,7 @@ ifeq ($(BUILD_TLS),yes)
|
||||
endif
|
||||
|
||||
TLS_MODULE=
|
||||
TLS_MODULE_NAME:=redis-tls$(PROG_SUFFIX).so
|
||||
TLS_MODULE_NAME:=valkey-tls$(PROG_SUFFIX).so
|
||||
TLS_MODULE_CFLAGS:=$(FINAL_CFLAGS)
|
||||
ifeq ($(BUILD_TLS),module)
|
||||
FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS)
|
||||
@@ -311,10 +319,32 @@ ifndef V
|
||||
@printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2
|
||||
@$(INSTALL) $(1) $(2)
|
||||
endef
|
||||
|
||||
define INSTALL_REDIS_SYMLINK
|
||||
@printf ' %b %b %b %b %b %b %b\n' \
|
||||
$(LINKCOLOR)INSTALL SYMLINK$(ENDCOLOR) \
|
||||
$(BINCOLOR)$(subst $(ENGINE_NAME),redis,$(1))$(ENDCOLOR) -\> $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2
|
||||
@ln -sf $(1) $(2)/$(subst $(ENGINE_NAME),redis,$(1))
|
||||
endef
|
||||
else
|
||||
define MAKE_INSTALL
|
||||
$(INSTALL) $(1) $(2)
|
||||
endef
|
||||
|
||||
define INSTALL_REDIS_SYMLINK
|
||||
ln -sf $(1) $(2)/$(subst $(ENGINE_NAME),redis,$(1))
|
||||
endef
|
||||
endif
|
||||
|
||||
# Determine install/uninstall Redis symlinks for compatibility when
|
||||
# installing/uninstalling Valkey binaries (defaulting to `yes`)
|
||||
USE_REDIS_SYMLINKS?=yes
|
||||
ifeq ($(USE_REDIS_SYMLINKS),yes)
|
||||
MAYBE_INSTALL_REDIS_SYMLINK=$(INSTALL_REDIS_SYMLINK)
|
||||
MAYBE_UNINSTALL_REDIS_SYMLINK=@rm -f $(1)/$(subst $(ENGINE_NAME),redis,$(2))
|
||||
else
|
||||
MAYBE_INSTALL_REDIS_SYMLINK=
|
||||
MAYBE_UNINSTALL_REDIS_SYMLINK=
|
||||
endif
|
||||
|
||||
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
|
||||
@@ -335,7 +365,7 @@ QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(EN
|
||||
QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
|
||||
endif
|
||||
|
||||
ifneq (, $(findstring LOG_REQ_RES, $(REDIS_CFLAGS)))
|
||||
ifneq (, $(findstring LOG_REQ_RES, $(SERVER_CFLAGS)))
|
||||
COMMANDS_DEF_FILENAME=commands_with_reply_schema
|
||||
GEN_COMMANDS_FLAGS=--with-reply-schema
|
||||
else
|
||||
@@ -343,15 +373,16 @@ else
|
||||
GEN_COMMANDS_FLAGS=
|
||||
endif
|
||||
|
||||
REDIS_SERVER_NAME=redis-server$(PROG_SUFFIX)
|
||||
REDIS_SENTINEL_NAME=redis-sentinel$(PROG_SUFFIX)
|
||||
REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o
|
||||
REDIS_CLI_NAME=redis-cli$(PROG_SUFFIX)
|
||||
REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o ae.o redisassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o
|
||||
REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX)
|
||||
REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o
|
||||
REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX)
|
||||
REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX)
|
||||
ENGINE_NAME=valkey
|
||||
REDIS_SERVER_NAME=valkey-server$(PROG_SUFFIX)
|
||||
REDIS_SENTINEL_NAME=valkey-sentinel$(PROG_SUFFIX)
|
||||
REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o eval.o bio.o rio.o rand.o memtest.o syscheck.o crcspeed.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o valkey-check-rdb.o valkey-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o tracking.o socket.o tls.o sha256.o timeout.o setcpuaffinity.o monotonic.o mt19937-64.o resp_parser.o call_reply.o script_lua.o script.o functions.o function_lua.o commands.o strl.o connection.o unix.o logreqres.o
|
||||
REDIS_CLI_NAME=valkey-cli$(PROG_SUFFIX)
|
||||
REDIS_CLI_OBJ=anet.o adlist.o dict.o valkey-cli.o zmalloc.o release.o ae.o redisassert.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o cli_commands.o
|
||||
REDIS_BENCHMARK_NAME=valkey-benchmark$(PROG_SUFFIX)
|
||||
REDIS_BENCHMARK_OBJ=ae.o anet.o valkey-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o strl.o
|
||||
REDIS_CHECK_RDB_NAME=valkey-check-rdb$(PROG_SUFFIX)
|
||||
REDIS_CHECK_AOF_NAME=valkey-check-aof$(PROG_SUFFIX)
|
||||
ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(REDIS_SERVER_OBJ) $(REDIS_CLI_OBJ) $(REDIS_BENCHMARK_OBJ)))
|
||||
|
||||
all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) $(TLS_MODULE)
|
||||
@@ -377,8 +408,8 @@ persist-settings: distclean
|
||||
echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings
|
||||
echo CFLAGS=$(CFLAGS) >> .make-settings
|
||||
echo LDFLAGS=$(LDFLAGS) >> .make-settings
|
||||
echo REDIS_CFLAGS=$(REDIS_CFLAGS) >> .make-settings
|
||||
echo REDIS_LDFLAGS=$(REDIS_LDFLAGS) >> .make-settings
|
||||
echo SERVER_CFLAGS=$(SERVER_CFLAGS) >> .make-settings
|
||||
echo SERVER_LDFLAGS=$(SERVER_LDFLAGS) >> .make-settings
|
||||
echo PREV_FINAL_CFLAGS=$(FINAL_CFLAGS) >> .make-settings
|
||||
echo PREV_FINAL_LDFLAGS=$(FINAL_LDFLAGS) >> .make-settings
|
||||
-(cd ../deps && $(MAKE) $(DEPENDENCY_TARGETS))
|
||||
@@ -398,31 +429,31 @@ ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS)))
|
||||
.make-prerequisites: persist-settings
|
||||
endif
|
||||
|
||||
# redis-server
|
||||
# valkey-server
|
||||
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ)
|
||||
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS)
|
||||
|
||||
# redis-sentinel
|
||||
# valkey-sentinel
|
||||
$(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME)
|
||||
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME)
|
||||
|
||||
# redis-check-rdb
|
||||
# valkey-check-rdb
|
||||
$(REDIS_CHECK_RDB_NAME): $(REDIS_SERVER_NAME)
|
||||
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_RDB_NAME)
|
||||
|
||||
# redis-check-aof
|
||||
# valkey-check-aof
|
||||
$(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME)
|
||||
$(REDIS_INSTALL) $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME)
|
||||
|
||||
# redis-tls.so
|
||||
# valkey-tls.so
|
||||
$(TLS_MODULE_NAME): $(REDIS_SERVER_NAME)
|
||||
$(QUIET_CC)$(CC) -o $@ tls.c -shared -fPIC $(TLS_MODULE_CFLAGS) $(TLS_CLIENT_LIBS)
|
||||
|
||||
# redis-cli
|
||||
# valkey-cli
|
||||
$(REDIS_CLI_NAME): $(REDIS_CLI_OBJ)
|
||||
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
|
||||
|
||||
# redis-benchmark
|
||||
# valkey-benchmark
|
||||
$(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ)
|
||||
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
|
||||
|
||||
@@ -490,7 +521,7 @@ bench: $(REDIS_BENCHMARK_NAME)
|
||||
$(MAKE) CFLAGS="-m32" LDFLAGS="-m32"
|
||||
|
||||
gcov:
|
||||
$(MAKE) REDIS_CFLAGS="-fprofile-arcs -ftest-coverage -DCOVERAGE_TEST" REDIS_LDFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
$(MAKE) SERVER_CFLAGS="-fprofile-arcs -ftest-coverage -DCOVERAGE_TEST" SERVER_LDFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
|
||||
noopt:
|
||||
$(MAKE) OPTIMIZATION="-O0"
|
||||
@@ -499,7 +530,7 @@ valgrind:
|
||||
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc"
|
||||
|
||||
helgrind:
|
||||
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS" REDIS_CFLAGS="-I/usr/local/include" REDIS_LDFLAGS="-L/usr/local/lib"
|
||||
$(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS" SERVER_CFLAGS="-I/usr/local/include" SERVER_LDFLAGS="-L/usr/local/lib"
|
||||
|
||||
install: all
|
||||
@mkdir -p $(INSTALL_BIN)
|
||||
@@ -509,6 +540,18 @@ install: all
|
||||
@ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_CHECK_RDB_NAME)
|
||||
@ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_CHECK_AOF_NAME)
|
||||
@ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME)
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_SERVER_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_CLI_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_BENCHMARK_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_CHECK_RDB_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_CHECK_AOF_NAME),$(INSTALL_BIN))
|
||||
$(call MAYBE_INSTALL_REDIS_SYMLINK,$(REDIS_SENTINEL_NAME),$(INSTALL_BIN))
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)}
|
||||
@rm -f $(INSTALL_BIN)/{$(SERVER_NAME),$(ENGINE_BENCHMARK_NAME),$(ENGINE_CLI_NAME),$(ENGINE_CHECK_RDB_NAME),$(ENGINE_CHECK_AOF_NAME),$(ENGINE_SENTINEL_NAME)}
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(SERVER_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CLI_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_BENCHMARK_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CHECK_RDB_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_CHECK_AOF_NAME))
|
||||
$(call MAYBE_UNINSTALL_REDIS_SYMLINK,$(INSTALL_BIN),$(ENGINE_SENTINEL_NAME))
|
||||
|
||||
@@ -62,7 +62,7 @@ static unsigned long nextid = 0; /* Next command id that has not been assigned *
|
||||
struct ACLCategoryItem {
|
||||
const char *name;
|
||||
uint64_t flag;
|
||||
} ACLCommandCategories[] = { /* See redis.conf for details on each category. */
|
||||
} ACLCommandCategories[] = { /* See valkey.conf for details on each category. */
|
||||
{"keyspace", ACL_CATEGORY_KEYSPACE},
|
||||
{"read", ACL_CATEGORY_READ},
|
||||
{"write", ACL_CATEGORY_WRITE},
|
||||
@@ -2207,7 +2207,7 @@ int ACLLoadConfiguredUsers(void) {
|
||||
|
||||
/* This function loads the ACL from the specified filename: every line
|
||||
* is validated and should be either empty or in the format used to specify
|
||||
* users in the redis.conf configuration or in the ACL file, that is:
|
||||
* users in the valkey.conf or in the ACL file, that is:
|
||||
*
|
||||
* user <username> ... rules ...
|
||||
*
|
||||
@@ -2469,7 +2469,7 @@ cleanup:
|
||||
|
||||
/* This function is called once the server is already running, modules are
|
||||
* loaded, and we are ready to start, in order to load the ACLs either from
|
||||
* the pending list of users defined in redis.conf, or from the ACL file.
|
||||
* the pending list of users defined in valkey.conf, or from the ACL file.
|
||||
* The function will just exit with an error if the user is trying to mix
|
||||
* both the loading methods. */
|
||||
void ACLLoadUsersAtStartup(void) {
|
||||
|
||||
@@ -333,7 +333,7 @@ static int processTimeEvents(aeEventLoop *eventLoop) {
|
||||
processed++;
|
||||
now = getMonotonicUs();
|
||||
if (retval != AE_NOMORE) {
|
||||
te->when = now + retval * 1000;
|
||||
te->when = now + (monotime)retval * 1000;
|
||||
} else {
|
||||
te->id = AE_DELETED_EVENT_ID;
|
||||
}
|
||||
|
||||
+6
-5
@@ -417,13 +417,16 @@ int anetUnixGenericConnect(char *err, const char *path, int flags)
|
||||
return s;
|
||||
}
|
||||
|
||||
static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len, int backlog) {
|
||||
static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len, int backlog, mode_t perm) {
|
||||
if (bind(s,sa,len) == -1) {
|
||||
anetSetError(err, "bind: %s", strerror(errno));
|
||||
close(s);
|
||||
return ANET_ERR;
|
||||
}
|
||||
|
||||
if (sa->sa_family == AF_LOCAL && perm)
|
||||
chmod(((struct sockaddr_un *) sa)->sun_path, perm);
|
||||
|
||||
if (listen(s, backlog) == -1) {
|
||||
anetSetError(err, "listen: %s", strerror(errno));
|
||||
close(s);
|
||||
@@ -467,7 +470,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backl
|
||||
|
||||
if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR) goto error;
|
||||
if (anetSetReuseAddr(err,s) == ANET_ERR) goto error;
|
||||
if (anetListen(err,s,p->ai_addr,p->ai_addrlen,backlog) == ANET_ERR) s = ANET_ERR;
|
||||
if (anetListen(err,s,p->ai_addr,p->ai_addrlen,backlog,0) == ANET_ERR) s = ANET_ERR;
|
||||
goto end;
|
||||
}
|
||||
if (p == NULL) {
|
||||
@@ -508,10 +511,8 @@ int anetUnixServer(char *err, char *path, mode_t perm, int backlog)
|
||||
memset(&sa,0,sizeof(sa));
|
||||
sa.sun_family = AF_LOCAL;
|
||||
redis_strlcpy(sa.sun_path,path,sizeof(sa.sun_path));
|
||||
if (anetListen(err,s,(struct sockaddr*)&sa,sizeof(sa),backlog) == ANET_ERR)
|
||||
if (anetListen(err,s,(struct sockaddr*)&sa,sizeof(sa),backlog,perm) == ANET_ERR)
|
||||
return ANET_ERR;
|
||||
if (perm)
|
||||
chmod(sa.sun_path, perm);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,9 @@ aofInfo *aofInfoDup(aofInfo *orig) {
|
||||
return ai;
|
||||
}
|
||||
|
||||
/* Format aofInfo as a string and it will be a line in the manifest. */
|
||||
/* Format aofInfo as a string and it will be a line in the manifest.
|
||||
*
|
||||
* When update this format, make sure to update valkey-check-aof as well. */
|
||||
sds aofInfoFormat(sds buf, aofInfo *ai) {
|
||||
sds filename_repr = NULL;
|
||||
|
||||
@@ -251,7 +253,7 @@ void aofLoadManifestFromDisk(void) {
|
||||
sdsfree(am_filepath);
|
||||
}
|
||||
|
||||
/* Generic manifest loading function, used in `aofLoadManifestFromDisk` and redis-check-aof tool. */
|
||||
/* Generic manifest loading function, used in `aofLoadManifestFromDisk` and valkey-check-aof tool. */
|
||||
#define MANIFEST_MAX_LINE 1024
|
||||
aofManifest *aofLoadManifestFromFile(sds am_filepath) {
|
||||
const char *err = NULL;
|
||||
@@ -976,18 +978,6 @@ void stopAppendOnly(void) {
|
||||
int startAppendOnly(void) {
|
||||
serverAssert(server.aof_state == AOF_OFF);
|
||||
|
||||
/* Wait for all bio jobs related to AOF to drain. This prevents a race
|
||||
* between updates to `fsynced_reploff_pending` of the worker thread, belonging
|
||||
* to the previous AOF, and the new one. This concern is specific for a full
|
||||
* sync scenario where we don't wanna risk the ACKed replication offset
|
||||
* jumping backwards or forward when switching to a different master. */
|
||||
bioDrainWorker(BIO_AOF_FSYNC);
|
||||
|
||||
/* Set the initial repl_offset, which will be applied to fsynced_reploff
|
||||
* when AOFRW finishes (after possibly being updated by a bio thread) */
|
||||
atomicSet(server.fsynced_reploff_pending, server.master_repl_offset);
|
||||
server.fsynced_reploff = 0;
|
||||
|
||||
server.aof_state = AOF_WAIT_REWRITE;
|
||||
if (hasActiveChildProcess() && server.child_type != CHILD_TYPE_AOF) {
|
||||
server.aof_rewrite_scheduled = 1;
|
||||
@@ -1637,14 +1627,14 @@ uxeof: /* Unexpected AOF end of file. */
|
||||
}
|
||||
}
|
||||
serverLog(LL_WARNING, "Unexpected end of file reading the append only file %s. You can: "
|
||||
"1) Make a backup of your AOF file, then use ./redis-check-aof --fix <filename.manifest>. "
|
||||
"1) Make a backup of your AOF file, then use ./valkey-check-aof --fix <filename.manifest>. "
|
||||
"2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server.", filename);
|
||||
ret = AOF_FAILED;
|
||||
goto cleanup;
|
||||
|
||||
fmterr: /* Format error. */
|
||||
serverLog(LL_WARNING, "Bad file format reading the append only file %s: "
|
||||
"make a backup of your AOF file, then use ./redis-check-aof --fix <filename.manifest>", filename);
|
||||
"make a backup of your AOF file, then use ./valkey-check-aof --fix <filename.manifest>", filename);
|
||||
ret = AOF_FAILED;
|
||||
/* fall through to cleanup. */
|
||||
|
||||
@@ -2213,7 +2203,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
|
||||
* that is exported by a module and is not handled by Redis itself.
|
||||
* The function returns 0 on error, 1 on success. */
|
||||
int rewriteModuleObject(rio *r, robj *key, robj *o, int dbid) {
|
||||
RedisModuleIO io;
|
||||
ValkeyModuleIO io;
|
||||
moduleValue *mv = o->ptr;
|
||||
moduleType *mt = mv->type;
|
||||
moduleInitIOContext(io,mt,r,key,dbid);
|
||||
@@ -2454,7 +2444,23 @@ int rewriteAppendOnlyFileBackground(void) {
|
||||
server.aof_lastbgrewrite_status = C_ERR;
|
||||
return C_ERR;
|
||||
}
|
||||
|
||||
if (server.aof_state == AOF_WAIT_REWRITE) {
|
||||
/* Wait for all bio jobs related to AOF to drain. This prevents a race
|
||||
* between updates to `fsynced_reploff_pending` of the worker thread, belonging
|
||||
* to the previous AOF, and the new one. This concern is specific for a full
|
||||
* sync scenario where we don't wanna risk the ACKed replication offset
|
||||
* jumping backwards or forward when switching to a different master. */
|
||||
bioDrainWorker(BIO_AOF_FSYNC);
|
||||
|
||||
/* Set the initial repl_offset, which will be applied to fsynced_reploff
|
||||
* when AOFRW finishes (after possibly being updated by a bio thread) */
|
||||
atomicSet(server.fsynced_reploff_pending, server.master_repl_offset);
|
||||
server.fsynced_reploff = 0;
|
||||
}
|
||||
|
||||
server.stat_aof_rewrites++;
|
||||
|
||||
if ((childpid = redisFork(CHILD_TYPE_AOF)) == 0) {
|
||||
char tmpfile[256];
|
||||
|
||||
|
||||
+19
-17
@@ -28,20 +28,22 @@
|
||||
*/
|
||||
|
||||
const char *ascii_logo =
|
||||
" _._ \n"
|
||||
" _.-``__ ''-._ \n"
|
||||
" _.-`` `. `_. ''-._ Redis %s (%s/%d) %s bit\n"
|
||||
" .-`` .-```. ```\\/ _.,_ ''-._ \n"
|
||||
" ( ' , .-` | `, ) Running in %s mode\n"
|
||||
" |`-._`-...-` __...-.``-._|'` _.-'| Port: %d\n"
|
||||
" | `-._ `._ / _.-' | PID: %ld\n"
|
||||
" `-._ `-._ `-./ _.-' _.-' \n"
|
||||
" |`-._`-._ `-.__.-' _.-'_.-'| \n"
|
||||
" | `-._`-._ _.-'_.-' | https://redis.io \n"
|
||||
" `-._ `-._`-.__.-'_.-' _.-' \n"
|
||||
" |`-._`-._ `-.__.-' _.-'_.-'| \n"
|
||||
" | `-._`-._ _.-'_.-' | \n"
|
||||
" `-._ `-._`-.__.-'_.-' _.-' \n"
|
||||
" `-._ `-.__.-' _.-' \n"
|
||||
" `-._ _.-' \n"
|
||||
" `-.__.-' \n\n";
|
||||
" .+^+. \n"
|
||||
" .+#########+. \n"
|
||||
" .+########+########+. Valkey %s (%s/%d) %s bit\n"
|
||||
" .+########+' '+########+. \n"
|
||||
" .########+' .+. '+########. Running in %s mode\n"
|
||||
" |####+' .+#######+. '+####| Port: %d\n"
|
||||
" |###| .+###############+. |###| PID: %ld \n"
|
||||
" |###| |#####*'' ''*#####| |###| \n"
|
||||
" |###| |####' .-. '####| |###| \n"
|
||||
" |###| |###( (@@@) )###| |###| https://valkey.io \n"
|
||||
" |###| |####. '-' .####| |###| \n"
|
||||
" |###| |#####*. .*#####| |###| \n"
|
||||
" |###| '+#####| |#####+' |###| \n"
|
||||
" |####+. +##| |#+' .+####| \n"
|
||||
" '#######+ |##| .+########' \n"
|
||||
" '+###| |##| .+########+' \n"
|
||||
" '| |####+########+' \n"
|
||||
" +#########+' \n"
|
||||
" '+v+' \n\n";
|
||||
|
||||
+6
-2
@@ -370,7 +370,12 @@ void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeo
|
||||
list *l;
|
||||
int j;
|
||||
|
||||
c->bstate.timeout = timeout;
|
||||
if (!(c->flags & CLIENT_REPROCESSING_COMMAND)) {
|
||||
/* If the client is re-processing the command, we do not set the timeout
|
||||
* because we need to retain the client's original timeout. */
|
||||
c->bstate.timeout = timeout;
|
||||
}
|
||||
|
||||
for (j = 0; j < numkeys; j++) {
|
||||
/* If the key already exists in the dictionary ignore it. */
|
||||
if (!(client_blocked_entry = dictAddRaw(c->bstate.keys,keys[j],NULL))) {
|
||||
@@ -392,7 +397,6 @@ void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeo
|
||||
listAddNodeTail(l,c);
|
||||
dictSetVal(c->bstate.keys,client_blocked_entry,listLast(l));
|
||||
|
||||
|
||||
/* We need to add the key to blocking_keys_unblock_on_nokey, if the client
|
||||
* wants to be awakened if key is deleted (like XREADGROUP) */
|
||||
if (unblock_on_nokey) {
|
||||
|
||||
+56
-56
@@ -73,55 +73,55 @@ static void callReplySetSharedData(CallReply *rep, int type, const char *proto,
|
||||
|
||||
static void callReplyNull(void *ctx, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
}
|
||||
|
||||
static void callReplyNullBulkString(void *ctx, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, 0);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, 0);
|
||||
}
|
||||
|
||||
static void callReplyNullArray(void *ctx, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, 0);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, 0);
|
||||
}
|
||||
|
||||
static void callReplyBulkString(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_STRING, proto, proto_len, 0);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_STRING, proto, proto_len, 0);
|
||||
rep->len = len;
|
||||
rep->val.str = str;
|
||||
}
|
||||
|
||||
static void callReplyError(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_ERROR, proto, proto_len, 0);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_ERROR, proto, proto_len, 0);
|
||||
rep->len = len;
|
||||
rep->val.str = str;
|
||||
}
|
||||
|
||||
static void callReplySimpleStr(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_STRING, proto, proto_len, 0);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_STRING, proto, proto_len, 0);
|
||||
rep->len = len;
|
||||
rep->val.str = str;
|
||||
}
|
||||
|
||||
static void callReplyLong(void *ctx, long long val, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_INTEGER, proto, proto_len, 0);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_INTEGER, proto, proto_len, 0);
|
||||
rep->val.ll = val;
|
||||
}
|
||||
|
||||
static void callReplyDouble(void *ctx, double val, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_DOUBLE, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_DOUBLE, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
rep->val.d = val;
|
||||
}
|
||||
|
||||
static void callReplyVerbatimString(void *ctx, const char *format, const char *str, size_t len, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
rep->len = len;
|
||||
rep->val.verbatim_str.str = str;
|
||||
rep->val.verbatim_str.format = format;
|
||||
@@ -129,14 +129,14 @@ static void callReplyVerbatimString(void *ctx, const char *format, const char *s
|
||||
|
||||
static void callReplyBigNumber(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_BIG_NUMBER, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_BIG_NUMBER, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
rep->len = len;
|
||||
rep->val.str = str;
|
||||
}
|
||||
|
||||
static void callReplyBool(void *ctx, int val, const char *proto, size_t proto_len) {
|
||||
CallReply *rep = ctx;
|
||||
callReplySetSharedData(rep, REDISMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
callReplySetSharedData(rep, VALKEYMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3);
|
||||
rep->val.ll = val;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ static void callReplyAttribute(ReplyParser *parser, void *ctx, size_t len, const
|
||||
|
||||
/* Continue parsing the attribute reply */
|
||||
rep->attribute->len = len;
|
||||
rep->attribute->type = REDISMODULE_REPLY_ATTRIBUTE;
|
||||
rep->attribute->type = VALKEYMODULE_REPLY_ATTRIBUTE;
|
||||
callReplyParseCollection(parser, rep->attribute, len, proto, 2);
|
||||
rep->attribute->flags |= REPLY_FLAG_PARSED | REPLY_FLAG_RESP3;
|
||||
rep->attribute->private_data = rep->private_data;
|
||||
@@ -180,39 +180,39 @@ static void callReplyAttribute(ReplyParser *parser, void *ctx, size_t len, const
|
||||
|
||||
static void callReplyArray(ReplyParser *parser, void *ctx, size_t len, const char *proto) {
|
||||
CallReply *rep = ctx;
|
||||
rep->type = REDISMODULE_REPLY_ARRAY;
|
||||
rep->type = VALKEYMODULE_REPLY_ARRAY;
|
||||
callReplyParseCollection(parser, rep, len, proto, 1);
|
||||
}
|
||||
|
||||
static void callReplySet(ReplyParser *parser, void *ctx, size_t len, const char *proto) {
|
||||
CallReply *rep = ctx;
|
||||
rep->type = REDISMODULE_REPLY_SET;
|
||||
rep->type = VALKEYMODULE_REPLY_SET;
|
||||
callReplyParseCollection(parser, rep, len, proto, 1);
|
||||
rep->flags |= REPLY_FLAG_RESP3;
|
||||
}
|
||||
|
||||
static void callReplyMap(ReplyParser *parser, void *ctx, size_t len, const char *proto) {
|
||||
CallReply *rep = ctx;
|
||||
rep->type = REDISMODULE_REPLY_MAP;
|
||||
rep->type = VALKEYMODULE_REPLY_MAP;
|
||||
callReplyParseCollection(parser, rep, len, proto, 2);
|
||||
rep->flags |= REPLY_FLAG_RESP3;
|
||||
}
|
||||
|
||||
static void callReplyParseError(void *ctx) {
|
||||
CallReply *rep = ctx;
|
||||
rep->type = REDISMODULE_REPLY_UNKNOWN;
|
||||
rep->type = VALKEYMODULE_REPLY_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Recursively free the current call reply and its sub-replies. */
|
||||
static void freeCallReplyInternal(CallReply *rep) {
|
||||
if (rep->type == REDISMODULE_REPLY_ARRAY || rep->type == REDISMODULE_REPLY_SET) {
|
||||
if (rep->type == VALKEYMODULE_REPLY_ARRAY || rep->type == VALKEYMODULE_REPLY_SET) {
|
||||
for (size_t i = 0 ; i < rep->len ; ++i) {
|
||||
freeCallReplyInternal(rep->val.array + i);
|
||||
}
|
||||
zfree(rep->val.array);
|
||||
}
|
||||
|
||||
if (rep->type == REDISMODULE_REPLY_MAP || rep->type == REDISMODULE_REPLY_ATTRIBUTE) {
|
||||
if (rep->type == VALKEYMODULE_REPLY_MAP || rep->type == VALKEYMODULE_REPLY_ATTRIBUTE) {
|
||||
for (size_t i = 0 ; i < rep->len ; ++i) {
|
||||
freeCallReplyInternal(rep->val.array + i * 2);
|
||||
freeCallReplyInternal(rep->val.array + i * 2 + 1);
|
||||
@@ -234,7 +234,7 @@ void freeCallReply(CallReply *rep) {
|
||||
return;
|
||||
}
|
||||
if (rep->flags & REPLY_FLAG_PARSED) {
|
||||
if (rep->type == REDISMODULE_REPLY_PROMISE) {
|
||||
if (rep->type == VALKEYMODULE_REPLY_PROMISE) {
|
||||
zfree(rep);
|
||||
return;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void freeCallReply(CallReply *rep) {
|
||||
|
||||
CallReply *callReplyCreatePromise(void *private_data) {
|
||||
CallReply *res = zmalloc(sizeof(*res));
|
||||
res->type = REDISMODULE_REPLY_PROMISE;
|
||||
res->type = VALKEYMODULE_REPLY_PROMISE;
|
||||
/* Mark the reply as parsed so there will be not attempt to parse
|
||||
* it when calling reply API such as freeCallReply.
|
||||
* Also mark the reply as root so freeCallReply will not ignore it. */
|
||||
@@ -289,16 +289,16 @@ static void callReplyParse(CallReply *rep) {
|
||||
rep->flags |= REPLY_FLAG_PARSED;
|
||||
}
|
||||
|
||||
/* Return the call reply type (REDISMODULE_REPLY_...). */
|
||||
/* Return the call reply type (VALKEYMODULE_REPLY_...). */
|
||||
int callReplyType(CallReply *rep) {
|
||||
if (!rep) return REDISMODULE_REPLY_UNKNOWN;
|
||||
if (!rep) return VALKEYMODULE_REPLY_UNKNOWN;
|
||||
callReplyParse(rep);
|
||||
return rep->type;
|
||||
}
|
||||
|
||||
/* Return reply string as buffer and len. Applicable to:
|
||||
* - REDISMODULE_REPLY_STRING
|
||||
* - REDISMODULE_REPLY_ERROR
|
||||
* - VALKEYMODULE_REPLY_STRING
|
||||
* - VALKEYMODULE_REPLY_ERROR
|
||||
*
|
||||
* The return value is borrowed from CallReply, so it must not be freed
|
||||
* explicitly or used after CallReply itself is freed.
|
||||
@@ -308,56 +308,56 @@ int callReplyType(CallReply *rep) {
|
||||
*/
|
||||
const char *callReplyGetString(CallReply *rep, size_t *len) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_STRING &&
|
||||
rep->type != REDISMODULE_REPLY_ERROR) return NULL;
|
||||
if (rep->type != VALKEYMODULE_REPLY_STRING &&
|
||||
rep->type != VALKEYMODULE_REPLY_ERROR) return NULL;
|
||||
if (len) *len = rep->len;
|
||||
return rep->val.str;
|
||||
}
|
||||
|
||||
/* Return a long long reply value. Applicable to:
|
||||
* - REDISMODULE_REPLY_INTEGER
|
||||
* - VALKEYMODULE_REPLY_INTEGER
|
||||
*/
|
||||
long long callReplyGetLongLong(CallReply *rep) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_INTEGER) return LLONG_MIN;
|
||||
if (rep->type != VALKEYMODULE_REPLY_INTEGER) return LLONG_MIN;
|
||||
return rep->val.ll;
|
||||
}
|
||||
|
||||
/* Return a double reply value. Applicable to:
|
||||
* - REDISMODULE_REPLY_DOUBLE
|
||||
* - VALKEYMODULE_REPLY_DOUBLE
|
||||
*/
|
||||
double callReplyGetDouble(CallReply *rep) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_DOUBLE) return LLONG_MIN;
|
||||
if (rep->type != VALKEYMODULE_REPLY_DOUBLE) return LLONG_MIN;
|
||||
return rep->val.d;
|
||||
}
|
||||
|
||||
/* Return a reply Boolean value. Applicable to:
|
||||
* - REDISMODULE_REPLY_BOOL
|
||||
* - VALKEYMODULE_REPLY_BOOL
|
||||
*/
|
||||
int callReplyGetBool(CallReply *rep) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_BOOL) return INT_MIN;
|
||||
if (rep->type != VALKEYMODULE_REPLY_BOOL) return INT_MIN;
|
||||
return rep->val.ll;
|
||||
}
|
||||
|
||||
/* Return reply length. Applicable to:
|
||||
* - REDISMODULE_REPLY_STRING
|
||||
* - REDISMODULE_REPLY_ERROR
|
||||
* - REDISMODULE_REPLY_ARRAY
|
||||
* - REDISMODULE_REPLY_SET
|
||||
* - REDISMODULE_REPLY_MAP
|
||||
* - REDISMODULE_REPLY_ATTRIBUTE
|
||||
* - VALKEYMODULE_REPLY_STRING
|
||||
* - VALKEYMODULE_REPLY_ERROR
|
||||
* - VALKEYMODULE_REPLY_ARRAY
|
||||
* - VALKEYMODULE_REPLY_SET
|
||||
* - VALKEYMODULE_REPLY_MAP
|
||||
* - VALKEYMODULE_REPLY_ATTRIBUTE
|
||||
*/
|
||||
size_t callReplyGetLen(CallReply *rep) {
|
||||
callReplyParse(rep);
|
||||
switch(rep->type) {
|
||||
case REDISMODULE_REPLY_STRING:
|
||||
case REDISMODULE_REPLY_ERROR:
|
||||
case REDISMODULE_REPLY_ARRAY:
|
||||
case REDISMODULE_REPLY_SET:
|
||||
case REDISMODULE_REPLY_MAP:
|
||||
case REDISMODULE_REPLY_ATTRIBUTE:
|
||||
case VALKEYMODULE_REPLY_STRING:
|
||||
case VALKEYMODULE_REPLY_ERROR:
|
||||
case VALKEYMODULE_REPLY_ARRAY:
|
||||
case VALKEYMODULE_REPLY_SET:
|
||||
case VALKEYMODULE_REPLY_MAP:
|
||||
case VALKEYMODULE_REPLY_ATTRIBUTE:
|
||||
return rep->len;
|
||||
default:
|
||||
return 0;
|
||||
@@ -370,26 +370,26 @@ static CallReply *callReplyGetCollectionElement(CallReply *rep, size_t idx, int
|
||||
}
|
||||
|
||||
/* Return a reply array element at a given index. Applicable to:
|
||||
* - REDISMODULE_REPLY_ARRAY
|
||||
* - VALKEYMODULE_REPLY_ARRAY
|
||||
*
|
||||
* The return value is borrowed from CallReply, so it must not be freed
|
||||
* explicitly or used after CallReply itself is freed.
|
||||
*/
|
||||
CallReply *callReplyGetArrayElement(CallReply *rep, size_t idx) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_ARRAY) return NULL;
|
||||
if (rep->type != VALKEYMODULE_REPLY_ARRAY) return NULL;
|
||||
return callReplyGetCollectionElement(rep, idx, 1);
|
||||
}
|
||||
|
||||
/* Return a reply set element at a given index. Applicable to:
|
||||
* - REDISMODULE_REPLY_SET
|
||||
* - VALKEYMODULE_REPLY_SET
|
||||
*
|
||||
* The return value is borrowed from CallReply, so it must not be freed
|
||||
* explicitly or used after CallReply itself is freed.
|
||||
*/
|
||||
CallReply *callReplyGetSetElement(CallReply *rep, size_t idx) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_SET) return NULL;
|
||||
if (rep->type != VALKEYMODULE_REPLY_SET) return NULL;
|
||||
return callReplyGetCollectionElement(rep, idx, 1);
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ static int callReplyGetMapElementInternal(CallReply *rep, size_t idx, CallReply
|
||||
}
|
||||
|
||||
/* Retrieve a map reply key and value at a given index. Applicable to:
|
||||
* - REDISMODULE_REPLY_MAP
|
||||
* - VALKEYMODULE_REPLY_MAP
|
||||
*
|
||||
* The key and value are returned by reference through key and val,
|
||||
* which may also be NULL if not needed.
|
||||
@@ -415,7 +415,7 @@ static int callReplyGetMapElementInternal(CallReply *rep, size_t idx, CallReply
|
||||
* explicitly or used after CallReply itself is freed.
|
||||
*/
|
||||
int callReplyGetMapElement(CallReply *rep, size_t idx, CallReply **key, CallReply **val) {
|
||||
return callReplyGetMapElementInternal(rep, idx, key, val, REDISMODULE_REPLY_MAP);
|
||||
return callReplyGetMapElementInternal(rep, idx, key, val, VALKEYMODULE_REPLY_MAP);
|
||||
}
|
||||
|
||||
/* Return reply attribute, or NULL if it does not exist. Applicable to all replies.
|
||||
@@ -428,7 +428,7 @@ CallReply *callReplyGetAttribute(CallReply *rep) {
|
||||
}
|
||||
|
||||
/* Retrieve attribute reply key and value at a given index. Applicable to:
|
||||
* - REDISMODULE_REPLY_ATTRIBUTE
|
||||
* - VALKEYMODULE_REPLY_ATTRIBUTE
|
||||
*
|
||||
* The key and value are returned by reference through key and val,
|
||||
* which may also be NULL if not needed.
|
||||
@@ -440,11 +440,11 @@ CallReply *callReplyGetAttribute(CallReply *rep) {
|
||||
* explicitly or used after CallReply itself is freed.
|
||||
*/
|
||||
int callReplyGetAttributeElement(CallReply *rep, size_t idx, CallReply **key, CallReply **val) {
|
||||
return callReplyGetMapElementInternal(rep, idx, key, val, REDISMODULE_REPLY_MAP);
|
||||
return callReplyGetMapElementInternal(rep, idx, key, val, VALKEYMODULE_REPLY_MAP);
|
||||
}
|
||||
|
||||
/* Return a big number reply value. Applicable to:
|
||||
* - REDISMODULE_REPLY_BIG_NUMBER
|
||||
* - VALKEYMODULE_REPLY_BIG_NUMBER
|
||||
*
|
||||
* The returned values are borrowed from CallReply, so they must not be freed
|
||||
* explicitly or used after CallReply itself is freed.
|
||||
@@ -457,13 +457,13 @@ int callReplyGetAttributeElement(CallReply *rep, size_t idx, CallReply **key, Ca
|
||||
*/
|
||||
const char *callReplyGetBigNumber(CallReply *rep, size_t *len) {
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_BIG_NUMBER) return NULL;
|
||||
if (rep->type != VALKEYMODULE_REPLY_BIG_NUMBER) return NULL;
|
||||
*len = rep->len;
|
||||
return rep->val.str;
|
||||
}
|
||||
|
||||
/* Return a verbatim string reply value. Applicable to:
|
||||
* - REDISMODULE_REPLY_VERBATIM_STRING
|
||||
* - VALKEYMODULE_REPLY_VERBATIM_STRING
|
||||
*
|
||||
* If format is non-NULL, the verbatim reply format is also returned by value.
|
||||
*
|
||||
@@ -478,7 +478,7 @@ const char *callReplyGetBigNumber(CallReply *rep, size_t *len) {
|
||||
*/
|
||||
const char *callReplyGetVerbatim(CallReply *rep, size_t *len, const char **format){
|
||||
callReplyParse(rep);
|
||||
if (rep->type != REDISMODULE_REPLY_VERBATIM_STRING) return NULL;
|
||||
if (rep->type != VALKEYMODULE_REPLY_VERBATIM_STRING) return NULL;
|
||||
*len = rep->len;
|
||||
if (format) *format = rep->val.verbatim_str.format;
|
||||
return rep->val.verbatim_str.str;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
#include "resp_parser.h"
|
||||
|
||||
typedef struct CallReply CallReply;
|
||||
typedef void (*RedisModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data);
|
||||
typedef void (*ValkeyModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data);
|
||||
|
||||
CallReply *callReplyCreate(sds reply, list *deferred_error_list, void *private_data);
|
||||
CallReply *callReplyCreateError(sds reply, void *private_data);
|
||||
|
||||
+155
-78
@@ -43,6 +43,12 @@
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* Only primaries that own slots have voting rights.
|
||||
* Returns 1 if the node has voting rights, otherwise returns 0. */
|
||||
static inline int clusterNodeIsVotingPrimary(clusterNode *n) {
|
||||
return (n->flags & CLUSTER_NODE_MASTER) && n->numslots;
|
||||
}
|
||||
|
||||
/* A global reference to myself is handy to make code more clear.
|
||||
* Myself always points to server.cluster->myself, that is, the clusterNode
|
||||
* that represents this node. */
|
||||
@@ -119,6 +125,20 @@ static inline int defaultClientPort(void) {
|
||||
return server.tls_cluster ? server.tls_port : server.port;
|
||||
}
|
||||
|
||||
/* When a cluster command is called, we need to decide whether to return TLS info or
|
||||
* non-TLS info by the client's connection type. However if the command is called by
|
||||
* a Lua script or RM_call, there is no connection in the fake client, so we use
|
||||
* server.current_client here to get the real client if available. And if it is not
|
||||
* available (modules may call commands without a real client), we return the default
|
||||
* info, which is determined by server.tls_cluster. */
|
||||
static int shouldReturnTlsInfo(void) {
|
||||
if (server.current_client && server.current_client->conn) {
|
||||
return connIsTLS(server.current_client->conn);
|
||||
} else {
|
||||
return server.tls_cluster;
|
||||
}
|
||||
}
|
||||
|
||||
/* Links to the next and previous entries for keys in the same slot are stored
|
||||
* in the dict entry metadata. See Slot to Key API below. */
|
||||
#define dictEntryNextInSlot(de) \
|
||||
@@ -938,13 +958,13 @@ static void updateAnnouncedHumanNodename(clusterNode *node, char *new) {
|
||||
|
||||
|
||||
static void updateShardId(clusterNode *node, const char *shard_id) {
|
||||
if (memcmp(node->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
||||
if (shard_id && memcmp(node->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
||||
clusterRemoveNodeFromShard(node);
|
||||
memcpy(node->shard_id, shard_id, CLUSTER_NAMELEN);
|
||||
clusterAddNodeToShard(shard_id, node);
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
|
||||
}
|
||||
if (myself != node && myself->slaveof == node) {
|
||||
if (shard_id && myself != node && myself->slaveof == node) {
|
||||
if (memcmp(myself->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
|
||||
/* shard-id can diverge right after a rolling upgrade
|
||||
* from pre-7.2 releases */
|
||||
@@ -974,7 +994,7 @@ void clusterInit(void) {
|
||||
server.cluster->myself = NULL;
|
||||
server.cluster->currentEpoch = 0;
|
||||
server.cluster->state = CLUSTER_FAIL;
|
||||
server.cluster->size = 1;
|
||||
server.cluster->size = 0;
|
||||
server.cluster->todo_before_sleep = 0;
|
||||
server.cluster->nodes = dictCreate(&clusterNodesDictType);
|
||||
server.cluster->shards = dictCreate(&clusterSdsToListType);
|
||||
@@ -1120,6 +1140,9 @@ void clusterReset(int hard) {
|
||||
}
|
||||
dictReleaseIterator(di);
|
||||
|
||||
/* Empty the nodes blacklist. */
|
||||
dictEmpty(server.cluster->nodes_black_list, NULL);
|
||||
|
||||
/* Hard reset only: set epochs to 0, change node ID. */
|
||||
if (hard) {
|
||||
sds oldname;
|
||||
@@ -1670,6 +1693,7 @@ void clusterRenameNode(clusterNode *node, char *newname) {
|
||||
serverAssert(retval == DICT_OK);
|
||||
memcpy(node->name, newname, CLUSTER_NAMELEN);
|
||||
clusterAddNode(node);
|
||||
clusterAddNodeToShard(node->shard_id, node);
|
||||
}
|
||||
|
||||
void clusterAddNodeToShard(const char *shard_id, clusterNode *node) {
|
||||
@@ -1943,8 +1967,8 @@ void markNodeAsFailingIfNeeded(clusterNode *node) {
|
||||
if (nodeFailed(node)) return; /* Already FAILing. */
|
||||
|
||||
failures = clusterNodeFailureReportsCount(node);
|
||||
/* Also count myself as a voter if I'm a master. */
|
||||
if (nodeIsMaster(myself)) failures++;
|
||||
/* Also count myself as a voter if I'm a voting primary. */
|
||||
if (clusterNodeIsVotingPrimary(myself)) failures++;
|
||||
if (failures < needed_quorum) return; /* No weak agreement from masters. */
|
||||
|
||||
serverLog(LL_NOTICE,
|
||||
@@ -1987,7 +2011,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
|
||||
* 1) The FAIL state is old enough.
|
||||
* 2) It is yet serving slots from our point of view (not failed over).
|
||||
* Apparently no one is going to fix these slots, clear the FAIL flag. */
|
||||
if (nodeIsMaster(node) && node->numslots > 0 &&
|
||||
if (clusterNodeIsVotingPrimary(node) &&
|
||||
(now - node->fail_time) >
|
||||
(server.cluster_node_timeout * CLUSTER_FAIL_UNDO_TIME_MULT))
|
||||
{
|
||||
@@ -2136,8 +2160,8 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
|
||||
node = clusterLookupNode(g->nodename, CLUSTER_NAMELEN);
|
||||
if (node) {
|
||||
/* We already know this node.
|
||||
Handle failure reports, only when the sender is a master. */
|
||||
if (sender && nodeIsMaster(sender) && node != myself) {
|
||||
Handle failure reports, only when the sender is a voting primary. */
|
||||
if (sender && clusterNodeIsVotingPrimary(sender) && node != myself) {
|
||||
if (flags & (CLUSTER_NODE_FAIL|CLUSTER_NODE_PFAIL)) {
|
||||
if (clusterNodeAddFailureReport(node,sender)) {
|
||||
serverLog(LL_VERBOSE,
|
||||
@@ -2217,6 +2241,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
|
||||
node->tls_port = msg_tls_port;
|
||||
node->cport = ntohs(g->cport);
|
||||
clusterAddNode(node);
|
||||
clusterAddNodeToShard(node->shard_id, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2394,7 +2419,6 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc
|
||||
}
|
||||
clusterDelSlot(j);
|
||||
clusterAddSlot(sender,j);
|
||||
bitmapClearBit(server.cluster->owner_not_claiming_slot, j);
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|
|
||||
CLUSTER_TODO_UPDATE_STATE|
|
||||
CLUSTER_TODO_FSYNC_CONFIG);
|
||||
@@ -2567,7 +2591,7 @@ uint32_t writePingExt(clusterMsg *hdr, int gossipcount) {
|
||||
clusterMsgPingExtHumanNodename *ext = preparePingExt(cursor, CLUSTERMSG_EXT_TYPE_HUMAN_NODENAME, getHumanNodenamePingExtSize());
|
||||
memcpy(ext->human_nodename, myself->human_nodename, sdslen(myself->human_nodename));
|
||||
|
||||
/* Move the write cursor */
|
||||
/* Move the write cursor */
|
||||
cursor = nextPingExt(cursor);
|
||||
}
|
||||
|
||||
@@ -2609,9 +2633,7 @@ uint32_t writePingExt(clusterMsg *hdr, int gossipcount) {
|
||||
extensions++;
|
||||
|
||||
if (hdr != NULL) {
|
||||
if (extensions != 0) {
|
||||
hdr->mflags[0] |= CLUSTERMSG_FLAG0_EXT_DATA;
|
||||
}
|
||||
hdr->mflags[0] |= CLUSTERMSG_FLAG0_EXT_DATA;
|
||||
hdr->extensions = htons(extensions);
|
||||
}
|
||||
|
||||
@@ -2633,7 +2655,7 @@ void clusterProcessPingExtensions(clusterMsg *hdr, clusterLink *link) {
|
||||
if (type == CLUSTERMSG_EXT_TYPE_HOSTNAME) {
|
||||
clusterMsgPingExtHostname *hostname_ext = (clusterMsgPingExtHostname *) &(ext->ext[0].hostname);
|
||||
ext_hostname = hostname_ext->hostname;
|
||||
} else if (type == CLUSTERMSG_EXT_TYPE_HUMAN_NODENAME) {
|
||||
} else if (type == CLUSTERMSG_EXT_TYPE_HUMAN_NODENAME) {
|
||||
clusterMsgPingExtHumanNodename *humannodename_ext = (clusterMsgPingExtHumanNodename *) &(ext->ext[0].human_nodename);
|
||||
ext_humannodename = humannodename_ext->human_nodename;
|
||||
} else if (type == CLUSTERMSG_EXT_TYPE_FORGOTTEN_NODE) {
|
||||
@@ -2641,8 +2663,7 @@ void clusterProcessPingExtensions(clusterMsg *hdr, clusterLink *link) {
|
||||
clusterNode *n = clusterLookupNode(forgotten_node_ext->name, CLUSTER_NAMELEN);
|
||||
if (n && n != myself && !(nodeIsSlave(myself) && myself->slaveof == n)) {
|
||||
sds id = sdsnewlen(forgotten_node_ext->name, CLUSTER_NAMELEN);
|
||||
dictEntry *de = dictAddRaw(server.cluster->nodes_black_list, id, NULL);
|
||||
serverAssert(de != NULL);
|
||||
dictEntry *de = dictAddOrFind(server.cluster->nodes_black_list, id);
|
||||
uint64_t expire = server.unixtime + ntohu64(forgotten_node_ext->ttl);
|
||||
dictSetUnsignedIntegerVal(de, expire);
|
||||
clusterDelNode(n);
|
||||
@@ -2660,11 +2681,24 @@ void clusterProcessPingExtensions(clusterMsg *hdr, clusterLink *link) {
|
||||
/* We know this will be valid since we validated it ahead of time */
|
||||
ext = getNextPingExt(ext);
|
||||
}
|
||||
|
||||
/* If the node did not send us a hostname extension, assume
|
||||
* they don't have an announced hostname. Otherwise, we'll
|
||||
* set it now. */
|
||||
updateAnnouncedHostname(sender, ext_hostname);
|
||||
updateAnnouncedHumanNodename(sender, ext_humannodename);
|
||||
|
||||
/* If the node did not send us a shard-id extension, it means the sender
|
||||
* does not support it (old version), node->shard_id is randomly generated.
|
||||
* A cluster-wide consensus for the node's shard_id is not necessary.
|
||||
* The key is maintaining consistency of the shard_id on each individual 7.2 node.
|
||||
* As the cluster progressively upgrades to version 7.2, we can expect the shard_ids
|
||||
* across all nodes to naturally converge and align.
|
||||
*
|
||||
* If sender is a replica, set the shard_id to the shard_id of its master.
|
||||
* Otherwise, we'll set it now. */
|
||||
if (ext_shardid == NULL) ext_shardid = clusterNodeGetMaster(sender)->shard_id;
|
||||
|
||||
updateShardId(sender, ext_shardid);
|
||||
}
|
||||
|
||||
@@ -2719,6 +2753,11 @@ int clusterProcessPacket(clusterLink *link) {
|
||||
|
||||
if (type == server.cluster_drop_packet_filter) {
|
||||
serverLog(LL_WARNING, "Dropping packet that matches debug drop filter");
|
||||
if (server.debug_cluster_close_link_on_packet_drop) {
|
||||
freeClusterLink(link);
|
||||
serverLog(LL_WARNING, "Closing link for matching packet type %hu", type);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2791,6 +2830,10 @@ int clusterProcessPacket(clusterLink *link) {
|
||||
|
||||
sender = getNodeFromLinkAndMsg(link, hdr);
|
||||
|
||||
if (sender && (hdr->mflags[0] & CLUSTERMSG_FLAG0_EXT_DATA)) {
|
||||
sender->flags |= CLUSTER_NODE_EXTENSIONS_SUPPORTED;
|
||||
}
|
||||
|
||||
/* Update the last time we saw any data from this node. We
|
||||
* use this in order to avoid detecting a timeout from a node that
|
||||
* is just sending a lot of data in the cluster bus, for instance
|
||||
@@ -2889,6 +2932,14 @@ int clusterProcessPacket(clusterLink *link) {
|
||||
serverLog(LL_DEBUG,"%s packet received: %.40s",
|
||||
clusterGetMessageTypeString(type),
|
||||
link->node ? link->node->name : "NULL");
|
||||
|
||||
if (sender && (sender->flags & CLUSTER_NODE_MEET)) {
|
||||
/* Once we get a response for MEET from the sender, we can stop sending more MEET. */
|
||||
sender->flags &= ~CLUSTER_NODE_MEET;
|
||||
serverLog(LL_NOTICE, "Successfully completed handshake with %.40s (%s)", sender->name,
|
||||
sender->human_nodename);
|
||||
}
|
||||
|
||||
if (!link->inbound) {
|
||||
if (nodeInHandshake(link->node)) {
|
||||
/* If we already have this node, try to change the
|
||||
@@ -3008,6 +3059,10 @@ int clusterProcessPacket(clusterLink *link) {
|
||||
clusterNodeAddSlave(master,sender);
|
||||
sender->slaveof = master;
|
||||
|
||||
/* Update the shard_id when a replica is connected to its
|
||||
* primary in the very first time. */
|
||||
updateShardId(sender, master->shard_id);
|
||||
|
||||
/* Update config. */
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
|
||||
}
|
||||
@@ -3149,10 +3204,10 @@ int clusterProcessPacket(clusterLink *link) {
|
||||
clusterSendFailoverAuthIfNeeded(sender,hdr);
|
||||
} else if (type == CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK) {
|
||||
if (!sender) return 1; /* We don't know that node. */
|
||||
/* We consider this vote only if the sender is a master serving
|
||||
/* We consider this vote only if the sender is a primary serving
|
||||
* a non zero number of slots, and its currentEpoch is greater or
|
||||
* equal to epoch where this node started the election. */
|
||||
if (nodeIsMaster(sender) && sender->numslots > 0 &&
|
||||
if (clusterNodeIsVotingPrimary(sender) &&
|
||||
senderCurrentEpoch >= server.cluster->failover_auth_epoch)
|
||||
{
|
||||
server.cluster->failover_auth_count++;
|
||||
@@ -3303,12 +3358,18 @@ void clusterLinkConnectHandler(connection *conn) {
|
||||
* replaced by the clusterSendPing() call. */
|
||||
node->ping_sent = old_ping_sent;
|
||||
}
|
||||
/* We can clear the flag after the first packet is sent.
|
||||
* If we'll never receive a PONG, we'll never send new packets
|
||||
* to this node. Instead after the PONG is received and we
|
||||
* are no longer in meet/handshake status, we want to send
|
||||
* normal PING packets. */
|
||||
node->flags &= ~CLUSTER_NODE_MEET;
|
||||
|
||||
/* NOTE: Assume the current node is A and is asked to MEET another node B.
|
||||
* Once A sends MEET to B, it cannot clear the MEET flag for B until it
|
||||
* gets a response from B. If the MEET packet is not accepted by B due to
|
||||
* link failure, A must continue sending MEET. If A doesn't continue sending
|
||||
* MEET, A will know about B, but B will never add A. Every node always
|
||||
* responds to PINGs from unknown nodes with a PONG, so A will know about B
|
||||
* and continue sending PINGs. But B won't add A until it sees a MEET (or it
|
||||
* gets to know about A from a trusted third node C). In this case, clearing
|
||||
* the MEET flag here leads to asymmetry in the cluster membership. So, we
|
||||
* clear the MEET flag in clusterProcessPacket.
|
||||
*/
|
||||
|
||||
serverLog(LL_DEBUG,"Connecting with Node %.40s at %s:%d",
|
||||
node->name, node->ip, node->cport);
|
||||
@@ -3587,7 +3648,9 @@ void clusterSendPing(clusterLink *link, int type) {
|
||||
* to put inside the packet. */
|
||||
estlen = sizeof(clusterMsg) - sizeof(union clusterMsgData);
|
||||
estlen += (sizeof(clusterMsgDataGossip)*(wanted + pfail_wanted));
|
||||
estlen += writePingExt(NULL, 0);
|
||||
if (link->node && nodeSupportsExtensions(link->node)) {
|
||||
estlen += writePingExt(NULL, 0);
|
||||
}
|
||||
/* Note: clusterBuildMessageHdr() expects the buffer to be always at least
|
||||
* sizeof(clusterMsg) or more. */
|
||||
if (estlen < (int)sizeof(clusterMsg)) estlen = sizeof(clusterMsg);
|
||||
@@ -3655,7 +3718,13 @@ void clusterSendPing(clusterLink *link, int type) {
|
||||
|
||||
/* Compute the actual total length and send! */
|
||||
uint32_t totlen = 0;
|
||||
totlen += writePingExt(hdr, gossipcount);
|
||||
|
||||
if (link->node && nodeSupportsExtensions(link->node)) {
|
||||
totlen += writePingExt(hdr, gossipcount);
|
||||
} else {
|
||||
serverLog(LL_DEBUG, "Unable to send extensions data, however setting ext data flag to true");
|
||||
hdr->mflags[0] |= CLUSTERMSG_FLAG0_EXT_DATA;
|
||||
}
|
||||
totlen += sizeof(clusterMsg)-sizeof(union clusterMsgData);
|
||||
totlen += (sizeof(clusterMsgDataGossip)*gossipcount);
|
||||
serverAssert(gossipcount < USHRT_MAX);
|
||||
@@ -4234,7 +4303,7 @@ void clusterHandleSlaveFailover(void) {
|
||||
if (server.cluster->mf_end) {
|
||||
server.cluster->failover_auth_time = mstime();
|
||||
server.cluster->failover_auth_rank = 0;
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_FAILOVER);
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_FAILOVER);
|
||||
}
|
||||
serverLog(LL_NOTICE,
|
||||
"Start of election delayed for %lld milliseconds "
|
||||
@@ -4737,11 +4806,14 @@ void clusterCron(void) {
|
||||
/* Timeout reached. Set the node as possibly failing if it is
|
||||
* not already in this state. */
|
||||
if (!(node->flags & (CLUSTER_NODE_PFAIL|CLUSTER_NODE_FAIL))) {
|
||||
serverLog(LL_DEBUG,"*** NODE %.40s possibly failing",
|
||||
node->name);
|
||||
node->flags |= CLUSTER_NODE_PFAIL;
|
||||
update_state = 1;
|
||||
}
|
||||
if (clusterNodeIsVotingPrimary(myself) && server.cluster->size == 1) {
|
||||
markNodeAsFailingIfNeeded(node);
|
||||
} else {
|
||||
serverLog(LL_DEBUG,"*** NODE %.40s possibly failing", node->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
dictReleaseIterator(di);
|
||||
@@ -4770,7 +4842,7 @@ void clusterCron(void) {
|
||||
* a migration if there is no master with at least *two* working
|
||||
* slaves. */
|
||||
if (orphaned_masters && max_slaves >= 2 && this_slaves == max_slaves &&
|
||||
server.cluster_allow_replica_migration)
|
||||
server.cluster_allow_replica_migration)
|
||||
clusterHandleSlaveMigration(max_slaves);
|
||||
}
|
||||
|
||||
@@ -4922,14 +4994,12 @@ int clusterDelSlot(int slot) {
|
||||
if (!n) return C_ERR;
|
||||
|
||||
/* Cleanup the channels in master/replica as part of slot deletion. */
|
||||
list *nodes_for_slot = clusterGetNodesInMyShard(n);
|
||||
serverAssert(nodes_for_slot != NULL);
|
||||
listNode *ln = listSearchKey(nodes_for_slot, myself);
|
||||
if (ln != NULL) {
|
||||
removeChannelsInSlot(slot);
|
||||
}
|
||||
removeChannelsInSlot(slot);
|
||||
/* Clear the slot bit. */
|
||||
serverAssert(clusterNodeClearSlotBit(n,slot) == 1);
|
||||
server.cluster->slots[slot] = NULL;
|
||||
/* Make owner_not_claiming_slot flag consistent with slot ownership information. */
|
||||
bitmapClearBit(server.cluster->owner_not_claiming_slot, slot);
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
@@ -5017,7 +5087,7 @@ void clusterUpdateState(void) {
|
||||
while((de = dictNext(di)) != NULL) {
|
||||
clusterNode *node = dictGetVal(de);
|
||||
|
||||
if (nodeIsMaster(node) && node->numslots) {
|
||||
if (clusterNodeIsVotingPrimary(node)) {
|
||||
server.cluster->size++;
|
||||
if ((node->flags & (CLUSTER_NODE_FAIL|CLUSTER_NODE_PFAIL)) == 0)
|
||||
reachable_masters++;
|
||||
@@ -5570,7 +5640,7 @@ void addNodeToNodeReply(client *c, clusterNode *node) {
|
||||
}
|
||||
|
||||
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
|
||||
addReplyLongLong(c, getNodeClientPort(node, connIsTLS(c->conn)));
|
||||
addReplyLongLong(c, getNodeClientPort(node, shouldReturnTlsInfo()));
|
||||
addReplyBulkCBuffer(c, node->name, CLUSTER_NAMELEN);
|
||||
|
||||
/* Add the additional endpoint information, this is all the known networking information
|
||||
@@ -5689,37 +5759,6 @@ void addNodeDetailsToShardReply(client *c, clusterNode *node) {
|
||||
setDeferredMapLen(c, node_replylen, reply_count);
|
||||
}
|
||||
|
||||
/* Add the shard reply of a single shard based off the given primary node. */
|
||||
void addShardReplyForClusterShards(client *c, list *nodes) {
|
||||
serverAssert(listLength(nodes) > 0);
|
||||
clusterNode *n = listNodeValue(listFirst(nodes));
|
||||
addReplyMapLen(c, 2);
|
||||
addReplyBulkCString(c, "slots");
|
||||
|
||||
/* Use slot_info_pairs from the primary only */
|
||||
while (n->slaveof != NULL) n = n->slaveof;
|
||||
|
||||
if (n->slot_info_pairs != NULL) {
|
||||
serverAssert((n->slot_info_pairs_count % 2) == 0);
|
||||
addReplyArrayLen(c, n->slot_info_pairs_count);
|
||||
for (int i = 0; i < n->slot_info_pairs_count; i++)
|
||||
addReplyBulkLongLong(c, (unsigned long)n->slot_info_pairs[i]);
|
||||
} else {
|
||||
/* If no slot info pair is provided, the node owns no slots */
|
||||
addReplyArrayLen(c, 0);
|
||||
}
|
||||
|
||||
addReplyBulkCString(c, "nodes");
|
||||
addReplyArrayLen(c, listLength(nodes));
|
||||
listIter li;
|
||||
listRewind(nodes, &li);
|
||||
for (listNode *ln = listNext(&li); ln != NULL; ln = listNext(&li)) {
|
||||
clusterNode *n = listNodeValue(ln);
|
||||
addNodeDetailsToShardReply(c, n);
|
||||
clusterFreeNodesSlotsInfo(n);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add to the output buffer of the given client, an array of slot (start, end)
|
||||
* pair owned by the shard, also the primary and set of replica(s) along with
|
||||
* information about each node. */
|
||||
@@ -5729,7 +5768,41 @@ void clusterReplyShards(client *c) {
|
||||
clusterGenNodesSlotsInfo(0);
|
||||
dictIterator *di = dictGetSafeIterator(server.cluster->shards);
|
||||
for(dictEntry *de = dictNext(di); de != NULL; de = dictNext(di)) {
|
||||
addShardReplyForClusterShards(c, dictGetVal(de));
|
||||
list *nodes = dictGetVal(de);
|
||||
serverAssert(listLength(nodes) > 0);
|
||||
addReplyMapLen(c, 2);
|
||||
addReplyBulkCString(c, "slots");
|
||||
|
||||
/* Find a node which has the slot information served by this shard. */
|
||||
clusterNode *n = NULL;
|
||||
listIter li;
|
||||
listRewind(nodes, &li);
|
||||
for (listNode *ln = listNext(&li); ln != NULL; ln = listNext(&li)) {
|
||||
n = listNodeValue(ln);
|
||||
if (n->slot_info_pairs) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (n && n->slot_info_pairs != NULL) {
|
||||
serverAssert((n->slot_info_pairs_count % 2) == 0);
|
||||
addReplyArrayLen(c, n->slot_info_pairs_count);
|
||||
for (int i = 0; i < n->slot_info_pairs_count; i++) {
|
||||
addReplyLongLong(c, (unsigned long)n->slot_info_pairs[i]);
|
||||
}
|
||||
} else {
|
||||
/* If no slot info pair is provided, the node owns no slots */
|
||||
addReplyArrayLen(c, 0);
|
||||
}
|
||||
|
||||
addReplyBulkCString(c, "nodes");
|
||||
addReplyArrayLen(c, listLength(nodes));
|
||||
listRewind(nodes, &li);
|
||||
for (listNode *ln = listNext(&li); ln != NULL; ln = listNext(&li)) {
|
||||
clusterNode *n = listNodeValue(ln);
|
||||
addNodeDetailsToShardReply(c, n);
|
||||
clusterFreeNodesSlotsInfo(n);
|
||||
}
|
||||
}
|
||||
dictReleaseIterator(di);
|
||||
}
|
||||
@@ -5946,7 +6019,7 @@ NULL
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"nodes") && c->argc == 2) {
|
||||
/* CLUSTER NODES */
|
||||
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
|
||||
sds nodes = clusterGenNodesDescription(c, 0, connIsTLS(c->conn));
|
||||
sds nodes = clusterGenNodesDescription(c, 0, shouldReturnTlsInfo());
|
||||
addReplyVerbatim(c,nodes,sdslen(nodes),"txt");
|
||||
sdsfree(nodes);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"myid") && c->argc == 2) {
|
||||
@@ -6312,7 +6385,7 @@ NULL
|
||||
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
|
||||
addReplyArrayLen(c,n->numslaves);
|
||||
for (j = 0; j < n->numslaves; j++) {
|
||||
sds ni = clusterGenNodeDescription(c, n->slaves[j], connIsTLS(c->conn));
|
||||
sds ni = clusterGenNodeDescription(c, n->slaves[j], shouldReturnTlsInfo());
|
||||
addReplyBulkCString(c,ni);
|
||||
sdsfree(ni);
|
||||
}
|
||||
@@ -7438,7 +7511,7 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co
|
||||
error_code == CLUSTER_REDIR_ASK)
|
||||
{
|
||||
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
|
||||
int port = getNodeClientPort(n, connIsTLS(c->conn));
|
||||
int port = getNodeClientPort(n, shouldReturnTlsInfo());
|
||||
addReplyErrorSds(c,sdscatprintf(sdsempty(),
|
||||
"-%s %d %s:%d",
|
||||
(error_code == CLUSTER_REDIR_ASK) ? "ASK" : "MOVED",
|
||||
@@ -7469,6 +7542,10 @@ int clusterRedirectBlockedClientIfNeeded(client *c) {
|
||||
dictEntry *de;
|
||||
dictIterator *di;
|
||||
|
||||
/* If the client is blocked on module, but not on a specific key,
|
||||
* don't unblock it. */
|
||||
if (c->bstate.btype == BLOCKED_MODULE && !moduleClientIsBlockedOnKeys(c)) return 0;
|
||||
|
||||
/* If the cluster is down, unblock the client with the right error.
|
||||
* If the cluster is configured to allow reads on cluster down, we
|
||||
* still want to emit this error since a write will be required
|
||||
@@ -7478,11 +7555,6 @@ int clusterRedirectBlockedClientIfNeeded(client *c) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If the client is blocked on module, but not on a specific key,
|
||||
* don't unblock it (except for the CLUSTER_FAIL case above). */
|
||||
if (c->bstate.btype == BLOCKED_MODULE && !moduleClientIsBlockedOnKeys(c))
|
||||
return 0;
|
||||
|
||||
/* All keys must belong to the same slot, so check first key only. */
|
||||
di = dictGetIterator(c->bstate.keys);
|
||||
if ((de = dictNext(di)) != NULL) {
|
||||
@@ -7631,6 +7703,11 @@ unsigned int countKeysInSlot(unsigned int hashslot) {
|
||||
return (*server.db->slots_to_keys).by_slot[hashslot].count;
|
||||
}
|
||||
|
||||
clusterNode *clusterNodeGetMaster(clusterNode *node) {
|
||||
while (node->slaveof != NULL) node = node->slaveof;
|
||||
return node;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Operation(s) on channel rax tree.
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
@@ -56,6 +56,7 @@ typedef struct clusterLink {
|
||||
#define CLUSTER_NODE_MEET 128 /* Send a MEET message to this node */
|
||||
#define CLUSTER_NODE_MIGRATE_TO 256 /* Master eligible for replica migration. */
|
||||
#define CLUSTER_NODE_NOFAILOVER 512 /* Slave will not try to failover. */
|
||||
#define CLUSTER_NODE_EXTENSIONS_SUPPORTED 1024 /* This node supports extensions. */
|
||||
#define CLUSTER_NODE_NULL_NAME "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
|
||||
#define nodeIsMaster(n) ((n)->flags & CLUSTER_NODE_MASTER)
|
||||
@@ -66,6 +67,7 @@ typedef struct clusterLink {
|
||||
#define nodeTimedOut(n) ((n)->flags & CLUSTER_NODE_PFAIL)
|
||||
#define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL)
|
||||
#define nodeCantFailover(n) ((n)->flags & CLUSTER_NODE_NOFAILOVER)
|
||||
#define nodeSupportsExtensions(n) ((n)->flags & CLUSTER_NODE_EXTENSIONS_SUPPORTED)
|
||||
|
||||
/* Reasons why a slave is not able to failover. */
|
||||
#define CLUSTER_CANT_FAILOVER_NONE 0
|
||||
@@ -413,6 +415,7 @@ void clusterInit(void);
|
||||
void clusterInitListeners(void);
|
||||
void clusterCron(void);
|
||||
void clusterBeforeSleep(void);
|
||||
clusterNode *clusterNodeGetMaster(clusterNode *node);
|
||||
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
|
||||
int verifyClusterNodeId(const char *name, int length);
|
||||
clusterNode *clusterLookupNode(const char *name, int length);
|
||||
|
||||
+76
-21
@@ -1391,7 +1391,10 @@ struct COMMAND_ARG CLIENT_REPLY_Args[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* CLIENT SETINFO tips */
|
||||
#define CLIENT_SETINFO_Tips NULL
|
||||
const char *CLIENT_SETINFO_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -1419,7 +1422,10 @@ struct COMMAND_ARG CLIENT_SETINFO_Args[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* CLIENT SETNAME tips */
|
||||
#define CLIENT_SETNAME_Tips NULL
|
||||
const char *CLIENT_SETNAME_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -1543,8 +1549,8 @@ struct COMMAND_STRUCT CLIENT_Subcommands[] = {
|
||||
{MAKE_CMD("no-touch","Controls whether commands sent by the client affect the LRU/LFU of accessed keys.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_NO_TOUCH_History,0,CLIENT_NO_TOUCH_Tips,0,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,ACL_CATEGORY_CONNECTION,CLIENT_NO_TOUCH_Keyspecs,0,NULL,1),.args=CLIENT_NO_TOUCH_Args},
|
||||
{MAKE_CMD("pause","Suspends commands processing.","O(1)","3.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_PAUSE_History,1,CLIENT_PAUSE_Tips,0,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_PAUSE_Keyspecs,0,NULL,2),.args=CLIENT_PAUSE_Args},
|
||||
{MAKE_CMD("reply","Instructs the server whether to reply to commands.","O(1)","3.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_REPLY_History,0,CLIENT_REPLY_Tips,0,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_REPLY_Keyspecs,0,NULL,1),.args=CLIENT_REPLY_Args},
|
||||
{MAKE_CMD("setinfo","Sets information specific to the client or connection.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_SETINFO_History,0,CLIENT_SETINFO_Tips,0,clientSetinfoCommand,4,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_SETINFO_Keyspecs,0,NULL,1),.args=CLIENT_SETINFO_Args},
|
||||
{MAKE_CMD("setname","Sets the connection name.","O(1)","2.6.9",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_SETNAME_History,0,CLIENT_SETNAME_Tips,0,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_SETNAME_Keyspecs,0,NULL,1),.args=CLIENT_SETNAME_Args},
|
||||
{MAKE_CMD("setinfo","Sets information specific to the client or connection.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_SETINFO_History,0,CLIENT_SETINFO_Tips,2,clientSetinfoCommand,4,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_SETINFO_Keyspecs,0,NULL,1),.args=CLIENT_SETINFO_Args},
|
||||
{MAKE_CMD("setname","Sets the connection name.","O(1)","2.6.9",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_SETNAME_History,0,CLIENT_SETNAME_Tips,2,clientCommand,3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_SETNAME_Keyspecs,0,NULL,1),.args=CLIENT_SETNAME_Args},
|
||||
{MAKE_CMD("tracking","Controls server-assisted client-side caching for the connection.","O(1). Some options may introduce additional complexity.","6.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_TRACKING_History,0,CLIENT_TRACKING_Tips,0,clientCommand,-3,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_TRACKING_Keyspecs,0,NULL,7),.args=CLIENT_TRACKING_Args},
|
||||
{MAKE_CMD("trackinginfo","Returns information about server-assisted client-side caching for the connection.","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_TRACKINGINFO_History,0,CLIENT_TRACKINGINFO_Tips,0,clientCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_TRACKINGINFO_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("unblock","Unblocks a client blocked by a blocking command from a different connection.","O(log N) where N is the number of client connections","5.0.0",CMD_DOC_NONE,NULL,NULL,"connection",COMMAND_GROUP_CONNECTION,CLIENT_UNBLOCK_History,0,CLIENT_UNBLOCK_Tips,0,clientCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_CONNECTION,CLIENT_UNBLOCK_Keyspecs,0,NULL,2),.args=CLIENT_UNBLOCK_Args},
|
||||
@@ -5886,7 +5892,10 @@ struct COMMAND_ARG ACL_CAT_Args[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* ACL DELUSER tips */
|
||||
#define ACL_DELUSER_Tips NULL
|
||||
const char *ACL_DELUSER_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -6060,7 +6069,10 @@ struct COMMAND_ARG ACL_LOG_Args[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* ACL SAVE tips */
|
||||
#define ACL_SAVE_Tips NULL
|
||||
const char *ACL_SAVE_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -6080,7 +6092,10 @@ commandHistory ACL_SETUSER_History[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* ACL SETUSER tips */
|
||||
#define ACL_SETUSER_Tips NULL
|
||||
const char *ACL_SETUSER_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -6131,7 +6146,7 @@ struct COMMAND_ARG ACL_SETUSER_Args[] = {
|
||||
/* ACL command table */
|
||||
struct COMMAND_STRUCT ACL_Subcommands[] = {
|
||||
{MAKE_CMD("cat","Lists the ACL categories, or the commands inside a category.","O(1) since the categories and commands are a fixed set.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_CAT_History,0,ACL_CAT_Tips,0,aclCommand,-2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_CAT_Keyspecs,0,NULL,1),.args=ACL_CAT_Args},
|
||||
{MAKE_CMD("deluser","Deletes ACL users, and terminates their connections.","O(1) amortized time considering the typical user.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_DELUSER_History,0,ACL_DELUSER_Tips,0,aclCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_DELUSER_Keyspecs,0,NULL,1),.args=ACL_DELUSER_Args},
|
||||
{MAKE_CMD("deluser","Deletes ACL users, and terminates their connections.","O(1) amortized time considering the typical user.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_DELUSER_History,0,ACL_DELUSER_Tips,2,aclCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_DELUSER_Keyspecs,0,NULL,1),.args=ACL_DELUSER_Args},
|
||||
{MAKE_CMD("dryrun","Simulates the execution of a command by a user, without executing the command.","O(1).","7.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_DRYRUN_History,0,ACL_DRYRUN_Tips,0,aclCommand,-4,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_DRYRUN_Keyspecs,0,NULL,3),.args=ACL_DRYRUN_Args},
|
||||
{MAKE_CMD("genpass","Generates a pseudorandom, secure password that can be used to identify ACL users.","O(1)","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_GENPASS_History,0,ACL_GENPASS_Tips,0,aclCommand,-2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_GENPASS_Keyspecs,0,NULL,1),.args=ACL_GENPASS_Args},
|
||||
{MAKE_CMD("getuser","Lists the ACL rules of a user.","O(N). Where N is the number of password, command and pattern rules that the user has.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_GETUSER_History,2,ACL_GETUSER_Tips,0,aclCommand,3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_GETUSER_Keyspecs,0,NULL,1),.args=ACL_GETUSER_Args},
|
||||
@@ -6139,8 +6154,8 @@ struct COMMAND_STRUCT ACL_Subcommands[] = {
|
||||
{MAKE_CMD("list","Dumps the effective rules in ACL file format.","O(N). Where N is the number of configured users.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_LIST_History,0,ACL_LIST_Tips,0,aclCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_LIST_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("load","Reloads the rules from the configured ACL file.","O(N). Where N is the number of configured users.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_LOAD_History,0,ACL_LOAD_Tips,0,aclCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_LOAD_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("log","Lists recent security events generated due to ACL rules.","O(N) with N being the number of entries shown.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_LOG_History,1,ACL_LOG_Tips,0,aclCommand,-2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_LOG_Keyspecs,0,NULL,1),.args=ACL_LOG_Args},
|
||||
{MAKE_CMD("save","Saves the effective ACL rules in the configured ACL file.","O(N). Where N is the number of configured users.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_SAVE_History,0,ACL_SAVE_Tips,0,aclCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_SAVE_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("setuser","Creates and modifies an ACL user and its rules.","O(N). Where N is the number of rules provided.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_SETUSER_History,2,ACL_SETUSER_Tips,0,aclCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_SETUSER_Keyspecs,0,NULL,2),.args=ACL_SETUSER_Args},
|
||||
{MAKE_CMD("save","Saves the effective ACL rules in the configured ACL file.","O(N). Where N is the number of configured users.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_SAVE_History,0,ACL_SAVE_Tips,2,aclCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_SAVE_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("setuser","Creates and modifies an ACL user and its rules.","O(N). Where N is the number of rules provided.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_SETUSER_History,2,ACL_SETUSER_Tips,2,aclCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_SETUSER_Keyspecs,0,NULL,2),.args=ACL_SETUSER_Args},
|
||||
{MAKE_CMD("users","Lists all ACL users.","O(N). Where N is the number of configured users.","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_USERS_History,0,ACL_USERS_Tips,0,aclCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_USERS_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("whoami","Returns the authenticated username of the current connection.","O(1)","6.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ACL_WHOAMI_History,0,ACL_WHOAMI_Tips,0,aclCommand,2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,ACL_WHOAMI_Keyspecs,0,NULL,0)},
|
||||
{0}
|
||||
@@ -6446,7 +6461,10 @@ struct COMMAND_ARG CONFIG_GET_Args[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* CONFIG RESETSTAT tips */
|
||||
#define CONFIG_RESETSTAT_Tips NULL
|
||||
const char *CONFIG_RESETSTAT_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -6463,7 +6481,10 @@ struct COMMAND_ARG CONFIG_GET_Args[] = {
|
||||
|
||||
#ifndef SKIP_CMD_TIPS_TABLE
|
||||
/* CONFIG REWRITE tips */
|
||||
#define CONFIG_REWRITE_Tips NULL
|
||||
const char *CONFIG_REWRITE_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_CMD_KEY_SPECS_TABLE
|
||||
@@ -6508,8 +6529,8 @@ struct COMMAND_ARG CONFIG_SET_Args[] = {
|
||||
struct COMMAND_STRUCT CONFIG_Subcommands[] = {
|
||||
{MAKE_CMD("get","Returns the effective values of configuration parameters.","O(N) when N is the number of configuration parameters provided","2.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_GET_History,1,CONFIG_GET_Tips,0,configGetCommand,-3,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,CONFIG_GET_Keyspecs,0,NULL,1),.args=CONFIG_GET_Args},
|
||||
{MAKE_CMD("help","Returns helpful text about the different subcommands.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_HELP_History,0,CONFIG_HELP_Tips,0,configHelpCommand,2,CMD_LOADING|CMD_STALE,0,CONFIG_HELP_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("resetstat","Resets the server's statistics.","O(1)","2.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_RESETSTAT_History,0,CONFIG_RESETSTAT_Tips,0,configResetStatCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,CONFIG_RESETSTAT_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("rewrite","Persists the effective configuration to file.","O(1)","2.8.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_REWRITE_History,0,CONFIG_REWRITE_Tips,0,configRewriteCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,CONFIG_REWRITE_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("resetstat","Resets the server's statistics.","O(1)","2.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_RESETSTAT_History,0,CONFIG_RESETSTAT_Tips,2,configResetStatCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,CONFIG_RESETSTAT_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("rewrite","Persists the effective configuration to file.","O(1)","2.8.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_REWRITE_History,0,CONFIG_REWRITE_Tips,2,configRewriteCommand,2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,CONFIG_REWRITE_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("set","Sets configuration parameters in-flight.","O(N) when N is the number of configuration parameters provided","2.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,CONFIG_SET_History,1,CONFIG_SET_Tips,2,configSetCommand,-4,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,CONFIG_SET_Keyspecs,0,NULL,1),.args=CONFIG_SET_Args},
|
||||
{0}
|
||||
};
|
||||
@@ -6862,7 +6883,7 @@ const char *LATENCY_LATEST_Tips[] = {
|
||||
/* LATENCY RESET tips */
|
||||
const char *LATENCY_RESET_Tips[] = {
|
||||
"request_policy:all_nodes",
|
||||
"response_policy:all_succeeded",
|
||||
"response_policy:agg_sum",
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -7292,12 +7313,29 @@ struct COMMAND_ARG PSYNC_Args[] = {
|
||||
#define REPLICAOF_Keyspecs NULL
|
||||
#endif
|
||||
|
||||
/* REPLICAOF argument table */
|
||||
struct COMMAND_ARG REPLICAOF_Args[] = {
|
||||
/* REPLICAOF args host_port argument table */
|
||||
struct COMMAND_ARG REPLICAOF_args_host_port_Subargs[] = {
|
||||
{MAKE_ARG("host",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
{MAKE_ARG("port",ARG_TYPE_INTEGER,-1,NULL,NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
};
|
||||
|
||||
/* REPLICAOF args no_one argument table */
|
||||
struct COMMAND_ARG REPLICAOF_args_no_one_Subargs[] = {
|
||||
{MAKE_ARG("no",ARG_TYPE_PURE_TOKEN,-1,"NO",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
{MAKE_ARG("one",ARG_TYPE_PURE_TOKEN,-1,"ONE",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
};
|
||||
|
||||
/* REPLICAOF args argument table */
|
||||
struct COMMAND_ARG REPLICAOF_args_Subargs[] = {
|
||||
{MAKE_ARG("host-port",ARG_TYPE_BLOCK,-1,NULL,NULL,NULL,CMD_ARG_NONE,2,NULL),.subargs=REPLICAOF_args_host_port_Subargs},
|
||||
{MAKE_ARG("no-one",ARG_TYPE_BLOCK,-1,NULL,NULL,NULL,CMD_ARG_NONE,2,NULL),.subargs=REPLICAOF_args_no_one_Subargs},
|
||||
};
|
||||
|
||||
/* REPLICAOF argument table */
|
||||
struct COMMAND_ARG REPLICAOF_Args[] = {
|
||||
{MAKE_ARG("args",ARG_TYPE_ONEOF,-1,NULL,NULL,NULL,CMD_ARG_NONE,2,NULL),.subargs=REPLICAOF_args_Subargs},
|
||||
};
|
||||
|
||||
/********** RESTORE_ASKING ********************/
|
||||
|
||||
#ifndef SKIP_CMD_HISTORY_TABLE
|
||||
@@ -7416,12 +7454,29 @@ struct COMMAND_ARG SHUTDOWN_Args[] = {
|
||||
#define SLAVEOF_Keyspecs NULL
|
||||
#endif
|
||||
|
||||
/* SLAVEOF argument table */
|
||||
struct COMMAND_ARG SLAVEOF_Args[] = {
|
||||
/* SLAVEOF args host_port argument table */
|
||||
struct COMMAND_ARG SLAVEOF_args_host_port_Subargs[] = {
|
||||
{MAKE_ARG("host",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
{MAKE_ARG("port",ARG_TYPE_INTEGER,-1,NULL,NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
};
|
||||
|
||||
/* SLAVEOF args no_one argument table */
|
||||
struct COMMAND_ARG SLAVEOF_args_no_one_Subargs[] = {
|
||||
{MAKE_ARG("no",ARG_TYPE_PURE_TOKEN,-1,"NO",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
{MAKE_ARG("one",ARG_TYPE_PURE_TOKEN,-1,"ONE",NULL,NULL,CMD_ARG_NONE,0,NULL)},
|
||||
};
|
||||
|
||||
/* SLAVEOF args argument table */
|
||||
struct COMMAND_ARG SLAVEOF_args_Subargs[] = {
|
||||
{MAKE_ARG("host-port",ARG_TYPE_BLOCK,-1,NULL,NULL,NULL,CMD_ARG_NONE,2,NULL),.subargs=SLAVEOF_args_host_port_Subargs},
|
||||
{MAKE_ARG("no-one",ARG_TYPE_BLOCK,-1,NULL,NULL,NULL,CMD_ARG_NONE,2,NULL),.subargs=SLAVEOF_args_no_one_Subargs},
|
||||
};
|
||||
|
||||
/* SLAVEOF argument table */
|
||||
struct COMMAND_ARG SLAVEOF_Args[] = {
|
||||
{MAKE_ARG("args",ARG_TYPE_ONEOF,-1,NULL,NULL,NULL,CMD_ARG_NONE,2,NULL),.subargs=SLAVEOF_args_Subargs},
|
||||
};
|
||||
|
||||
/********** SLOWLOG GET ********************/
|
||||
|
||||
#ifndef SKIP_CMD_HISTORY_TABLE
|
||||
@@ -10731,12 +10786,12 @@ struct COMMAND_STRUCT redisCommandTable[] = {
|
||||
{MAKE_CMD("monitor","Listens for all requests received by the server in real-time.",NULL,"1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,MONITOR_History,0,MONITOR_Tips,0,monitorCommand,1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,MONITOR_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("psync","An internal command used in replication.",NULL,"2.8.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,PSYNC_History,0,PSYNC_Tips,0,syncCommand,-3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NO_MULTI|CMD_NOSCRIPT,0,PSYNC_Keyspecs,0,NULL,2),.args=PSYNC_Args},
|
||||
{MAKE_CMD("replconf","An internal command for configuring the replication stream.","O(1)","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLCONF_History,0,REPLCONF_Tips,0,replconfCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_ALLOW_BUSY,0,REPLCONF_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("replicaof","Configures a server as replica of another, or promotes it to a master.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLICAOF_History,0,REPLICAOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,REPLICAOF_Keyspecs,0,NULL,2),.args=REPLICAOF_Args},
|
||||
{MAKE_CMD("replicaof","Configures a server as replica of another, or promotes it to a master.","O(1)","5.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,REPLICAOF_History,0,REPLICAOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,REPLICAOF_Keyspecs,0,NULL,1),.args=REPLICAOF_Args},
|
||||
{MAKE_CMD("restore-asking","An internal command for migrating keys in a cluster.","O(1) to create the new key and additional O(N*M) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set values the complexity is O(N*M*log(N)) because inserting values into sorted sets is O(log(N)).","3.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,RESTORE_ASKING_History,3,RESTORE_ASKING_Tips,0,restoreCommand,-4,CMD_WRITE|CMD_DENYOOM|CMD_ASKING,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,RESTORE_ASKING_Keyspecs,1,NULL,7),.args=RESTORE_ASKING_Args},
|
||||
{MAKE_CMD("role","Returns the replication role.","O(1)","2.8.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,ROLE_History,0,ROLE_Tips,0,roleCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_SENTINEL,ACL_CATEGORY_ADMIN|ACL_CATEGORY_DANGEROUS,ROLE_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("save","Synchronously saves the database(s) to disk.","O(N) where N is the total number of keys in all databases","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SAVE_History,0,SAVE_Tips,0,saveCommand,1,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_NO_MULTI,0,SAVE_Keyspecs,0,NULL,0)},
|
||||
{MAKE_CMD("shutdown","Synchronously saves the database(s) to disk and shuts down the Redis server.","O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SHUTDOWN_History,1,SHUTDOWN_Tips,0,shutdownCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_NO_MULTI|CMD_SENTINEL|CMD_ALLOW_BUSY,0,SHUTDOWN_Keyspecs,0,NULL,4),.args=SHUTDOWN_Args},
|
||||
{MAKE_CMD("slaveof","Sets a Redis server as a replica of another, or promotes it to being a master.","O(1)","1.0.0",CMD_DOC_DEPRECATED,"`REPLICAOF`","5.0.0","server",COMMAND_GROUP_SERVER,SLAVEOF_History,0,SLAVEOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,SLAVEOF_Keyspecs,0,NULL,2),.args=SLAVEOF_Args},
|
||||
{MAKE_CMD("slaveof","Sets a Redis server as a replica of another, or promotes it to being a master.","O(1)","1.0.0",CMD_DOC_DEPRECATED,"`REPLICAOF`","5.0.0","server",COMMAND_GROUP_SERVER,SLAVEOF_History,0,SLAVEOF_Tips,0,replicaofCommand,3,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,SLAVEOF_Keyspecs,0,NULL,1),.args=SLAVEOF_Args},
|
||||
{MAKE_CMD("slowlog","A container for slow log commands.","Depends on subcommand.","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_History,0,SLOWLOG_Tips,0,NULL,-2,0,0,SLOWLOG_Keyspecs,0,NULL,0),.subcommands=SLOWLOG_Subcommands},
|
||||
{MAKE_CMD("swapdb","Swaps two Redis databases.","O(N) where N is the count of clients watching or blocking on keys from both databases.","4.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SWAPDB_History,0,SWAPDB_Tips,0,swapdbCommand,3,CMD_WRITE|CMD_FAST,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,SWAPDB_Keyspecs,0,NULL,2),.args=SWAPDB_Args},
|
||||
{MAKE_CMD("sync","An internal command used in replication.",NULL,"1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SYNC_History,0,SYNC_Tips,0,syncCommand,1,CMD_NO_ASYNC_LOADING|CMD_ADMIN|CMD_NO_MULTI|CMD_NOSCRIPT,0,SYNC_Keyspecs,0,NULL,0)},
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
"STALE",
|
||||
"SENTINEL"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"reply_schema": {
|
||||
"type": "integer",
|
||||
"description": "The number of users that were deleted"
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
"STALE",
|
||||
"SENTINEL"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"reply_schema": {
|
||||
"const": "OK"
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
"STALE",
|
||||
"SENTINEL"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"reply_schema": {
|
||||
"const": "OK"
|
||||
},
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
"STALE",
|
||||
"SENTINEL"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"acl_categories": [
|
||||
"CONNECTION"
|
||||
],
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
"STALE",
|
||||
"SENTINEL"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"acl_categories": [
|
||||
"CONNECTION"
|
||||
],
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"description": "an even number element array specifying the start and end slot numbers for slot ranges owned by this shard",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"nodes": {
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
"LOADING",
|
||||
"STALE"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"reply_schema": {
|
||||
"const": "OK"
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
"LOADING",
|
||||
"STALE"
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
],
|
||||
"reply_schema": {
|
||||
"const": "OK"
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
],
|
||||
"command_tips": [
|
||||
"REQUEST_POLICY:ALL_NODES",
|
||||
"RESPONSE_POLICY:ALL_SUCCEEDED"
|
||||
"RESPONSE_POLICY:AGG_SUM"
|
||||
],
|
||||
"reply_schema": {
|
||||
"type": "integer",
|
||||
|
||||
@@ -14,12 +14,40 @@
|
||||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "host",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"type": "integer"
|
||||
"name": "args",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "host-port",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "host",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "no-one",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "no",
|
||||
"type": "pure-token",
|
||||
"token": "NO"
|
||||
},
|
||||
{
|
||||
"name": "one",
|
||||
"type": "pure-token",
|
||||
"token": "ONE"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reply_schema": {
|
||||
|
||||
@@ -19,12 +19,40 @@
|
||||
],
|
||||
"arguments": [
|
||||
{
|
||||
"name": "host",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"type": "integer"
|
||||
"name": "args",
|
||||
"type": "oneof",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "host-port",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "host",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "no-one",
|
||||
"type": "block",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "no",
|
||||
"type": "pure-token",
|
||||
"token": "NO"
|
||||
},
|
||||
{
|
||||
"name": "one",
|
||||
"type": "pure-token",
|
||||
"token": "ONE"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reply_schema": {
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "GET option is specified, but no object was found ",
|
||||
"description": "GET option is specified, but no object was found",
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -117,7 +117,15 @@
|
||||
"description": "a list of sorted elements",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "GET option is specified, but no object was found",
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -634,8 +634,7 @@ void loadServerConfigFromString(char *config) {
|
||||
|
||||
loaderr:
|
||||
if (argv) sdsfreesplitres(argv,argc);
|
||||
fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n",
|
||||
REDIS_VERSION);
|
||||
fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", VALKEY_VERSION);
|
||||
if (i < totlines) {
|
||||
fprintf(stderr, "Reading the configuration file, at line %d\n", linenum);
|
||||
fprintf(stderr, ">>> '%s'\n", lines[i]);
|
||||
@@ -935,8 +934,8 @@ void configSetCommand(client *c) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
RedisModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names};
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_CONFIG, REDISMODULE_SUBEVENT_CONFIG_CHANGE, &cc);
|
||||
ValkeyModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names};
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_CONFIG, VALKEYMODULE_SUBEVENT_CONFIG_CHANGE, &cc);
|
||||
addReply(c,shared.ok);
|
||||
goto end;
|
||||
|
||||
@@ -1265,7 +1264,7 @@ int rewriteConfigRewriteLine(struct rewriteConfigState *state, const char *optio
|
||||
}
|
||||
|
||||
/* Write the long long 'bytes' value as a string in a way that is parsable
|
||||
* inside redis.conf. If possible uses the GB, MB, KB notation. */
|
||||
* inside valkey.conf. If possible uses the GB, MB, KB notation. */
|
||||
int rewriteConfigFormatMemory(char *buf, size_t len, long long bytes) {
|
||||
int gb = 1024*1024*1024;
|
||||
int mb = 1024*1024;
|
||||
@@ -1463,7 +1462,7 @@ void rewriteConfigReplicaOfOption(standardConfig *config, const char *name, stru
|
||||
|
||||
/* If this is a master, we want all the slaveof config options
|
||||
* in the file to be removed. Note that if this is a cluster instance
|
||||
* we don't want a slaveof directive inside redis.conf. */
|
||||
* we don't want a slaveof directive inside valkey.conf. */
|
||||
if (server.cluster_enabled || server.masterhost == NULL) {
|
||||
rewriteConfigMarkAsProcessed(state, name);
|
||||
return;
|
||||
@@ -1579,7 +1578,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) {
|
||||
dictIterator *di = dictGetIterator(modules);
|
||||
dictEntry *de;
|
||||
while ((de = dictNext(di)) != NULL) {
|
||||
struct RedisModule *module = dictGetVal(de);
|
||||
struct ValkeyModule *module = dictGetVal(de);
|
||||
line = sdsnew("loadmodule ");
|
||||
line = sdscatsds(line, module->loadmod->path);
|
||||
for (int i = 0; i < module->loadmod->argc; i++) {
|
||||
|
||||
+7
-3
@@ -40,8 +40,12 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
#define MAC_OS_10_6_DETECTED
|
||||
#endif
|
||||
|
||||
/* Define redis_fstat to fstat or fstat64() */
|
||||
#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
|
||||
#if defined(__APPLE__) && !defined(MAC_OS_10_6_DETECTED)
|
||||
#define redis_fstat fstat64
|
||||
#define redis_stat stat64
|
||||
#else
|
||||
@@ -96,7 +100,7 @@
|
||||
#define HAVE_ACCEPT4 1
|
||||
#endif
|
||||
|
||||
#if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
|
||||
#if (defined(__APPLE__) && defined(MAC_OS_10_6_DETECTED)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
|
||||
#define HAVE_KQUEUE 1
|
||||
#endif
|
||||
|
||||
@@ -293,7 +297,7 @@ void setproctitle(const char *fmt, ...);
|
||||
#include <kernel/OS.h>
|
||||
#define redis_set_thread_title(name) rename_thread(find_thread(0), name)
|
||||
#else
|
||||
#if (defined __APPLE__ && defined(MAC_OS_X_VERSION_10_7))
|
||||
#if (defined __APPLE__ && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
||||
int pthread_setname_np(const char *name);
|
||||
#include <pthread.h>
|
||||
#define redis_set_thread_title(name) pthread_setname_np(name)
|
||||
|
||||
@@ -495,7 +495,7 @@ long long emptyDbStructure(redisDb *dbarray, int dbnum, int async,
|
||||
long long emptyData(int dbnum, int flags, void(callback)(dict*)) {
|
||||
int async = (flags & EMPTYDB_ASYNC);
|
||||
int with_functions = !(flags & EMPTYDB_NOFUNCTIONS);
|
||||
RedisModuleFlushInfoV1 fi = {REDISMODULE_FLUSHINFO_VERSION,!async,dbnum};
|
||||
ValkeyModuleFlushInfoV1 fi = {VALKEYMODULE_FLUSHINFO_VERSION,!async,dbnum};
|
||||
long long removed = 0;
|
||||
|
||||
if (dbnum < -1 || dbnum >= server.dbnum) {
|
||||
@@ -504,8 +504,8 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) {
|
||||
}
|
||||
|
||||
/* Fire the flushdb modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_FLUSHDB,
|
||||
REDISMODULE_SUBEVENT_FLUSHDB_START,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_FLUSHDB,
|
||||
VALKEYMODULE_SUBEVENT_FLUSHDB_START,
|
||||
&fi);
|
||||
|
||||
/* Make sure the WATCHed keys are affected by the FLUSH* commands.
|
||||
@@ -530,8 +530,8 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) {
|
||||
|
||||
/* Also fire the end event. Note that this event will fire almost
|
||||
* immediately after the start event if the flush is asynchronous. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_FLUSHDB,
|
||||
REDISMODULE_SUBEVENT_FLUSHDB_END,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_FLUSHDB,
|
||||
VALKEYMODULE_SUBEVENT_FLUSHDB_END,
|
||||
&fi);
|
||||
|
||||
return removed;
|
||||
@@ -828,7 +828,7 @@ int objectTypeCompare(robj *o, long long target) {
|
||||
return 1;
|
||||
}
|
||||
/* module type compare */
|
||||
long long mt = (long long)REDISMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id);
|
||||
long long mt = (long long)VALKEYMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id);
|
||||
if (target != -mt)
|
||||
return 0;
|
||||
else
|
||||
@@ -921,7 +921,7 @@ long long getObjectTypeByName(char *name) {
|
||||
}
|
||||
|
||||
moduleType *mt = moduleTypeLookupModuleByNameIgnoreCase(name);
|
||||
if (mt != NULL) return -(REDISMODULE_TYPE_SIGN(mt->id));
|
||||
if (mt != NULL) return -(VALKEYMODULE_TYPE_SIGN(mt->id));
|
||||
|
||||
return LLONG_MAX;
|
||||
}
|
||||
@@ -1631,8 +1631,8 @@ void swapdbCommand(client *c) {
|
||||
addReplyError(c,"DB index is out of range");
|
||||
return;
|
||||
} else {
|
||||
RedisModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2};
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_SWAPDB,0,&si);
|
||||
ValkeyModuleSwapDbInfo si = {VALKEYMODULE_SWAPDBINFO_VERSION,id1,id2};
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_SWAPDB,0,&si);
|
||||
server.dirty++;
|
||||
addReply(c,shared.ok);
|
||||
}
|
||||
@@ -2294,7 +2294,8 @@ int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
|
||||
keys = getKeysPrepareResult(result, 1);
|
||||
keys[0].pos = 1; /* <sort-key> is always present. */
|
||||
keys[0].flags = CMD_KEY_RO | CMD_KEY_ACCESS;
|
||||
return 1;
|
||||
result->numkeys = 1;
|
||||
return result->numkeys;
|
||||
}
|
||||
|
||||
/* Helper function to extract keys from the SORT command.
|
||||
|
||||
+17
-11
@@ -253,7 +253,7 @@ void xorObjectDigest(redisDb *db, robj *keyobj, unsigned char *digest, robj *o)
|
||||
}
|
||||
streamIteratorStop(&si);
|
||||
} else if (o->type == OBJ_MODULE) {
|
||||
RedisModuleDigest md = {{0},{0},keyobj,db->id};
|
||||
ValkeyModuleDigest md = {{0},{0},keyobj,db->id};
|
||||
moduleValue *mv = o->ptr;
|
||||
moduleType *mt = mv->type;
|
||||
moduleInitDigestContext(md);
|
||||
@@ -431,6 +431,9 @@ void debugCommand(client *c) {
|
||||
" Show low level info about `key` and associated value.",
|
||||
"DROP-CLUSTER-PACKET-FILTER <packet-type>",
|
||||
" Drop all packets that match the filtered type. Set to -1 allow all packets.",
|
||||
"CLOSE-CLUSTER-LINK-ON-PACKET-DROP <0|1>",
|
||||
" This is valid only when DROP-CLUSTER-PACKET-FILTER is set to a valid packet type.",
|
||||
" When set to 1, the cluster link is closed after dropping a packet based on the filter.",
|
||||
"OOM",
|
||||
" Crash the server simulating an out-of-memory error.",
|
||||
"PANIC",
|
||||
@@ -599,8 +602,11 @@ NULL
|
||||
if (getLongFromObjectOrReply(c, c->argv[2], &packet_type, NULL) != C_OK)
|
||||
return;
|
||||
server.cluster_drop_packet_filter = packet_type;
|
||||
addReply(c,shared.ok);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) {
|
||||
addReply(c, shared.ok);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr, "close-cluster-link-on-packet-drop") && c->argc == 3) {
|
||||
server.debug_cluster_close_link_on_packet_drop = atoi(c->argv[2]->ptr) != 0;
|
||||
addReply(c, shared.ok);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr, "object") && c->argc == 3) {
|
||||
dictEntry *de;
|
||||
robj *val;
|
||||
char *strenc;
|
||||
@@ -1190,7 +1196,7 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
|
||||
} \
|
||||
return old_val; \
|
||||
} while(0)
|
||||
#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
|
||||
#if defined(__APPLE__) && !defined(MAC_OS_10_6_DETECTED)
|
||||
/* OSX < 10.6 */
|
||||
#if defined(__x86_64__)
|
||||
GET_SET_RETURN(uc->uc_mcontext->__ss.__rip, eip);
|
||||
@@ -1199,7 +1205,7 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
|
||||
#else
|
||||
GET_SET_RETURN(uc->uc_mcontext->__ss.__srr0, eip);
|
||||
#endif
|
||||
#elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)
|
||||
#elif defined(__APPLE__) && defined(MAC_OS_10_6_DETECTED)
|
||||
/* OSX >= 10.6 */
|
||||
#if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__)
|
||||
GET_SET_RETURN(uc->uc_mcontext->__ss.__rip, eip);
|
||||
@@ -1290,7 +1296,7 @@ void logRegisters(ucontext_t *uc) {
|
||||
} while(0)
|
||||
|
||||
/* OSX */
|
||||
#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)
|
||||
#if defined(__APPLE__) && defined(MAC_OS_10_6_DETECTED)
|
||||
/* OSX AMD64 */
|
||||
#if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__)
|
||||
serverLog(LL_WARNING,
|
||||
@@ -2122,7 +2128,7 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
|
||||
|
||||
bugReportStart();
|
||||
serverLog(LL_WARNING,
|
||||
"Redis %s crashed by signal: %d, si_code: %d", REDIS_VERSION, sig, info->si_code);
|
||||
SERVER_NAME " %s crashed by signal: %d, si_code: %d", VALKEY_VERSION, sig, info->si_code);
|
||||
if (sig == SIGSEGV || sig == SIGBUS) {
|
||||
serverLog(LL_WARNING,
|
||||
"Accessing address: %p", (void*)info->si_addr);
|
||||
@@ -2196,10 +2202,10 @@ void bugReportEnd(int killViaSignal, int sig) {
|
||||
serverLogRaw(LL_WARNING|LL_RAW,
|
||||
"\n=== REDIS BUG REPORT END. Make sure to include from START to END. ===\n\n"
|
||||
" Please report the crash by opening an issue on github:\n\n"
|
||||
" http://github.com/redis/redis/issues\n\n"
|
||||
" If a Redis module was involved, please open in the module's repo instead.\n\n"
|
||||
" Suspect RAM error? Use redis-server --test-memory to verify it.\n\n"
|
||||
" Some other issues could be detected by redis-server --check-system\n"
|
||||
" http://github.com/valkey-io/valkey/issues\n\n"
|
||||
" If a module was involved, please open in the module's repo instead.\n\n"
|
||||
" Suspect RAM error? Use valkey-server --test-memory to verify it.\n\n"
|
||||
" Some other issues could be detected by valkey-server --check-system\n"
|
||||
);
|
||||
|
||||
/* free(messages); Don't call free() with possibly corrupted memory. */
|
||||
|
||||
+5
-10
@@ -1414,30 +1414,25 @@ static int _dictExpandIfNeeded(dict *d)
|
||||
* table (global setting) or we should avoid it but the ratio between
|
||||
* elements/buckets is over the "safe" threshold, we resize doubling
|
||||
* the number of buckets. */
|
||||
if (!dictTypeExpandAllowed(d))
|
||||
return DICT_OK;
|
||||
if ((dict_can_resize == DICT_RESIZE_ENABLE &&
|
||||
d->ht_used[0] >= DICTHT_SIZE(d->ht_size_exp[0])) ||
|
||||
(dict_can_resize != DICT_RESIZE_FORBID &&
|
||||
d->ht_used[0] / DICTHT_SIZE(d->ht_size_exp[0]) > dict_force_resize_ratio))
|
||||
{
|
||||
if (!dictTypeExpandAllowed(d))
|
||||
return DICT_OK;
|
||||
return dictExpand(d, d->ht_used[0] + 1);
|
||||
}
|
||||
return DICT_OK;
|
||||
}
|
||||
|
||||
/* TODO: clz optimization */
|
||||
/* Our hash table capability is a power of two */
|
||||
static signed char _dictNextExp(unsigned long size)
|
||||
{
|
||||
unsigned char e = DICT_HT_INITIAL_EXP;
|
||||
|
||||
if (size <= DICT_HT_INITIAL_SIZE) return DICT_HT_INITIAL_EXP;
|
||||
if (size >= LONG_MAX) return (8*sizeof(long)-1);
|
||||
while(1) {
|
||||
if (((unsigned long)1<<e) >= size)
|
||||
return e;
|
||||
e++;
|
||||
}
|
||||
|
||||
return 8*sizeof(long) - __builtin_clzl(size-1);
|
||||
}
|
||||
|
||||
/* Finds and returns the position within the dict where the provided key should
|
||||
|
||||
+8
-1
@@ -27,6 +27,13 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file initializes the global LUA object and registers functions to call Valkey API from within the LUA language.
|
||||
* It heavily invokes LUA's C API documented at https://www.lua.org/pil/24.html. There are 2 entrypoint functions in this file:
|
||||
* 1. evalCommand() - Gets invoked every time a user runs LUA script via eval command on Valkey.
|
||||
* 2. scriptingInit() - initServer() function from server.c invokes this to initialize LUA at startup.
|
||||
* It is also invoked between 2 eval invocations to reset Lua.
|
||||
*/
|
||||
#include "server.h"
|
||||
#include "sha1.h"
|
||||
#include "rand.h"
|
||||
@@ -1579,7 +1586,7 @@ ldbLog(sdsnew(" next line of code."));
|
||||
luaPushError(lua, "script aborted for user request");
|
||||
luaError(lua);
|
||||
} else if (argc > 1 &&
|
||||
(!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) {
|
||||
(!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],REDIS_API_NAME) || !strcasecmp(argv[0],SERVER_API_NAME))) {
|
||||
ldbRedis(lua,argv,argc);
|
||||
ldbSendLogs();
|
||||
} else if ((!strcasecmp(argv[0],"p") || !strcasecmp(argv[0],"print"))) {
|
||||
|
||||
@@ -667,6 +667,7 @@ int performEvictions(void) {
|
||||
*
|
||||
* AOF and Output buffer memory will be freed eventually so
|
||||
* we only care about memory used by the key space. */
|
||||
enterExecutionUnit(1, 0);
|
||||
delta = (long long) zmalloc_used_memory();
|
||||
latencyStartMonitor(eviction_latency);
|
||||
dbGenericDelete(db,keyobj,server.lazyfree_lazy_eviction,DB_FLAG_KEY_EVICTED);
|
||||
@@ -679,6 +680,7 @@ int performEvictions(void) {
|
||||
notifyKeyspaceEvent(NOTIFY_EVICTED, "evicted",
|
||||
keyobj, db->id);
|
||||
propagateDeletion(db,keyobj,server.lazyfree_lazy_eviction);
|
||||
exitExecutionUnit();
|
||||
postExecutionUnitOperations();
|
||||
decrRefCount(keyobj);
|
||||
keys_freed++;
|
||||
|
||||
@@ -54,10 +54,12 @@
|
||||
int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
|
||||
long long t = dictGetSignedIntegerVal(de);
|
||||
if (now > t) {
|
||||
enterExecutionUnit(1, 0);
|
||||
sds key = dictGetKey(de);
|
||||
robj *keyobj = createStringObject(key,sdslen(key));
|
||||
deleteExpiredKeyAndPropagate(db,keyobj);
|
||||
decrRefCount(keyobj);
|
||||
exitExecutionUnit();
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
@@ -439,6 +439,11 @@ int luaEngineInitEngine(void) {
|
||||
luaRegisterVersion(lua_engine_ctx->lua);
|
||||
|
||||
luaSetErrorMetatable(lua_engine_ctx->lua);
|
||||
lua_setfield(lua_engine_ctx->lua, -2, SERVER_API_NAME);
|
||||
|
||||
/* Get the server object and also set it to the Redis API
|
||||
* compatibility namespace. */
|
||||
lua_getfield(lua_engine_ctx->lua, -1, SERVER_API_NAME);
|
||||
lua_setfield(lua_engine_ctx->lua, -2, REDIS_API_NAME);
|
||||
|
||||
luaSetErrorMetatable(lua_engine_ctx->lua);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@
|
||||
|
||||
#include "server.h"
|
||||
#include "script.h"
|
||||
#include "redismodule.h"
|
||||
#include "valkeymodule.h"
|
||||
|
||||
typedef struct functionLibInfo functionLibInfo;
|
||||
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ void lolwut6Command(client *c);
|
||||
* This is what unstable versions of Redis will display. */
|
||||
void lolwutUnstableCommand(client *c) {
|
||||
sds rendered = sdsnew("Redis ver. ");
|
||||
rendered = sdscat(rendered,REDIS_VERSION);
|
||||
rendered = sdscat(rendered,VALKEY_VERSION);
|
||||
rendered = sdscatlen(rendered,"\n",1);
|
||||
addReplyVerbatim(c,rendered,sdslen(rendered),"txt");
|
||||
sdsfree(rendered);
|
||||
@@ -52,7 +52,7 @@ void lolwutUnstableCommand(client *c) {
|
||||
|
||||
/* LOLWUT [VERSION <version>] [... version specific arguments ...] */
|
||||
void lolwutCommand(client *c) {
|
||||
char *v = REDIS_VERSION;
|
||||
char *v = VALKEY_VERSION;
|
||||
char verstr[64];
|
||||
|
||||
if (c->argc >= 3 && !strcasecmp(c->argv[1]->ptr,"version")) {
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ void lolwut5Command(client *c) {
|
||||
sds rendered = renderCanvas(canvas);
|
||||
rendered = sdscat(rendered,
|
||||
"\nGeorg Nees - schotter, plotter on paper, 1968. Redis ver. ");
|
||||
rendered = sdscat(rendered,REDIS_VERSION);
|
||||
rendered = sdscat(rendered,VALKEY_VERSION);
|
||||
rendered = sdscatlen(rendered,"\n",1);
|
||||
addReplyVerbatim(c,rendered,sdslen(rendered),"txt");
|
||||
sdsfree(rendered);
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ void lolwut6Command(client *c) {
|
||||
rendered = sdscat(rendered,
|
||||
"\nDedicated to the 8 bit game developers of past and present.\n"
|
||||
"Original 8 bit image from Plaguemon by hikikomori. Redis ver. ");
|
||||
rendered = sdscat(rendered,REDIS_VERSION);
|
||||
rendered = sdscat(rendered,VALKEY_VERSION);
|
||||
rendered = sdscatlen(rendered,"\n",1);
|
||||
addReplyVerbatim(c,rendered,sdslen(rendered),"txt");
|
||||
sdsfree(rendered);
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@ echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h
|
||||
echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h
|
||||
echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h
|
||||
echo "#include \"version.h\"" >> release.h
|
||||
echo "#define REDIS_BUILD_ID_RAW REDIS_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h
|
||||
echo "#define REDIS_BUILD_ID_RAW SERVER_NAME VALKEY_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h
|
||||
touch release.c # Force recompile of release.c
|
||||
|
||||
+2844
-2820
File diff suppressed because it is too large
Load Diff
@@ -25,42 +25,42 @@ all: helloworld.so hellotype.so helloblock.so hellocluster.so hellotimer.so hell
|
||||
.c.xo:
|
||||
$(CC) -I. $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@
|
||||
|
||||
helloworld.xo: ../redismodule.h
|
||||
helloworld.xo: ../valkeymodule.h
|
||||
|
||||
helloworld.so: helloworld.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
hellotype.xo: ../redismodule.h
|
||||
hellotype.xo: ../valkeymodule.h
|
||||
|
||||
hellotype.so: hellotype.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
helloblock.xo: ../redismodule.h
|
||||
helloblock.xo: ../valkeymodule.h
|
||||
|
||||
helloblock.so: helloblock.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lpthread -lc
|
||||
|
||||
hellocluster.xo: ../redismodule.h
|
||||
hellocluster.xo: ../valkeymodule.h
|
||||
|
||||
hellocluster.so: hellocluster.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
hellotimer.xo: ../redismodule.h
|
||||
hellotimer.xo: ../valkeymodule.h
|
||||
|
||||
hellotimer.so: hellotimer.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
hellodict.xo: ../redismodule.h
|
||||
hellodict.xo: ../valkeymodule.h
|
||||
|
||||
hellodict.so: hellodict.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
hellohook.xo: ../redismodule.h
|
||||
hellohook.xo: ../valkeymodule.h
|
||||
|
||||
hellohook.so: hellohook.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
helloacl.xo: ../redismodule.h
|
||||
helloacl.xo: ../valkeymodule.h
|
||||
|
||||
helloacl.so: helloacl.xo
|
||||
$(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc
|
||||
|
||||
+29
-29
@@ -31,7 +31,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -42,8 +42,8 @@ static uint64_t global_auth_client_id = 0;
|
||||
/* HELLOACL.REVOKE
|
||||
* Synchronously revoke access from a user. */
|
||||
int RevokeCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (global_auth_client_id) {
|
||||
RedisModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id);
|
||||
@@ -56,8 +56,8 @@ int RevokeCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in
|
||||
/* HELLOACL.RESET
|
||||
* Synchronously delete and re-create a module user. */
|
||||
int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
RedisModule_FreeModuleUser(global);
|
||||
global = RedisModule_CreateModuleUser("global");
|
||||
@@ -71,16 +71,16 @@ int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
/* Callback handler for user changes, use this to notify a module of
|
||||
* changes to users authenticated by the module */
|
||||
void HelloACL_UserChanged(uint64_t client_id, void *privdata) {
|
||||
REDISMODULE_NOT_USED(privdata);
|
||||
REDISMODULE_NOT_USED(client_id);
|
||||
VALKEYMODULE_NOT_USED(privdata);
|
||||
VALKEYMODULE_NOT_USED(client_id);
|
||||
global_auth_client_id = 0;
|
||||
}
|
||||
|
||||
/* HELLOACL.AUTHGLOBAL
|
||||
* Synchronously assigns a module user to the current context. */
|
||||
int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (global_auth_client_id) {
|
||||
return RedisModule_ReplyWithError(ctx, "Global user currently used");
|
||||
@@ -95,15 +95,15 @@ int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
|
||||
|
||||
/* Reply callback for auth command HELLOACL.AUTHASYNC */
|
||||
int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
size_t length;
|
||||
|
||||
RedisModuleString *user_string = RedisModule_GetBlockedClientPrivateData(ctx);
|
||||
const char *name = RedisModule_StringPtrLen(user_string, &length);
|
||||
|
||||
if (RedisModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) ==
|
||||
REDISMODULE_ERR) {
|
||||
VALKEYMODULE_ERR) {
|
||||
return RedisModule_ReplyWithError(ctx, "Invalid Username or password");
|
||||
}
|
||||
return RedisModule_ReplyWithSimpleString(ctx, "OK");
|
||||
@@ -111,14 +111,14 @@ int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
|
||||
/* Timeout callback for auth command HELLOACL.AUTHASYNC */
|
||||
int HelloACL_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
return RedisModule_ReplyWithSimpleString(ctx, "Request timedout");
|
||||
}
|
||||
|
||||
/* Private data frees data for HELLOACL.AUTHASYNC command. */
|
||||
void HelloACL_FreeData(RedisModuleCtx *ctx, void *privdata) {
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
VALKEYMODULE_NOT_USED(ctx);
|
||||
RedisModule_FreeString(NULL, privdata);
|
||||
}
|
||||
|
||||
@@ -151,33 +151,33 @@ int AuthAsyncCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
return RedisModule_ReplyWithError(ctx, "-ERR Can't start thread");
|
||||
}
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"helloacl",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"helloacl",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"helloacl.reset",
|
||||
ResetCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
ResetCommand_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"helloacl.revoke",
|
||||
RevokeCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
RevokeCommand_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"helloacl.authglobal",
|
||||
AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"helloacl.authasync",
|
||||
AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
global = RedisModule_CreateModuleUser("global");
|
||||
RedisModule_SetModuleUserACL(global, "allcommands");
|
||||
@@ -186,5 +186,5 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
|
||||
global_auth_client_id = 0;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+21
-21
@@ -31,7 +31,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
@@ -39,22 +39,22 @@
|
||||
|
||||
/* Reply callback for blocking command HELLO.BLOCK */
|
||||
int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
int *myint = RedisModule_GetBlockedClientPrivateData(ctx);
|
||||
return RedisModule_ReplyWithLongLong(ctx,*myint);
|
||||
}
|
||||
|
||||
/* Timeout callback for blocking command HELLO.BLOCK */
|
||||
int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
return RedisModule_ReplyWithSimpleString(ctx,"Request timedout");
|
||||
}
|
||||
|
||||
/* Private data freeing callback for HELLO.BLOCK command. */
|
||||
void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) {
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
VALKEYMODULE_NOT_USED(ctx);
|
||||
RedisModule_Free(privdata);
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
|
||||
long long delay;
|
||||
long long timeout;
|
||||
|
||||
if (RedisModule_StringToLongLong(argv[1],&delay) != REDISMODULE_OK) {
|
||||
if (RedisModule_StringToLongLong(argv[1],&delay) != VALKEYMODULE_OK) {
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid count");
|
||||
}
|
||||
|
||||
if (RedisModule_StringToLongLong(argv[2],&timeout) != REDISMODULE_OK) {
|
||||
if (RedisModule_StringToLongLong(argv[2],&timeout) != VALKEYMODULE_OK) {
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid count");
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
|
||||
RedisModule_AbortBlock(bc);
|
||||
return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread");
|
||||
}
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* The thread entry point that actually executes the blocking part
|
||||
@@ -141,7 +141,7 @@ void *HelloKeys_ThreadMain(void *arg) {
|
||||
long long cursor = 0;
|
||||
size_t replylen = 0;
|
||||
|
||||
RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
|
||||
RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN);
|
||||
do {
|
||||
RedisModule_ThreadSafeContextLock(ctx);
|
||||
RedisModuleCallReply *reply = RedisModule_Call(ctx,
|
||||
@@ -178,7 +178,7 @@ void *HelloKeys_ThreadMain(void *arg) {
|
||||
* that were in the database from the start to the end are guaranteed to be
|
||||
* there. */
|
||||
int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
if (argc != 1) return RedisModule_WrongArity(ctx);
|
||||
|
||||
pthread_t tid;
|
||||
@@ -195,24 +195,24 @@ int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int ar
|
||||
RedisModule_AbortBlock(bc);
|
||||
return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread");
|
||||
}
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"helloblock",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"helloblock",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.block",
|
||||
HelloBlock_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloBlock_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
if (RedisModule_CreateCommand(ctx,"hello.keys",
|
||||
HelloKeys_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloKeys_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+19
-19
@@ -30,7 +30,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -41,8 +41,8 @@
|
||||
|
||||
/* HELLOCLUSTER.PINGALL */
|
||||
int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PING,"Hey",3);
|
||||
return RedisModule_ReplyWithSimpleString(ctx, "OK");
|
||||
@@ -50,8 +50,8 @@ int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
|
||||
/* HELLOCLUSTER.LIST */
|
||||
int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
size_t numnodes;
|
||||
char **ids = RedisModule_GetClusterNodesList(ctx,&numnodes);
|
||||
@@ -64,17 +64,17 @@ int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
int port;
|
||||
RedisModule_GetClusterNodeInfo(ctx,ids[j],NULL,NULL,&port,NULL);
|
||||
RedisModule_ReplyWithArray(ctx,2);
|
||||
RedisModule_ReplyWithStringBuffer(ctx,ids[j],REDISMODULE_NODE_ID_LEN);
|
||||
RedisModule_ReplyWithStringBuffer(ctx,ids[j],VALKEYMODULE_NODE_ID_LEN);
|
||||
RedisModule_ReplyWithLongLong(ctx,port);
|
||||
}
|
||||
RedisModule_FreeClusterNodesList(ids);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* Callback for message MSGTYPE_PING */
|
||||
void PingReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) {
|
||||
RedisModule_Log(ctx,"notice","PING (type %d) RECEIVED from %.*s: '%.*s'",
|
||||
type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
|
||||
type,VALKEYMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
|
||||
RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PONG,"Ohi!",4);
|
||||
RedisModuleCallReply *reply = RedisModule_Call(ctx, "INCR", "c", "pings_received");
|
||||
RedisModule_FreeCallReply(reply);
|
||||
@@ -83,25 +83,25 @@ void PingReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, cons
|
||||
/* Callback for message MSGTYPE_PONG. */
|
||||
void PongReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) {
|
||||
RedisModule_Log(ctx,"notice","PONG (type %d) RECEIVED from %.*s: '%.*s'",
|
||||
type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
|
||||
type,VALKEYMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"hellocluster",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"hellocluster",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellocluster.pingall",
|
||||
PingallCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
PingallCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellocluster.list",
|
||||
ListCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
ListCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
/* Disable Redis Cluster sharding and redirections. This way every node
|
||||
* will be able to access every possible key, regardless of the hash slot.
|
||||
@@ -109,10 +109,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
* variable. Normally you do that in order for the distributed system
|
||||
* you create as a module to have total freedom in the keyspace
|
||||
* manipulation. */
|
||||
RedisModule_SetClusterFlags(ctx,REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION);
|
||||
RedisModule_SetClusterFlags(ctx,VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION);
|
||||
|
||||
/* Register our handlers for different message types. */
|
||||
RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PING,PingReceiver);
|
||||
RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PONG,PongReceiver);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+16
-16
@@ -33,7 +33,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -76,7 +76,7 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
|
||||
/* Parse the count argument. */
|
||||
long long count;
|
||||
if (RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) {
|
||||
if (RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) {
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid count");
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
char *key;
|
||||
size_t keylen;
|
||||
long long replylen = 0; /* Keep track of the emitted array len. */
|
||||
RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
|
||||
RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN);
|
||||
while((key = RedisModule_DictNextC(iter,&keylen,NULL)) != NULL) {
|
||||
if (replylen >= count) break;
|
||||
if (RedisModule_DictCompare(iter,"<=",argv[2]) == REDISMODULE_ERR)
|
||||
if (RedisModule_DictCompare(iter,"<=",argv[2]) == VALKEYMODULE_ERR)
|
||||
break;
|
||||
RedisModule_ReplyWithStringBuffer(ctx,key,keylen);
|
||||
replylen++;
|
||||
@@ -100,32 +100,32 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
|
||||
/* Cleanup. */
|
||||
RedisModule_DictIteratorStop(iter);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"hellodict",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"hellodict",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellodict.set",
|
||||
cmd_SET,"write deny-oom",1,1,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
cmd_SET,"write deny-oom",1,1,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellodict.get",
|
||||
cmd_GET,"readonly",1,1,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
cmd_GET,"readonly",1,1,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellodict.keyrange",
|
||||
cmd_KEYRANGE,"readonly",1,1,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
cmd_KEYRANGE,"readonly",1,1,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
/* Create our global dictionary. Here we'll set our keys and values. */
|
||||
Keyspace = RedisModule_CreateDict(NULL);
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+12
-12
@@ -30,7 +30,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -39,23 +39,23 @@
|
||||
/* Client state change callback. */
|
||||
void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data)
|
||||
{
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
REDISMODULE_NOT_USED(e);
|
||||
VALKEYMODULE_NOT_USED(ctx);
|
||||
VALKEYMODULE_NOT_USED(e);
|
||||
|
||||
RedisModuleClientInfo *ci = data;
|
||||
printf("Client %s event for client #%llu %s:%d\n",
|
||||
(sub == REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ?
|
||||
(sub == VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ?
|
||||
"connection" : "disconnection",
|
||||
(unsigned long long)ci->id,ci->addr,ci->port);
|
||||
}
|
||||
|
||||
void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data)
|
||||
{
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
REDISMODULE_NOT_USED(e);
|
||||
VALKEYMODULE_NOT_USED(ctx);
|
||||
VALKEYMODULE_NOT_USED(e);
|
||||
|
||||
RedisModuleFlushInfo *fi = data;
|
||||
if (sub == REDISMODULE_SUBEVENT_FLUSHDB_START) {
|
||||
if (sub == VALKEYMODULE_SUBEVENT_FLUSHDB_START) {
|
||||
if (fi->dbnum != -1) {
|
||||
RedisModuleCallReply *reply;
|
||||
reply = RedisModule_Call(ctx,"DBSIZE","");
|
||||
@@ -78,15 +78,15 @@ void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"hellohook",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"hellohook",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
RedisModule_SubscribeToServerEvent(ctx,
|
||||
RedisModuleEvent_ClientChange, clientChangeCallback);
|
||||
RedisModule_SubscribeToServerEvent(ctx,
|
||||
RedisModuleEvent_FlushDB, flushdbCallback);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+12
-12
@@ -30,7 +30,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -38,22 +38,22 @@
|
||||
|
||||
/* Timer callback. */
|
||||
void timerHandler(RedisModuleCtx *ctx, void *data) {
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
VALKEYMODULE_NOT_USED(ctx);
|
||||
printf("Fired %s!\n", (char *)data);
|
||||
RedisModule_Free(data);
|
||||
}
|
||||
|
||||
/* HELLOTIMER.TIMER*/
|
||||
int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
for (int j = 0; j < 10; j++) {
|
||||
int delay = rand() % 5000;
|
||||
char *buf = RedisModule_Alloc(256);
|
||||
snprintf(buf,256,"After %d", delay);
|
||||
RedisModuleTimerID tid = RedisModule_CreateTimer(ctx,delay,timerHandler,buf);
|
||||
REDISMODULE_NOT_USED(tid);
|
||||
VALKEYMODULE_NOT_USED(tid);
|
||||
}
|
||||
return RedisModule_ReplyWithSimpleString(ctx, "OK");
|
||||
}
|
||||
@@ -61,15 +61,15 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"hellotimer",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"hellotimer",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellotimer.timer",
|
||||
TimerCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
TimerCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+47
-47
@@ -35,7 +35,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -105,22 +105,22 @@ int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
|
||||
if (argc != 3) return RedisModule_WrongArity(ctx);
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
int type = RedisModule_KeyType(key);
|
||||
if (type != REDISMODULE_KEYTYPE_EMPTY &&
|
||||
if (type != VALKEYMODULE_KEYTYPE_EMPTY &&
|
||||
RedisModule_ModuleTypeGetType(key) != HelloType)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
long long value;
|
||||
if ((RedisModule_StringToLongLong(argv[2],&value) != REDISMODULE_OK)) {
|
||||
if ((RedisModule_StringToLongLong(argv[2],&value) != VALKEYMODULE_OK)) {
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid value: must be a signed 64 bit integer");
|
||||
}
|
||||
|
||||
/* Create an empty value object if the key is currently empty. */
|
||||
struct HelloTypeObject *hto;
|
||||
if (type == REDISMODULE_KEYTYPE_EMPTY) {
|
||||
if (type == VALKEYMODULE_KEYTYPE_EMPTY) {
|
||||
hto = createHelloTypeObject();
|
||||
RedisModule_ModuleTypeSetValue(key,HelloType,hto);
|
||||
} else {
|
||||
@@ -133,7 +133,7 @@ int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
|
||||
RedisModule_ReplyWithLongLong(ctx,hto->len);
|
||||
RedisModule_ReplicateVerbatim(ctx);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLOTYPE.RANGE key first count */
|
||||
@@ -142,17 +142,17 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
|
||||
if (argc != 4) return RedisModule_WrongArity(ctx);
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
int type = RedisModule_KeyType(key);
|
||||
if (type != REDISMODULE_KEYTYPE_EMPTY &&
|
||||
if (type != VALKEYMODULE_KEYTYPE_EMPTY &&
|
||||
RedisModule_ModuleTypeGetType(key) != HelloType)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
long long first, count;
|
||||
if (RedisModule_StringToLongLong(argv[2],&first) != REDISMODULE_OK ||
|
||||
RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK ||
|
||||
if (RedisModule_StringToLongLong(argv[2],&first) != VALKEYMODULE_OK ||
|
||||
RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK ||
|
||||
first < 0 || count < 0)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,
|
||||
@@ -161,7 +161,7 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
|
||||
struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key);
|
||||
struct HelloTypeNode *node = hto ? hto->head : NULL;
|
||||
RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
|
||||
RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN);
|
||||
long long arraylen = 0;
|
||||
while(node && count--) {
|
||||
RedisModule_ReplyWithLongLong(ctx,node->value);
|
||||
@@ -169,7 +169,7 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
node = node->next;
|
||||
}
|
||||
RedisModule_ReplySetArrayLength(ctx,arraylen);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLOTYPE.LEN key */
|
||||
@@ -178,17 +178,17 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
|
||||
if (argc != 2) return RedisModule_WrongArity(ctx);
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
int type = RedisModule_KeyType(key);
|
||||
if (type != REDISMODULE_KEYTYPE_EMPTY &&
|
||||
if (type != VALKEYMODULE_KEYTYPE_EMPTY &&
|
||||
RedisModule_ModuleTypeGetType(key) != HelloType)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key);
|
||||
RedisModule_ReplyWithLongLong(ctx,hto ? hto->len : 0);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* ====================== Example of a blocking command ==================== */
|
||||
@@ -197,17 +197,17 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
* called when the key we blocked for is ready: we need to check if we
|
||||
* can really serve the client, and reply OK or ERR accordingly. */
|
||||
int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
RedisModuleString *keyname = RedisModule_GetBlockedClientReadyKey(ctx);
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,REDISMODULE_READ);
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,VALKEYMODULE_READ);
|
||||
int type = RedisModule_KeyType(key);
|
||||
if (type != REDISMODULE_KEYTYPE_MODULE ||
|
||||
if (type != VALKEYMODULE_KEYTYPE_MODULE ||
|
||||
RedisModule_ModuleTypeGetType(key) != HelloType)
|
||||
{
|
||||
RedisModule_CloseKey(key);
|
||||
return REDISMODULE_ERR;
|
||||
return VALKEYMODULE_ERR;
|
||||
}
|
||||
|
||||
/* In case the key is able to serve our blocked client, let's directly
|
||||
@@ -218,14 +218,14 @@ int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
|
||||
/* Timeout callback for blocking command HELLOTYPE.BRANGE */
|
||||
int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
return RedisModule_ReplyWithSimpleString(ctx,"Request timedout");
|
||||
}
|
||||
|
||||
/* Private data freeing callback for HELLOTYPE.BRANGE command. */
|
||||
void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) {
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
VALKEYMODULE_NOT_USED(ctx);
|
||||
RedisModule_Free(privdata);
|
||||
}
|
||||
|
||||
@@ -236,31 +236,31 @@ int HelloTypeBRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
if (argc != 5) return RedisModule_WrongArity(ctx);
|
||||
RedisModule_AutoMemory(ctx); /* Use automatic memory management. */
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
int type = RedisModule_KeyType(key);
|
||||
if (type != REDISMODULE_KEYTYPE_EMPTY &&
|
||||
if (type != VALKEYMODULE_KEYTYPE_EMPTY &&
|
||||
RedisModule_ModuleTypeGetType(key) != HelloType)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
/* Parse the timeout before even trying to serve the client synchronously,
|
||||
* so that we always fail ASAP on syntax errors. */
|
||||
long long timeout;
|
||||
if (RedisModule_StringToLongLong(argv[4],&timeout) != REDISMODULE_OK) {
|
||||
if (RedisModule_StringToLongLong(argv[4],&timeout) != VALKEYMODULE_OK) {
|
||||
return RedisModule_ReplyWithError(ctx,
|
||||
"ERR invalid timeout parameter");
|
||||
}
|
||||
|
||||
/* Can we serve the reply synchronously? */
|
||||
if (type != REDISMODULE_KEYTYPE_EMPTY) {
|
||||
if (type != VALKEYMODULE_KEYTYPE_EMPTY) {
|
||||
return HelloTypeRange_RedisCommand(ctx,argv,argc-1);
|
||||
}
|
||||
|
||||
/* Otherwise let's block on the key. */
|
||||
void *privdata = RedisModule_Alloc(100);
|
||||
RedisModule_BlockClientOnKeys(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout,argv+1,1,privdata);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* ========================== "hellotype" type methods ======================= */
|
||||
@@ -323,14 +323,14 @@ void HelloTypeDigest(RedisModuleDigest *md, void *value) {
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"hellotype",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"hellotype",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
RedisModuleTypeMethods tm = {
|
||||
.version = REDISMODULE_TYPE_METHOD_VERSION,
|
||||
.version = VALKEYMODULE_TYPE_METHOD_VERSION,
|
||||
.rdb_load = HelloTypeRdbLoad,
|
||||
.rdb_save = HelloTypeRdbSave,
|
||||
.aof_rewrite = HelloTypeAofRewrite,
|
||||
@@ -340,23 +340,23 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
};
|
||||
|
||||
HelloType = RedisModule_CreateDataType(ctx,"hellotype",0,&tm);
|
||||
if (HelloType == NULL) return REDISMODULE_ERR;
|
||||
if (HelloType == NULL) return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellotype.insert",
|
||||
HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellotype.range",
|
||||
HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloTypeRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellotype.len",
|
||||
HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloTypeLen_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hellotype.brange",
|
||||
HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloTypeBRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+110
-110
@@ -34,7 +34,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../redismodule.h"
|
||||
#include "../valkeymodule.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@@ -46,10 +46,10 @@
|
||||
* fetch the currently selected DB, the other in order to send the client
|
||||
* an integer reply as response. */
|
||||
int HelloSimple_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
RedisModule_ReplyWithLongLong(ctx,RedisModule_GetSelectedDb(ctx));
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.PUSH.NATIVE re-implements RPUSH, and shows the low level modules API
|
||||
@@ -63,13 +63,13 @@ int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
if (argc != 3) return RedisModule_WrongArity(ctx);
|
||||
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
|
||||
RedisModule_ListPush(key,REDISMODULE_LIST_TAIL,argv[2]);
|
||||
RedisModule_ListPush(key,VALKEYMODULE_LIST_TAIL,argv[2]);
|
||||
size_t newlen = RedisModule_ValueLength(key);
|
||||
RedisModule_CloseKey(key);
|
||||
RedisModule_ReplyWithLongLong(ctx,newlen);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.PUSH.CALL implements RPUSH using an higher level approach, calling
|
||||
@@ -87,7 +87,7 @@ int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in
|
||||
long long len = RedisModule_CallReplyInteger(reply);
|
||||
RedisModule_FreeCallReply(reply);
|
||||
RedisModule_ReplyWithLongLong(ctx,len);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.PUSH.CALL2
|
||||
@@ -102,7 +102,7 @@ int HelloPushCall2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]);
|
||||
RedisModule_ReplyWithCallReply(ctx,reply);
|
||||
RedisModule_FreeCallReply(reply);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.LIST.SUM.LEN returns the total length of all the items inside
|
||||
@@ -124,7 +124,7 @@ int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
}
|
||||
RedisModule_FreeCallReply(reply);
|
||||
RedisModule_ReplyWithLongLong(ctx,strlen);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.LIST.SPLICE srclist dstlist count
|
||||
@@ -135,23 +135,23 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
if (argc != 4) return RedisModule_WrongArity(ctx);
|
||||
|
||||
RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
|
||||
/* Src and dst key must be empty or lists. */
|
||||
if ((RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) ||
|
||||
(RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY))
|
||||
if ((RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_EMPTY) ||
|
||||
(RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_EMPTY))
|
||||
{
|
||||
RedisModule_CloseKey(srckey);
|
||||
RedisModule_CloseKey(dstkey);
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
long long count;
|
||||
if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) ||
|
||||
if ((RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) ||
|
||||
(count < 0)) {
|
||||
RedisModule_CloseKey(srckey);
|
||||
RedisModule_CloseKey(dstkey);
|
||||
@@ -161,9 +161,9 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
while(count-- > 0) {
|
||||
RedisModuleString *ele;
|
||||
|
||||
ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL);
|
||||
ele = RedisModule_ListPop(srckey,VALKEYMODULE_LIST_TAIL);
|
||||
if (ele == NULL) break;
|
||||
RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele);
|
||||
RedisModule_ListPush(dstkey,VALKEYMODULE_LIST_HEAD,ele);
|
||||
RedisModule_FreeString(ctx,ele);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
RedisModule_CloseKey(srckey);
|
||||
RedisModule_CloseKey(dstkey);
|
||||
RedisModule_ReplyWithLongLong(ctx,len);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* Like the HELLO.LIST.SPLICE above, but uses automatic memory management
|
||||
@@ -182,21 +182,21 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
|
||||
RedisModule_AutoMemory(ctx);
|
||||
|
||||
RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
|
||||
/* Src and dst key must be empty or lists. */
|
||||
if ((RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) ||
|
||||
(RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY))
|
||||
if ((RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_EMPTY) ||
|
||||
(RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_LIST &&
|
||||
RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_EMPTY))
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
long long count;
|
||||
if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) ||
|
||||
if ((RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) ||
|
||||
(count < 0))
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid count");
|
||||
@@ -205,14 +205,14 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
|
||||
while(count-- > 0) {
|
||||
RedisModuleString *ele;
|
||||
|
||||
ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL);
|
||||
ele = RedisModule_ListPop(srckey,VALKEYMODULE_LIST_TAIL);
|
||||
if (ele == NULL) break;
|
||||
RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele);
|
||||
RedisModule_ListPush(dstkey,VALKEYMODULE_LIST_HEAD,ele);
|
||||
}
|
||||
|
||||
size_t len = RedisModule_ValueLength(srckey);
|
||||
RedisModule_ReplyWithLongLong(ctx,len);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.RAND.ARRAY <count>
|
||||
@@ -221,7 +221,7 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
|
||||
int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
if (argc != 2) return RedisModule_WrongArity(ctx);
|
||||
long long count;
|
||||
if (RedisModule_StringToLongLong(argv[1],&count) != REDISMODULE_OK ||
|
||||
if (RedisModule_StringToLongLong(argv[1],&count) != VALKEYMODULE_OK ||
|
||||
count < 0)
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid count");
|
||||
|
||||
@@ -230,7 +230,7 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
* the elements of the array. */
|
||||
RedisModule_ReplyWithArray(ctx,count);
|
||||
while(count--) RedisModule_ReplyWithLongLong(ctx,rand());
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* This is a simple command to test replication. Because of the "!" modified
|
||||
@@ -239,8 +239,8 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
* comments the function implementation). */
|
||||
int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
{
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
VALKEYMODULE_NOT_USED(argv);
|
||||
VALKEYMODULE_NOT_USED(argc);
|
||||
RedisModule_AutoMemory(ctx);
|
||||
|
||||
/* This will be replicated *after* the two INCR statements, since
|
||||
@@ -262,7 +262,7 @@ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
|
||||
|
||||
RedisModule_ReplyWithLongLong(ctx,0);
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* Another command to show replication. In this case, we call
|
||||
@@ -280,27 +280,27 @@ int HelloRepl2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
|
||||
|
||||
RedisModule_AutoMemory(ctx); /* Use automatic memory management. */
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
|
||||
if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST)
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_LIST)
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
|
||||
size_t listlen = RedisModule_ValueLength(key);
|
||||
long long sum = 0;
|
||||
|
||||
/* Rotate and increment. */
|
||||
while(listlen--) {
|
||||
RedisModuleString *ele = RedisModule_ListPop(key,REDISMODULE_LIST_TAIL);
|
||||
RedisModuleString *ele = RedisModule_ListPop(key,VALKEYMODULE_LIST_TAIL);
|
||||
long long val;
|
||||
if (RedisModule_StringToLongLong(ele,&val) != REDISMODULE_OK) val = 0;
|
||||
if (RedisModule_StringToLongLong(ele,&val) != VALKEYMODULE_OK) val = 0;
|
||||
val++;
|
||||
sum += val;
|
||||
RedisModuleString *newele = RedisModule_CreateStringFromLongLong(ctx,val);
|
||||
RedisModule_ListPush(key,REDISMODULE_LIST_HEAD,newele);
|
||||
RedisModule_ListPush(key,VALKEYMODULE_LIST_HEAD,newele);
|
||||
}
|
||||
RedisModule_ReplyWithLongLong(ctx,sum);
|
||||
RedisModule_ReplicateVerbatim(ctx);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* This is an example of strings DMA access. Given a key containing a string
|
||||
@@ -315,19 +315,19 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
if (argc != 2) return RedisModule_WrongArity(ctx);
|
||||
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
|
||||
int keytype = RedisModule_KeyType(key);
|
||||
if (keytype != REDISMODULE_KEYTYPE_STRING &&
|
||||
keytype != REDISMODULE_KEYTYPE_EMPTY)
|
||||
if (keytype != VALKEYMODULE_KEYTYPE_STRING &&
|
||||
keytype != VALKEYMODULE_KEYTYPE_EMPTY)
|
||||
{
|
||||
RedisModule_CloseKey(key);
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
if (keytype == REDISMODULE_KEYTYPE_STRING) {
|
||||
if (keytype == VALKEYMODULE_KEYTYPE_STRING) {
|
||||
size_t len, j;
|
||||
char *s = RedisModule_StringDMA(key,&len,REDISMODULE_WRITE);
|
||||
char *s = RedisModule_StringDMA(key,&len,VALKEYMODULE_WRITE);
|
||||
for (j = 0; j < len; j++) {
|
||||
if (isupper(s[j])) {
|
||||
s[j] = tolower(s[j]);
|
||||
@@ -340,7 +340,7 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
RedisModule_CloseKey(key);
|
||||
RedisModule_ReplyWithSimpleString(ctx,"OK");
|
||||
RedisModule_ReplicateVerbatim(ctx);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.MORE.EXPIRE key milliseconds.
|
||||
@@ -353,13 +353,13 @@ int HelloMoreExpire_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
|
||||
|
||||
mstime_t addms, expire;
|
||||
|
||||
if (RedisModule_StringToLongLong(argv[2],&addms) != REDISMODULE_OK)
|
||||
if (RedisModule_StringToLongLong(argv[2],&addms) != VALKEYMODULE_OK)
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid expire time");
|
||||
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
expire = RedisModule_GetExpire(key);
|
||||
if (expire != REDISMODULE_NO_EXPIRE) {
|
||||
if (expire != VALKEYMODULE_NO_EXPIRE) {
|
||||
expire += addms;
|
||||
RedisModule_SetExpire(key,expire);
|
||||
}
|
||||
@@ -376,16 +376,16 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
double score_start, score_end;
|
||||
if (argc != 4) return RedisModule_WrongArity(ctx);
|
||||
|
||||
if (RedisModule_StringToDouble(argv[2],&score_start) != REDISMODULE_OK ||
|
||||
RedisModule_StringToDouble(argv[3],&score_end) != REDISMODULE_OK)
|
||||
if (RedisModule_StringToDouble(argv[2],&score_start) != VALKEYMODULE_OK ||
|
||||
RedisModule_StringToDouble(argv[3],&score_end) != VALKEYMODULE_OK)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid range");
|
||||
}
|
||||
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) {
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_ZSET) {
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
double scoresum_a = 0;
|
||||
@@ -417,7 +417,7 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
|
||||
RedisModule_ReplyWithArray(ctx,2);
|
||||
RedisModule_ReplyWithDouble(ctx,scoresum_a);
|
||||
RedisModule_ReplyWithDouble(ctx,scoresum_b);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.LEXRANGE key min_lex max_lex min_age max_age
|
||||
@@ -433,17 +433,17 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in
|
||||
if (argc != 6) return RedisModule_WrongArity(ctx);
|
||||
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) {
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_ZSET) {
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDISMODULE_OK) {
|
||||
if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != VALKEYMODULE_OK) {
|
||||
return RedisModule_ReplyWithError(ctx,"invalid range");
|
||||
}
|
||||
|
||||
int arraylen = 0;
|
||||
RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
|
||||
RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN);
|
||||
while(!RedisModule_ZsetRangeEndReached(key)) {
|
||||
double score;
|
||||
RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(key,&score);
|
||||
@@ -455,7 +455,7 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in
|
||||
RedisModule_ZsetRangeStop(key);
|
||||
RedisModule_ReplySetArrayLength(ctx,arraylen);
|
||||
RedisModule_CloseKey(key);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.HCOPY key srcfield dstfield
|
||||
@@ -470,22 +470,22 @@ int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
|
||||
|
||||
if (argc != 4) return RedisModule_WrongArity(ctx);
|
||||
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
|
||||
REDISMODULE_READ|REDISMODULE_WRITE);
|
||||
VALKEYMODULE_READ|VALKEYMODULE_WRITE);
|
||||
int type = RedisModule_KeyType(key);
|
||||
if (type != REDISMODULE_KEYTYPE_HASH &&
|
||||
type != REDISMODULE_KEYTYPE_EMPTY)
|
||||
if (type != VALKEYMODULE_KEYTYPE_HASH &&
|
||||
type != VALKEYMODULE_KEYTYPE_EMPTY)
|
||||
{
|
||||
return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
|
||||
return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE);
|
||||
}
|
||||
|
||||
/* Get the old field value. */
|
||||
RedisModuleString *oldval;
|
||||
RedisModule_HashGet(key,REDISMODULE_HASH_NONE,argv[2],&oldval,NULL);
|
||||
RedisModule_HashGet(key,VALKEYMODULE_HASH_NONE,argv[2],&oldval,NULL);
|
||||
if (oldval) {
|
||||
RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[3],oldval,NULL);
|
||||
RedisModule_HashSet(key,VALKEYMODULE_HASH_NONE,argv[3],oldval,NULL);
|
||||
}
|
||||
RedisModule_ReplyWithLongLong(ctx,oldval != NULL);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* HELLO.LEFTPAD str len ch
|
||||
@@ -512,7 +512,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
|
||||
if (argc != 4) return RedisModule_WrongArity(ctx);
|
||||
|
||||
if ((RedisModule_StringToLongLong(argv[2],&padlen) != REDISMODULE_OK) ||
|
||||
if ((RedisModule_StringToLongLong(argv[2],&padlen) != VALKEYMODULE_OK) ||
|
||||
(padlen< 0)) {
|
||||
return RedisModule_ReplyWithError(ctx,"ERR invalid padding length");
|
||||
}
|
||||
@@ -537,14 +537,14 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
memcpy(buf+padlen,str,strlen);
|
||||
|
||||
RedisModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen);
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
if (RedisModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
if (RedisModule_Init(ctx,"helloworld",1,VALKEYMODULE_APIVER_1)
|
||||
== VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
||||
|
||||
/* Log the list of parameters passing loading the module. */
|
||||
for (int j = 0; j < argc; j++) {
|
||||
@@ -553,69 +553,69 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
}
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.simple",
|
||||
HelloSimple_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloSimple_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.push.native",
|
||||
HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.push.call",
|
||||
HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.push.call2",
|
||||
HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.list.sum.len",
|
||||
HelloListSumLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloListSumLen_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.list.splice",
|
||||
HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.list.splice.auto",
|
||||
HelloListSpliceAuto_RedisCommand,
|
||||
"write deny-oom",1,2,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
"write deny-oom",1,2,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.rand.array",
|
||||
HelloRandArray_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloRandArray_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.repl1",
|
||||
HelloRepl1_RedisCommand,"write",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloRepl1_RedisCommand,"write",0,0,0) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.repl2",
|
||||
HelloRepl2_RedisCommand,"write",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloRepl2_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.toggle.case",
|
||||
HelloToggleCase_RedisCommand,"write",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloToggleCase_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.more.expire",
|
||||
HelloMoreExpire_RedisCommand,"write",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloMoreExpire_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.zsumrange",
|
||||
HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloZsumRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.lexrange",
|
||||
HelloLexRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloLexRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.hcopy",
|
||||
HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"hello.leftpad",
|
||||
HelloLeftPad_RedisCommand,"",1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
HelloLeftPad_RedisCommand,"",1,1,1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
+7
-7
@@ -1291,8 +1291,8 @@ void clientAcceptHandler(connection *conn) {
|
||||
}
|
||||
|
||||
server.stat_numconnections++;
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE,
|
||||
REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_CLIENT_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED,
|
||||
c);
|
||||
}
|
||||
|
||||
@@ -1555,8 +1555,8 @@ void freeClient(client *c) {
|
||||
|
||||
/* For connected clients, call the disconnection event of modules hooks. */
|
||||
if (c->conn) {
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE,
|
||||
REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_CLIENT_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED,
|
||||
c);
|
||||
}
|
||||
|
||||
@@ -1669,8 +1669,8 @@ void freeClient(client *c) {
|
||||
refreshGoodSlavesCount();
|
||||
/* Fire the replica change modules event. */
|
||||
if (c->replstate == SLAVE_STATE_ONLINE)
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE,
|
||||
REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -3603,7 +3603,7 @@ void helloCommand(client *c) {
|
||||
addReplyBulkCString(c,"redis");
|
||||
|
||||
addReplyBulkCString(c,"version");
|
||||
addReplyBulkCString(c,REDIS_VERSION);
|
||||
addReplyBulkCString(c,VALKEY_VERSION);
|
||||
|
||||
addReplyBulkCString(c,"proto");
|
||||
addReplyLongLong(c,c->resp);
|
||||
|
||||
+64
-18
@@ -104,6 +104,9 @@ quicklistBookmark *_quicklistBookmarkFindByName(quicklist *ql, const char *name)
|
||||
quicklistBookmark *_quicklistBookmarkFindByNode(quicklist *ql, quicklistNode *node);
|
||||
void _quicklistBookmarkDelete(quicklist *ql, quicklistBookmark *bm);
|
||||
|
||||
quicklistNode *_quicklistSplitNode(quicklistNode *node, int offset, int after);
|
||||
quicklistNode *_quicklistMergeNodes(quicklist *quicklist, quicklistNode *center);
|
||||
|
||||
/* Simple way to give quicklistEntry structs default values with one call. */
|
||||
#define initEntry(e) \
|
||||
do { \
|
||||
@@ -378,6 +381,15 @@ REDIS_STATIC void __quicklistCompress(const quicklist *quicklist,
|
||||
quicklistCompressNode(reverse);
|
||||
}
|
||||
|
||||
/* This macro is used to compress a node.
|
||||
*
|
||||
* If the 'recompress' flag of the node is true, we compress it directly without
|
||||
* checking whether it is within the range of compress depth.
|
||||
* However, it's important to ensure that the 'recompress' flag of head and tail
|
||||
* is always false, as we always assume that head and tail are not compressed.
|
||||
*
|
||||
* If the 'recompress' flag of the node is false, we check whether the node is
|
||||
* within the range of compress depth before compressing it. */
|
||||
#define quicklistCompress(_ql, _node) \
|
||||
do { \
|
||||
if ((_node)->recompress) \
|
||||
@@ -529,19 +541,25 @@ REDIS_STATIC int _quicklistNodeAllowMerge(const quicklistNode *a,
|
||||
(node)->sz = lpBytes((node)->entry); \
|
||||
} while (0)
|
||||
|
||||
static quicklistNode* __quicklistCreatePlainNode(void *value, size_t sz) {
|
||||
static quicklistNode* __quicklistCreateNode(int container, void *value, size_t sz) {
|
||||
quicklistNode *new_node = quicklistCreateNode();
|
||||
new_node->entry = zmalloc(sz);
|
||||
new_node->container = QUICKLIST_NODE_CONTAINER_PLAIN;
|
||||
memcpy(new_node->entry, value, sz);
|
||||
new_node->container = container;
|
||||
if (container == QUICKLIST_NODE_CONTAINER_PLAIN) {
|
||||
new_node->entry = zmalloc(sz);
|
||||
memcpy(new_node->entry, value, sz);
|
||||
} else {
|
||||
new_node->entry = lpPrepend(lpNew(0), value, sz);
|
||||
}
|
||||
new_node->sz = sz;
|
||||
new_node->count++;
|
||||
return new_node;
|
||||
}
|
||||
|
||||
static void __quicklistInsertPlainNode(quicklist *quicklist, quicklistNode *old_node,
|
||||
void *value, size_t sz, int after) {
|
||||
__quicklistInsertNode(quicklist, old_node, __quicklistCreatePlainNode(value, sz), after);
|
||||
void *value, size_t sz, int after)
|
||||
{
|
||||
quicklistNode *new_node = __quicklistCreateNode(QUICKLIST_NODE_CONTAINER_PLAIN, value, sz);
|
||||
__quicklistInsertNode(quicklist, old_node, new_node, after);
|
||||
quicklist->count++;
|
||||
}
|
||||
|
||||
@@ -741,9 +759,13 @@ void quicklistReplaceEntry(quicklistIter *iter, quicklistEntry *entry,
|
||||
void *data, size_t sz)
|
||||
{
|
||||
quicklist* quicklist = iter->quicklist;
|
||||
quicklistNode *node = entry->node;
|
||||
unsigned char *newentry;
|
||||
|
||||
if (likely(!QL_NODE_IS_PLAIN(entry->node) && !isLargeElement(sz))) {
|
||||
entry->node->entry = lpReplace(entry->node->entry, &entry->zi, data, sz);
|
||||
if (likely(!QL_NODE_IS_PLAIN(entry->node) && !isLargeElement(sz) &&
|
||||
(newentry = lpReplace(entry->node->entry, &entry->zi, data, sz)) != NULL))
|
||||
{
|
||||
entry->node->entry = newentry;
|
||||
quicklistNodeUpdateSz(entry->node);
|
||||
/* quicklistNext() and quicklistGetIteratorEntryAtIdx() provide an uncompressed node */
|
||||
quicklistCompress(quicklist, entry->node);
|
||||
@@ -758,17 +780,37 @@ void quicklistReplaceEntry(quicklistIter *iter, quicklistEntry *entry,
|
||||
quicklistInsertAfter(iter, entry, data, sz);
|
||||
__quicklistDelNode(quicklist, entry->node);
|
||||
}
|
||||
} else {
|
||||
entry->node->dont_compress = 1; /* Prevent compression in quicklistInsertAfter() */
|
||||
quicklistInsertAfter(iter, entry, data, sz);
|
||||
} else { /* The node is full or data is a large element */
|
||||
quicklistNode *split_node = NULL, *new_node;
|
||||
node->dont_compress = 1; /* Prevent compression in __quicklistInsertNode() */
|
||||
|
||||
/* If the entry is not at the tail, split the node at the entry's offset. */
|
||||
if (entry->offset != node->count - 1 && entry->offset != -1)
|
||||
split_node = _quicklistSplitNode(node, entry->offset, 1);
|
||||
|
||||
/* Create a new node and insert it after the original node.
|
||||
* If the original node was split, insert the split node after the new node. */
|
||||
new_node = __quicklistCreateNode(isLargeElement(sz) ?
|
||||
QUICKLIST_NODE_CONTAINER_PLAIN : QUICKLIST_NODE_CONTAINER_PACKED, data, sz);
|
||||
__quicklistInsertNode(quicklist, node, new_node, 1);
|
||||
if (split_node) __quicklistInsertNode(quicklist, new_node, split_node, 1);
|
||||
quicklist->count++;
|
||||
|
||||
/* Delete the replaced element. */
|
||||
if (entry->node->count == 1) {
|
||||
__quicklistDelNode(quicklist, entry->node);
|
||||
} else {
|
||||
unsigned char *p = lpSeek(entry->node->entry, -1);
|
||||
quicklistDelIndex(quicklist, entry->node, &p);
|
||||
entry->node->dont_compress = 0; /* Re-enable compression */
|
||||
quicklistCompress(quicklist, entry->node);
|
||||
quicklistCompress(quicklist, entry->node->next);
|
||||
new_node = _quicklistMergeNodes(quicklist, new_node);
|
||||
/* We can't know if the current node and its sibling nodes are correctly compressed,
|
||||
* and we don't know if they are within the range of compress depth, so we need to
|
||||
* use quicklistCompress() for compression, which checks if node is within compress
|
||||
* depth before compressing. */
|
||||
quicklistCompress(quicklist, new_node);
|
||||
quicklistCompress(quicklist, new_node->prev);
|
||||
if (new_node->next) quicklistCompress(quicklist, new_node->next);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,6 +868,8 @@ REDIS_STATIC quicklistNode *_quicklistListpackMerge(quicklist *quicklist,
|
||||
}
|
||||
keep->count = lpLength(keep->entry);
|
||||
quicklistNodeUpdateSz(keep);
|
||||
keep->recompress = 0; /* Prevent 'keep' from being recompressed if
|
||||
* it becomes head or tail after merging. */
|
||||
|
||||
nokeep->count = 0;
|
||||
__quicklistDelNode(quicklist, nokeep);
|
||||
@@ -844,9 +888,10 @@ REDIS_STATIC quicklistNode *_quicklistListpackMerge(quicklist *quicklist,
|
||||
* - (center->next, center->next->next)
|
||||
* - (center->prev, center)
|
||||
* - (center, center->next)
|
||||
*
|
||||
* Returns the new 'center' after merging.
|
||||
*/
|
||||
REDIS_STATIC void _quicklistMergeNodes(quicklist *quicklist,
|
||||
quicklistNode *center) {
|
||||
REDIS_STATIC quicklistNode *_quicklistMergeNodes(quicklist *quicklist, quicklistNode *center) {
|
||||
int fill = quicklist->fill;
|
||||
quicklistNode *prev, *prev_prev, *next, *next_next, *target;
|
||||
prev = prev_prev = next = next_next = target = NULL;
|
||||
@@ -886,8 +931,9 @@ REDIS_STATIC void _quicklistMergeNodes(quicklist *quicklist,
|
||||
|
||||
/* Use result of center merge (or original) to merge with next node. */
|
||||
if (_quicklistNodeAllowMerge(target, target->next, fill)) {
|
||||
_quicklistListpackMerge(quicklist, target, target->next);
|
||||
target = _quicklistListpackMerge(quicklist, target, target->next);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
/* Split 'node' into two parts, parameterized by 'offset' and 'after'.
|
||||
@@ -1002,7 +1048,7 @@ REDIS_STATIC void _quicklistInsert(quicklistIter *iter, quicklistEntry *entry,
|
||||
} else {
|
||||
quicklistDecompressNodeForUse(node);
|
||||
new_node = _quicklistSplitNode(node, entry->offset, after);
|
||||
quicklistNode *entry_node = __quicklistCreatePlainNode(value, sz);
|
||||
quicklistNode *entry_node = __quicklistCreateNode(QUICKLIST_NODE_CONTAINER_PLAIN, value, sz);
|
||||
__quicklistInsertNode(quicklist, node, entry_node, after);
|
||||
__quicklistInsertNode(quicklist, entry_node, new_node, after);
|
||||
quicklist->count++;
|
||||
@@ -3224,7 +3270,7 @@ int quicklistTest(int argc, char *argv[], int flags) {
|
||||
memcpy(s, "helloworld", 10);
|
||||
memcpy(s + sz - 10, "1234567890", 10);
|
||||
|
||||
quicklistNode *node = __quicklistCreatePlainNode(s, sz);
|
||||
quicklistNode *node = __quicklistCreateNode(QUICKLIST_NODE_CONTAINER_PLAIN, s, sz);
|
||||
|
||||
/* Just to avoid triggering the assertion in __quicklistCompressNode(),
|
||||
* it disables the passing of quicklist head or tail node. */
|
||||
|
||||
@@ -1079,7 +1079,7 @@ ssize_t rdbSaveObject(rio *rdb, robj *o, robj *key, int dbid) {
|
||||
}
|
||||
} else if (o->type == OBJ_MODULE) {
|
||||
/* Save a module-specific value. */
|
||||
RedisModuleIO io;
|
||||
ValkeyModuleIO io;
|
||||
moduleValue *mv = o->ptr;
|
||||
moduleType *mt = mv->type;
|
||||
|
||||
@@ -1195,7 +1195,7 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
|
||||
int aof_base = (rdbflags & RDBFLAGS_AOF_PREAMBLE) != 0;
|
||||
|
||||
/* Add a few fields about the state when the RDB was created. */
|
||||
if (rdbSaveAuxFieldStrStr(rdb,"redis-ver",REDIS_VERSION) == -1) return -1;
|
||||
if (rdbSaveAuxFieldStrStr(rdb,"valkey-ver",VALKEY_VERSION) == -1) return -1;
|
||||
if (rdbSaveAuxFieldStrInt(rdb,"redis-bits",redis_bits) == -1) return -1;
|
||||
if (rdbSaveAuxFieldStrInt(rdb,"ctime",time(NULL)) == -1) return -1;
|
||||
if (rdbSaveAuxFieldStrInt(rdb,"used-mem",zmalloc_used_memory()) == -1) return -1;
|
||||
@@ -1215,7 +1215,7 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
|
||||
|
||||
ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) {
|
||||
/* Save a module-specific aux value. */
|
||||
RedisModuleIO io;
|
||||
ValkeyModuleIO io;
|
||||
int retval = 0;
|
||||
moduleInitIOContext(io,mt,rdb,NULL,-1);
|
||||
|
||||
@@ -1384,7 +1384,7 @@ int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) {
|
||||
snprintf(magic,sizeof(magic),"REDIS%04d",RDB_VERSION);
|
||||
if (rdbWriteRaw(rdb,magic,9) == -1) goto werr;
|
||||
if (rdbSaveInfoAuxFields(rdb,rdbflags,rsi) == -1) goto werr;
|
||||
if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, REDISMODULE_AUX_BEFORE_RDB) == -1) goto werr;
|
||||
if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, VALKEYMODULE_AUX_BEFORE_RDB) == -1) goto werr;
|
||||
|
||||
/* save functions */
|
||||
if (!(req & SLAVE_REQ_RDB_EXCLUDE_FUNCTIONS) && rdbSaveFunctions(rdb) == -1) goto werr;
|
||||
@@ -1396,7 +1396,7 @@ int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, REDISMODULE_AUX_AFTER_RDB) == -1) goto werr;
|
||||
if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, VALKEYMODULE_AUX_AFTER_RDB) == -1) goto werr;
|
||||
|
||||
/* EOF opcode */
|
||||
if (rdbSaveType(rdb,RDB_OPCODE_EOF) == -1) goto werr;
|
||||
@@ -2803,7 +2803,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
|
||||
rdbReportCorruptRDB("The RDB file contains module data I can't load: no matching module type '%s'", name);
|
||||
return NULL;
|
||||
}
|
||||
RedisModuleIO io;
|
||||
ValkeyModuleIO io;
|
||||
robj keyobj;
|
||||
initStaticStringObject(keyobj,key);
|
||||
moduleInitIOContext(io,mt,rdb,&keyobj,dbid);
|
||||
@@ -2870,12 +2870,12 @@ void startLoading(size_t size, int rdbflags, int async) {
|
||||
/* Fire the loading modules start event. */
|
||||
int subevent;
|
||||
if (rdbflags & RDBFLAGS_AOF_PREAMBLE)
|
||||
subevent = REDISMODULE_SUBEVENT_LOADING_AOF_START;
|
||||
subevent = VALKEYMODULE_SUBEVENT_LOADING_AOF_START;
|
||||
else if(rdbflags & RDBFLAGS_REPLICATION)
|
||||
subevent = REDISMODULE_SUBEVENT_LOADING_REPL_START;
|
||||
subevent = VALKEYMODULE_SUBEVENT_LOADING_REPL_START;
|
||||
else
|
||||
subevent = REDISMODULE_SUBEVENT_LOADING_RDB_START;
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_LOADING,subevent,NULL);
|
||||
subevent = VALKEYMODULE_SUBEVENT_LOADING_RDB_START;
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING,subevent,NULL);
|
||||
}
|
||||
|
||||
/* Mark that we are loading in the global state and setup the fields
|
||||
@@ -2913,10 +2913,10 @@ void stopLoading(int success) {
|
||||
rdbFileBeingLoaded = NULL;
|
||||
|
||||
/* Fire the loading modules end event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_LOADING,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING,
|
||||
success?
|
||||
REDISMODULE_SUBEVENT_LOADING_ENDED:
|
||||
REDISMODULE_SUBEVENT_LOADING_FAILED,
|
||||
VALKEYMODULE_SUBEVENT_LOADING_ENDED:
|
||||
VALKEYMODULE_SUBEVENT_LOADING_FAILED,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -2924,22 +2924,22 @@ void startSaving(int rdbflags) {
|
||||
/* Fire the persistence modules start event. */
|
||||
int subevent;
|
||||
if (rdbflags & RDBFLAGS_AOF_PREAMBLE && getpid() != server.pid)
|
||||
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START;
|
||||
subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START;
|
||||
else if (rdbflags & RDBFLAGS_AOF_PREAMBLE)
|
||||
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START;
|
||||
subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START;
|
||||
else if (getpid()!=server.pid)
|
||||
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START;
|
||||
subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START;
|
||||
else
|
||||
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START;
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE,subevent,NULL);
|
||||
subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START;
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PERSISTENCE,subevent,NULL);
|
||||
}
|
||||
|
||||
void stopSaving(int success) {
|
||||
/* Fire the persistence modules end event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PERSISTENCE,
|
||||
success?
|
||||
REDISMODULE_SUBEVENT_PERSISTENCE_ENDED:
|
||||
REDISMODULE_SUBEVENT_PERSISTENCE_FAILED,
|
||||
VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED:
|
||||
VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -3138,7 +3138,10 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
|
||||
} else if (!strcasecmp(auxkey->ptr,"lua")) {
|
||||
/* Won't load the script back in memory anymore. */
|
||||
} else if (!strcasecmp(auxkey->ptr,"redis-ver")) {
|
||||
serverLog(LL_NOTICE,"Loading RDB produced by version %s",
|
||||
serverLog(LL_NOTICE,"Loading RDB produced by Redis version %s",
|
||||
(char*)auxval->ptr);
|
||||
} else if (!strcasecmp(auxkey->ptr,"valkey-ver")) {
|
||||
serverLog(LL_NOTICE,"Loading RDB produced by valkey version %s",
|
||||
(char*)auxval->ptr);
|
||||
} else if (!strcasecmp(auxkey->ptr,"ctime")) {
|
||||
time_t age = time(NULL)-strtol(auxval->ptr,NULL,10);
|
||||
@@ -3195,7 +3198,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
|
||||
exit(1);
|
||||
}
|
||||
|
||||
RedisModuleIO io;
|
||||
ValkeyModuleIO io;
|
||||
moduleInitIOContext(io,mt,rdb,NULL,-1);
|
||||
/* Call the rdb_load method of the module providing the 10 bit
|
||||
* encoding version in the lower 10 bits of the module ID. */
|
||||
@@ -3204,7 +3207,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
|
||||
moduleFreeContext(io.ctx);
|
||||
zfree(io.ctx);
|
||||
}
|
||||
if (rc != REDISMODULE_OK || io.error) {
|
||||
if (rc != VALKEYMODULE_OK || io.error) {
|
||||
moduleTypeNameByID(name,moduleid);
|
||||
serverLog(LL_WARNING,"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.", name);
|
||||
goto eoferr;
|
||||
|
||||
@@ -81,9 +81,6 @@
|
||||
#define RDB_TYPE_MODULE_PRE_GA 6 /* Used in 4.0 release candidates */
|
||||
#define RDB_TYPE_MODULE_2 7 /* Module value with annotations for parsing without
|
||||
the generating module being loaded. */
|
||||
/* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType() BELOW */
|
||||
|
||||
/* Object types for encoded objects. */
|
||||
#define RDB_TYPE_HASH_ZIPMAP 9
|
||||
#define RDB_TYPE_LIST_ZIPLIST 10
|
||||
#define RDB_TYPE_SET_INTSET 11
|
||||
@@ -97,7 +94,7 @@
|
||||
#define RDB_TYPE_STREAM_LISTPACKS_2 19
|
||||
#define RDB_TYPE_SET_LISTPACK 20
|
||||
#define RDB_TYPE_STREAM_LISTPACKS_3 21
|
||||
/* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType() BELOW */
|
||||
/* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType(), and rdb_type_string[] */
|
||||
|
||||
/* Test if a type is an object type. */
|
||||
#define rdbIsObjectType(t) (((t) >= 0 && (t) <= 7) || ((t) >= 9 && (t) <= 21))
|
||||
|
||||
+712
-1674
File diff suppressed because it is too large
Load Diff
+25
-24
@@ -821,8 +821,8 @@ int masterTryPartialResynchronization(client *c, long long psync_offset) {
|
||||
refreshGoodSlavesCount();
|
||||
|
||||
/* Fire the replica change modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE,
|
||||
REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
|
||||
NULL);
|
||||
|
||||
return C_OK; /* The caller can return, no full resync needed. */
|
||||
@@ -1304,8 +1304,8 @@ int replicaPutOnline(client *slave) {
|
||||
|
||||
refreshGoodSlavesCount();
|
||||
/* Fire the replica change modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE,
|
||||
REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
|
||||
NULL);
|
||||
serverLog(LL_NOTICE,"Synchronization with replica %s succeeded",
|
||||
replicationGetSlaveName(slave));
|
||||
@@ -2064,8 +2064,8 @@ void readSyncBulkPayload(connection *conn) {
|
||||
diskless_load_tempDb = disklessLoadInitTempDb();
|
||||
temp_functions_lib_ctx = functionsLibCtxCreate();
|
||||
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD,
|
||||
REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD,
|
||||
VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED,
|
||||
NULL);
|
||||
} else {
|
||||
replicationAttachToNewMaster();
|
||||
@@ -2138,8 +2138,8 @@ void readSyncBulkPayload(connection *conn) {
|
||||
|
||||
if (server.repl_diskless_load == REPL_DISKLESS_LOAD_SWAPDB) {
|
||||
/* Discard potentially partially loaded tempDb. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD,
|
||||
REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD,
|
||||
VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED,
|
||||
NULL);
|
||||
|
||||
disklessLoadDiscardTempDb(diskless_load_tempDb);
|
||||
@@ -2169,8 +2169,8 @@ void readSyncBulkPayload(connection *conn) {
|
||||
/* swap existing functions ctx with the temporary one */
|
||||
functionsLibCtxSwapWithCurrent(temp_functions_lib_ctx);
|
||||
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD,
|
||||
REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD,
|
||||
VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED,
|
||||
NULL);
|
||||
|
||||
/* Delete the old db as it's useless now. */
|
||||
@@ -2250,6 +2250,7 @@ void readSyncBulkPayload(connection *conn) {
|
||||
}
|
||||
|
||||
zfree(server.repl_transfer_tmpfile);
|
||||
close(server.repl_transfer_fd);
|
||||
server.repl_transfer_fd = -1;
|
||||
server.repl_transfer_tmpfile = NULL;
|
||||
}
|
||||
@@ -2260,8 +2261,8 @@ void readSyncBulkPayload(connection *conn) {
|
||||
server.repl_down_since = 0;
|
||||
|
||||
/* Fire the master link modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE,
|
||||
REDISMODULE_SUBEVENT_MASTER_LINK_UP,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP,
|
||||
NULL);
|
||||
|
||||
/* After a full resynchronization we use the replication ID and
|
||||
@@ -3035,14 +3036,14 @@ void replicationSetMaster(char *ip, int port) {
|
||||
}
|
||||
|
||||
/* Fire the role change modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED,
|
||||
REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED,
|
||||
VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA,
|
||||
NULL);
|
||||
|
||||
/* Fire the master link modules event. */
|
||||
if (server.repl_state == REPL_STATE_CONNECTED)
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE,
|
||||
REDISMODULE_SUBEVENT_MASTER_LINK_DOWN,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN,
|
||||
NULL);
|
||||
|
||||
server.repl_state = REPL_STATE_CONNECT;
|
||||
@@ -3057,8 +3058,8 @@ void replicationUnsetMaster(void) {
|
||||
|
||||
/* Fire the master link modules event. */
|
||||
if (server.repl_state == REPL_STATE_CONNECTED)
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE,
|
||||
REDISMODULE_SUBEVENT_MASTER_LINK_DOWN,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN,
|
||||
NULL);
|
||||
|
||||
/* Clear masterhost first, since the freeClient calls
|
||||
@@ -3099,8 +3100,8 @@ void replicationUnsetMaster(void) {
|
||||
server.repl_down_since = 0;
|
||||
|
||||
/* Fire the role change modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED,
|
||||
REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED,
|
||||
VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY,
|
||||
NULL);
|
||||
|
||||
/* Restart the AOF subsystem in case we shut it down during a sync when
|
||||
@@ -3113,8 +3114,8 @@ void replicationUnsetMaster(void) {
|
||||
void replicationHandleMasterDisconnection(void) {
|
||||
/* Fire the master link modules event. */
|
||||
if (server.repl_state == REPL_STATE_CONNECTED)
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE,
|
||||
REDISMODULE_SUBEVENT_MASTER_LINK_DOWN,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN,
|
||||
NULL);
|
||||
|
||||
server.master = NULL;
|
||||
@@ -3402,8 +3403,8 @@ void replicationResurrectCachedMaster(connection *conn) {
|
||||
server.repl_down_since = 0;
|
||||
|
||||
/* Fire the master link modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE,
|
||||
REDISMODULE_SUBEVENT_MASTER_LINK_UP,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE,
|
||||
VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP,
|
||||
NULL);
|
||||
|
||||
/* Re-add to the list of clients. */
|
||||
|
||||
+34
-5
@@ -56,7 +56,8 @@ static char *libraries_allow_list[] = {
|
||||
|
||||
/* Redis Lua API globals */
|
||||
static char *redis_api_allow_list[] = {
|
||||
"redis",
|
||||
SERVER_API_NAME,
|
||||
REDIS_API_NAME,
|
||||
"__redis__err__handler", /* error handler for eval, currently located on globals.
|
||||
Should move to registry. */
|
||||
NULL,
|
||||
@@ -818,8 +819,17 @@ static robj **luaArgsToRedisArgv(lua_State *lua, int *argc, int *argv_len) {
|
||||
/* We can't use lua_tolstring() for number -> string conversion
|
||||
* since Lua uses a format specifier that loses precision. */
|
||||
lua_Number num = lua_tonumber(lua,j+1);
|
||||
obj_len = fpconv_dtoa((double)num, dbuf);
|
||||
dbuf[obj_len] = '\0';
|
||||
/* Integer printing function is much faster, check if we can safely use it.
|
||||
* Since lua_Number is not explicitly an integer or a double, we need to make an effort
|
||||
* to convert it as an integer when that's possible, since the string could later be used
|
||||
* in a context that doesn't support scientific notation (e.g. 1e9 instead of 100000000). */
|
||||
long long lvalue;
|
||||
if (double2ll((double)num, &lvalue))
|
||||
obj_len = ll2string(dbuf, sizeof(dbuf), lvalue);
|
||||
else {
|
||||
obj_len = fpconv_dtoa((double)num, dbuf);
|
||||
dbuf[obj_len] = '\0';
|
||||
}
|
||||
obj_s = dbuf;
|
||||
} else {
|
||||
obj_s = (char*)lua_tolstring(lua,j+1,&obj_len);
|
||||
@@ -1373,6 +1383,7 @@ void luaSetTableProtectionRecursively(lua_State *lua) {
|
||||
}
|
||||
|
||||
void luaRegisterVersion(lua_State* lua) {
|
||||
/* For legacy compatibility reasons include Redis versions. */
|
||||
lua_pushstring(lua,"REDIS_VERSION_NUM");
|
||||
lua_pushnumber(lua,REDIS_VERSION_NUM);
|
||||
lua_settable(lua,-3);
|
||||
@@ -1380,6 +1391,19 @@ void luaRegisterVersion(lua_State* lua) {
|
||||
lua_pushstring(lua,"REDIS_VERSION");
|
||||
lua_pushstring(lua,REDIS_VERSION);
|
||||
lua_settable(lua,-3);
|
||||
|
||||
/* Now push the Valkey version information. */
|
||||
lua_pushstring(lua,"VALKEY_VERSION_NUM");
|
||||
lua_pushnumber(lua,VALKEY_VERSION_NUM);
|
||||
lua_settable(lua,-3);
|
||||
|
||||
lua_pushstring(lua,"VALKEY_VERSION");
|
||||
lua_pushstring(lua,VALKEY_VERSION);
|
||||
lua_settable(lua,-3);
|
||||
|
||||
lua_pushstring(lua,"SERVER_NAME");
|
||||
lua_pushstring(lua,SERVER_NAME);
|
||||
lua_settable(lua,-3);
|
||||
}
|
||||
|
||||
void luaRegisterLogFunction(lua_State* lua) {
|
||||
@@ -1480,9 +1504,14 @@ void luaRegisterRedisAPI(lua_State* lua) {
|
||||
lua_pushcfunction(lua,luaRedisAclCheckCmdPermissionsCommand);
|
||||
lua_settable(lua,-3);
|
||||
|
||||
/* Finally set the table as 'redis' global var. */
|
||||
/* Finally set the table as 'server' global var.
|
||||
* We will also alias it to 'redis' global var for backwards compatibility. */
|
||||
lua_setglobal(lua,SERVER_API_NAME);
|
||||
/* lua_getglobal invocation retrieves the 'server' variable value to the stack.
|
||||
* lua_setglobal invocation uses the value from stack to set 'redis' global variable.
|
||||
* This is not a deep copy but is enough for our purpose here. */
|
||||
lua_getglobal(lua,SERVER_API_NAME);
|
||||
lua_setglobal(lua,REDIS_API_NAME);
|
||||
|
||||
/* Replace math.random and math.randomseed with our implementations. */
|
||||
lua_getglobal(lua,"math");
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#define REGISTRY_RUN_CTX_NAME "__RUN_CTX__"
|
||||
#define REGISTRY_SET_GLOBALS_PROTECTION_NAME "__GLOBAL_PROTECTION__"
|
||||
#define REDIS_API_NAME "redis"
|
||||
#define SERVER_API_NAME "server"
|
||||
|
||||
typedef struct errorInfo {
|
||||
sds msg;
|
||||
|
||||
@@ -349,20 +349,22 @@ sds sdsResize(sds s, size_t size, int would_regrow) {
|
||||
* type. */
|
||||
int use_realloc = (oldtype==type || (type < oldtype && type > SDS_TYPE_8));
|
||||
size_t newlen = use_realloc ? oldhdrlen+size+1 : hdrlen+size+1;
|
||||
int alloc_already_optimal = 0;
|
||||
#if defined(USE_JEMALLOC)
|
||||
/* je_nallocx returns the expected allocation size for the newlen.
|
||||
* We aim to avoid calling realloc() when using Jemalloc if there is no
|
||||
* change in the allocation size, as it incurs a cost even if the
|
||||
* allocation size stays the same. */
|
||||
alloc_already_optimal = (je_nallocx(newlen, 0) == zmalloc_size(sh));
|
||||
#endif
|
||||
|
||||
if (use_realloc && !alloc_already_optimal) {
|
||||
newsh = s_realloc(sh, newlen);
|
||||
if (newsh == NULL) return NULL;
|
||||
s = (char*)newsh+oldhdrlen;
|
||||
} else if (!alloc_already_optimal) {
|
||||
if (use_realloc) {
|
||||
int alloc_already_optimal = 0;
|
||||
#if defined(USE_JEMALLOC)
|
||||
/* je_nallocx returns the expected allocation size for the newlen.
|
||||
* We aim to avoid calling realloc() when using Jemalloc if there is no
|
||||
* change in the allocation size, as it incurs a cost even if the
|
||||
* allocation size stays the same. */
|
||||
alloc_already_optimal = (je_nallocx(newlen, 0) == zmalloc_size(sh));
|
||||
#endif
|
||||
if (!alloc_already_optimal) {
|
||||
newsh = s_realloc(sh, newlen);
|
||||
if (newsh == NULL) return NULL;
|
||||
s = (char*)newsh+oldhdrlen;
|
||||
}
|
||||
} else {
|
||||
newsh = s_malloc(newlen);
|
||||
if (newsh == NULL) return NULL;
|
||||
memcpy((char*)newsh+hdrlen, s, len);
|
||||
|
||||
+1
-2
@@ -1846,8 +1846,7 @@ void loadSentinelConfigFromQueue(void) {
|
||||
return;
|
||||
|
||||
loaderr:
|
||||
fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n",
|
||||
REDIS_VERSION);
|
||||
fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", VALKEY_VERSION);
|
||||
fprintf(stderr, "Reading the configuration file, at line %d\n", linenum);
|
||||
fprintf(stderr, ">>> '%s'\n", line);
|
||||
fprintf(stderr, "%s\n", err);
|
||||
|
||||
+68
-45
@@ -532,7 +532,7 @@ dictType keylistDictType = {
|
||||
};
|
||||
|
||||
/* Modules system dictionary type. Keys are module name,
|
||||
* values are pointer to RedisModule struct. */
|
||||
* values are pointer to ValkeyModule struct. */
|
||||
dictType modulesDictType = {
|
||||
dictSdsCaseHash, /* hash function */
|
||||
NULL, /* key dup */
|
||||
@@ -671,8 +671,8 @@ void resetChildState(void) {
|
||||
server.stat_current_save_keys_total = 0;
|
||||
updateDictResizePolicy();
|
||||
closeChildInfoPipe();
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD,
|
||||
REDISMODULE_SUBEVENT_FORK_CHILD_DIED,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_FORK_CHILD,
|
||||
VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -1514,8 +1514,8 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
||||
}
|
||||
|
||||
/* Fire the cron loop modules event. */
|
||||
RedisModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,server.hz};
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP,
|
||||
ValkeyModuleCronLoopV1 ei = {VALKEYMODULE_CRON_LOOP_VERSION,server.hz};
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_CRON_LOOP,
|
||||
0,
|
||||
&ei);
|
||||
|
||||
@@ -1677,8 +1677,8 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
||||
activeExpireCycle(ACTIVE_EXPIRE_CYCLE_FAST);
|
||||
|
||||
if (moduleCount()) {
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP,
|
||||
REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_EVENTLOOP,
|
||||
VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -1794,8 +1794,8 @@ void afterSleep(struct aeEventLoop *eventLoop) {
|
||||
latencyStartMonitor(latency);
|
||||
|
||||
moduleAcquireGIL();
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP,
|
||||
REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_EVENTLOOP,
|
||||
VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP,
|
||||
NULL);
|
||||
latencyEndMonitor(latency);
|
||||
latencyAddSampleIfNeeded("module-acquire-GIL",latency);
|
||||
@@ -2118,7 +2118,7 @@ void initServerConfig(void) {
|
||||
|
||||
/* Command table -- we initialize it here as it is part of the
|
||||
* initial configuration, since command names may be changed via
|
||||
* redis.conf using the rename-command directive. */
|
||||
* valkey.conf using the rename-command directive. */
|
||||
server.commands = dictCreate(&commandTableDictType);
|
||||
server.orig_commands = dictCreate(&commandTableDictType);
|
||||
populateCommandTable();
|
||||
@@ -3039,7 +3039,7 @@ void populateCommandTable(void) {
|
||||
|
||||
retval1 = dictAdd(server.commands, sdsdup(c->fullname), c);
|
||||
/* Populate an additional dictionary that will be unaffected
|
||||
* by rename-command statements in redis.conf. */
|
||||
* by rename-command statements in valkey.conf. */
|
||||
retval2 = dictAdd(server.orig_commands, sdsdup(c->fullname), c);
|
||||
serverAssert(retval1 == DICT_OK && retval2 == DICT_OK);
|
||||
}
|
||||
@@ -3193,7 +3193,7 @@ struct redisCommand *lookupCommandByCString(const char *s) {
|
||||
|
||||
/* Lookup the command in the current table, if not found also check in
|
||||
* the original table containing the original command names unaffected by
|
||||
* redis.conf rename-command statement.
|
||||
* valkey.conf rename-command statement.
|
||||
*
|
||||
* This is used by functions rewriting the argument vector such as
|
||||
* rewriteClientCommandVector() in order to set client->cmd pointer
|
||||
@@ -3512,12 +3512,20 @@ void call(client *c, int flags) {
|
||||
* re-processing and unblock the client.*/
|
||||
c->flags |= CLIENT_EXECUTING_COMMAND;
|
||||
|
||||
/* Setting the CLIENT_REPROCESSING_COMMAND flag so that during the actual
|
||||
* processing of the command proc, the client is aware that it is being
|
||||
* re-processed. */
|
||||
if (reprocessing_command) c->flags |= CLIENT_REPROCESSING_COMMAND;
|
||||
|
||||
monotime monotonic_start = 0;
|
||||
if (monotonicGetType() == MONOTONIC_CLOCK_HW)
|
||||
monotonic_start = getMonotonicUs();
|
||||
|
||||
c->cmd->proc(c);
|
||||
|
||||
/* Clear the CLIENT_REPROCESSING_COMMAND flag after the proc is executed. */
|
||||
if (reprocessing_command) c->flags &= ~CLIENT_REPROCESSING_COMMAND;
|
||||
|
||||
exitExecutionUnit();
|
||||
|
||||
/* In case client is blocked after trying to execute the command,
|
||||
@@ -3575,7 +3583,7 @@ void call(client *c, int flags) {
|
||||
|
||||
/* Send the command to clients in MONITOR mode if applicable,
|
||||
* since some administrative commands are considered too dangerous to be shown.
|
||||
* Other exceptions is a client which is unblocked and retring to process the command
|
||||
* Other exceptions is a client which is unblocked and retrying to process the command
|
||||
* or we are currently in the process of loading AOF. */
|
||||
if (update_command_stats && !reprocessing_command &&
|
||||
!(c->cmd->flags & (CMD_SKIP_MONITOR|CMD_ADMIN))) {
|
||||
@@ -3952,7 +3960,8 @@ int processCommand(client *c) {
|
||||
} else {
|
||||
flagTransaction(c);
|
||||
}
|
||||
clusterRedirectClient(c,n,c->slot,error_code);
|
||||
clusterRedirectClient(c, n, c->slot, error_code);
|
||||
c->duration = 0;
|
||||
c->cmd->rejected_calls++;
|
||||
return C_OK;
|
||||
}
|
||||
@@ -4424,7 +4433,7 @@ int finishShutdown(void) {
|
||||
if (server.aof_manifest) aofManifestFree(server.aof_manifest);
|
||||
|
||||
/* Fire the shutdown modules event. */
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_SHUTDOWN,0,NULL);
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_SHUTDOWN,0,NULL);
|
||||
|
||||
/* Remove the pid file if possible and needed. */
|
||||
if (server.daemonize || server.pidfile) {
|
||||
@@ -4448,7 +4457,7 @@ int finishShutdown(void) {
|
||||
|
||||
|
||||
serverLog(LL_WARNING,"%s is now ready to exit, bye bye...",
|
||||
server.sentinel_mode ? "Sentinel" : "Redis");
|
||||
server.sentinel_mode ? "Sentinel" : "Valkey");
|
||||
return C_OK;
|
||||
|
||||
error:
|
||||
@@ -5489,6 +5498,8 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
|
||||
info = sdscatfmt(info,
|
||||
"# Server\r\n"
|
||||
"redis_version:%s\r\n"
|
||||
"server_name:%s\r\n"
|
||||
"valkey_version:%s\r\n"
|
||||
"redis_git_sha1:%s\r\n"
|
||||
"redis_git_dirty:%i\r\n"
|
||||
"redis_build_id:%s\r\n"
|
||||
@@ -5513,6 +5524,8 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
|
||||
"config_file:%s\r\n"
|
||||
"io_threads_active:%i\r\n",
|
||||
REDIS_VERSION,
|
||||
SERVER_NAME,
|
||||
VALKEY_VERSION,
|
||||
redisGitSHA1(),
|
||||
strtol(redisGitDirty(),NULL,10) > 0,
|
||||
redisBuildIdString(),
|
||||
@@ -6376,8 +6389,8 @@ void daemonize(void) {
|
||||
}
|
||||
|
||||
void version(void) {
|
||||
printf("Redis server v=%s sha=%s:%d malloc=%s bits=%d build=%llx\n",
|
||||
REDIS_VERSION,
|
||||
printf("Server v=%s sha=%s:%d malloc=%s bits=%d build=%llx\n",
|
||||
VALKEY_VERSION,
|
||||
redisGitSHA1(),
|
||||
atoi(redisGitDirty()) > 0,
|
||||
ZMALLOC_LIB,
|
||||
@@ -6387,23 +6400,23 @@ void version(void) {
|
||||
}
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf] [options] [-]\n");
|
||||
fprintf(stderr," ./redis-server - (read config from stdin)\n");
|
||||
fprintf(stderr," ./redis-server -v or --version\n");
|
||||
fprintf(stderr," ./redis-server -h or --help\n");
|
||||
fprintf(stderr," ./redis-server --test-memory <megabytes>\n");
|
||||
fprintf(stderr," ./redis-server --check-system\n");
|
||||
fprintf(stderr,"Usage: ./valkey-server [/path/to/valkey.conf] [options] [-]\n");
|
||||
fprintf(stderr," ./valkey-server - (read config from stdin)\n");
|
||||
fprintf(stderr," ./valkey-server -v or --version\n");
|
||||
fprintf(stderr," ./valkey-server -h or --help\n");
|
||||
fprintf(stderr," ./valkey-server --test-memory <megabytes>\n");
|
||||
fprintf(stderr," ./valkey-server --check-system\n");
|
||||
fprintf(stderr,"\n");
|
||||
fprintf(stderr,"Examples:\n");
|
||||
fprintf(stderr," ./redis-server (run the server with default conf)\n");
|
||||
fprintf(stderr," echo 'maxmemory 128mb' | ./redis-server -\n");
|
||||
fprintf(stderr," ./redis-server /etc/redis/6379.conf\n");
|
||||
fprintf(stderr," ./redis-server --port 7777\n");
|
||||
fprintf(stderr," ./redis-server --port 7777 --replicaof 127.0.0.1 8888\n");
|
||||
fprintf(stderr," ./redis-server /etc/myredis.conf --loglevel verbose -\n");
|
||||
fprintf(stderr," ./redis-server /etc/myredis.conf --loglevel verbose\n\n");
|
||||
fprintf(stderr," ./valkey-server (run the server with default conf)\n");
|
||||
fprintf(stderr," echo 'maxmemory 128mb' | ./valkey-server -\n");
|
||||
fprintf(stderr," ./valkey-server /etc/valkey/6379.conf\n");
|
||||
fprintf(stderr," ./valkey-server --port 7777\n");
|
||||
fprintf(stderr," ./valkey-server --port 7777 --replicaof 127.0.0.1 8888\n");
|
||||
fprintf(stderr," ./valkey-server /etc/myvalkey.conf --loglevel verbose -\n");
|
||||
fprintf(stderr," ./valkey-server /etc/myvalkey.conf --loglevel verbose\n\n");
|
||||
fprintf(stderr,"Sentinel mode:\n");
|
||||
fprintf(stderr," ./redis-server /etc/sentinel.conf --sentinel\n");
|
||||
fprintf(stderr," ./valkey-server /etc/sentinel.conf --sentinel\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -6418,7 +6431,7 @@ void redisAsciiArt(void) {
|
||||
|
||||
/* Show the ASCII logo if: log file is stdout AND stdout is a
|
||||
* tty AND syslog logging is disabled. Also show logo if the user
|
||||
* forced us to do so via redis.conf. */
|
||||
* forced us to do so via valkey.conf. */
|
||||
int show_logo = ((!server.syslog_enabled &&
|
||||
server.logfile[0] == '\0' &&
|
||||
isatty(fileno(stdout))) ||
|
||||
@@ -6431,7 +6444,7 @@ void redisAsciiArt(void) {
|
||||
);
|
||||
} else {
|
||||
snprintf(buf,1024*16,ascii_logo,
|
||||
REDIS_VERSION,
|
||||
VALKEY_VERSION,
|
||||
redisGitSHA1(),
|
||||
strtol(redisGitDirty(),NULL,10) > 0,
|
||||
(sizeof(long) == 8) ? "64" : "32",
|
||||
@@ -6648,8 +6661,8 @@ int redisFork(int purpose) {
|
||||
}
|
||||
|
||||
updateDictResizePolicy();
|
||||
moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD,
|
||||
REDISMODULE_SUBEVENT_FORK_CHILD_BORN,
|
||||
moduleFireServerEvent(VALKEYMODULE_EVENT_FORK_CHILD,
|
||||
VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN,
|
||||
NULL);
|
||||
}
|
||||
return childpid;
|
||||
@@ -6748,9 +6761,12 @@ void dismissMemoryInChild(void) {
|
||||
void memtest(size_t megabytes, int passes);
|
||||
|
||||
/* Returns 1 if there is --sentinel among the arguments or if
|
||||
* executable name contains "redis-sentinel". */
|
||||
* executable name contains "valkey-sentinel". */
|
||||
int checkForSentinelMode(int argc, char **argv, char *exec_name) {
|
||||
if (strstr(exec_name,"redis-sentinel") != NULL) return 1;
|
||||
if (strstr(exec_name,"valkey-sentinel") != NULL) return 1;
|
||||
|
||||
/* valkey may install symlinks like redis-sentinel -> valkey-sentinel. */
|
||||
if (strstr(exec_name, "redis-sentinel") != NULL) return 1;
|
||||
|
||||
for (int j = 1; j < argc; j++)
|
||||
if (!strcmp(argv[j],"--sentinel")) return 1;
|
||||
@@ -6836,7 +6852,7 @@ void redisOutOfMemoryHandler(size_t allocation_size) {
|
||||
allocation_size);
|
||||
}
|
||||
|
||||
/* Callback for sdstemplate on proc-title-template. See redis.conf for
|
||||
/* Callback for sdstemplate on proc-title-template. See valkey.conf for
|
||||
* supported variables.
|
||||
*/
|
||||
static sds redisProcTitleGetVariable(const sds varname, void *arg)
|
||||
@@ -7129,8 +7145,16 @@ int main(int argc, char **argv) {
|
||||
/* Check if we need to start in redis-check-rdb/aof mode. We just execute
|
||||
* the program main. However the program is part of the Redis executable
|
||||
* so that we can easily execute an RDB check on loading errors. */
|
||||
if (strstr(exec_name,"redis-check-rdb") != NULL)
|
||||
if (strstr(exec_name,"valkey-check-rdb") != NULL)
|
||||
redis_check_rdb_main(argc,argv,NULL);
|
||||
else if (strstr(exec_name,"valkey-check-aof") != NULL)
|
||||
redis_check_aof_main(argc,argv);
|
||||
|
||||
/* valkey may install symlinks like
|
||||
* redis-server -> valkey-server, redis-check-rdb -> valkey-check-rdb,
|
||||
* redis-check-aof -> valkey-check-aof, etc. */
|
||||
if (strstr(exec_name,"redis-check-rdb") != NULL)
|
||||
redis_check_rdb_main(argc, argv, NULL);
|
||||
else if (strstr(exec_name,"redis-check-aof") != NULL)
|
||||
redis_check_aof_main(argc,argv);
|
||||
|
||||
@@ -7280,17 +7304,16 @@ int main(int argc, char **argv) {
|
||||
int background = server.daemonize && !server.supervised;
|
||||
if (background) daemonize();
|
||||
|
||||
serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo");
|
||||
serverLog(LL_NOTICE,
|
||||
"Redis version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started",
|
||||
REDIS_VERSION,
|
||||
serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo");
|
||||
serverLog(LL_NOTICE, "Valkey version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started",
|
||||
VALKEY_VERSION,
|
||||
(sizeof(long) == 8) ? 64 : 32,
|
||||
redisGitSHA1(),
|
||||
strtol(redisGitDirty(),NULL,10) > 0,
|
||||
(int)getpid());
|
||||
|
||||
if (argc == 1) {
|
||||
serverLog(LL_WARNING, "Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/redis.conf", argv[0]);
|
||||
serverLog(LL_WARNING, "Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/valkey.conf", argv[0]);
|
||||
} else {
|
||||
serverLog(LL_NOTICE, "Configuration loaded");
|
||||
}
|
||||
|
||||
+54
-51
@@ -80,9 +80,9 @@ typedef long long ustime_t; /* microsecond time type. */
|
||||
#include "rax.h" /* Radix tree */
|
||||
#include "connection.h" /* Connection abstraction */
|
||||
|
||||
#define REDISMODULE_CORE 1
|
||||
#define VALKEYMODULE_CORE 1
|
||||
typedef struct redisObject robj;
|
||||
#include "redismodule.h" /* Redis modules API defines. */
|
||||
#include "valkeymodule.h" /* Redis modules API defines. */
|
||||
|
||||
/* Following includes allow test functions to be called from Redis main() */
|
||||
#include "zipmap.h"
|
||||
@@ -400,6 +400,7 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT];
|
||||
auth had been authenticated from the Module. */
|
||||
#define CLIENT_MODULE_PREVENT_AOF_PROP (1ULL<<48) /* Module client do not want to propagate to AOF */
|
||||
#define CLIENT_MODULE_PREVENT_REPL_PROP (1ULL<<49) /* Module client do not want to propagate to replica */
|
||||
#define CLIENT_REPROCESSING_COMMAND (1ULL<<50) /* The client is re-processing the command. */
|
||||
|
||||
/* Client block type (btype field in client structure)
|
||||
* if CLIENT_BLOCKED flag is set. */
|
||||
@@ -700,7 +701,7 @@ typedef enum {
|
||||
/* The "module" object type is a special one that signals that the object
|
||||
* is one directly managed by a Redis module. In this case the value points
|
||||
* to a moduleValue struct, which contains the object value (which is only
|
||||
* handled by the module itself) and the RedisModuleType struct which lists
|
||||
* handled by the module itself) and the ValkeyModuleType struct which lists
|
||||
* function pointers in order to serialize, deserialize, AOF-rewrite and
|
||||
* free the object.
|
||||
*
|
||||
@@ -713,52 +714,52 @@ typedef enum {
|
||||
#define OBJ_TYPE_MAX 7 /* Maximum number of object types */
|
||||
|
||||
/* Extract encver / signature from a module type ID. */
|
||||
#define REDISMODULE_TYPE_ENCVER_BITS 10
|
||||
#define REDISMODULE_TYPE_ENCVER_MASK ((1<<REDISMODULE_TYPE_ENCVER_BITS)-1)
|
||||
#define REDISMODULE_TYPE_ENCVER(id) ((id) & REDISMODULE_TYPE_ENCVER_MASK)
|
||||
#define REDISMODULE_TYPE_SIGN(id) (((id) & ~((uint64_t)REDISMODULE_TYPE_ENCVER_MASK)) >>REDISMODULE_TYPE_ENCVER_BITS)
|
||||
#define VALKEYMODULE_TYPE_ENCVER_BITS 10
|
||||
#define VALKEYMODULE_TYPE_ENCVER_MASK ((1<<VALKEYMODULE_TYPE_ENCVER_BITS)-1)
|
||||
#define VALKEYMODULE_TYPE_ENCVER(id) ((id) & VALKEYMODULE_TYPE_ENCVER_MASK)
|
||||
#define VALKEYMODULE_TYPE_SIGN(id) (((id) & ~((uint64_t)VALKEYMODULE_TYPE_ENCVER_MASK)) >>VALKEYMODULE_TYPE_ENCVER_BITS)
|
||||
|
||||
/* Bit flags for moduleTypeAuxSaveFunc */
|
||||
#define REDISMODULE_AUX_BEFORE_RDB (1<<0)
|
||||
#define REDISMODULE_AUX_AFTER_RDB (1<<1)
|
||||
#define VALKEYMODULE_AUX_BEFORE_RDB (1<<0)
|
||||
#define VALKEYMODULE_AUX_AFTER_RDB (1<<1)
|
||||
|
||||
struct RedisModule;
|
||||
struct RedisModuleIO;
|
||||
struct RedisModuleDigest;
|
||||
struct RedisModuleCtx;
|
||||
struct ValkeyModule;
|
||||
struct ValkeyModuleIO;
|
||||
struct ValkeyModuleDigest;
|
||||
struct ValkeyModuleCtx;
|
||||
struct moduleLoadQueueEntry;
|
||||
struct RedisModuleKeyOptCtx;
|
||||
struct RedisModuleCommand;
|
||||
struct ValkeyModuleKeyOptCtx;
|
||||
struct ValkeyModuleCommand;
|
||||
|
||||
/* Each module type implementation should export a set of methods in order
|
||||
* to serialize and deserialize the value in the RDB file, rewrite the AOF
|
||||
* log, create the digest for "DEBUG DIGEST", and free the value when a key
|
||||
* is deleted. */
|
||||
typedef void *(*moduleTypeLoadFunc)(struct RedisModuleIO *io, int encver);
|
||||
typedef void (*moduleTypeSaveFunc)(struct RedisModuleIO *io, void *value);
|
||||
typedef int (*moduleTypeAuxLoadFunc)(struct RedisModuleIO *rdb, int encver, int when);
|
||||
typedef void (*moduleTypeAuxSaveFunc)(struct RedisModuleIO *rdb, int when);
|
||||
typedef void (*moduleTypeRewriteFunc)(struct RedisModuleIO *io, struct redisObject *key, void *value);
|
||||
typedef void (*moduleTypeDigestFunc)(struct RedisModuleDigest *digest, void *value);
|
||||
typedef void *(*moduleTypeLoadFunc)(struct ValkeyModuleIO *io, int encver);
|
||||
typedef void (*moduleTypeSaveFunc)(struct ValkeyModuleIO *io, void *value);
|
||||
typedef int (*moduleTypeAuxLoadFunc)(struct ValkeyModuleIO *rdb, int encver, int when);
|
||||
typedef void (*moduleTypeAuxSaveFunc)(struct ValkeyModuleIO *rdb, int when);
|
||||
typedef void (*moduleTypeRewriteFunc)(struct ValkeyModuleIO *io, struct redisObject *key, void *value);
|
||||
typedef void (*moduleTypeDigestFunc)(struct ValkeyModuleDigest *digest, void *value);
|
||||
typedef size_t (*moduleTypeMemUsageFunc)(const void *value);
|
||||
typedef void (*moduleTypeFreeFunc)(void *value);
|
||||
typedef size_t (*moduleTypeFreeEffortFunc)(struct redisObject *key, const void *value);
|
||||
typedef void (*moduleTypeUnlinkFunc)(struct redisObject *key, void *value);
|
||||
typedef void *(*moduleTypeCopyFunc)(struct redisObject *fromkey, struct redisObject *tokey, const void *value);
|
||||
typedef int (*moduleTypeDefragFunc)(struct RedisModuleDefragCtx *ctx, struct redisObject *key, void **value);
|
||||
typedef size_t (*moduleTypeMemUsageFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value, size_t sample_size);
|
||||
typedef void (*moduleTypeFreeFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value);
|
||||
typedef size_t (*moduleTypeFreeEffortFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value);
|
||||
typedef void (*moduleTypeUnlinkFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value);
|
||||
typedef void *(*moduleTypeCopyFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value);
|
||||
typedef int (*moduleTypeAuthCallback)(struct RedisModuleCtx *ctx, void *username, void *password, const char **err);
|
||||
typedef int (*moduleTypeDefragFunc)(struct ValkeyModuleDefragCtx *ctx, struct redisObject *key, void **value);
|
||||
typedef size_t (*moduleTypeMemUsageFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value, size_t sample_size);
|
||||
typedef void (*moduleTypeFreeFunc2)(struct ValkeyModuleKeyOptCtx *ctx, void *value);
|
||||
typedef size_t (*moduleTypeFreeEffortFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value);
|
||||
typedef void (*moduleTypeUnlinkFunc2)(struct ValkeyModuleKeyOptCtx *ctx, void *value);
|
||||
typedef void *(*moduleTypeCopyFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value);
|
||||
typedef int (*moduleTypeAuthCallback)(struct ValkeyModuleCtx *ctx, void *username, void *password, const char **err);
|
||||
|
||||
|
||||
/* The module type, which is referenced in each value of a given type, defines
|
||||
* the methods and links to the module exporting the type. */
|
||||
typedef struct RedisModuleType {
|
||||
typedef struct ValkeyModuleType {
|
||||
uint64_t id; /* Higher 54 bits of type ID + 10 lower bits of encoding ver. */
|
||||
struct RedisModule *module;
|
||||
struct ValkeyModule *module;
|
||||
moduleTypeLoadFunc rdb_load;
|
||||
moduleTypeSaveFunc rdb_save;
|
||||
moduleTypeRewriteFunc aof_rewrite;
|
||||
@@ -801,7 +802,7 @@ typedef struct moduleValue {
|
||||
} moduleValue;
|
||||
|
||||
/* This structure represents a module inside the system. */
|
||||
struct RedisModule {
|
||||
struct ValkeyModule {
|
||||
void *handle; /* Module dlopen() handle. */
|
||||
char *name; /* Module name. */
|
||||
int ver; /* Module version. We use just progressive integers. */
|
||||
@@ -815,24 +816,24 @@ struct RedisModule {
|
||||
int in_call; /* RM_Call() nesting level */
|
||||
int in_hook; /* Hooks callback nesting level for this module (0 or 1). */
|
||||
int options; /* Module options and capabilities. */
|
||||
int blocked_clients; /* Count of RedisModuleBlockedClient in this module. */
|
||||
RedisModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */
|
||||
RedisModuleDefragFunc defrag_cb; /* Callback for global data defrag. */
|
||||
int blocked_clients; /* Count of ValkeyModuleBlockedClient in this module. */
|
||||
ValkeyModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */
|
||||
ValkeyModuleDefragFunc defrag_cb; /* Callback for global data defrag. */
|
||||
struct moduleLoadQueueEntry *loadmod; /* Module load arguments for config rewrite. */
|
||||
int num_commands_with_acl_categories; /* Number of commands in this module included in acl categories */
|
||||
int onload; /* Flag to identify if the call is being made from Onload (0 or 1) */
|
||||
};
|
||||
typedef struct RedisModule RedisModule;
|
||||
typedef struct ValkeyModule ValkeyModule;
|
||||
|
||||
/* This is a wrapper for the 'rio' streams used inside rdb.c in Redis, so that
|
||||
* the user does not have to take the total count of the written bytes nor
|
||||
* to care about error conditions. */
|
||||
struct RedisModuleIO {
|
||||
struct ValkeyModuleIO {
|
||||
size_t bytes; /* Bytes read / written so far. */
|
||||
rio *rio; /* Rio stream. */
|
||||
moduleType *type; /* Module type doing the operation. */
|
||||
int error; /* True if error condition happened. */
|
||||
struct RedisModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/
|
||||
struct ValkeyModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/
|
||||
struct redisObject *key; /* Optional name of key processed */
|
||||
int dbid; /* The dbid of the key being processed, -1 when unknown. */
|
||||
sds pre_flush_buffer; /* A buffer that should be flushed before next write operation
|
||||
@@ -857,7 +858,7 @@ struct RedisModuleIO {
|
||||
* a data structure, so that a digest can be created in a way that correctly
|
||||
* reflects the values. See the DEBUG DIGEST command implementation for more
|
||||
* background. */
|
||||
struct RedisModuleDigest {
|
||||
struct ValkeyModuleDigest {
|
||||
unsigned char o[20]; /* Ordered elements. */
|
||||
unsigned char x[20]; /* Xored elements. */
|
||||
struct redisObject *key; /* Optional name of key processed */
|
||||
@@ -1032,11 +1033,11 @@ typedef struct blockingState {
|
||||
long long reploffset; /* Replication offset to reach. */
|
||||
|
||||
/* BLOCKED_MODULE */
|
||||
void *module_blocked_handle; /* RedisModuleBlockedClient structure.
|
||||
void *module_blocked_handle; /* ValkeyModuleBlockedClient structure.
|
||||
which is opaque for the Redis core, only
|
||||
handled in module.c. */
|
||||
|
||||
void *async_rm_call_handle; /* RedisModuleAsyncRMCallPromise structure.
|
||||
void *async_rm_call_handle; /* ValkeyModuleAsyncRMCallPromise structure.
|
||||
which is opaque for the Redis core, only
|
||||
handled in module.c. */
|
||||
} blockingState;
|
||||
@@ -1223,13 +1224,13 @@ typedef struct client {
|
||||
listNode *client_list_node; /* list node in client list */
|
||||
listNode *postponed_list_node; /* list node within the postponed list */
|
||||
listNode *pending_read_list_node; /* list node in clients pending read list */
|
||||
void *module_blocked_client; /* Pointer to the RedisModuleBlockedClient associated with this
|
||||
void *module_blocked_client; /* Pointer to the ValkeyModuleBlockedClient associated with this
|
||||
* client. This is set in case of module authentication before the
|
||||
* unblocked client is reprocessed to handle reply callbacks. */
|
||||
void *module_auth_ctx; /* Ongoing / attempted module based auth callback's ctx.
|
||||
* This is only tracked within the context of the command attempting
|
||||
* authentication. If not NULL, it means module auth is in progress. */
|
||||
RedisModuleUserChangedFunc auth_callback; /* Module callback to execute
|
||||
ValkeyModuleUserChangedFunc auth_callback; /* Module callback to execute
|
||||
* when the authenticated user
|
||||
* changes. */
|
||||
void *auth_callback_privdata; /* Private data that is passed when the auth
|
||||
@@ -1716,7 +1717,7 @@ struct redisServer {
|
||||
durationStats duration_stats[EL_DURATION_TYPE_NUM];
|
||||
|
||||
/* Configuration */
|
||||
int verbosity; /* Loglevel in redis.conf */
|
||||
int verbosity; /* Loglevel verbosity */
|
||||
int maxidletime; /* Client timeout in seconds */
|
||||
int tcpkeepalive; /* Set SO_KEEPALIVE if non-zero. */
|
||||
int active_expire_enabled; /* Can be disabled for testing purposes. */
|
||||
@@ -1989,13 +1990,15 @@ struct redisServer {
|
||||
int cluster_module_flags; /* Set of flags that Redis modules are able
|
||||
to set in order to suppress certain
|
||||
native Redis Cluster features. Check the
|
||||
REDISMODULE_CLUSTER_FLAG_*. */
|
||||
VALKEYMODULE_CLUSTER_FLAG_*. */
|
||||
int cluster_allow_reads_when_down; /* Are reads allowed when the cluster
|
||||
is down? */
|
||||
int cluster_config_file_lock_fd; /* cluster config fd, will be flocked. */
|
||||
unsigned long long cluster_link_msg_queue_limit_bytes; /* Memory usage limit on individual link msg queue */
|
||||
int cluster_drop_packet_filter; /* Debug config that allows tactically
|
||||
* dropping packets of a specific type */
|
||||
/* Debug config that goes along with cluster_drop_packet_filter. When set, the link is closed on packet drop. */
|
||||
uint32_t debug_cluster_close_link_on_packet_drop : 1;
|
||||
/* Scripting */
|
||||
mstime_t busy_reply_threshold; /* Script / module timeout in milliseconds */
|
||||
int pre_command_oom_state; /* OOM before command (script?) was started */
|
||||
@@ -2088,7 +2091,7 @@ typedef struct {
|
||||
* 2. keynum: there's an arg that contains the number of key args somewhere before the keys themselves
|
||||
*/
|
||||
|
||||
/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecBeginSearchType */
|
||||
/* WARNING! Must be synced with generate-command-code.py and ValkeyModuleKeySpecBeginSearchType */
|
||||
typedef enum {
|
||||
KSPEC_BS_INVALID = 0, /* Must be 0 */
|
||||
KSPEC_BS_UNKNOWN,
|
||||
@@ -2096,7 +2099,7 @@ typedef enum {
|
||||
KSPEC_BS_KEYWORD
|
||||
} kspec_bs_type;
|
||||
|
||||
/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecFindKeysType */
|
||||
/* WARNING! Must be synced with generate-command-code.py and ValkeyModuleKeySpecFindKeysType */
|
||||
typedef enum {
|
||||
KSPEC_FK_INVALID = 0, /* Must be 0 */
|
||||
KSPEC_FK_UNKNOWN,
|
||||
@@ -2104,7 +2107,7 @@ typedef enum {
|
||||
KSPEC_FK_KEYNUM
|
||||
} kspec_fk_type;
|
||||
|
||||
/* WARNING! This struct must match RedisModuleCommandKeySpec */
|
||||
/* WARNING! This struct must match ValkeyModuleCommandKeySpec */
|
||||
typedef struct {
|
||||
/* Declarative data */
|
||||
const char *notes;
|
||||
@@ -2184,7 +2187,7 @@ typedef struct jsonObject {
|
||||
|
||||
#endif
|
||||
|
||||
/* WARNING! This struct must match RedisModuleCommandHistoryEntry */
|
||||
/* WARNING! This struct must match ValkeyModuleCommandHistoryEntry */
|
||||
typedef struct {
|
||||
const char *since;
|
||||
const char *changes;
|
||||
@@ -2289,7 +2292,7 @@ typedef int redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, ge
|
||||
*
|
||||
* The following additional flags are only used in order to put commands
|
||||
* in a specific ACL category. Commands can have multiple ACL categories.
|
||||
* See redis.conf for the exact meaning of each.
|
||||
* See valkey.conf for the exact meaning of each.
|
||||
*
|
||||
* @keyspace, @read, @write, @set, @sortedset, @list, @hash, @string, @bitmap,
|
||||
* @hyperloglog, @stream, @admin, @fast, @slow, @pubsub, @blocking, @dangerous,
|
||||
@@ -2358,7 +2361,7 @@ struct redisCommand {
|
||||
dict *subcommands_dict; /* A dictionary that holds the subcommands, the key is the subcommand sds name
|
||||
* (not the fullname), and the value is the redisCommand structure pointer. */
|
||||
struct redisCommand *parent;
|
||||
struct RedisModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */
|
||||
struct ValkeyModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */
|
||||
};
|
||||
|
||||
struct redisError {
|
||||
@@ -2477,7 +2480,7 @@ moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name);
|
||||
void moduleTypeNameByID(char *name, uint64_t moduleid);
|
||||
const char *moduleTypeModuleName(moduleType *mt);
|
||||
const char *moduleNameFromCommand(struct redisCommand *cmd);
|
||||
void moduleFreeContext(struct RedisModuleCtx *ctx);
|
||||
void moduleFreeContext(struct ValkeyModuleCtx *ctx);
|
||||
void moduleCallCommandUnblockedHandler(client *c);
|
||||
void unblockClientFromModule(client *c);
|
||||
void moduleHandleBlockedClients(void);
|
||||
|
||||
+3
-2
@@ -1172,7 +1172,8 @@ unsigned long zsetLength(const robj *zobj) {
|
||||
* and the value len hint indicates the approximate individual size of the added elements,
|
||||
* they are used to determine the initial representation.
|
||||
*
|
||||
* If the hints are not known, and underestimation or 0 is suitable. */
|
||||
* If the hints are not known, and underestimation or 0 is suitable.
|
||||
* We should never pass a negative value because it will convert to a very large unsigned number. */
|
||||
robj *zsetTypeCreate(size_t size_hint, size_t val_len_hint) {
|
||||
if (size_hint <= server.zset_max_listpack_entries &&
|
||||
val_len_hint <= server.zset_max_listpack_value)
|
||||
@@ -3001,7 +3002,7 @@ static void zrangeResultFinalizeClient(zrange_result_handler *handler,
|
||||
/* Result handler methods for storing the ZRANGESTORE to a zset. */
|
||||
static void zrangeResultBeginStore(zrange_result_handler *handler, long length)
|
||||
{
|
||||
handler->dstobj = zsetTypeCreate(length, 0);
|
||||
handler->dstobj = zsetTypeCreate(length >= 0 ? length : 0, 0);
|
||||
}
|
||||
|
||||
static void zrangeResultEmitCBufferForStore(zrange_result_handler *handler,
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define REDISMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */
|
||||
#define VALKEYMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */
|
||||
|
||||
#include "server.h"
|
||||
#include "connhelpers.h"
|
||||
@@ -1169,36 +1169,36 @@ int RedisRegisterConnectionTypeTLS(void) {
|
||||
|
||||
#include "release.h"
|
||||
|
||||
int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) {
|
||||
int ValkeyModule_OnLoad(void *ctx, ValkeyModuleString **argv, int argc) {
|
||||
UNUSED(argv);
|
||||
UNUSED(argc);
|
||||
|
||||
/* Connection modules must be part of the same build as redis. */
|
||||
if (strcmp(REDIS_BUILD_ID_RAW, redisBuildIdRaw())) {
|
||||
serverLog(LL_NOTICE, "Connection type %s was not built together with the redis-server used.", CONN_TYPE_TLS);
|
||||
return REDISMODULE_ERR;
|
||||
return VALKEYMODULE_ERR;
|
||||
}
|
||||
|
||||
if (RedisModule_Init(ctx,"tls",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
if (ValkeyModule_Init(ctx,"tls",1,VALKEYMODULE_APIVER_1) == VALKEYMODULE_ERR)
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
/* Connection modules is available only bootup. */
|
||||
if ((RedisModule_GetContextFlags(ctx) & REDISMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) {
|
||||
if ((ValkeyModule_GetContextFlags(ctx) & VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) {
|
||||
serverLog(LL_NOTICE, "Connection type %s can be loaded only during bootup", CONN_TYPE_TLS);
|
||||
return REDISMODULE_ERR;
|
||||
return VALKEYMODULE_ERR;
|
||||
}
|
||||
|
||||
RedisModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD);
|
||||
ValkeyModule_SetModuleOptions(ctx, VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD);
|
||||
|
||||
if(connTypeRegister(&CT_TLS) != C_OK)
|
||||
return REDISMODULE_ERR;
|
||||
return VALKEYMODULE_ERR;
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return VALKEYMODULE_OK;
|
||||
}
|
||||
|
||||
int RedisModule_OnUnload(void *arg) {
|
||||
int ValkeyModule_OnUnload(void *arg) {
|
||||
UNUSED(arg);
|
||||
serverLog(LL_NOTICE, "Connection type %s can not be unloaded", CONN_TYPE_TLS);
|
||||
return REDISMODULE_ERR;
|
||||
return VALKEYMODULE_ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1424,7 +1424,7 @@ int parseOptions(int argc, char **argv) {
|
||||
config.numclients = atoi(argv[++i]);
|
||||
} else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) {
|
||||
sds version = benchmarkVersion();
|
||||
printf("redis-benchmark %s\n", version);
|
||||
printf("valkey-benchmark %s\n", version);
|
||||
sdsfree(version);
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[i],"-n")) {
|
||||
@@ -1606,12 +1606,12 @@ usage:
|
||||
|
||||
printf(
|
||||
"%s%s%s", /* Split to avoid strings longer than 4095 (-Woverlength-strings). */
|
||||
"Usage: redis-benchmark [OPTIONS] [COMMAND ARGS...]\n\n"
|
||||
"Usage: valkey-benchmark [OPTIONS] [COMMAND ARGS...]\n\n"
|
||||
"Options:\n"
|
||||
" -h <hostname> Server hostname (default 127.0.0.1)\n"
|
||||
" -p <port> Server port (default 6379)\n"
|
||||
" -s <socket> Server socket (overrides host and port)\n"
|
||||
" -a <password> Password for Redis Auth\n"
|
||||
" -a <password> Password for Valkey Auth\n"
|
||||
" --user <username> Used to send ACL style 'AUTH username pass'. Needs -a.\n"
|
||||
" -u <uri> Server URI.\n"
|
||||
" -c <clients> Number of parallel connections (default 50).\n"
|
||||
@@ -1655,17 +1655,17 @@ tls_usage,
|
||||
" --version Output version and exit.\n\n"
|
||||
"Examples:\n\n"
|
||||
" Run the benchmark with the default configuration against 127.0.0.1:6379:\n"
|
||||
" $ redis-benchmark\n\n"
|
||||
" $ valkey-benchmark\n\n"
|
||||
" Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:\n"
|
||||
" $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20\n\n"
|
||||
" $ valkey-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20\n\n"
|
||||
" Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:\n"
|
||||
" $ redis-benchmark -t set -n 1000000 -r 100000000\n\n"
|
||||
" $ valkey-benchmark -t set -n 1000000 -r 100000000\n\n"
|
||||
" Benchmark 127.0.0.1:6379 for a few commands producing CSV output:\n"
|
||||
" $ redis-benchmark -t ping,set,get -n 100000 --csv\n\n"
|
||||
" $ valkey-benchmark -t ping,set,get -n 100000 --csv\n\n"
|
||||
" Benchmark a specific command line:\n"
|
||||
" $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call(\"ping\")' 0\n\n"
|
||||
" $ valkey-benchmark -r 10000 -n 10000 eval 'return redis.call(\"ping\")' 0\n\n"
|
||||
" Fill a list with 10000 random elements:\n"
|
||||
" $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__\n\n"
|
||||
" $ valkey-benchmark -r 10000 -n 10000 lpush mylist __rand_int__\n\n"
|
||||
" On user specified command lines __rand_int__ is replaced with a random integer\n"
|
||||
" with a range of values selected by the -r option.\n"
|
||||
);
|
||||
@@ -199,7 +199,7 @@ int processAnnotations(FILE *fp, char *filename, int last_file) {
|
||||
printf("Failed to truncate AOF %s to timestamp %ld to offset %ld because it is not the last file.\n",
|
||||
filename, to_timestamp, (long int)epos);
|
||||
printf("If you insist, please delete all files after this file according to the manifest "
|
||||
"file and delete the corresponding records in manifest file manually. Then re-run redis-check-aof.\n");
|
||||
"file and delete the corresponding records in manifest file manually. Then re-run valkey-check-aof.\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Truncate remaining AOF if exceeding 'to_timestamp' */
|
||||
@@ -233,6 +233,7 @@ int checkSingleAof(char *aof_filename, char *aof_filepath, int last_file, int fi
|
||||
struct redis_stat sb;
|
||||
if (redis_fstat(fileno(fp),&sb) == -1) {
|
||||
printf("Cannot stat file: %s, aborting...\n", aof_filename);
|
||||
fclose(fp);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -343,6 +344,7 @@ int fileIsRDB(char *filepath) {
|
||||
struct redis_stat sb;
|
||||
if (redis_fstat(fileno(fp), &sb) == -1) {
|
||||
printf("Cannot stat file: %s\n", filepath);
|
||||
fclose(fp);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -379,6 +381,7 @@ int fileIsManifest(char *filepath) {
|
||||
struct redis_stat sb;
|
||||
if (redis_fstat(fileno(fp), &sb) == -1) {
|
||||
printf("Cannot stat file: %s\n", filepath);
|
||||
fclose(fp);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -395,15 +398,20 @@ int fileIsManifest(char *filepath) {
|
||||
break;
|
||||
} else {
|
||||
printf("Cannot read file: %s\n", filepath);
|
||||
fclose(fp);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip comments lines */
|
||||
/* We will skip comments lines.
|
||||
* At present, the manifest format is fixed, see aofInfoFormat.
|
||||
* We will break directly as long as it encounters other items. */
|
||||
if (buf[0] == '#') {
|
||||
continue;
|
||||
} else if (!memcmp(buf, "file", strlen("file"))) {
|
||||
is_manifest = 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +424,7 @@ int fileIsManifest(char *filepath) {
|
||||
* AOF_RDB_PREAMBLE: Old-style RDB-preamble AOF
|
||||
* AOF_MULTI_PART: manifest in Multi Part AOF
|
||||
*
|
||||
* redis-check-aof tool will automatically perform different
|
||||
* valkey-check-aof tool will automatically perform different
|
||||
* verification logic according to different file formats.
|
||||
* */
|
||||
input_file_type getInputFileType(char *filepath) {
|
||||
@@ -98,7 +98,9 @@ char *rdb_type_string[] = {
|
||||
"hash-listpack",
|
||||
"zset-listpack",
|
||||
"quicklist-v2",
|
||||
"stream-v2",
|
||||
"set-listpack",
|
||||
"stream-v3",
|
||||
};
|
||||
|
||||
/* Show a few stats collected into 'rdbstate' */
|
||||
@@ -419,7 +421,7 @@ int redis_check_rdb_main(int argc, char **argv, FILE *fp) {
|
||||
exit(1);
|
||||
} else if (!strcmp(argv[1],"-v") || !strcmp(argv[1], "--version")) {
|
||||
sds version = checkRdbVersion();
|
||||
printf("redis-check-rdb %s\n", version);
|
||||
printf("valkey-check-rdb %s\n", version);
|
||||
sdsfree(version);
|
||||
exit(0);
|
||||
}
|
||||
@@ -77,9 +77,9 @@
|
||||
#define REDIS_CLI_KEEPALIVE_INTERVAL 15 /* seconds */
|
||||
#define REDIS_CLI_DEFAULT_PIPE_TIMEOUT 30 /* seconds */
|
||||
#define REDIS_CLI_HISTFILE_ENV "REDISCLI_HISTFILE"
|
||||
#define REDIS_CLI_HISTFILE_DEFAULT ".rediscli_history"
|
||||
#define CLI_HISTFILE_DEFAULT ".valkeycli_history"
|
||||
#define REDIS_CLI_RCFILE_ENV "REDISCLI_RCFILE"
|
||||
#define REDIS_CLI_RCFILE_DEFAULT ".redisclirc"
|
||||
#define CLI_RCFILE_DEFAULT ".valkeyclirc"
|
||||
#define REDIS_CLI_AUTH_ENV "REDISCLI_AUTH"
|
||||
#define REDIS_CLI_CLUSTER_YES_ENV "REDISCLI_CLUSTER_YES"
|
||||
|
||||
@@ -322,7 +322,7 @@ static void cliRefreshPrompt(void) {
|
||||
|
||||
sds prompt = sdsempty();
|
||||
if (config.hostsocket != NULL) {
|
||||
prompt = sdscatfmt(prompt,"redis %s",config.hostsocket);
|
||||
prompt = sdscatfmt(prompt,"valkey %s",config.hostsocket);
|
||||
} else {
|
||||
char addr[256];
|
||||
formatAddr(addr, sizeof(addr), config.conn_info.hostip, config.conn_info.hostport);
|
||||
@@ -850,7 +850,7 @@ static size_t cliLegacyCountCommands(struct commandDocs *commands, sds version)
|
||||
* Stores the result in config.server_version.
|
||||
* When not connected, or not possible, returns NULL. */
|
||||
static sds cliGetServerVersion(void) {
|
||||
static const char *key = "\nredis_version:";
|
||||
static const char *key = "\nvalkey_version:";
|
||||
redisReply *serverInfo = NULL;
|
||||
char *pos;
|
||||
|
||||
@@ -868,7 +868,7 @@ static sds cliGetServerVersion(void) {
|
||||
assert(serverInfo->type == REDIS_REPLY_STRING || serverInfo->type == REDIS_REPLY_VERB);
|
||||
sds info = serverInfo->str;
|
||||
|
||||
/* Finds the first appearance of "redis_version" in the INFO SERVER reply. */
|
||||
/* Finds the first appearance of "valkey_version" in the INFO SERVER reply. */
|
||||
pos = strstr(info, key);
|
||||
if (pos) {
|
||||
pos += strlen(key);
|
||||
@@ -964,17 +964,17 @@ static void cliOutputCommandHelp(struct commandDocs *help, int group) {
|
||||
static void cliOutputGenericHelp(void) {
|
||||
sds version = cliVersion();
|
||||
printf(
|
||||
"redis-cli %s\n"
|
||||
"To get help about Redis commands type:\n"
|
||||
"valkey-cli %s\n"
|
||||
"To get help about Valkey commands type:\n"
|
||||
" \"help @<group>\" to get a list of commands in <group>\n"
|
||||
" \"help <command>\" for help on <command>\n"
|
||||
" \"help <tab>\" to get a list of possible help topics\n"
|
||||
" \"quit\" to exit\n"
|
||||
"\n"
|
||||
"To set redis-cli preferences:\n"
|
||||
"To set valkey-cli preferences:\n"
|
||||
" \":set hints\" enable online hints\n"
|
||||
" \":set nohints\" disable online hints\n"
|
||||
"Set your preferences in ~/.redisclirc\n",
|
||||
"Set your preferences in ~/.valkeyclirc\n",
|
||||
version
|
||||
);
|
||||
sdsfree(version);
|
||||
@@ -1657,6 +1657,7 @@ static int cliConnect(int flags) {
|
||||
redisFree(context);
|
||||
config.dbnum = 0;
|
||||
config.in_multi = 0;
|
||||
config.pubsub_mode = 0;
|
||||
cliRefreshPrompt();
|
||||
}
|
||||
|
||||
@@ -1680,7 +1681,7 @@ static int cliConnect(int flags) {
|
||||
|
||||
if (context->err) {
|
||||
if (!(flags & CC_QUIET)) {
|
||||
fprintf(stderr,"Could not connect to Redis at ");
|
||||
fprintf(stderr,"Could not connect to Valkey at ");
|
||||
if (config.hostsocket == NULL ||
|
||||
(config.cluster_mode && config.cluster_reissue_command))
|
||||
{
|
||||
@@ -2683,7 +2684,7 @@ static int parseOptions(int argc, char **argv) {
|
||||
} else if (!strcmp(argv[i],"--user") && !lastarg) {
|
||||
config.conn_info.user = sdsnew(argv[++i]);
|
||||
} else if (!strcmp(argv[i],"-u") && !lastarg) {
|
||||
parseRedisUri(argv[++i],"redis-cli",&config.conn_info,&config.tls);
|
||||
parseRedisUri(argv[++i],"valkey-cli",&config.conn_info,&config.tls);
|
||||
if (config.conn_info.hostport < 0 || config.conn_info.hostport > 65535) {
|
||||
fprintf(stderr, "Invalid server port.\n");
|
||||
exit(1);
|
||||
@@ -2898,7 +2899,7 @@ static int parseOptions(int argc, char **argv) {
|
||||
#endif
|
||||
} else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) {
|
||||
sds version = cliVersion();
|
||||
printf("redis-cli %s\n", version);
|
||||
printf("valkey-cli %s\n", version);
|
||||
sdsfree(version);
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[i],"-2")) {
|
||||
@@ -3012,9 +3013,9 @@ static void usage(int err) {
|
||||
"";
|
||||
|
||||
fprintf(target,
|
||||
"redis-cli %s\n"
|
||||
"valkey-cli %s\n"
|
||||
"\n"
|
||||
"Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]\n"
|
||||
"Usage: valkey-cli [OPTIONS] [cmd [arg [arg ...]]]\n"
|
||||
" -h <hostname> Server hostname (default: 127.0.0.1).\n"
|
||||
" -p <port> Server port (default: 6379).\n"
|
||||
" -s <socket> Server socket (overrides hostname and port).\n"
|
||||
@@ -3073,17 +3074,17 @@ version,tls_usage);
|
||||
" Use filename of \"-\" to write to stdout.\n"
|
||||
" --functions-rdb <filename> Like --rdb but only get the functions (not the keys)\n"
|
||||
" when getting the RDB dump file.\n"
|
||||
" --pipe Transfer raw Redis protocol from stdin to server.\n"
|
||||
" --pipe Transfer raw RESP protocol from stdin to server.\n"
|
||||
" --pipe-timeout <n> In --pipe mode, abort with error if after sending all data.\n"
|
||||
" no reply is received within <n> seconds.\n"
|
||||
" Default timeout: %d. Use 0 to wait forever.\n",
|
||||
REDIS_CLI_DEFAULT_PIPE_TIMEOUT);
|
||||
fprintf(target,
|
||||
" --bigkeys Sample Redis keys looking for keys with many elements (complexity).\n"
|
||||
" --memkeys Sample Redis keys looking for keys consuming a lot of memory.\n"
|
||||
" --memkeys-samples <n> Sample Redis keys looking for keys consuming a lot of memory.\n"
|
||||
" --bigkeys Sample keys looking for keys with many elements (complexity).\n"
|
||||
" --memkeys Sample keys looking for keys consuming a lot of memory.\n"
|
||||
" --memkeys-samples <n> Sample keys looking for keys consuming a lot of memory.\n"
|
||||
" And define number of key elements to sample\n"
|
||||
" --hotkeys Sample Redis keys looking for hot keys.\n"
|
||||
" --hotkeys Sample keys looking for hot keys.\n"
|
||||
" only works when maxmemory-policy is *lfu.\n"
|
||||
" --scan List all keys using the SCAN command.\n"
|
||||
" --pattern <pat> Keys pattern when using the --scan, --bigkeys or --hotkeys\n"
|
||||
@@ -3094,7 +3095,7 @@ version,tls_usage);
|
||||
" --intrinsic-latency <sec> Run a test to measure intrinsic system latency.\n"
|
||||
" The test will run for the specified amount of seconds.\n"
|
||||
" --eval <file> Send an EVAL command using the Lua script at <file>.\n"
|
||||
" --ldb Used with --eval enable the Redis Lua debugger.\n"
|
||||
" --ldb Used with --eval enable the Server Lua debugger.\n"
|
||||
" --ldb-sync-mode Like --ldb but uses the synchronous Lua debugger, in\n"
|
||||
" this mode the server is blocked and script changes are\n"
|
||||
" not rolled back from the server memory.\n"
|
||||
@@ -3112,18 +3113,19 @@ version,tls_usage);
|
||||
" Use --cluster help to list all available cluster manager commands.\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" cat /etc/passwd | redis-cli -x set mypasswd\n"
|
||||
" redis-cli -D \"\" --raw dump key > key.dump && redis-cli -X dump_tag restore key2 0 dump_tag replace < key.dump\n"
|
||||
" redis-cli -r 100 lpush mylist x\n"
|
||||
" redis-cli -r 100 -i 1 info | grep used_memory_human:\n"
|
||||
" redis-cli --quoted-input set '\"null-\\x00-separated\"' value\n"
|
||||
" redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3\n"
|
||||
" redis-cli --scan --pattern '*:12345*'\n"
|
||||
" redis-cli --scan --pattern '*:12345*' --count 100\n"
|
||||
" valkey-cli -u redis://default:PASSWORD@localhost:6379/0\n"
|
||||
" cat /etc/passwd | valkey-cli -x set mypasswd\n"
|
||||
" valkey-cli -D \"\" --raw dump key > key.dump && valkey-cli -X dump_tag restore key2 0 dump_tag replace < key.dump\n"
|
||||
" valkey-cli -r 100 lpush mylist x\n"
|
||||
" valkey-cli -r 100 -i 1 info | grep used_memory_human:\n"
|
||||
" valkey-cli --quoted-input set '\"null-\\x00-separated\"' value\n"
|
||||
" valkey-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3\n"
|
||||
" valkey-cli --scan --pattern '*:12345*'\n"
|
||||
" valkey-cli --scan --pattern '*:12345*' --count 100\n"
|
||||
"\n"
|
||||
" (Note: when using --eval the comma separates KEYS[] from ARGV[] items)\n"
|
||||
"\n"
|
||||
"When no command is given, redis-cli starts in interactive mode.\n"
|
||||
"When no command is given, valkey-cli starts in interactive mode.\n"
|
||||
"Type \"help\" in interactive mode for information on available commands\n"
|
||||
"and settings.\n"
|
||||
"\n");
|
||||
@@ -3219,27 +3221,27 @@ static sds *cliSplitArgs(char *line, int *argc) {
|
||||
}
|
||||
|
||||
/* Set the CLI preferences. This function is invoked when an interactive
|
||||
* ":command" is called, or when reading ~/.redisclirc file, in order to
|
||||
* ":command" is called, or when reading ~/.valkeyclirc file, in order to
|
||||
* set user preferences. */
|
||||
void cliSetPreferences(char **argv, int argc, int interactive) {
|
||||
if (!strcasecmp(argv[0],":set") && argc >= 2) {
|
||||
if (!strcasecmp(argv[1],"hints")) pref.hints = 1;
|
||||
else if (!strcasecmp(argv[1],"nohints")) pref.hints = 0;
|
||||
else {
|
||||
printf("%sunknown redis-cli preference '%s'\n",
|
||||
interactive ? "" : ".redisclirc: ",
|
||||
printf("%sunknown valkey-cli preference '%s'\n",
|
||||
interactive ? "" : ".valkeyclirc: ",
|
||||
argv[1]);
|
||||
}
|
||||
} else {
|
||||
printf("%sunknown redis-cli internal command '%s'\n",
|
||||
interactive ? "" : ".redisclirc: ",
|
||||
printf("%sunknown valkey-cli internal command '%s'\n",
|
||||
interactive ? "" : ".valkeyclirc: ",
|
||||
argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Load the ~/.redisclirc file if any. */
|
||||
/* Load the ~/.valkeyclirc file if any. */
|
||||
void cliLoadPreferences(void) {
|
||||
sds rcfile = getDotfilePath(REDIS_CLI_RCFILE_ENV,REDIS_CLI_RCFILE_DEFAULT);
|
||||
sds rcfile = getDotfilePath(REDIS_CLI_RCFILE_ENV,CLI_RCFILE_DEFAULT);
|
||||
if (rcfile == NULL) return;
|
||||
FILE *fp = fopen(rcfile,"r");
|
||||
char buf[1024];
|
||||
@@ -3336,7 +3338,7 @@ static void repl(void) {
|
||||
|
||||
/* Only use history and load the rc file when stdin is a tty. */
|
||||
if (isatty(fileno(stdin))) {
|
||||
historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,REDIS_CLI_HISTFILE_DEFAULT);
|
||||
historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,CLI_HISTFILE_DEFAULT);
|
||||
//keep in-memory history always regardless if history file can be determined
|
||||
history = 1;
|
||||
if (historyfile != NULL) {
|
||||
@@ -3381,7 +3383,7 @@ static void repl(void) {
|
||||
repeat = strtol(argv[0], &endptr, 10);
|
||||
if (argc > 1 && *endptr == '\0') {
|
||||
if (errno == ERANGE || errno == EINVAL || repeat <= 0) {
|
||||
fputs("Invalid redis-cli repeat command option value.\n", stdout);
|
||||
fputs("Invalid valkey-cli repeat command option value.\n", stdout);
|
||||
sdsfreesplitres(argv, argc);
|
||||
linenoiseFree(line);
|
||||
continue;
|
||||
@@ -3982,7 +3984,7 @@ static sds clusterManagerGetNodeRDBFilename(clusterManagerNode *node) {
|
||||
sds filename = sdsnew(config.cluster_manager_command.backup_dir);
|
||||
if (filename[sdslen(filename) - 1] != '/')
|
||||
filename = sdscat(filename, "/");
|
||||
filename = sdscatprintf(filename, "redis-node-%s-%d-%s.rdb", node->ip,
|
||||
filename = sdscatprintf(filename, "valkey-node-%s-%d-%s.rdb", node->ip,
|
||||
node->port, node->name);
|
||||
return filename;
|
||||
}
|
||||
@@ -4058,7 +4060,7 @@ static int clusterManagerNodeConnect(clusterManagerNode *node) {
|
||||
}
|
||||
}
|
||||
if (node->context->err) {
|
||||
fprintf(stderr,"Could not connect to Redis at ");
|
||||
fprintf(stderr,"Could not connect to Valkey at ");
|
||||
fprintf(stderr,"%s:%d: %s\n", node->ip, node->port,
|
||||
node->context->errstr);
|
||||
redisFree(node->context);
|
||||
@@ -5930,7 +5932,7 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
|
||||
CLUSTER_MANAGER_CMD_FLAG_FIX_WITH_UNREACHABLE_MASTERS;
|
||||
|
||||
if (cluster_manager.unreachable_masters > 0 && !force_fix) {
|
||||
clusterManagerLogWarn("*** Fixing slots coverage with %d unreachable masters is dangerous: redis-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters);
|
||||
clusterManagerLogWarn("*** Fixing slots coverage with %d unreachable masters is dangerous: valkey-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -6132,7 +6134,7 @@ static int clusterManagerFixOpenSlot(int slot) {
|
||||
CLUSTER_MANAGER_CMD_FLAG_FIX_WITH_UNREACHABLE_MASTERS;
|
||||
|
||||
if (cluster_manager.unreachable_masters > 0 && !force_fix) {
|
||||
clusterManagerLogWarn("*** Fixing open slots with %d unreachable masters is dangerous: redis-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters);
|
||||
clusterManagerLogWarn("*** Fixing open slots with %d unreachable masters is dangerous: valkey-cli will assume that slots about masters that are not reachable are not covered, and will try to reassign them to the reachable nodes. This can cause data loss and is rarely what you want to do. If you really want to proceed use the --cluster-fix-with-unreachable-masters option.\n", cluster_manager.unreachable_masters);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -6443,7 +6445,7 @@ static int clusterManagerFixOpenSlot(int slot) {
|
||||
} else {
|
||||
unhandled_case:
|
||||
success = 0;
|
||||
clusterManagerLogErr("[ERR] Sorry, redis-cli can't fix this slot "
|
||||
clusterManagerLogErr("[ERR] Sorry, valkey-cli can't fix this slot "
|
||||
"yet (work in progress). Slot is set as "
|
||||
"migrating in %s, as importing in %s, "
|
||||
"owner is %s:%d\n", migrating_str,
|
||||
@@ -6898,7 +6900,7 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
|
||||
if (masters_count < 3) {
|
||||
clusterManagerLogErr(
|
||||
"*** ERROR: Invalid configuration for cluster creation.\n"
|
||||
"*** Redis Cluster requires at least 3 master nodes.\n"
|
||||
"*** Valkey Cluster requires at least 3 master nodes.\n"
|
||||
"*** This is not possible with %d nodes and %d replicas per node.",
|
||||
node_len, replicas);
|
||||
clusterManagerLogErr("\n*** At least %d nodes are required.\n",
|
||||
@@ -7218,7 +7220,7 @@ static int clusterManagerCommandAddNode(int argc, char **argv) {
|
||||
reply = CLUSTER_MANAGER_COMMAND(refnode, "FUNCTION DUMP");
|
||||
if (!clusterManagerCheckRedisReply(refnode, reply, &err)) {
|
||||
clusterManagerLogInfo(">>> Failed retrieving Functions from the cluster, "
|
||||
"skip this step as Redis version do not support function command (error = '%s')\n", err? err : "NULL reply");
|
||||
"skip this step as Valkey version do not support function command (error = '%s')\n", err? err : "NULL reply");
|
||||
if (err) zfree(err);
|
||||
} else {
|
||||
assert(reply->type == REDIS_REPLY_STRING);
|
||||
@@ -7869,7 +7871,7 @@ static int clusterManagerCommandImport(int argc, char **argv) {
|
||||
redisContext *src_ctx = redisConnect(src_ip, src_port);
|
||||
if (src_ctx->err) {
|
||||
success = 0;
|
||||
fprintf(stderr,"Could not connect to Redis at %s:%d: %s.\n", src_ip,
|
||||
fprintf(stderr,"Could not connect to Valkey at %s:%d: %s.\n", src_ip,
|
||||
src_port, src_ctx->errstr);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -8838,7 +8840,8 @@ static redisReply *sendScan(unsigned long long *it) {
|
||||
reply = redisCommand(context, "SCAN %llu MATCH %b COUNT %d",
|
||||
*it, config.pattern, sdslen(config.pattern), config.count);
|
||||
else
|
||||
reply = redisCommand(context,"SCAN %llu",*it);
|
||||
reply = redisCommand(context, "SCAN %llu COUNT %d",
|
||||
*it, config.count);
|
||||
|
||||
/* Handle any error conditions */
|
||||
if(reply == NULL) {
|
||||
+1698
File diff suppressed because it is too large
Load Diff
+8
-2
@@ -1,2 +1,8 @@
|
||||
#define REDIS_VERSION "255.255.255"
|
||||
#define REDIS_VERSION_NUM 0x00ffffff
|
||||
#define SERVER_NAME "valkey"
|
||||
#define VALKEY_VERSION "7.2.6"
|
||||
#define VALKEY_VERSION_NUM 0x00070206
|
||||
|
||||
/* Redis compatibility version, should never
|
||||
* exceed 7.2.x. */
|
||||
#define REDIS_VERSION "7.2.4"
|
||||
#define REDIS_VERSION_NUM 0x00070204
|
||||
|
||||
@@ -84,7 +84,7 @@ test "Cluster consistency during live resharding" {
|
||||
flush stdout
|
||||
set target [dict get [get_myself [randomInt 5]] id]
|
||||
set tribpid [lindex [exec \
|
||||
../../../src/redis-cli --cluster reshard \
|
||||
../../../src/valkey-cli --cluster reshard \
|
||||
127.0.0.1:[get_instance_attrib redis 0 port] \
|
||||
--cluster-from all \
|
||||
--cluster-to $target \
|
||||
|
||||
@@ -38,7 +38,7 @@ test "Set allow-replica-migration yes" {
|
||||
set master0_id [dict get [get_myself 0] id]
|
||||
test "Resharding all the master #0 slots away from it" {
|
||||
set output [exec \
|
||||
../../../src/redis-cli --cluster rebalance \
|
||||
../../../src/valkey-cli --cluster rebalance \
|
||||
127.0.0.1:[get_instance_attrib redis 0 port] \
|
||||
{*}[rediscli_tls_config "../../../tests"] \
|
||||
--cluster-weight ${master0_id}=0 >@ stdout ]
|
||||
@@ -59,7 +59,7 @@ test "Resharding back some slot to master #0" {
|
||||
# new resharding.
|
||||
after 10000
|
||||
set output [exec \
|
||||
../../../src/redis-cli --cluster rebalance \
|
||||
../../../src/valkey-cli --cluster rebalance \
|
||||
127.0.0.1:[get_instance_attrib redis 0 port] \
|
||||
{*}[rediscli_tls_config "../../../tests"] \
|
||||
--cluster-weight ${master0_id}=.01 \
|
||||
|
||||
@@ -37,7 +37,7 @@ test "Set allow-replica-migration no" {
|
||||
set master0_id [dict get [get_myself 0] id]
|
||||
test "Resharding all the master #0 slots away from it" {
|
||||
set output [exec \
|
||||
../../../src/redis-cli --cluster rebalance \
|
||||
../../../src/valkey-cli --cluster rebalance \
|
||||
127.0.0.1:[get_instance_attrib redis 0 port] \
|
||||
{*}[rediscli_tls_config "../../../tests"] \
|
||||
--cluster-weight ${master0_id}=0 >@ stdout ]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Read the standard input and only shows dots in the output, filtering out
|
||||
# all the other characters. Designed to avoid bufferization so that when
|
||||
# we get the output of redis-trib and want to show just the dots, we'll see
|
||||
# the dots as soon as redis-trib will output them.
|
||||
# we get the output of valkey-trib and want to show just the dots, we'll see
|
||||
# the dots as soon as valkey-trib will output them.
|
||||
|
||||
fconfigure stdin -buffering none
|
||||
|
||||
|
||||
@@ -8,25 +8,25 @@ proc config_set_all_nodes {keyword value} {
|
||||
|
||||
proc fix_cluster {addr} {
|
||||
set code [catch {
|
||||
exec ../../../src/redis-cli {*}[rediscli_tls_config "../../../tests"] --cluster fix $addr << yes
|
||||
exec ../../../src/valkey-cli {*}[rediscli_tls_config "../../../tests"] --cluster fix $addr << yes
|
||||
} result]
|
||||
if {$code != 0} {
|
||||
puts "redis-cli --cluster fix returns non-zero exit code, output below:\n$result"
|
||||
puts "valkey-cli --cluster fix returns non-zero exit code, output below:\n$result"
|
||||
}
|
||||
# Note: redis-cli --cluster fix may return a non-zero exit code if nodes don't agree,
|
||||
# Note: valkey-cli --cluster fix may return a non-zero exit code if nodes don't agree,
|
||||
# but we can ignore that and rely on the check below.
|
||||
assert_cluster_state ok
|
||||
wait_for_condition 100 100 {
|
||||
[catch {exec ../../../src/redis-cli {*}[rediscli_tls_config "../../../tests"] --cluster check $addr} result] == 0
|
||||
[catch {exec ../../../src/valkey-cli {*}[rediscli_tls_config "../../../tests"] --cluster check $addr} result] == 0
|
||||
} else {
|
||||
puts "redis-cli --cluster check returns non-zero exit code, output below:\n$result"
|
||||
puts "valkey-cli --cluster check returns non-zero exit code, output below:\n$result"
|
||||
fail "Cluster could not settle with configuration"
|
||||
}
|
||||
}
|
||||
|
||||
proc wait_cluster_stable {} {
|
||||
wait_for_condition 1000 50 {
|
||||
[catch {exec ../../../src/redis-cli --cluster \
|
||||
[catch {exec ../../../src/valkey-cli --cluster \
|
||||
check 127.0.0.1:[get_instance_attrib redis 0 port] \
|
||||
{*}[rediscli_tls_config "../../../tests"] \
|
||||
}] == 0
|
||||
|
||||
+5
-5
@@ -48,9 +48,9 @@ if {[catch {cd tmp}]} {
|
||||
# the provided configuration file. Returns the PID of the process.
|
||||
proc exec_instance {type dirname cfgfile} {
|
||||
if {$type eq "redis"} {
|
||||
set prgname redis-server
|
||||
set prgname valkey-server
|
||||
} elseif {$type eq "sentinel"} {
|
||||
set prgname redis-sentinel
|
||||
set prgname valkey-sentinel
|
||||
} else {
|
||||
error "Unknown instance type."
|
||||
}
|
||||
@@ -87,7 +87,7 @@ proc spawn_instance {type base_port count {conf {}} {base_conf_file ""}} {
|
||||
|
||||
if {$::tls} {
|
||||
if {$::tls_module} {
|
||||
puts $cfg [format "loadmodule %s/../../../src/redis-tls.so" [pwd]]
|
||||
puts $cfg [format "loadmodule %s/../../../src/valkey-tls.so" [pwd]]
|
||||
}
|
||||
|
||||
puts $cfg "tls-port $port"
|
||||
@@ -342,7 +342,7 @@ proc pause_on_error {} {
|
||||
set cmd [lindex $argv 0]
|
||||
if {$cmd eq {continue}} {
|
||||
break
|
||||
} elseif {$cmd eq {show-redis-logs}} {
|
||||
} elseif {$cmd eq {show-valkey-logs}} {
|
||||
set count 10
|
||||
if {[lindex $argv 1] ne {}} {set count [lindex $argv 1]}
|
||||
foreach_redis_id id {
|
||||
@@ -393,7 +393,7 @@ proc pause_on_error {} {
|
||||
} elseif {$cmd eq {help}} {
|
||||
puts "ls List Sentinel and Redis instances."
|
||||
puts "show-sentinel-logs \[N\] Show latest N lines of logs."
|
||||
puts "show-redis-logs \[N\] Show latest N lines of logs."
|
||||
puts "show-valkey-logs \[N\] Show latest N lines of logs."
|
||||
puts "S <id> cmd ... arg Call command in Sentinel <id>."
|
||||
puts "R <id> cmd ... arg Call command in Redis <id>."
|
||||
puts "SI <id> <field> Show Sentinel <id> INFO <field>."
|
||||
|
||||
@@ -8,7 +8,7 @@ tags {"aof external:skip"} {
|
||||
# was subsequently appended to the new AOF, resulting in duplicate commands.
|
||||
start_server_aof [list dir $server_path] {
|
||||
set client [redis [dict get $srv host] [dict get $srv port] 0 $::tls]
|
||||
set bench [open "|src/redis-benchmark -q -s [dict get $srv unixsocket] -c 20 -n 20000 incr foo" "r+"]
|
||||
set bench [open "|src/valkey-benchmark -q -s [dict get $srv unixsocket] -c 20 -n 20000 incr foo" "r+"]
|
||||
|
||||
wait_for_condition 100 1 {
|
||||
[$client get foo] > 0
|
||||
|
||||
+46
-21
@@ -140,10 +140,10 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
}
|
||||
|
||||
## Test that redis-check-aof indeed sees this AOF is not valid
|
||||
## Test that valkey-check-aof indeed sees this AOF is not valid
|
||||
test "Short read: Utility should confirm the AOF is not valid" {
|
||||
catch {
|
||||
exec src/redis-check-aof $aof_manifest_file
|
||||
exec src/valkey-check-aof $aof_manifest_file
|
||||
} result
|
||||
assert_match "*not valid*" $result
|
||||
}
|
||||
@@ -155,13 +155,13 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof $aof_manifest_file
|
||||
exec src/valkey-check-aof $aof_manifest_file
|
||||
} result
|
||||
assert_match "*ok_up_to_line=8*" $result
|
||||
}
|
||||
|
||||
test "Short read: Utility should be able to fix the AOF" {
|
||||
set result [exec src/redis-check-aof --fix $aof_manifest_file << "y\n"]
|
||||
set result [exec src/valkey-check-aof --fix $aof_manifest_file << "y\n"]
|
||||
assert_match "*Successfully truncated AOF*" $result
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ tags {"aof external:skip"} {
|
||||
|
||||
test {Truncate AOF to specific timestamp} {
|
||||
# truncate to timestamp 1628217473
|
||||
exec src/redis-check-aof --truncate-to-timestamp 1628217473 $aof_manifest_file
|
||||
exec src/valkey-check-aof --truncate-to-timestamp 1628217473 $aof_manifest_file
|
||||
start_server_aof [list dir $server_path] {
|
||||
set c [redis [dict get $srv host] [dict get $srv port] 0 $::tls]
|
||||
wait_done_loading $c
|
||||
@@ -455,7 +455,7 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
# truncate to timestamp 1628217471
|
||||
exec src/redis-check-aof --truncate-to-timestamp 1628217471 $aof_manifest_file
|
||||
exec src/valkey-check-aof --truncate-to-timestamp 1628217471 $aof_manifest_file
|
||||
start_server_aof [list dir $server_path] {
|
||||
set c [redis [dict get $srv host] [dict get $srv port] 0 $::tls]
|
||||
wait_done_loading $c
|
||||
@@ -465,7 +465,7 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
# truncate to timestamp 1628217470
|
||||
exec src/redis-check-aof --truncate-to-timestamp 1628217470 $aof_manifest_file
|
||||
exec src/valkey-check-aof --truncate-to-timestamp 1628217470 $aof_manifest_file
|
||||
start_server_aof [list dir $server_path] {
|
||||
set c [redis [dict get $srv host] [dict get $srv port] 0 $::tls]
|
||||
wait_done_loading $c
|
||||
@@ -474,7 +474,7 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
# truncate to timestamp 1628217469
|
||||
catch {exec src/redis-check-aof --truncate-to-timestamp 1628217469 $aof_manifest_file} e
|
||||
catch {exec src/valkey-check-aof --truncate-to-timestamp 1628217469 $aof_manifest_file} e
|
||||
assert_match {*aborting*} $e
|
||||
}
|
||||
|
||||
@@ -517,26 +517,38 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
}
|
||||
|
||||
test {Test redis-check-aof for old style resp AOF} {
|
||||
test {Test valkey-check-aof for old style resp AOF} {
|
||||
create_aof $aof_dirpath $aof_file {
|
||||
append_to_aof [formatCommand set foo hello]
|
||||
append_to_aof [formatCommand set bar world]
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof $aof_file
|
||||
exec src/valkey-check-aof $aof_file
|
||||
} result
|
||||
assert_match "*Start checking Old-Style AOF*is valid*" $result
|
||||
}
|
||||
|
||||
test {Test redis-check-aof for old style rdb-preamble AOF} {
|
||||
test {Test valkey-check-aof for old style resp AOF - has data in the same format as manifest} {
|
||||
create_aof $aof_dirpath $aof_file {
|
||||
append_to_aof [formatCommand set file file]
|
||||
append_to_aof [formatCommand set "file appendonly.aof.2.base.rdb seq 2 type b" "file appendonly.aof.2.base.rdb seq 2 type b"]
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof tests/assets/rdb-preamble.aof
|
||||
exec src/valkey-check-aof $aof_file
|
||||
} result
|
||||
assert_match "*Start checking Old-Style AOF*is valid*" $result
|
||||
}
|
||||
|
||||
test {Test valkey-check-aof for old style rdb-preamble AOF} {
|
||||
catch {
|
||||
exec src/valkey-check-aof tests/assets/rdb-preamble.aof
|
||||
} result
|
||||
assert_match "*Start checking Old-Style AOF*RDB preamble is OK, proceeding with AOF tail*is valid*" $result
|
||||
}
|
||||
|
||||
test {Test redis-check-aof for Multi Part AOF with resp AOF base} {
|
||||
test {Test valkey-check-aof for Multi Part AOF with resp AOF base} {
|
||||
create_aof $aof_dirpath $aof_base_file {
|
||||
append_to_aof [formatCommand set foo hello]
|
||||
append_to_aof [formatCommand set bar world]
|
||||
@@ -553,12 +565,12 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof $aof_manifest_file
|
||||
exec src/valkey-check-aof $aof_manifest_file
|
||||
} result
|
||||
assert_match "*Start checking Multi Part AOF*Start to check BASE AOF (RESP format)*BASE AOF*is valid*Start to check INCR files*INCR AOF*is valid*All AOF files and manifest are valid*" $result
|
||||
}
|
||||
|
||||
test {Test redis-check-aof for Multi Part AOF with rdb-preamble AOF base} {
|
||||
test {Test valkey-check-aof for Multi Part AOF with rdb-preamble AOF base} {
|
||||
exec cp tests/assets/rdb-preamble.aof $aof_base_file
|
||||
|
||||
create_aof $aof_dirpath $aof_file {
|
||||
@@ -572,12 +584,25 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof $aof_manifest_file
|
||||
exec src/valkey-check-aof $aof_manifest_file
|
||||
} result
|
||||
assert_match "*Start checking Multi Part AOF*Start to check BASE AOF (RDB format)*DB preamble is OK, proceeding with AOF tail*BASE AOF*is valid*Start to check INCR files*INCR AOF*is valid*All AOF files and manifest are valid*" $result
|
||||
}
|
||||
|
||||
test {Test redis-check-aof only truncates the last file for Multi Part AOF in fix mode} {
|
||||
test {Test valkey-check-aof for Multi Part AOF contains a format error} {
|
||||
create_aof_manifest $aof_dirpath $aof_manifest_file {
|
||||
append_to_manifest "file appendonly.aof.1.base.aof seq 1 type b\n"
|
||||
append_to_manifest "file appendonly.aof.1.incr.aof seq 1 type i\n"
|
||||
append_to_manifest "!!!\n"
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/valkey-check-aof $aof_manifest_file
|
||||
} result
|
||||
assert_match "*Invalid AOF manifest file format*" $result
|
||||
}
|
||||
|
||||
test {Test valkey-check-aof only truncates the last file for Multi Part AOF in fix mode} {
|
||||
create_aof $aof_dirpath $aof_base_file {
|
||||
append_to_aof [formatCommand set foo hello]
|
||||
append_to_aof [formatCommand multi]
|
||||
@@ -595,17 +620,17 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof $aof_manifest_file
|
||||
exec src/valkey-check-aof $aof_manifest_file
|
||||
} result
|
||||
assert_match "*not valid*" $result
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof --fix $aof_manifest_file
|
||||
exec src/valkey-check-aof --fix $aof_manifest_file
|
||||
} result
|
||||
assert_match "*Failed to truncate AOF*because it is not the last file*" $result
|
||||
}
|
||||
|
||||
test {Test redis-check-aof only truncates the last file for Multi Part AOF in truncate-to-timestamp mode} {
|
||||
test {Test valkey-check-aof only truncates the last file for Multi Part AOF in truncate-to-timestamp mode} {
|
||||
create_aof $aof_dirpath $aof_base_file {
|
||||
append_to_aof "#TS:1628217470\r\n"
|
||||
append_to_aof [formatCommand set foo1 bar1]
|
||||
@@ -628,7 +653,7 @@ tags {"aof external:skip"} {
|
||||
}
|
||||
|
||||
catch {
|
||||
exec src/redis-check-aof --truncate-to-timestamp 1628217473 $aof_manifest_file
|
||||
exec src/valkey-check-aof --truncate-to-timestamp 1628217473 $aof_manifest_file
|
||||
} result
|
||||
assert_match "*Failed to truncate AOF*to timestamp*because it is not the last file*" $result
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ if {$system_name eq {darwin}} {
|
||||
# Avoid the test on libmusl, which does not support backtrace
|
||||
# and on static binaries (ldd exit code 1) where we can't detect libmusl
|
||||
catch {
|
||||
set ldd [exec ldd src/redis-server]
|
||||
set ldd [exec ldd src/valkey-server]
|
||||
if {![string match {*libc.*musl*} $ldd]} {
|
||||
set backtrace_supported 1
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Issue 3899 regression test.
|
||||
# We create a chain of three instances: master -> slave -> slave2
|
||||
# and continuously break the link while traffic is generated by
|
||||
# redis-benchmark. At the end we check that the data is the same
|
||||
# valkey-benchmark. At the end we check that the data is the same
|
||||
# everywhere.
|
||||
|
||||
start_server {tags {"psync2 external:skip"}} {
|
||||
@@ -40,7 +40,7 @@ start_server {} {
|
||||
}
|
||||
|
||||
set cycle_start_time [clock milliseconds]
|
||||
set bench_pid [exec src/redis-benchmark -s $R_unixsocket(0) -n 10000000 -r 1000 incr __rand_int__ > /dev/null &]
|
||||
set bench_pid [exec src/valkey-benchmark -s $R_unixsocket(0) -n 10000000 -r 1000 incr __rand_int__ > /dev/null &]
|
||||
while 1 {
|
||||
set elapsed [expr {[clock milliseconds]-$cycle_start_time}]
|
||||
if {$elapsed > $duration*1000} break
|
||||
|
||||
@@ -5,14 +5,14 @@ proc cmdstat {cmd} {
|
||||
return [cmdrstat $cmd r]
|
||||
}
|
||||
|
||||
# common code to reset stats, flush the db and run redis-benchmark
|
||||
# common code to reset stats, flush the db and run valkey-benchmark
|
||||
proc common_bench_setup {cmd} {
|
||||
r config resetstat
|
||||
r flushall
|
||||
if {[catch { exec {*}$cmd } error]} {
|
||||
set first_line [lindex [split $error "\n"] 0]
|
||||
puts [colorstr red "redis-benchmark non zero code. first line: $first_line"]
|
||||
fail "redis-benchmark non zero code. first line: $first_line"
|
||||
puts [colorstr red "valkey-benchmark non zero code. first line: $first_line"]
|
||||
fail "valkey-benchmark non zero code. first line: $first_line"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ start_server {tags {"benchmark network external:skip logreqres:skip"}} {
|
||||
puts "Skipping test, TLSv1.3 not supported."
|
||||
}
|
||||
} else {
|
||||
puts [colorstr red "redis-benchmark non zero code. first line: $first_line"]
|
||||
fail "redis-benchmark non zero code. first line: $first_line"
|
||||
puts [colorstr red "valkey-benchmark non zero code. first line: $first_line"]
|
||||
fail "valkey-benchmark non zero code. first line: $first_line"
|
||||
}
|
||||
}
|
||||
if {$ciphersuites_supported} {
|
||||
@@ -509,7 +509,7 @@ if {!$::tls} { ;# fake_redis_node doesn't support TLS
|
||||
wait_for_condition 500 100 {
|
||||
[string match {*slave0:*state=online*} [r info]]
|
||||
} else {
|
||||
fail "redis-cli --replica did not connect"
|
||||
fail "valkey-cli --replica did not connect"
|
||||
}
|
||||
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
@@ -519,7 +519,7 @@ if {!$::tls} { ;# fake_redis_node doesn't support TLS
|
||||
wait_for_condition 500 100 {
|
||||
[string match {*test-value-99*} [read_cli $fd]]
|
||||
} else {
|
||||
fail "redis-cli --replica didn't read commands"
|
||||
fail "valkey-cli --replica didn't read commands"
|
||||
}
|
||||
|
||||
fconfigure $fd -blocking true
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "redismodule.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
static RedisModuleString *log_key_name;
|
||||
|
||||
@@ -92,7 +93,7 @@ int CommandFilter_LogCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
int CommandFilter_UnfilteredClientdId(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
int CommandFilter_UnfilteredClientId(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
{
|
||||
if (argc < 2)
|
||||
return RedisModule_WrongArity(ctx);
|
||||
@@ -192,7 +193,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
if (RedisModule_Init(ctx,"commandfilter",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 2 && argc != 3) {
|
||||
RedisModule_Log(ctx, "warning", "Log key name not specified");
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
@@ -219,7 +220,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx, unfiltered_clientid_name,
|
||||
CommandFilter_UnfilteredClientdId, "admin", 1,1,1) == REDISMODULE_ERR)
|
||||
CommandFilter_UnfilteredClientId, "admin", 1,1,1) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
if ((filter = RedisModule_RegisterCommandFilter(ctx, CommandFilter_CommandFilter,
|
||||
@@ -229,6 +230,16 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
if ((filter1 = RedisModule_RegisterCommandFilter(ctx, CommandFilter_BlmoveSwap, 0)) == NULL)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
if (argc == 3) {
|
||||
const char *ptr = RedisModule_StringPtrLen(argv[2], NULL);
|
||||
if (!strcasecmp(ptr, "noload")) {
|
||||
/* This is a hint that we return ERR at the last moment of OnLoad. */
|
||||
RedisModule_FreeString(ctx, log_key_name);
|
||||
if (retained) RedisModule_FreeString(NULL, retained);
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
|
||||
+13
-3
@@ -33,6 +33,7 @@
|
||||
#include "redismodule.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* We need to store events to be able to test and see what we got, and we can't
|
||||
@@ -407,9 +408,6 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_ERR; \
|
||||
}
|
||||
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"testhook",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
|
||||
@@ -471,6 +469,18 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
if (RedisModule_CreateCommand(ctx,"hooks.pexpireat", cmdKeyExpiry,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
if (argc == 1) {
|
||||
const char *ptr = RedisModule_StringPtrLen(argv[0], NULL);
|
||||
if (!strcasecmp(ptr, "noload")) {
|
||||
/* This is a hint that we return ERR at the last moment of OnLoad. */
|
||||
RedisModule_FreeDict(ctx, event_log);
|
||||
RedisModule_FreeDict(ctx, removed_event_log);
|
||||
RedisModule_FreeDict(ctx, removed_subevent_type);
|
||||
RedisModule_FreeDict(ctx, removed_expiry_log);
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "redismodule.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
ustime_t cached_time = 0;
|
||||
@@ -318,9 +319,6 @@ static int cmdGetDels(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
|
||||
if (RedisModule_Init(ctx,"testkeyspace",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR){
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
@@ -405,6 +403,16 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
const char *ptr = RedisModule_StringPtrLen(argv[0], NULL);
|
||||
if (!strcasecmp(ptr, "noload")) {
|
||||
/* This is a hint that we return ERR at the last moment of OnLoad. */
|
||||
RedisModule_FreeDict(ctx, loaded_event_log);
|
||||
RedisModule_FreeDict(ctx, module_event_log);
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ int test_setlfu(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
int test_redisversion(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
|
||||
int test_serverversion(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
|
||||
(void) argv;
|
||||
(void) argc;
|
||||
|
||||
@@ -543,7 +543,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_ERR;
|
||||
if (RedisModule_CreateCommand(ctx,"test.setname", test_setname,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
if (RedisModule_CreateCommand(ctx,"test.redisversion", test_redisversion,"",0,0,0) == REDISMODULE_ERR)
|
||||
if (RedisModule_CreateCommand(ctx,"test.serverversion", test_serverversion,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
if (RedisModule_CreateCommand(ctx,"test.getclientcert", test_getclientcert,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
@@ -90,6 +90,10 @@ static int KeySpace_NotificationEvicted(RedisModuleCtx *ctx, int type, const cha
|
||||
return REDISMODULE_OK; /* do not count the evicted key */
|
||||
}
|
||||
|
||||
if (strncmp(key_str, "before_evicted", 14) == 0) {
|
||||
return REDISMODULE_OK; /* do not count the before_evicted key */
|
||||
}
|
||||
|
||||
RedisModuleString *new_key = RedisModule_CreateString(NULL, "evicted", 7);
|
||||
RedisModule_AddPostNotificationJob(ctx, KeySpace_PostNotificationString, new_key, KeySpace_PostNotificationStringFreePD);
|
||||
return REDISMODULE_OK;
|
||||
@@ -186,6 +190,55 @@ static int KeySpace_PostNotificationsAsyncSet(RedisModuleCtx *ctx, RedisModuleSt
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
typedef struct KeySpace_EventPostNotificationCtx {
|
||||
RedisModuleString *triggered_on;
|
||||
RedisModuleString *new_key;
|
||||
} KeySpace_EventPostNotificationCtx;
|
||||
|
||||
static void KeySpace_ServerEventPostNotificationFree(void *pd) {
|
||||
KeySpace_EventPostNotificationCtx *pn_ctx = pd;
|
||||
RedisModule_FreeString(NULL, pn_ctx->new_key);
|
||||
RedisModule_FreeString(NULL, pn_ctx->triggered_on);
|
||||
RedisModule_Free(pn_ctx);
|
||||
}
|
||||
|
||||
static void KeySpace_ServerEventPostNotification(RedisModuleCtx *ctx, void *pd) {
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
KeySpace_EventPostNotificationCtx *pn_ctx = pd;
|
||||
RedisModuleCallReply* rep = RedisModule_Call(ctx, "lpush", "!ss", pn_ctx->new_key, pn_ctx->triggered_on);
|
||||
RedisModule_FreeCallReply(rep);
|
||||
}
|
||||
|
||||
static void KeySpace_ServerEventCallback(RedisModuleCtx *ctx, RedisModuleEvent eid, uint64_t subevent, void *data) {
|
||||
REDISMODULE_NOT_USED(eid);
|
||||
REDISMODULE_NOT_USED(data);
|
||||
if (subevent > 3) {
|
||||
RedisModule_Log(ctx, "warning", "Got an unexpected subevent '%ld'", subevent);
|
||||
return;
|
||||
}
|
||||
static const char* events[] = {
|
||||
"before_deleted",
|
||||
"before_expired",
|
||||
"before_evicted",
|
||||
"before_overwritten",
|
||||
};
|
||||
|
||||
const RedisModuleString *key_name = RedisModule_GetKeyNameFromModuleKey(((RedisModuleKeyInfo*)data)->key);
|
||||
const char *key_str = RedisModule_StringPtrLen(key_name, NULL);
|
||||
|
||||
for (int i = 0 ; i < 4 ; ++i) {
|
||||
const char *event = events[i];
|
||||
if (strncmp(key_str, event , strlen(event)) == 0) {
|
||||
return; /* don't log any event on our tracking keys */
|
||||
}
|
||||
}
|
||||
|
||||
KeySpace_EventPostNotificationCtx *pn_ctx = RedisModule_Alloc(sizeof(*pn_ctx));
|
||||
pn_ctx->triggered_on = RedisModule_HoldString(NULL, (RedisModuleString*)key_name);
|
||||
pn_ctx->new_key = RedisModule_CreateString(NULL, events[subevent], strlen(events[subevent]));
|
||||
RedisModule_AddPostNotificationJob(ctx, KeySpace_ServerEventPostNotification, pn_ctx, KeySpace_ServerEventPostNotificationFree);
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
@@ -200,6 +253,14 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
|
||||
int with_key_events = 0;
|
||||
if (argc >= 1) {
|
||||
const char *arg = RedisModule_StringPtrLen(argv[0], 0);
|
||||
if (strcmp(arg, "with_key_events") == 0) {
|
||||
with_key_events = 1;
|
||||
}
|
||||
}
|
||||
|
||||
RedisModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS);
|
||||
|
||||
if(RedisModule_SubscribeToKeyspaceEvents(ctx, REDISMODULE_NOTIFY_STRING, KeySpace_NotificationString) != REDISMODULE_OK){
|
||||
@@ -222,6 +283,12 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
|
||||
if (with_key_events) {
|
||||
if(RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_Key, KeySpace_ServerEventCallback) != REDISMODULE_OK){
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
if (RedisModule_CreateCommand(ctx, "postnotification.async_set", KeySpace_PostNotificationsAsyncSet,
|
||||
"write", 0, 0, 0) == REDISMODULE_ERR){
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
@@ -12,21 +12,21 @@ proc redisbenchmark_tls_config {testsdir} {
|
||||
}
|
||||
|
||||
proc redisbenchmark {host port {opts {}}} {
|
||||
set cmd [list src/redis-benchmark -h $host -p $port]
|
||||
set cmd [list src/valkey-benchmark -h $host -p $port]
|
||||
lappend cmd {*}[redisbenchmark_tls_config "tests"]
|
||||
lappend cmd {*}$opts
|
||||
return $cmd
|
||||
}
|
||||
|
||||
proc redisbenchmarkuri {host port {opts {}}} {
|
||||
set cmd [list src/redis-benchmark -u redis://$host:$port]
|
||||
set cmd [list src/valkey-benchmark -u redis://$host:$port]
|
||||
lappend cmd {*}[redisbenchmark_tls_config "tests"]
|
||||
lappend cmd {*}$opts
|
||||
return $cmd
|
||||
}
|
||||
|
||||
proc redisbenchmarkuriuserpass {host port user pass {opts {}}} {
|
||||
set cmd [list src/redis-benchmark -u redis://$user:$pass@$host:$port]
|
||||
set cmd [list src/valkey-benchmark -u redis://$user:$pass@$host:$port]
|
||||
lappend cmd {*}[redisbenchmark_tls_config "tests"]
|
||||
lappend cmd {*}$opts
|
||||
return $cmd
|
||||
|
||||
@@ -11,20 +11,20 @@ proc rediscli_tls_config {testsdir} {
|
||||
}
|
||||
}
|
||||
|
||||
# Returns command line for executing redis-cli
|
||||
# Returns command line for executing valkey-cli
|
||||
proc rediscli {host port {opts {}}} {
|
||||
set cmd [list src/redis-cli -h $host -p $port]
|
||||
set cmd [list src/valkey-cli -h $host -p $port]
|
||||
lappend cmd {*}[rediscli_tls_config "tests"]
|
||||
lappend cmd {*}$opts
|
||||
return $cmd
|
||||
}
|
||||
|
||||
# Returns command line for executing redis-cli with a unix socket address
|
||||
# Returns command line for executing valkey-cli with a unix socket address
|
||||
proc rediscli_unixsocket {unixsocket {opts {}}} {
|
||||
return [list src/redis-cli -s $unixsocket {*}$opts]
|
||||
return [list src/valkey-cli -s $unixsocket {*}$opts]
|
||||
}
|
||||
|
||||
# Run redis-cli with specified args on the server of specified level.
|
||||
# Run valkey-cli with specified args on the server of specified level.
|
||||
# Returns output broken down into individual lines.
|
||||
proc rediscli_exec {level args} {
|
||||
set cmd [rediscli_unixsocket [srv $level unixsocket] $args]
|
||||
|
||||
@@ -199,3 +199,43 @@ proc are_hostnames_propagated {match_string} {
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
proc wait_node_marked_fail {ref_node_index instance_id_to_check} {
|
||||
wait_for_condition 1000 50 {
|
||||
[check_cluster_node_mark fail $ref_node_index $instance_id_to_check]
|
||||
} else {
|
||||
fail "Replica node never marked as FAIL ('fail')"
|
||||
}
|
||||
}
|
||||
|
||||
proc wait_node_marked_pfail {ref_node_index instance_id_to_check} {
|
||||
wait_for_condition 1000 50 {
|
||||
[check_cluster_node_mark fail\? $ref_node_index $instance_id_to_check]
|
||||
} else {
|
||||
fail "Replica node never marked as PFAIL ('fail?')"
|
||||
}
|
||||
}
|
||||
|
||||
proc check_cluster_node_mark {flag ref_node_index instance_id_to_check} {
|
||||
set nodes [get_cluster_nodes $ref_node_index]
|
||||
|
||||
foreach n $nodes {
|
||||
if {[dict get $n id] eq $instance_id_to_check} {
|
||||
return [cluster_has_flag $n $flag]
|
||||
}
|
||||
}
|
||||
fail "Unable to find instance id in cluster nodes. ID: $instance_id_to_check"
|
||||
}
|
||||
|
||||
proc cluster_allocate_slots {masters replicas} {
|
||||
set slot 16383
|
||||
while {$slot >= 0} {
|
||||
# Allocate successive slots to random nodes.
|
||||
set node [randomInt $masters]
|
||||
lappend slots_$node $slot
|
||||
incr slot -1
|
||||
}
|
||||
for {set j 0} {$j < $masters} {incr j} {
|
||||
R $j cluster addslots {*}[set slots_${j}]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ proc create_server_config_file {filename config config_lines} {
|
||||
}
|
||||
|
||||
proc spawn_server {config_file stdout stderr args} {
|
||||
set cmd [list src/redis-server $config_file]
|
||||
set cmd [list src/valkey-server $config_file]
|
||||
set args {*}$args
|
||||
if {[llength $args] > 0} {
|
||||
lappend cmd {*}$args
|
||||
@@ -471,7 +471,7 @@ proc start_server {options {code undefined}} {
|
||||
set config {}
|
||||
if {$::tls} {
|
||||
if {$::tls_module} {
|
||||
lappend config_lines [list "loadmodule" [format "%s/src/redis-tls.so" [pwd]]]
|
||||
lappend config_lines [list "loadmodule" [format "%s/src/valkey-tls.so" [pwd]]]
|
||||
}
|
||||
dict set config "tls-cert-file" [format "%s/tests/tls/server.crt" [pwd]]
|
||||
dict set config "tls-key-file" [format "%s/tests/tls/server.key" [pwd]]
|
||||
@@ -527,7 +527,7 @@ proc start_server {options {code undefined}} {
|
||||
}
|
||||
|
||||
# write new configuration to temporary file
|
||||
set config_file [tmpfile redis.conf]
|
||||
set config_file [tmpfile valkey.conf]
|
||||
create_server_config_file $config_file $config $config_lines
|
||||
|
||||
set stdout [format "%s/%s" [dict get $config "dir"] "stdout"]
|
||||
|
||||
@@ -258,7 +258,7 @@ proc test {name code {okpattern undefined} {tags {}}} {
|
||||
}
|
||||
|
||||
if {$::traceleaks} {
|
||||
set output [exec leaks redis-server]
|
||||
set output [exec leaks valkey-server]
|
||||
if {![string match {*0 leaks*} $output]} {
|
||||
send_data_packet $::test_server_fd err "Detected a memory leak in test '$name': $output"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user