Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
76b9c13d
Unverified
Commit
76b9c13d
authored
Jul 11, 2022
by
Oran Agra
Committed by
GitHub
Jul 11, 2022
Browse files
Merge pull request #10962 from oranagra/release-7.0.3
Release 7.0.3
parents
05833959
85abb7cf
Changes
86
Show whitespace changes
Inline
Side-by-side
tests/unit/moduleapi/misc.tcl
View file @
76b9c13d
...
...
@@ -30,6 +30,11 @@ start_server {tags {"modules"}} {
assert
{[
string match $ld
"0.00000000000000001"
]}
}
test
{
test unsigned long long conversions
}
{
set ret
[
r test.ull_conversion
]
assert
{[
string match $ret
"ok"
]}
}
test
{
test module db commands
}
{
r set x foo
set key
[
r test.randomkey
]
...
...
@@ -103,6 +108,18 @@ start_server {tags {"modules"}} {
assert
{
[
dict get $info flags
]
==
"
${ssl_flag}
::tracking::"
}
}
test
{
test module get/set client name by id api
}
{
catch
{
r test.getname
}
e
assert_equal
"-ERR No name"
$e
r client setname nobody
catch
{
r test.setname
"name with spaces"
}
e
assert_match
"*Invalid argument*"
$e
assert_equal nobody
[
r client getname
]
assert_equal nobody
[
r test.getname
]
r test.setname somebody
assert_equal somebody
[
r client getname
]
}
test
{
test module getclientcert api
}
{
set cert
[
r test.getclientcert
]
...
...
tests/unit/obuf-limits.tcl
View file @
76b9c13d
...
...
@@ -140,7 +140,7 @@ start_server {tags {"obuf-limits external:skip"}} {
# Read nothing
set fd
[
$rd
channel
]
assert_equal
{}
[
read $f
d
]
assert_equal
{}
[
$rd
rawrea
d
]
}
# Note: This test assumes that what's written with one write, will be read by redis in one read.
...
...
@@ -180,8 +180,7 @@ start_server {tags {"obuf-limits external:skip"}} {
assert_equal
"PONG"
[
r ping
]
set clients
[
r client list
]
assert_no_match
"*name=multicommands*"
$clients
set fd
[
$rd2
channel
]
assert_equal
{}
[
read $fd
]
assert_equal
{}
[
$rd2
rawread
]
}
test
{
Execute transactions completely even if client output buffer limit is enforced
}
{
...
...
tests/unit/scripting.tcl
View file @
76b9c13d
...
...
@@ -1570,6 +1570,52 @@ start_server {tags {"scripting"}} {
r config set min-replicas-to-write 0
}
test
"not enough good replicas state change during long script"
{
r set x
"pre-script value"
r config set min-replicas-to-write 1
r config set lua-time-limit 10
start_server
{
tags
{
"external:skip"
}}
{
# add a replica and wait for the master to recognize it's online
r slaveof
[
srv -1 host
]
[
srv -1 port
]
wait_replica_online
[
srv -1 client
]
# run a slow script that does one write, then waits for INFO to indicate
# that the replica dropped, and then runs another write
set rd
[
redis_deferring_client -1
]
$rd eval
{
redis.call
(
'set','x',
"script value"
)
while true do
local info = redis.call
(
'info','replication'
)
if
(
string.match
(
info,
"connected_slaves:0"
))
then
redis.call
(
'set','x',info
)
break
end
end
return 1
}
1 x
# wait for the script to time out and yield
wait_for_condition 100 100
{
[
catch
{
r -1 ping
}
e
]
== 1
}
else
{
fail
"Can't wait for script to start running"
}
catch
{
r -1 ping
}
e
assert_match
{
BUSY*
}
$e
# cause the replica to disconnect
(
triggering the busy script to exit
)
r slaveof no one
# make sure the script was able to write after the replica dropped
assert_equal
[
$rd
read
]
1
assert_match
{
*connected_slaves:0*
}
[
r -1 get x
]
$rd close
}
r config set min-replicas-to-write 0
r config set lua-time-limit 5000
}
{
OK
}
{
external:skip needs:repl
}
test
"allow-stale shebang flag"
{
r config set replica-serve-stale-data no
r replicaof 127.0.0.1 1
...
...
@@ -1599,19 +1645,19 @@ start_server {tags {"scripting"}} {
}
1 x
}
assert_match
{
*redis_version*
}
[
assert_match
{
foobar
}
[
r eval
{
#!lua flags=allow-stale,no-writes
return redis.call
(
'
inf
o','
serve
r'
)
return redis.call
(
'
ech
o','
fooba
r'
)
}
0
]
# Test again with EVALSHA
set sha
[
r script load
{
#!lua flags=allow-stale,no-writes
return redis.call
(
'
inf
o','
serve
r'
)
return redis.call
(
'
ech
o','
fooba
r'
)
}
]
assert_match
{
*redis_version*
}
[
r evalsha $sha 0
]
assert_match
{
foobar
}
[
r evalsha $sha 0
]
r replicaof no one
r config set replica-serve-stale-data yes
...
...
tests/unit/type/zset.tcl
View file @
76b9c13d
...
...
@@ -2208,7 +2208,7 @@ start_server {tags {"zset"}} {
assert_match
"*syntax*"
$err
}
test
{
ZRANGESTORE with zset-max-listpack-entries 0
dst key should use skiplist encoding
}
{
test
{
ZRANGESTORE with zset-max-listpack-entries 0
#10767 case
}
{
set original_max
[
lindex
[
r config get zset-max-listpack-entries
]
1
]
r config set zset-max-listpack-entries 0
r del z1
{
t
}
z2
{
t
}
...
...
@@ -2217,6 +2217,18 @@ start_server {tags {"zset"}} {
r config set zset-max-listpack-entries $original_max
}
test
{
ZRANGESTORE with zset-max-listpack-entries 1 dst key should use skiplist encoding
}
{
set original_max
[
lindex
[
r config get zset-max-listpack-entries
]
1
]
r config set zset-max-listpack-entries 1
r del z1
{
t
}
z2
{
t
}
z3
{
t
}
r zadd z1
{
t
}
1 a 2 b
assert_equal 1
[
r zrangestore z2
{
t
}
z1
{
t
}
0 0
]
assert_encoding listpack z2
{
t
}
assert_equal 2
[
r zrangestore z3
{
t
}
z1
{
t
}
0 1
]
assert_encoding skiplist z3
{
t
}
r config set zset-max-listpack-entries $original_max
}
test
{
ZRANGE invalid syntax
}
{
catch
{
r zrange z1
{
t
}
0 -1 limit 1 2
}
err
assert_match
"*syntax*"
$err
...
...
utils/generate-module-api-doc.rb
View file @
76b9c13d
...
...
@@ -11,12 +11,13 @@ def markdown(s)
s
.
chop!
while
s
[
-
1
]
==
"
\n
"
||
s
[
-
1
]
==
" "
lines
=
s
.
split
(
"
\n
"
)
newlines
=
[]
# Fix some markdown
, except in code blocks indented by 4 spaces.
# Fix some markdown
lines
.
each
{
|
l
|
# Rewrite RM_Xyz() to RedisModule_Xyz().
l
=
l
.
gsub
(
/(?<![A-Z_])RM_(?=[A-Z])/
,
'RedisModule_'
)
# Fix more markdown, except in code blocks indented by 4 spaces, which we
# don't want to mess with.
if
not
l
.
start_with?
(
' '
)
# Rewrite RM_Xyz() to `RedisModule_Xyz()`. The () suffix is
# optional. Even RM_Xyz*() with * as wildcard is handled.
l
=
l
.
gsub
(
/(?<!`)RM_([A-z]+(?:\*?\(\))?)/
,
'`RedisModule_\1`'
)
# Add backquotes around RedisModule functions and type where missing.
l
=
l
.
gsub
(
/(?<!`)RedisModule[A-z]+(?:\*?\(\))?/
){
|
x
|
"`
#{
x
}
`"
}
# Add backquotes around c functions like malloc() where missing.
...
...
utils/lru/lfu-simulation.c
View file @
76b9c13d
...
...
@@ -19,7 +19,7 @@ struct entry {
};
#define to_16bit_minutes(x) ((x/60) & 65535)
#define
COUNTER
_INIT_VAL 5
#define
LFU
_INIT_VAL 5
/* Compute the difference in minutes between two 16 bit minutes times
* obtained with to_16bit_minutes(). Since they can wrap around if
...
...
@@ -36,7 +36,7 @@ uint16_t minutes_diff(uint16_t now, uint16_t prev) {
uint8_t
log_incr
(
uint8_t
counter
)
{
if
(
counter
==
255
)
return
counter
;
double
r
=
(
double
)
rand
()
/
RAND_MAX
;
double
baseval
=
counter
-
COUNTER
_INIT_VAL
;
double
baseval
=
counter
-
LFU
_INIT_VAL
;
if
(
baseval
<
0
)
baseval
=
0
;
double
limit
=
1
.
0
/
(
baseval
*
10
+
1
);
if
(
r
<
limit
)
counter
++
;
...
...
@@ -56,7 +56,7 @@ uint8_t scan_entry(struct entry *e) {
>=
decr_every
)
{
if
(
e
->
counter
)
{
if
(
e
->
counter
>
COUNTER
_INIT_VAL
*
2
)
{
if
(
e
->
counter
>
LFU
_INIT_VAL
*
2
)
{
e
->
counter
/=
2
;
}
else
{
e
->
counter
--
;
...
...
@@ -89,7 +89,7 @@ int main(void) {
/* Initialize. */
for
(
j
=
0
;
j
<
keyspace_size
;
j
++
)
{
entries
[
j
].
counter
=
COUNTER
_INIT_VAL
;
entries
[
j
].
counter
=
LFU
_INIT_VAL
;
entries
[
j
].
decrtime
=
to_16bit_minutes
(
start
);
entries
[
j
].
hits
=
0
;
entries
[
j
].
ctime
=
time
(
NULL
);
...
...
@@ -131,7 +131,7 @@ int main(void) {
* 10 and 19, a random one every 10 seconds. */
if
(
new_entry_time
<=
now
)
{
idx
=
10
+
(
rand
()
%
10
);
entries
[
idx
].
counter
=
COUNTER
_INIT_VAL
;
entries
[
idx
].
counter
=
LFU
_INIT_VAL
;
entries
[
idx
].
decrtime
=
to_16bit_minutes
(
time
(
NULL
));
entries
[
idx
].
hits
=
0
;
entries
[
idx
].
ctime
=
time
(
NULL
);
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment