Skip to content

Commit

Permalink
Merge branch 'valkey-io:unstable' into mimalloc-support
Browse files Browse the repository at this point in the history
  • Loading branch information
WM0323 authored Apr 25, 2024
2 parents 5d9095e + 4948d53 commit 854cfec
Show file tree
Hide file tree
Showing 51 changed files with 269 additions and 250 deletions.
15 changes: 15 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# License 1

Copyright (c) 2024-present, Valkey contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# License 2

Copyright (c) 2006-2020, Salvatore Sanfilippo
All rights reserved.

Expand Down
12 changes: 8 additions & 4 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#ifndef CONFIG_H
#define CONFIG_H

#include <sys/param.h>

#ifdef __APPLE__
#include <fcntl.h> // for fcntl(fd, F_FULLFSYNC)
#include <AvailabilityMacros.h>
Expand Down Expand Up @@ -96,9 +98,11 @@
#endif

/* Test for accept4() */
#if defined(__linux__) || defined(OpenBSD5_7) || \
(__FreeBSD__ >= 10 || __FreeBSD_version >= 1000000) || \
(defined(NetBSD8_0) || __NetBSD_Version__ >= 800000000)
#if defined(__linux__) || \
defined(__FreeBSD__) || \
defined(OpenBSD5_7) || \
(defined(__DragonFly__) && __DragonFly_version >= 400305) || \
(defined(__NetBSD__) && (defined(NetBSD8_0) || __NetBSD_Version__ >= 800000000))
#define HAVE_ACCEPT4 1
#endif

Expand Down Expand Up @@ -316,7 +320,7 @@ void setcpuaffinity(const char *cpulist);
#endif

/* Test for posix_fadvise() */
#if defined(__linux__) || __FreeBSD__ >= 10
#if defined(__linux__) || defined(__FreeBSD__)
#define HAVE_FADVISE
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ dictType BenchmarkDictType = {
printf(msg ": %ld items in %lld ms\n", count, elapsed); \
} while(0)

/* ./redis-server test dict [<count> | --accurate] */
/* ./valkey-server test dict [<count> | --accurate] */
int dictTest(int argc, char **argv, int flags) {
long j;
long long start, elapsed;
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ char *stringFromInt(int value) {
return s;
}

/* ./redis-server test kvstore */
/* ./valkey-server test kvstore */
int kvstoreTest(int argc, char **argv, int flags) {
UNUSED(argc);
UNUSED(argv);
Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -7052,7 +7052,7 @@ int main(int argc, char **argv) {
exit(0);
} else {
fprintf(stderr,"Please specify the amount of memory to test in megabytes.\n");
fprintf(stderr,"Example: ./redis-server --test-memory 4096\n\n");
fprintf(stderr,"Example: ./valkey-server --test-memory 4096\n\n");
exit(1);
}
} if (strcmp(argv[1], "--check-system") == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/syscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int checkXenClocksource(sds *error_msg) {
} else if (strcmp(curr, "xen") == 0) {
*error_msg = sdsnew(
"Your system is configured to use the 'xen' clocksource which might lead to degraded performance. "
"Check the result of the [slow-clocksource] system check: run 'redis-server --check-system' to check if "
"Check the result of the [slow-clocksource] system check: run 'valkey-server --check-system' to check if "
"the system's clocksource isn't degrading performance.");
res = -1;
}
Expand Down Expand Up @@ -180,10 +180,10 @@ int checkTHPEnabled(sds *error_msg) {
if (strstr(buf,"[always]") != NULL) {
*error_msg = sdsnew(
"You have Transparent Huge Pages (THP) support enabled in your kernel. "
"This will create latency and memory usage issues with Redis. "
"This will create latency and memory usage issues with Valkey. "
"To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root, "
"and add it to your /etc/rc.local in order to retain the setting after a reboot. "
"Redis must be restarted after THP is disabled (set to 'madvise' or 'never').");
"Valkey must be restarted after THP is disabled (set to 'madvise' or 'never').");
return -1;
} else {
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ int ValkeyModule_OnLoad(void *ctx, ValkeyModuleString **argv, int argc) {

/* Connection modules must be part of the same build as the server. */
if (strcmp(REDIS_BUILD_ID_RAW, serverBuildIdRaw())) {
serverLog(LL_NOTICE, "Connection type %s was not built together with the redis-server used.", CONN_TYPE_TLS);
serverLog(LL_NOTICE, "Connection type %s was not built together with the valkey-server used.", CONN_TYPE_TLS);
return VALKEYMODULE_ERR;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ziplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ static size_t strEntryBytesLarge(size_t slen) {
return slen + zipStorePrevEntryLength(NULL, ZIP_BIG_PREVLEN) + zipStoreEntryEncoding(NULL, 0, slen);
}

/* ./redis-server test ziplist <randomseed> */
/* ./valkey-server test ziplist <randomseed> */
int ziplistTest(int argc, char **argv, int flags) {
int accurate = (flags & TEST_ACCURATE);
unsigned char *zl, *p;
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ match different external server configurations:
| `--singledb` | Only use database 0, don't assume others are supported. |
| `--ignore-encoding` | Skip all checks for specific encoding. |
| `--ignore-digest` | Skip key value digest validations. |
| `--cluster-mode` | Run in strict Redis Cluster compatibility mode. |
| `--cluster-mode` | Run in strict Valkey Cluster compatibility mode. |
| `--large-memory` | Enables tests that consume more than 100mb |

Tags
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/cluster.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ proc set_cluster_node_timeout {to} {
proc cluster_write_test {id} {
set prefix [randstring 20 20 alpha]
set port [get_instance_attrib valkey $id port]
set cluster [redis_cluster 127.0.0.1:$port]
set cluster [valkey_cluster 127.0.0.1:$port]
for {set j 0} {$j < 100} {incr j} {
$cluster set key.$j $prefix.$j
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/03-failover-loop.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test "Cluster is up" {
}

set iterations 20
set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]

while {[incr iterations -1]} {
set tokill [randomInt 10]
Expand Down
4 changes: 2 additions & 2 deletions tests/cluster/tests/04-resharding.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ proc process_is_running {pid} {
set numkeys 50000
set numops 200000
set start_node_port [get_instance_attrib valkey 0 port]
set cluster [redis_cluster 127.0.0.1:$start_node_port]
set cluster [valkey_cluster 127.0.0.1:$start_node_port]
if {$::tls} {
# setup a non-TLS cluster client to the TLS cluster
set plaintext_port [get_instance_attrib valkey 0 plaintext-port]
set cluster_plaintext [redis_cluster 127.0.0.1:$plaintext_port 0]
set cluster_plaintext [valkey_cluster 127.0.0.1:$plaintext_port 0]
puts "Testing TLS cluster on start node 127.0.0.1:$start_node_port, plaintext port $plaintext_port"
} else {
set cluster_plaintext $cluster
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/05-slave-selection.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test "Instance #5 and #10 synced with the master" {
}
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]

test "Slaves are both able to receive and acknowledge writes" {
for {set j 0} {$j < 100} {incr j} {
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/10-manual-failover.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set current_epoch [CI 1 cluster_current_epoch]

set numkeys 50000
set numops 10000
set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
catch {unset content}
array set content {}

Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/14-consistency-check.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ proc get_one_of_my_replica {id} {
proc cluster_write_keys_with_expire {id ttl} {
set prefix [randstring 20 20 alpha]
set port [get_instance_attrib valkey $id port]
set cluster [redis_cluster 127.0.0.1:$port]
set cluster [valkey_cluster 127.0.0.1:$port]
for {set j 100} {$j < 200} {incr j} {
$cluster setex key_expire.$j $ttl $prefix.$j
}
Expand Down
6 changes: 3 additions & 3 deletions tests/cluster/tests/15-cluster-slots.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ test "client do not break when cluster slot" {
}

test "client can handle keys with hash tag" {
set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
$cluster set foo{tag} bar
$cluster close
}

test "slot migration is valid from primary to another primary" {
set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set key order1
set slot [$cluster cluster keyslot $key]
array set nodefrom [$cluster masternode_for_slot $slot]
Expand All @@ -61,7 +61,7 @@ test "slot migration is valid from primary to another primary" {
}

test "slot migration is invalid from primary to replica" {
set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set key order1
set slot [$cluster cluster keyslot $key]
array set nodefrom [$cluster masternode_for_slot $slot]
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/20-half-migrated-slot.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test "Cluster is up" {
assert_cluster_state ok
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
catch {unset nodefrom}
catch {unset nodeto}

Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/21-many-slot-migration.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test "Cluster is up" {
assert_cluster_state ok
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
catch {unset nodefrom}
catch {unset nodeto}

Expand Down
4 changes: 2 additions & 2 deletions tests/cluster/tests/25-pubsubshard-slot-migration.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ test "Cluster is up" {
assert_cluster_state ok
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]

proc get_addr_replica_serving_slot slot {
set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
array set node [$cluster masternode_for_slot $slot]

set replicanodeinfo [$cluster cluster replicas $node(id)]
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/26-pubsubshard.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test "Create a 3 nodes cluster" {
cluster_create_with_continuous_slots 3 3
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
test "Pub/Sub shard basics" {

set slot [$cluster cluster keyslot "channel.0"]
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/tests/29-slot-migration-response.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test "Cluster is up" {
assert_cluster_state ok
}

set cluster [redis_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
set cluster [valkey_cluster 127.0.0.1:[get_instance_attrib valkey 0 port]]
catch {unset nodefrom}
catch {unset nodeto}

Expand Down
4 changes: 2 additions & 2 deletions tests/cluster/tests/includes/utils.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ proc fix_cluster {addr} {
exec ../../../src/valkey-cli {*}[valkeycli_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: 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/valkey-cli {*}[valkeycli_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"
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/bg_block_op.tcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source tests/support/redis.tcl
source tests/support/valkey.tcl
source tests/support/util.tcl

set ::tlsdir "tests/tls"
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/bg_complex_data.tcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source tests/support/redis.tcl
source tests/support/valkey.tcl
source tests/support/util.tcl

set ::tlsdir "tests/tls"
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/gen_write_load.tcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source tests/support/redis.tcl
source tests/support/valkey.tcl

set ::tlsdir "tests/tls"

Expand Down
22 changes: 11 additions & 11 deletions tests/instances.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package require Tcl 8.5

set tcl_precision 17
source ../support/redis.tcl
source ../support/valkey.tcl
source ../support/util.tcl
source ../support/aofmanifest.tcl
source ../support/server.tcl
Expand Down Expand Up @@ -40,7 +40,7 @@ set ::loop 0

if {[catch {cd tmp}]} {
puts "tmp directory not found."
puts "Please run this test from the Redis source root."
puts "Please run this test from the Valkey source root."
exit 1
}

Expand Down Expand Up @@ -313,7 +313,7 @@ proc parse_options {} {
puts "--fail Simulate a test failure."
puts "--valgrind Run with valgrind."
puts "--tls Run tests in TLS mode."
puts "--tls-module Run tests in TLS mode with Redis module."
puts "--tls-module Run tests in TLS mode with Valkey module."
puts "--host <host> Use hostname instead of 127.0.0.1."
puts "--config <k> <v> Extra config argument(s)."
puts "--stop Blocks once the first test fails."
Expand Down Expand Up @@ -342,12 +342,12 @@ 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_valkey_id id {
puts "=== REDIS $id ===="
puts [exec tail -$count redis_$id/log.txt]
puts "=== VALKEY $id ===="
puts [exec tail -$count valkey_$id/log.txt]
puts "---------------------\n"
}
} elseif {$cmd eq {show-sentinel-logs}} {
Expand All @@ -360,7 +360,7 @@ proc pause_on_error {} {
}
} elseif {$cmd eq {ls}} {
foreach_valkey_id id {
puts -nonewline "Redis $id"
puts -nonewline "Valkey $id"
set errcode [catch {
set str {}
append str "@[RI $id tcp_port]: "
Expand Down Expand Up @@ -391,13 +391,13 @@ proc pause_on_error {} {
}
}
} elseif {$cmd eq {help}} {
puts "ls List Sentinel and Redis instances."
puts "ls List Sentinel and Valkey 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 "R <id> cmd ... arg Call command in Valkey <id>."
puts "SI <id> <field> Show Sentinel <id> INFO <field>."
puts "RI <id> <field> Show Redis <id> INFO <field>."
puts "RI <id> <field> Show Valkey <id> INFO <field>."
puts "continue Resume test."
} else {
set errcode [catch {eval $line} retval]
Expand Down
Loading

0 comments on commit 854cfec

Please sign in to comment.