12396 Commits

Author SHA1 Message Date
Samuel Adetunji
93123f97a0
Format yaml files (#615)
Closes #533

---------

Signed-off-by: adetunjii <adetunjithomas1@outlook.com>
2024-06-14 13:40:06 -07:00
Madelyn Olson
6faa48a358
Don't initialize the key buffer in getKeysResult (#631)
getKeysResults is typically initialized with 2kb of zeros (16 * 256),
which isn't strictly necessary since the only thing we have to
initialize is some of the metadata fields. The rest of the data can
remain junk as long as we don't access it. This was a bit of a
regression in 7.0 with the keyspecs, since we doubled the size of the
zeros, but hopefully this recovers a lot of the performance drop.

I saw a modest performance bump for deep pipeline of cluster mode (~8%).

I think we would see some comparable improvements in the other places
where we are using it such as tracking and ACLs.

---------

Signed-off-by: Madelyn Olson <matolson@amazon.com>
2024-06-14 08:42:00 -07:00
Binbin
d5496e42bc
Lua scripts promoted from eval to script load to avoid evict (#637)
In ad28d222edcef9d4496fd7a94656013f07dd08e5, we added a Lua eval
scripts eviction. If the script was previously added via EVAL, we
promote it to SCRIPT LOAD, prevent it from being evicted later.

Signed-off-by: Binbin <binloveplay1314@qq.com>
2024-06-14 08:32:19 -07:00
Wenwen-Chen
4c6bf30f58
Latency report: Rebranding and refine Dave dialog (#644)
This patch try to correct the latency report.

1. Rename Redis to Valkey.
2. Remove redundant Dave dialog, and refine the output message.

---------

Signed-off-by: Wenwen Chen <wenwen.chen@samsung.com>
Signed-off-by: hwware <wen.hui.ware@gmail.com>
2024-06-14 12:56:59 +02:00
Ping Xie
8a776c3509
Fix potential infinite loop in clusterNodeGetPrimary (#651) 2024-06-13 23:43:36 -07:00
Ping Xie
5d9d41868d
Replace DEBUG RESTART with pause_server and resume_server (#652) 2024-06-13 17:52:50 -07:00
Binbin
d309b9b235
Make configs dir/dbfilename/cluster-config-file reject empty string (#636)
Until now, these configuration items allowed typing empty strings,
but empty strings behave strangely.

Empty dir will fail in chdir with No such file or directory:
```
./src/valkey-server --dir ""

*** FATAL CONFIG FILE ERROR (Version 255.255.255) ***
Reading the configuration file, at line 2
>>> 'dir ""'
No such file or directory
```

Empty dbfilename will cause shutdown to fail since it will
always fail in rdb save:
```
./src/valkey-server --dbfilename ""

 * User requested shutdown...
 * Saving the final RDB snapshot before exiting.
 # Error moving temp DB file temp-19530.rdb on the final destination  (in server root dir /xxx/xxx/valkey): No such file or directory
 # Error trying to save the DB, can't exit.
 # Errors trying to shut down the server. Check the logs for more information.
```

Empty cluster-config-file will fail in clusterLockConfig:
```
./src/valkey-server --cluster-enabled yes --cluster-config-file ""

 Can't open  in order to acquire a lock: No such file or directory
```

With this patch, now we will just reject it in config set like:
```
*** FATAL CONFIG FILE ERROR (Version 255.255.255) ***
Reading the configuration file, at line 2
>>> 'xxx ""'
xxx can't be empty
```

Signed-off-by: Binbin <binloveplay1314@qq.com>
2024-06-14 01:47:20 +02:00
Harkrishn Patro
76fc041685
represent cluster node flags with bitwise shift value (#642)
While debugging a cluster bus issue, found the cluster node flags were
represented in numbers. I generally find it easy when these are
represented as bitwise shift operation. It improves readability a bit.

Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
2024-06-14 00:58:03 +02:00
uriyage
d211078a27
Fix query buffer resized test flakiness (#646)
Added a wait_for_condition to avoid the timing issue.
```
*** [err]: query buffer resized correctly in tests/unit/querybuf.tcl
Expected 11 >= 16384 && 11 <= 32770 (context: type eval line 24 cmd {assert {$orig_test_client_qbuf >= 16384 && $orig_test_client_qbuf <= $MAX_QUERY_BUFFER_SIZE}} proc ::test)
*** [err]: query buffer resized correctly when not idle in tests/unit/querybuf.tcl
Expected 11 > 32768 (context: type eval line 14 cmd {assert {$orig_test_client_qbuf > 32768}} proc ::test)
*** [err]: query buffer resized correctly with fat argv in tests/unit/querybuf.tcl
query buffer should not be resized when client idle time smaller than 2s
```

Signed-off-by: Uri Yagelnik <uriy@amazon.com>
2024-06-13 18:07:07 +08:00
Harkrishn Patro
b546dd26e5
Allow CLUSTER NODES/INFO/MYID/MYSHARDID during loading state (#596)
Allow CLUSTER subcommands NODES, INFO, MYID, MYSHARDID while loading
data.

It's safe to allow them and it's helpful for clients to get cluster
nodes/info information
during a node failover and while loading data to monitor the
state of the cluster.

---------

Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
2024-06-13 06:09:01 +02:00
Madelyn Olson
627d387ad8
Improve reliability of querybuf test (#639)
We've been seeing some pretty consistent failures from
`test-valgrind-test` and `test-sanitizer-address` because of the
querybuf test periodically failing. I tracked it down to the test
periodically taking too long and the client cron getting triggered. A
simple solution is to just disable the cron during the key race
condition. I was able to run this locally for 100 iterations without
seeing a failure.

Example:
https://github.com/valkey-io/valkey/actions/runs/9474458354/job/26104103514
and
https://github.com/valkey-io/valkey/actions/runs/9474458354/job/26104106830.

Signed-off-by: Madelyn Olson <matolson@amazon.com>
2024-06-12 14:27:42 -07:00
Viktor Söderqvist
4bb7cc471a
Remove unnecessary clang-format off annotations (#628)
We added some clang-format off comments before we had decided on the
format configuration. Now, it turns out that turning formatting off is
often not necessary.

---------

Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2024-06-12 12:52:18 +02:00
Shivshankar
e65b2d235c
Update rewriteConfigSaveOption function code to rewrite multiple save in one line. (#583)
Currently, "config rewrite" writes some default value in the config file
incase of empty config file specified.

But it adds multiple "save" config entries as follows:
```
save 3600 1
save 300 100
save 60 10000
```

After the fix the save will look like:
```
save 3600 1 300 100 60 10000
```

---------

Signed-off-by: Shivshankar-Reddy <shiva.sheri.github@gmail.com>
2024-06-10 16:24:04 -04:00
Madelyn Olson
a3f1535b57
Fix misuse of safe iterators (#612)
Safe iterators must call resetIterators when they are done being used.
Fix one issue where a safe iterator was not correctly calling reset
during cluster slot caching and fixed a second issue where reset
iterator was being called twice. For the double release case,
kvstoreIteratorNextDict is responsible for patching up the iterator, but
we were calling it a second time in kvstoreIteratorNext.

In addition, I added some documentation around initializing iterators,
added an assert to prevent double initialization, and remove a function
from the public interface which isn't needed and might lead to incorrect
usage of the safe iterators.

Bumping srgsanky for finding it here:
c4782066e7 (r142867004).

---------

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
2024-06-10 12:30:57 -07:00
Wen Hui
95a753b18d
Add BSD license explicitly (#620)
Add "BSD 3-Clause License" in License 1 and License 2 part

---------

Signed-off-by: hwware <wen.hui.ware@gmail.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
2024-06-10 13:14:37 -04:00
Neal Gompa (ニール・ゴンパ)
71dd85dc5a
src/Makefile: Link libatomic on POWER systems (#607)
This ensures that fallbacks for unsupported atomic operations are
available for POWER systems.

Signed-off-by: Neal Gompa <neal@gompa.dev>
2024-06-09 15:09:08 -07:00
skyfirelee
09b5825b26
Moving client->authenticated to a flag instead of an int (#592)
Moving client->authenticated to a flag

Fix #589 

Signed-off-by: artikell <739609084@qq.com>
2024-06-09 11:49:05 -07:00
flowerysong
d28ae52004
Remove redundant function nextPingExt() (#613)
Functionally identical to the older, documented `getNextPingExt()`.

Fixes #610.

Signed-off-by: Paul Arthur <paul.arthur@flowerysong.com>
2024-06-08 21:55:58 -07:00
Ping Xie
aad6769a80
Replicate slot migration states via RDB aux fields (#586) 2024-06-07 20:32:27 -07:00
Ping Xie
54c9747935
Remove master and slave from source code (#591)
External facing interfaces are not affected.

---------

Signed-off-by: Ping Xie <pingxie@google.com>
2024-06-07 14:21:33 -07:00
Madelyn Olson
bce240eab7
Replace masteruser and masterauth with primaryuser and primaryauth (#598)
Make the one backwards compatible config change we are allowed to
replace for removing master from our API.

`masterauth` and `masteruser` are still used as an alias, but aren't
explicitly referenced. As an addendum to
https://github.com/valkey-io/valkey/pull/591, it would be good to have
this in 8. Given the related PR for updated other references for master,
I just updated the ones around this specific change.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
2024-06-07 00:46:52 -07:00
Viktor Söderqvist
ad5fd5b95c
More rebranding (#606)
More rebranding of

* Log messages (#252)
* The DENIED error reply
* Internal function names and comments, mainly Lua API

---------

Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2024-06-07 01:40:55 +02:00
Viktor Söderqvist
278ce0cae0
Rebrand the Lua debugger (#603)
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2024-06-06 19:53:17 +02:00
Eran Liberty
60c10a5a4d
Remove valdup from BenchmarkDictType (#600)
makes SERVER_CFLAGS='-DSERVER_TEST' compile as well

Introduced in #443.

Signed-off-by: Eran Liberty <eranl@amazon.com>
Co-authored-by: Eran Liberty <eranl@amazon.com>
2024-06-05 11:00:53 +08:00
Shivshankar
9319f7aeca
Replace valkey in log and panic messages (#550)
Part of #207

---------

Signed-off-by: Shivshankar-Reddy <shiva.sheri.github@gmail.com>
2024-06-04 20:46:59 +02:00
Eran Liberty
0700c441c6
Remove unused valDup (#443)
Remove the unused value duplicate API from dict. It's unused in the codebase and introduces unnecessary overhead. 

---------

Signed-off-by: Eran Liberty <eran.liberty@gmail.com>
2024-06-03 12:22:06 -07:00
Madelyn Olson
b95e7c384f
Skip tls for xgroup read regression since it doesn't matter (#595)
"Client blocked on XREADGROUP while stream's slot is migrated" uses the
migrate command, which requires special handling for TLS and non-tls.
This was not being handled, so was throwing an error.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
2024-06-03 11:49:15 -07:00
uriyage
b72e43ed16
Adjust query buffer resized correctly test to non-jemalloc allocators. (#593)
Test `query buffer resized correctly` start to fail
(https://github.com/valkey-io/valkey/actions/runs/9278013807) with
non-jemalloc allocators after
https://github.com/valkey-io/valkey/pull/258 PR.

With Jemalloc we allocate ~20K for the query buffer, in the test we read
1 byte in the first read, in the second read we make sure we have at
least 16KB free place in the query buffer and we have as Jemalloc
allocated 20KB, But with non jemalloc we allocate in the first read
exactly 16KB. in the second read we check and see that we don't have
16KB free space as we already read 1 byte hence we reallocate this time
greedly (*2 of the requested size of 16KB+1) hence the test condition
that the querybuf size is < 32KB is no longer true

The `query buffer resized correctly test` starts
[failing](https://github.com/valkey-io/valkey/actions/runs/9278013807)
with non-jemalloc allocators after PR #258 .

With jemalloc, we allocate ~20KB for the query buffer. In the test, we
read 1 byte initially and then ensure there is at least 16KB of free
space in the buffer for the second read, which is satisfied by
jemalloc's 20KB allocation. However, with non-jemalloc allocators, the
first read allocates exactly 16KB. When we check again, we don't have
16KB free due to the 1 byte already read. This triggers a greedy
reallocation (doubling the requested size of 16KB+1), causing the query
buffer size to exceed the 32KB limit, thus failing the test condition.

This PR adjusted the test query buffer upper limit to be 32KB +2.

Signed-off-by: Uri Yagelnik <uriy@amazon.com>
2024-06-03 11:15:28 -07:00
poiuj
417660449f
Adjust sds types (#502)
sds type should be determined based on the size of the underlying
buffer, not the logical length of the sds. Currently we truncate the
alloc field in case buffer is larger than we can handle. It leads to a
mismatch between alloc field and the actual size of the buffer. Even
considering that alloc doesn't include header size and the null
terminator.

It also leads to a waste of memory with jemalloc. For example, let's
consider creation of sds of length 253. According to the length, the
appropriate type is SDS_TYPE_8. But we allocate `253 + sizeof(struct
sdshdr8) + 1` bytes, which sums to 257 bytes. In this case jemalloc
allocates buffer from the next size bucket. With current configuration
on Linux it's 320 bytes. So we end up with 320 bytes buffer, while we
can't address more than 255.

The same happens with other types and length close enough to the
appropriate powers of 2.

The downside of the adjustment is that with allocators that do not
allocate larger than requested chunks (like GNU allocator), we switch to
a larger type "too early". It leads to small waste of memory.
Specifically: sds of length 31 takes 35 bytes instead of 33 (2 bytes
wasted) sds of length 255 takes 261 bytes instead of 259 (2 bytes
wasted) sds of length 65,535 takes 65,545 bytes instead of 65,541 (4
bytes wasted) sds of length 4,294,967,295 takes 4,294,967,313 bytes
instead of 4,294,967,305 (8 bytes wasted)

---------

Signed-off-by: Vadym Khoptynets <vadymkh@amazon.com>
2024-06-02 20:55:54 -07:00
naglera
28e055af0b
Deflake chained replicas disconnect (#574)
Deflake chained replicas disconnect when replica re-connect with the
same master. sync_partial_ok counter might get incremented if replica
timed out during test.

Signed-off-by: naglera <anagler123@gmail.com>
2024-06-02 20:53:39 -07:00
Ping Xie
30f277a86d
Enable debug asserts for cluster and sentinel tests (#588)
Also make `enable-debug-assert` an immutable config

Address review comments in #584

---------

Signed-off-by: Ping Xie <pingxie@google.com>
2024-06-02 13:15:08 -07:00
Chen Tianjie
d16b4ec1b9
Unshare object to avoid LRU/LFU being messed up (#250)
When LRU/LFU enabled, Valkey does not allow using shared objects, as
value objects may be shared among many different keys and they can't
share LRU/LFU information.

However `maxmemory-policy` is modifiable at runtime. If LRU/LFU is not
enabled at start, but then enabled when some shared objects are already
used, there could be some confusion in LRU/LFU information.

For `set` command it is OK since it is going to create a new object when
LRU/LFU enabled, but `get` command will not unshare the object and just
update LRU/LFU information.

So we may duplicate the object in this case. It is a one-time task for
each key using shared objects, unless this is the case for so many keys,
there should be no serious performance degradation.

Still, LRU will be updated anyway, no matter LRU/LFU is enabled or not,
because `OBJECT IDLETIME` needs it, unless `maxmemory-policy` is set to
LFU. So idle time of a key may still be messed up.

---------

Signed-off-by: chentianjie.ctj <chentianjie.ctj@alibaba-inc.com>
Signed-off-by: Chen Tianjie <TJ_Chen@outlook.com>
2024-06-01 10:09:20 +02:00
Ping Xie
2b97aa6171
Introduce enable-debug-assert to enable/disable debug asserts at runtime (#584)
Introduce a new hidden server configuration, `enable-debug-assert`, which
allows selectively enabling or disabling, at runtime, expensive or risky
assertions used primarily for debugging and testing.

Fix #569

---------

Signed-off-by: Ping Xie <pingxie@google.com>
2024-05-31 22:50:08 -07:00
Ping Xie
f927565d28
Consolidate various BLOCKED_WAIT* states (#562)
There are currently three block types: BLOCKED_WAIT, BLOCKED_WAITAOF,
and BLOCKED_WAIT_PREREPL, used to block clients executing `WAIT`,
`WAITAOF`, and `CLUSTER SETSLOT`, respectively. They share the same
workflow: the client is blocked until replication to the expected number
of replicas completes. However, they provide different responses
depending on the commands involved. Using distinct block types leads to
code duplication and reduced readability. This PR consolidates the three
types into a single WAIT type, differentiating them using the pending
command to ensure the appropriate response is returned.


Fix #427

---------

Signed-off-by: Ping Xie <pingxie@google.com>
2024-05-30 23:45:47 -07:00
nitaicaro
6fb90adf4b
Fix crash where command duration is not reset when client is blocked … (#526)
In #11012, we changed the way command durations were computed to handle
the same command being executed multiple times. In #11970, we added an
assert if the duration is not properly reset, potentially indicating
that a call to report statistics was missed.

I found an edge case where this happens - easily reproduced by blocking
a client on `XGROUPREAD` and migrating the stream's slot. This causes
the engine to process the `XGROUPREAD` command twice:

1. First time, we are blocked on the stream, so we wait for unblock to
come back to it a second time. In most cases, when we come back to
process the command second time after unblock, we process the command
normally, which includes recording the duration and then resetting it.
2. After unblocking we come back to process the command, and this is
where we hit the edge case - at this point, we had already migrated the
slot to another node, so we return a `MOVED` response. But when we do
that, we don’t reset the duration field.

Fix: also reset the duration when returning a `MOVED` response. I think
this is right, because the client should redirect the command to the
right node, which in turn will calculate the execution duration.

Also wrote a test which reproduces this, it fails without the fix and
passes with it.

---------

Signed-off-by: Nitai Caro <caronita@amazon.com>
Co-authored-by: Nitai Caro <caronita@amazon.com>
2024-05-30 12:55:00 -07:00
Wen Hui
0d2ba9b94d
Update redis legacy word when run TLS cert file (#572)
Reference:
https://github.com/valkey-io/valkey-doc/blob/main/topics/encryption.md

Before we runtest --tls, we need first run utils/gen-test-certs.sh

I found there are some redis legacy word there, update them.

Signed-off-by: hwware <wen.hui.ware@gmail.com>
2024-05-30 13:09:29 -04:00
Binbin
6bab2d7968
Make sure clear the CLUSTER SLOTS cache on time when updating hostname (#564)
In #53, we will cache the CLUSTER SLOTS response to improve the
throughput and reduct the latency.

In the code snippet below, the second cluster slots will use the
old hostname:
```
config set cluster-preferred-endpoint-type hostname
config set cluster-announce-hostname old-hostname.com
multi
cluster slots
config set cluster-announce-hostname new-hostname.com
cluster slots
exec
```

When updating the hostname, in updateAnnouncedHostname, we will set
CLUSTER_TODO_SAVE_CONFIG and we will do a clearCachedClusterSlotsResponse
in clusterSaveConfigOrDie, so harmless in most cases.

Move the clearCachedClusterSlotsResponse call to clusterDoBeforeSleep
instead of scheduling it to be called in clusterSaveConfigOrDie.

Signed-off-by: Binbin <binloveplay1314@qq.com>
2024-05-30 10:44:12 +08:00
LiiNen
168da8b52e
Fix bitops.c clang-format properly (#570)
ref:
- https://github.com/valkey-io/valkey/pull/118 (my pervious change)
- https://github.com/valkey-io/valkey/pull/461 (issuing that clang
format checker fails due to my change)

There was an issue that clang-format cheker failed.
I don't know why I missed it and why it didn't catch.

just running `clang-format -i bitops.c` was all.

Signed-off-by: LiiNen <kjeonghoon065@gmail.com>
2024-05-28 21:49:50 -07:00
LiiNen
96dcd1183a
Change BITCOUNT 'end' as optional like BITPOS (#118)
_This change is the thing I suggested to redis when it was BSD, and is
not just migration - this is of course more advanced_

### Issue
There is weird difference in syntax between BITPOS and BITCOUNT:
```
BITPOS key bit [start [end [BYTE | BIT]]]
BITCOUNT key [start end [BYTE | BIT]]
```

I think this might cause confusion in terms of usability.
It was not just a syntax typo error, and really works differently.
The results below are with unstable build:
```
> get TEST:ABCD
"ABCD"
> BITPOS TEST:ABCD 1 0 -1
(integer) 1
> BITCOUNT TEST:ABCD 0 -1
(integer) 9
> BITPOS TEST:ABCD 1 0
(integer) 1
> BITCOUNT TEST:ABCD 0
(error) ERR syntax error
```

### What did I fix

simply changes logic, to accept BITCOUNT also without 'end' - 'end'
become optional, like BITPOS
```
> GET TEST:ABCD
"ABCD"
> BITPOS TEST:ABCD 1 0 -1
(integer) 1
> BITCOUNT TEST:ABCD 0 -1
(integer) 9
> BITPOS TEST:ABCD 1 0
(integer) 1
> BITCOUNT TEST:ABCD 0
(integer) 9
```

Of course, I also fixed syntax hint:
```
# ASIS 
> BITCOUNT key [start end [BYTE|BIT]]
# TOBE
> BITCOUNT key [start [end [BYTE|BIT]]]
```

![image](https://github.com/valkey-io/valkey/assets/38001238/8485f58e-6785-4106-9f3f-45e62f90d24b)


### Moreover ...
I hadn't noticed that there was very small dead code in these command
logic, when I wrote PR to redis.
I found it now, when write code again, so I wrote it in valkey.
``` c
/* asis unstable */

/* bitcountCommand() */
if (!strcasecmp(c->argv[4]->ptr,"bit")) isbit = 1;
// ...
if (c->argc < 4) {
    if (isbit) end = (totlen<<3) + 7;
    else end = totlen-1;
}

/* bitposCommand() */
if (!strcasecmp(c->argv[5]->ptr,"bit")) isbit = 1;
// ...
if (c->argc < 5) {
    if (isbit) end = (totlen<<3) + 7;
    else end = totlen-1;
}
```
Bit variable (actually int) "isbit" is only being set as 1, when 'BIT'
is declared.
But we were checking whether 'isbit' is true or false in this 'if'
phrase, even if isbit could never be 1, because argc is always less than
4 (or 5 in bitpos).



I think this minor fixes will make valkey command operation more
consistent.
Of course, this PR contains just changing args from "required" to
"optional", so it will never hurt previous users.

Thanks,

---------

Signed-off-by: LiiNen <kjeonghoon065@gmail.com>
Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com>
2024-05-28 15:01:28 -04:00
uriyage
fd58b73f0a
Introduce shared query buffer for client reads (#258)
This PR optimizes client query buffer handling in Valkey by introducing
a shared query buffer that is used by default for client reads. This
reduces memory usage by ~20KB per client by avoiding allocations for
most clients using short (<16KB) complete commands. For larger or
partial commands, the client still gets its own private buffer.

The primary changes are:

* Adding a shared query buffer `shared_qb` that clients use by default
* Modifying client querybuf initialization and reset logic
* Copying any partial query from shared to private buffer before command
execution
* Freeing idle client query buffers when empty to allow reuse of shared
buffer
* Master client query buffers are kept private as their contents need to
be preserved for replication stream

In addition to the memory savings, this change shows a 3% improvement in
latency and throughput when running with 1000 active clients.

The memory reduction may also help reduce the need to evict clients when
reaching max memory limit, as the query buffer is the main memory
consumer per client.

---------

Signed-off-by: Uri Yagelnik <uriy@amazon.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
2024-05-28 11:09:37 -07:00
Shivshankar
7ba7e4d053
Update zfree on data in test_crc64combine before return. (#548)
Signed-off-by: Shivshankar-Reddy <shiva.sheri.github@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
2024-05-28 10:36:54 -07:00
Ping Xie
84157890fd
Set up clang-format github action (#538)
Setup clang-format GitHub action to ensure coding style consistency
---------

Signed-off-by: Ping Xie <pingxie@google.com>
2024-05-28 09:27:51 -07:00
Viktor Söderqvist
4e44f5aae9
Fix races in test for tot-net-in, tot-net-out, tot-cmds (#559)
The races are between the '$rd' client and the 'r' client in the test
case.

Test case "client input output and command process statistics" in
unit/introspection.

---------

Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2024-05-28 17:13:16 +02:00
Viktor Söderqvist
045d475a94
Implement REPLCONF VERSION (#554)
The replica sends its version when initiating replication, in
pipeline with other REPLCONF commands.

The primary stores it in the client struct. Other fields are made
smaller to avoid making the client struct consume more memory.

Fixes #414.

---------

Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2024-05-27 23:03:34 +02:00
Ping Xie
e4ead9442b
Make CLUSTER SETSLOT with TIMEOUT 0 block indefinitely (#556)
This aligns the behaviour with established Valkey commands with a
TIMEOUT argument, such as BLPOP.

Fix #422

Signed-off-by: Ping Xie <pingxie@google.com>
2024-05-27 07:11:24 -07:00
Samuel Adetunji
5d0f4bc9f0
Require C11 atomics (#490)
- Replaces custom atomics logic with C11 default atomics logic.
- Drops  "atomicvar_api" field from server info

Closes #485

---------

Signed-off-by: adetunjii <adetunjithomas1@outlook.com>
Signed-off-by: Samuel Adetunji <adetunjithomas1@outlook.com>
Co-authored-by: teej4y <samuel.adetunji@prunny.com>
2024-05-26 18:41:11 +02:00
Jonathan Wright
1c55f3ca5a
Replace centos 7 with alternative versions (#543)
replace centos 7 with almalinux 8, add almalinux 9, centos stream 9, fedora stable, rawhide

Fixes #527

---------

Signed-off-by: Jonathan Wright <jonathan@almalinux.org>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
2024-05-24 16:08:51 -07:00
Madelyn Olson
fbbabe3543
Revert format updates on config.c file for config block (#552)
Although I think this improves the readability of individual configs,
the fact there are now 1k more lines of configs makes this overall much
harder to parse. So reverting it back to the way it was before.

`,\n               [ ]+` replace with `, `.

---------

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
2024-05-24 15:53:44 -07:00
Viktor Söderqvist
d72ba06dd0
Make cluster replicas return ASK and TRYAGAIN (#495)
After READONLY, make a cluster replica behave as its primary regarding
returning ASK redirects and TRYAGAIN.

Without this patch, a client reading from a replica cannot tell if a key
doesn't exist or if it has already been migrated to another shard as
part of an ongoing slot migration. Therefore, without an ASK redirect in
this situation, offloading reads to cluster replicas wasn't reliable.

Note: The target of a redirect is always a primary. If a client wants to
continue reading from a replica after following a redirect, it needs to
figure out the replicas of that new primary using CLUSTER SHARDS or
similar.

This is related to #21 and has been made possible by the introduction of
Replication of Slot Migration States in #445.

----

Release notes:

During cluster slot migration, replicas are able to return -ASK
redirects and -TRYAGAIN.

---------

Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2024-05-24 17:58:03 +02:00
Harkrishn Patro
3dd2f5a586
Undeprecate cluster slots command (#536)
Undeprecate cluster slots command. This command is widely used by
clients to form the cluster topology and with the recent change to
improve performance of `CLUSTER SLOTS` command via #53 as well as us
looking to further improve the usability via #517, it makes sense to
undeprecate this command.

---------

Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
2024-05-24 07:14:23 +02:00