1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-15 17:51:06 +00:00
Commit graph

2091 commits

Author SHA1 Message Date
Lakshya Garg
fb2ee90b2d
chore(acl_family): add allcomands and nocommands (#3783)
* add allcommands alias for acl
* add nocommands alias for acl
* add test
2024-09-25 10:58:33 +03:00
Kostas Kyrimis
105c2bd761
fix: bitop do not add dst key if result is empty (#3751)
* fix bitiop creating the dst key if result is empty
* fix replicating dst with the wrong type
* make bitop a blind update (similar to set command)

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-25 09:45:20 +03:00
Borys
987e6feaa5
fix: GETRANGE params validation (#3781)
fix: getrange params validation
2024-09-24 13:54:35 +00:00
Shahar Mike
526bce4222
chore: Forbid replicating a replica (#3779)
* chore: Forbid replicating a replica

We do not support connecting a replica to a replica, but before this PR
we allowed doing so. This PR disables that behavior.

Fixes #3679

* `replicaof_mu_`
2024-09-24 13:42:22 +00:00
Borys
3804076ea9
fix: setrange with empty value doesn't modify the DB (#3771) 2024-09-23 19:09:53 +03:00
Roman Gershman
b7b4cabacc
chore: some renames + fix a typo in RETURN_ON_BAD_STATUS (#3763)
* chore: some renames + fix a typo in RETURN_ON_BAD_STATUS

Renames in transaction.h - no functional changes.
Fix a typo in error.h following  #3758
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-23 13:16:50 +03:00
Borys
9303591010
fix: mark pubusb commands as unsupported for cluster (#3767) 2024-09-23 09:59:13 +00:00
Roman Gershman
9c49aee43d
chore: give up on InlinedVector due to spurious warnings with optional (#3765) 2024-09-23 11:34:39 +03:00
adiholden
7df95dfb6e
fix server: fix last error reply (#3728)
fix 1: in multi command squasher error message was not set therefore it was not printed to log on the relevant command only on exec, fixed by setting the last error in CapturingReplyBuilder::SendError
fix 2: non clearing cached error replies before the command is Invoked

---------

Signed-off-by: adi_holden <adi@dragonflydb.io>
Co-authored-by: kostas <kostas@dragonflydb.io>
2024-09-23 11:34:13 +03:00
Andy Dunstall
45ffc605bd
feat(zset_family): add ZRANGESTORE (#3757) 2024-09-23 11:28:12 +03:00
Borys
6185617949
fix: substr/getrange result for invalid range (#3766) 2024-09-23 08:20:08 +00:00
Roman Gershman
0a049ab631
chore: add more error logs around ziplist parsing checks (#3764)
Also, reformat ziplist.c to valkey 8 formatting (no code changes besides this).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-23 10:13:36 +03:00
Roman Gershman
f1f8ee17dc
fix: make snapshotting process more responsive (#3759)
* fix: improve BreakStalledFlowsInShard heuristic

Before this change - we wrote in a single call whatever record chunks we pulled from the channel.
This can be problematic for 1GB chunks for example, which might take 10sec to write.

Lately we added a replication breaker on the master side that breaks the fully sync after
a predefined threshold has passed. By default it was 10sec. To improve the robustness of this
breaker, we now write chunks of upto 1MB and update last_write_time_ns_ more frequently.

Also, we added more logs to make replication delays on both sides more visible.
We also added logs of breaking the replication on the master sides.

Unfortunately, this did not help making BreakStalledFlowsInShard more robust because now the
problem moved to replica side which may take 20s+ seconds to parse huge values.
Therefore, I increased the threshold for breaking the replication to 30s.

Finally, instrument GetMetrics call as it takes sometimes more than 1 sec.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-22 17:05:28 +03:00
Roman Gershman
2e9b133ea0
chore: add integrity checks to consumer->pel (#3754)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-22 15:40:42 +03:00
adiholden
4d38271efa
feat(server): introduce rss oom limit (#3702)
* introduce rss denyoom limit

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-09-22 13:28:24 +03:00
adiholden
5cf917871c
feat(server): introduce oom_deny_commands flag (#3718)
* server: introduce oom_deny_commands flag

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-09-22 09:32:18 +03:00
Vladislav
d9f8f2553b
chore: fix return on bad status (#3758) 2024-09-22 01:36:39 +03:00
Roman Gershman
cce2eb35ed
chore: refactor a lambda function into a named one (#3753)
Also did some cosmetic improvements. No functionality should be changed.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-22 01:35:56 +03:00
Andy Dunstall
9dd79657ce
fix: zset store conclude transaction on error (#3755) 2024-09-21 19:08:53 +03:00
Borys
ce79da0f7a
fix: add value range check for SETBIT command (#3750) 2024-09-20 18:20:35 +03:00
Roman Gershman
abf3acec4a
chore: introduce a Clone function for the dense set (#3740)
* chore: introduce a Clone function for the dense set

We use a state machine to prefetch data in batches.
After this change, the hot spots are predominantly inside ObjectClone and
Hash methods.

All in all benchmarks show ~45% CPU reduction:
```
BM_Clone/elements:32000    1517322 ns      1517338 ns         2772
BM_Fill/elements:32000      841087 ns       841097 ns         4900
```

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-19 16:14:33 +03:00
Vladislav
3af2dfc4e7
chore: add SetReplies (#3727) 2024-09-19 12:54:25 +03:00
Kostas Kyrimis
0e0b2e78a4
chore: change log level to warning for empty keys (#3722)
* adjust log level to warning for allowed empty keys in rdb_load and rdb_save

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-19 09:45:09 +00:00
adiholden
409c2a3beb
test: add test for replication deadlock on replication timeout (#3691)
* test: add test for replication deadlock on replication timeout

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-09-19 12:11:28 +03:00
Borys
efa4efd2bf
refactor: use CmdArgParser for XGROUP command (#3739) 2024-09-18 22:30:37 +03:00
Kostas Kyrimis
6e45c9c3e2
fix: properly track json memory usage (#3641)
* add JsonMemTracker
* add logic based on MiMallocResource deltas that calculates json object usage
* add test

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-18 13:08:43 +00:00
Stepan Bagritsevich
b235617a0d
fix(json_family): Fix out of bound ranges for the JSON.ARR* commands (#3712)
* fix(json_family): Fix out of bound ranges for theJSON.ARR* commands

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): address comments 2

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-09-18 14:31:17 +02:00
Vladislav
41ba864924
chore: Remove ReqSerializer (#3721)
Signed-off-by: Vladislav <vladislav.oleshko@gmail.com>
2024-09-18 14:31:47 +03:00
Stepan Bagritsevich
ae5ce9b497
fix(json_family): Separate double and int values during the comparison of the JSON objects (#3711)
* fix(json_family): Separate the double and int values in JSON commands

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): Address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-09-18 07:24:48 +02:00
Stepan Bagritsevich
824af02f6f
fix(json_family): Fix JSON.ARRPOP command in legacy mode should not return WRONGTYPE error (#3683)
* fix(json_family): Fix WRONGTYPE error for the JSON legacy mode in the JSON.ARRPOP command

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): address comments 2

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-09-18 07:24:18 +02:00
Kostas Kyrimis
8a34b3e730
chore: enable ReplyGuard in ReplyBuilder2 (#3705)
* add ReplyGuard in ReplyBuilder2

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-17 13:37:23 +03:00
Kostas Kyrimis
6f84115152
chore: add log info on failed commands (#3694)
* log errors on failed commands

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-17 13:07:46 +03:00
Shahar Mike
51746d99c7
fix(cluster): Do not Pause() replication / migrations (#3716)
Pre-this change, whenever Dragonfly was paused (either by a user or by
internal processes like takeover or slot migration finalization),
migrations and replications were also paused.

This could cause timing issues, which sometime result in migration
failures. Specifically, when 2 nodes have migrations from one to the
other **in parallel** (A->B and B->A), the `Pause()` that happens on A
(which happens because it's a source node) will stop it from processing
incoming traffic from B (incoming because it is also a target node).

If timed correctly, it will be locked until it times out, and so the
migration will fail.

The fix is to prevent replications and migrations from adhering to
`Pause()`s, which I think should not have happened in the first place
because they should use the admin port anyway.

Fixes #3319
2024-09-17 10:47:55 +03:00
Andy Dunstall
b9ff6934e8
fix: fix s3 load snapshot (#3717) 2024-09-17 07:17:24 +01:00
Borys
e2a852b7e4
fix: add default value has_mc_flag field (#3710) 2024-09-16 10:03:08 +03:00
Roman Gershman
267bd431e4
chore: add clone benchmark (#3709) 2024-09-15 13:10:43 +03:00
Borys
93de559977
Update dflycluster slot-migration-status reply (#3707)
* feat: update DFLYCLUSTER SLOT-MIGRATION-STATUS reply
2024-09-15 09:44:40 +03:00
Kostas Kyrimis
b5929f0162
fix: allow parsing extra spaces on acl files (#3703)
* allow parsing extra whitespace characters in acl files

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-13 10:17:20 +03:00
Yang Hau
35c70dbfe1
feat(core): Support RISCV RVV (#3655) 2024-09-12 18:40:46 +03:00
Stepan Bagritsevich
3815cda26d
fix(json_family) Add NOESCAPE option to the JSON.GET command (#3685)
* fix(json_family) Add NOESCAPE option to the JSON.GET command

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(json_family): address comments 2

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-09-12 13:04:46 +02:00
Stepan Bagritsevich
3ece1725a1
fix(json_family): Fix the JSON.SET bug if the path is in legacy mode and is not the root (#3693)
Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-09-10 15:50:32 +02:00
Borys
9b8aa8eab4
fix: join for cancel incoming migration (#3692) 2024-09-10 14:42:37 +03:00
adiholden
e71f679386
fix(server): fix replication master deadlock on cancelation flow (#3686)
* fix server: fix replication deadlock on cancelation

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-09-10 14:13:38 +03:00
Roman Gershman
bdc578acef
chore: limit number of descriptors in the exec map (#3688)
For some cases, this map can grow indefinitely.
This change makes it less detailed by makes sure that number of possible keys is bounded.
Still it can provide a good summary of nature of exec transactions.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-10 07:50:30 +00:00
Roman Gershman
3cdc8fa128
chore: add a script that parses allocator tracking logs (#3687) 2024-09-10 07:26:44 +00:00
Roman Gershman
257749263b
chore: adjust RdbChannel sizes (#3676)
Fixes #3658

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-09 22:21:42 +03:00
Stepan Bagritsevich
2fad54e41f
fix(search_family): Fix LOAD option behavior in the FT.AGGREGATE command (#3660)
* fix(search_family): Fix LOAD option behavior in the FT.AGGREGATE command

fixes dragonflydb#3646

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* Update src/server/search/search_family.cc

Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
Signed-off-by: Stepan Bagritsevich <43710058+BagritsevichStepan@users.noreply.github.com>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
Signed-off-by: Stepan Bagritsevich <43710058+BagritsevichStepan@users.noreply.github.com>
Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
2024-09-09 09:21:48 +00:00
adiholden
c34f2b7eeb
server logs: change script error to warning (#3670)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-09-09 11:23:37 +03:00
Shahar Mike
b10a4a5348
feat(server): Support CLIENT SETINFO (#3673)
Add support for `CLIENT SETINFO <LIB-NAME | LIB-VER>` and also return
that as part of `CLIENT LIST`, like Valkey.

Fixes #3137
2024-09-09 11:03:05 +03:00
Roman Gershman
b7b96424e4
deprecate RecordsPopper and serialize channel records during push (#3667)
chore: deprecate RecordsPopper and serialize channel records during push

Records channel is redundant for DFS/replication because we have single producer/consumer
scenario and both running on the same thread. Unfortunately we need it for RDB snapshotting.

For non-rdb cases we could just pass a io sink to the snapshot producer,
so that it would use it directly instead of StringFile inside FlushChannelRecord.

This would reduce memory usage, eliminate yet another memory copy and generally would make everything simpler.
For that to work, we must serialize the order of FlushChannelRecord, and that's implemented by
this PR. Also fixes #3658.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-09 06:19:04 +00:00
Shahar Mike
1306a91bda
chore: Add CLIENT ID command (#3672)
We already adhere to all requirements, we just need to return the id
when the command is issued :)

Fixes #3651
2024-09-08 22:00:53 +03:00
Stepan Bagritsevich
0e7c12f5d6
fix(search_family): Fix FT.AGGREGATE GROUPBY option (#3657) 2024-09-08 17:29:09 +02:00
Roman Gershman
264835e9c4
chore: cosmetic changes around Snapshot functions (#3652)
* chore: cosmetic changes around Snapshot functions

Some renames and added comments. Refactored StartIncremental into a separate function
without any functional changes.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* chore: fix comments

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-08 09:25:41 +03:00
Roman Gershman
1d34bf735e
fix: recursive calls in the allocation tracker (#3665)
Also, remove dependence of absl::TimeZone bloated monstrosity, which was required by
absl::FormatTime api, even though we do not actually format a timezone.

When absl::LocalTimeZone is accessed it allocates hundreds of thousands of bytes
for each shard thread (maybe due to lack thread safety during lazy initialization).

At the end, strftime does a great job without any shenanigans.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-08 06:24:09 +00:00
Borys
894bf4735b
fix: fix multi mget exec error message (#3662) 2024-09-06 13:06:02 +03:00
Borys
2cc2a23247
fix: deadlock in the cluster migration process (#3653) 2024-09-05 21:55:15 +03:00
Borys
a1e9ee1b6d
CmdArgParser improvement (#3633)
* feat: add processing of tail args into CmdArgParser::Check
* refactor: rename CmdArgParser::Switch to Map
* feat: add CheckMap method into CmdArgParser
2024-09-05 15:30:54 +03:00
Roman Gershman
3461419088
chore: allow disabling io_uring registered buffers (#3650) 2024-09-05 14:47:42 +03:00
Roman Gershman
67117ff081
fix: crash during SORT DESC call (#3637)
fixes #3636

The problem was that instead of implementing GT operator, we implemented
!LT, which is GE operator. As a result the iterators inside the sort algorithm reached
out of bounds.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-03 12:00:31 +00:00
Kostas Kyrimis
2c32e5085c
fix: debug help printed layout (#3635)
* add missing comma to fix the printed layout

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-03 14:04:50 +03:00
Roman Gershman
cf7c983423
fix: 'renamenx foo foo' should return 0 if foo exists (#3630)
fix: renamenx foo foo should return 0 if foo exists

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-03 10:58:55 +00:00
Roman Gershman
e6f5a2073c
fix: crash when passing empty arguments (#3627)
* fix: crash when passing empty arguments

Fix the case where we pass an empty argument, which then is parsed as an
empty string view with null pointer. The null pointer is not handled correctly
by our low level c code, hence switch to using ""sv for that.


* chore: add more list asserts + improve test_hypothesis
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-03 12:43:12 +03:00
Roman Gershman
1a0d44354f
fix: limit parsing in zrange commands (#3626)
1. The offset value can be negative, in that case we should return an empty array.
2. Fix edge cases of inf*0 and -inf + inf, so they will result in 0 and non NaN (similarily to Valkey).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-03 10:08:45 +03:00
Borys
d40e9088ae
refactor: remove extra code from CmdArgParser (#3619)
* refactor: remove extra code from CmdArgParser
2024-09-03 07:04:05 +00:00
Roman Gershman
879f2950e5
fix: edge cases around mismatched path in json code (#3609)
For legacy mode:
1. For mutate commands, an empty result should throw an error
2. For read commands, it returns nil if path was not found, but if it was matched
   but only with a wrong types, it will throw an error.

For non-legacy mode, objlen should throw an error for non existing key.

Simplified JsonCallbackResult a bit and made sure more fakeredis tests are passing.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-02 21:37:59 +03:00
Roman Gershman
eef1de33fd
chore: improve debug logs in dragonfly_connection (#3624)
Adresses #3623

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Co-authored-by: adiholden <adi@dragonflydb.io>
2024-09-02 18:13:16 +03:00
adiholden
7203667723
fix(bug): zinter command should run on replica (#3620)
fix bug: zinter command should run on replica

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-09-02 12:59:11 +03:00
Borys
8e9b097b9d
fix: fix expiration processing for set command (#3607)
* fix: fix expiration processing for set command
2024-09-02 08:44:11 +03:00
Shahar Mike
de5ecc7447
chore: Split --cluster_announce_ip and --replica_announce_ip (#3615)
chore: Split `cluster_announce_ip` and `replica_announce_ip`

This PR partially reverts #3421

Fixes #3541
2024-09-01 12:43:44 +00:00
Roman Gershman
10de338926
chore: run fakeredis flow with the debug build (#3612)
1. Fix html publishing code
2. Upload dragonfly logs
3. Run it on pull requests

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-01 14:51:00 +03:00
Roman Gershman
5c48320496
fix: debug crash inside parsing of ZRANGE (#3611)
Also, fix error msg for EXEC command and finally tune more fakeredis tests.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-31 08:02:21 +03:00
Stepan Bagritsevich
31463c288d
fix(json_family): Fix JsonFromString method (#3602)
Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-08-30 19:39:25 +03:00
Roman Gershman
dd0effac6f
feat: add slave_repl_offset to the replication section. (#3596)
* feat: add slave_repl_offset to the replication section.

In Valkey slave_repl_offset denotes the replication offset on replica site during stable sync phase.
During fullsync phase it appears with 0 value.

In Dragonfly this field appears only after full sync has completed, thus it allows
to check whether Dragonfly reached stable sync phase. The value of this field describes the cumulative progress
of all the replication flows and it does not directly correspond to master side metrics.

In addition, this PR fixes the bug in wait_available_async() function in our replication tests.
This function is intended to wait until a replica reaches stable state and it did by sending pings until they do not
respond with LOADING error, hence the assumption is that the replica is in full sync state already.

However it can happen that master_link_status is "up" but replica has not reached full sync state, and the PING will succeed
just because wait_available_async() was called before full sync started. The whole approach of polling the state is fragile.

Now we use `slave_repl_offset` explicitly to see if the replica reaches stable state.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* chore: simplify wait_available_async

* chore: comments

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-30 18:58:07 +03:00
Kostas Kyrimis
41f7b611d0
chore: enable -Werror=thread-safety and add missing annotations (part 2/2) (#3595)
* add missing annotations
* small mutex fixes
* enable -Werror=thread-safety for clang builds

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-30 15:42:30 +03:00
Kostas Kyrimis
0705bbb536
feat(acl): add pub/sub (#3574)
* add support for pub/sub
* add tests
---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-30 15:41:28 +03:00
Stepan Bagritsevich
a22eff15dc
fix(server_family): Remove search indexes during the FLUSHALL command (#3539)
* fix(server_family): Add search indixes removing to the FLUSHALL command

fixes dragonflydf#3532

---------

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-08-30 08:26:14 +03:00
Roman Gershman
20336805f3
chore: enable experimental_new_io by default. (#3605)
* chore: enable experimental_new_io by default.

It has been running for weeks with the flag on, so enabled it also for community.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Co-authored-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-08-29 23:30:26 +03:00
Roman Gershman
fa2d67b8a8
fix: xreadgroup replies as a map for RESP3 (#3576)
* fix: xreadgroup replies as a map for RESP3

Moreover, it returns data for all the strings, irrespective whether they have results or not
(unlike with XREAD)

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* fix: properly handle xpending with 0 results

Also reject ENTRIESREAD instead of silently accepting it.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-29 20:05:57 +00:00
Roman Gershman
b74bd5a7b2
fix: JSON.STRAPPEND (#3597)
* fix: JSON.STRAPPEND

JSON.STRAPPEND was completely broken.

First, it accepts exactly 3 arguments, i.e. a single value to append.
Secondly, the value must be a json string, not the regular string. Meaning it must be in double quotes.
So, before we parsed: `JSON.STRAPPEND key $.field bar` and now we parse:
`JSON.STRAPPEND key $.field "bar"`

In addition fixed the behavior of JSON.STRLEN to return "no such key" error in case the
json key does not exist and path is specified.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-29 12:29:34 +00:00
Borys
88229cf365
refactor: remove toUpper() from cmd_arg_parser (#3599)
* refactor: remove usage of toUpper() from cmd_arg_parser

* refactor: remove CmdArgParser::NextUpper
2024-08-29 15:19:52 +03:00
Borys
79a80a0b06
refactor: remove double conversion from str to number to str in search (#3591)
fixes #3581
2024-08-29 09:47:41 +03:00
Roman Gershman
0ee52c9d35
chore: remove DflyVersion::VER0 (#3593)
Stop supporting DflyVersion::VER0 from more than a year ago.
In addition, rename Metrics fields to make them more clear
General improvements and fix the reconnect metric.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-28 18:21:53 +03:00
Borys
ee1aee8cee
feat: add escaping symbols for tag search (#3578)
* feat: add escaping symbols for tag search
2024-08-28 12:15:23 +03:00
Kostas Kyrimis
9d68d8f741
fix: warning as error on sanitizers build (#3587)
* disable implicit capture by this

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-28 08:30:42 +00:00
Roman Gershman
59068c3f8e
feat: add oom_deny_ratio to mutable config (#3585)
Also order other configuration variables alphabetically.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-28 06:24:20 +00:00
Roman Gershman
dc040b53ad
fix: return an error when invalid number of arguments is passed. (#3584)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-28 06:20:29 +00:00
Stepan Bagritsevich
832b79563d
fix(json_family): Fix JSON.GET crash for the multiple legacy mode paths (#3582)
fixes dragonflydb#3558

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-08-27 16:20:34 +00:00
Stepan Bagritsevich
f4fd0f1a07
fix(json_family): Fix json get crash due to an invalid json path (#3580)
fixes dragonflydb##3558

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-08-27 16:35:54 +02:00
Eunoia
cfb9fdab34
feat(generic_family): Implement EXPIRETIME and PEXPIRETIME commands (#3524)
Introduce EXPIRETIME and PEXPIRETIME commands
2024-08-26 15:55:24 +00:00
Kostas Kyrimis
839b1be82d
chore: add -Wthread-analysis and annotate (part 1/2) (#3502)
* enable -Wthread-analysis
* add missing annotations
* small fixes

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-26 18:22:38 +03:00
Roman Gershman
908290a268
chore: improve compatibility of set and ping commands (#3569)
* chore: improve compatibility of set and ping commands

smismember should return an array of longs and not array of strings.
ping in subscribe mode returns an array for resp2.
Also, fix double rounding for legacy float mode.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-26 13:33:03 +03:00
Vladislav
10816b500f
chore(search): Silence query parser error (#3570) 2024-08-26 13:03:16 +03:00
Kostas Kyrimis
9c3d69e0ec
fix: delete empty dense sets in HGetGeneric (#3543)
* remove DelEmptyPrimeValue
* delete empty dense set in HGetGeneric
* const qualify FindReadOnly

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-26 11:33:57 +03:00
Vladislav
b7eccad5bd
chore(transaction): More blocking tests (#3546) 2024-08-26 10:02:08 +03:00
Vladislav
789603d1a7
chore(server): Unify zset boolean operations into single function (#3567) 2024-08-26 10:01:58 +03:00
Vladislav
fce7970ad7
chore(server): Sort correctly in ZINTER (#3566) 2024-08-25 23:43:52 +03:00
Roman Gershman
20b8817148
fix: compatibility around list,string and sort commands (#3568)
1. Fix corner cases around non existing keys
2. Fix matching logic for * glob, as well as '' glob.
3. Improve SORT option parsing.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-25 16:30:55 +03:00
Vladislav
067fdd83b9
chore(server): Unify zset arg parsing (#3563) 2024-08-25 11:55:10 +03:00
Roman Gershman
be822ae9e1
fix: compatibility around list and string commands (#3565) 2024-08-25 10:41:25 +03:00
Vladislav
1646e90923
fix(server): Fix ZRANGEBYLEX limit params (#3562) 2024-08-25 09:21:49 +03:00
Roman Gershman
caf677ea76
fix: string compatibility issues (#3564)
1. strlen should return 0 for non existing types.
2. reject both EX and PX options in SET
3. prevent overflow of expiry time that is too large

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-25 08:08:14 +03:00
Roman Gershman
52b3866351
chore: allow limiting pipelining queue by length (#3551)
* chore: allow limiting pipelining queue by length

We already allow limiting the queue by memory usage but it also makes sense to limit by depth,
so that in extreme cases we would provide backpressure back to client connections. Otherwise if we parse and read everything,
clients do not have a sense of how loaded the connection is on the server side.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-24 18:22:56 +03:00
Vladislav
9f7cbc7d4d
chore(search): fix numeric index query in rev order (#3555) 2024-08-24 13:32:36 +03:00
Vladislav
0e4e971ad9
chore(server): Fix watch (#3557) 2024-08-24 13:32:21 +03:00
Stepan Bagritsevich
3fd3c40b74
fix(search_family): Fix query parsing for the integer tags in OR expression (#3544)
fixes dragonflydb#3490

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2024-08-24 11:58:16 +03:00
Roman Gershman
358c644335
fix: zinterstore correctly finds weights (#3554)
1. Fix the bug of computing incorrectly the weight index in OpInter
2. Remove code duplication and factor out the parsing code from OpInter and OpUnion into PrepareWeightedSets
3. Implement TODO and support union of zsets and sets, which has already been implemented for ZINTER.

fixes #3553

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-24 11:52:21 +03:00
Stepan Bagritsevich
80c3579596
feat(server_family): Add backup/restore Prometheus metrics (#3520)
* feat(server_family): Add backup/restore Prometheus metrics

fixes dragonflydb#3210

---------

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
2024-08-24 00:36:31 +03:00
Roman Gershman
dc4dcbfcbd
chore: add deallocation logs in the allocation tracker (#3549) 2024-08-23 17:20:53 +03:00
Vladislav
f88e49ba68
chore: fix search replication (#3547)
chore: fix search replcation

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-08-23 08:35:09 +03:00
Kostas Kyrimis
80972c7ace
fix: build errors in sanitizers daily workflow (#3542)
* disable warning for the problematic block in list_family

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-22 17:52:35 +00:00
Stepan Bagritsevich
6cfbc08013
fix(jsonpath): Add JsonPath grammar for the child identifier in brackets (#3533)
* fix(jsonpath): Add json path grammar for the child identifier with brackets

fixes dragonflydb##3511

---------

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
2024-08-22 13:49:50 +03:00
Vladislav
1bf6d73aa3
fix(transaction): Don't set continuation for blocking (#3540) 2024-08-21 17:48:23 +00:00
Borys
8266c8d026
fix: MC flags size and serialization #3134 (#3538) 2024-08-21 18:31:03 +03:00
Kostas Kyrimis
51f6bbed09
fix: macos build (#3536)
* define IOV_MAX on macos if it's not defined

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-21 16:33:45 +03:00
Stepan Bagritsevich
54cf6f0d06
fix(search_family): Add error on creating indexes from non-zero databases (#3537) 2024-08-21 15:19:21 +03:00
Kostas Kyrimis
4835b5debc
fix: deadlock in Heartbeat() (#3530)
* acquire and immediately release db_slice.GetSerializationMutex() in Heartbeat()

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-20 17:32:04 +03:00
Kostas Kyrimis
b979994025
fix: skip empty objects on load and replication (#3514)
* skip empty objects in rdb save
* skip empty objects in rdb load
* delete empty keys in FindReadOnly

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-20 09:44:41 +03:00
Vladislav
f90ae4fcff
chore(config): make pipeline_squash configurable (#3529) 2024-08-20 09:31:44 +03:00
Kostas Kyrimis
86e79e13c5
fix: disable sanitizers false positive (#3522)
* disable false positive test cases

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-19 13:46:14 +03:00
Vladislav
d13cd53e17
chore(io): Optimize repeated ReservePiece calls (#3525) 2024-08-19 13:20:34 +03:00
Vladislav
1f36c9952d
chore(io): Introduce (carefully) new io with use_new_io flag (#3513)
Plugs in new IO, must be reverted after successful testing
2024-08-16 16:56:04 +03:00
Kostas Kyrimis
d3a893f2a6
fix: disable ThreadLocalMutex when big value ser is off (#3521)
* fix: disable ThreadLocalMutex when big value ser is off

* refactor: address comments

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-28-29.ec2.internal>
Co-authored-by: Borys <borys@dragonflydb.io>
2024-08-15 22:19:01 +03:00
Shahar Mike
ad3ebf61d2
feat(cluster): Allow appending RDB to existing store (#3505)
* feat(cluster): Allow appending RDB to existing store

The goal of this PR is to support the loadoing of multiple RDB files into a single server, like when migrating from a Valkey cluster to Dragonfly with a different number of nodes.

It makes the following changes:

* Removes `DEBUG LOAD`, as we already have `DFLY LOAD`
* Adds `APPEND` option to `DFLY LOAD` (i.e. `DFLY LOAD <filename> APPEND`) that loads an RDB without first flushing the data store, overriding existing keys
* Does not load keys belonging to unowned slots, if in cluster mode

Fixes #2840
2024-08-15 14:56:40 +03:00
Shahar Mike
5b546df94d
chore: Change Lua embedded flags syntax (#3517)
Background

We tried to be compatible with Valkey in their support of Lua flags, but we generally failed:

We are not really compatible with Valkey because our flags are different (we reject unknown flags, and Valkey flags are unknown to us)
The #!lua syntax doesn't work with Lua (# is not a comment), so scripts written for older versions of Redis can't be used with Dragonfly (i.e. they can't add Dragonfly flags and remain compatible with older Redis versions)
Changes

Instead of the previous syntax:

#!lua flags=allow-undeclared-keys,disable-atomicity

We now use this syntax:

--!df flags=allow-undeclared-keys,disable-atomicity
It is not backwards compatible (with older versions of Dragonfly), but it should be very easy to adapt to, and doesn't suffer from the disadvantages above.

Related to #3512
2024-08-15 08:04:20 +03:00
Roman Gershman
81eff01b9d
fix: bugs around the growth of a tiered file (#3516)
1. Before - when 15% margin of total size becomes larger than 256MB, we increased the file by 256MB even though
   we still had unused 256MB. Now it's fixed.
2. We attempted to grow a file even if it reached the limit and then returned the error.
   It is wrong handle "reach the limit" state as an error - it's just a logical constraint,
   so now we do not attempt to grow and handle this quietly.
3. There was a segfault bug in extent tree in case the existing segment and the new one needs to be united.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-15 07:24:31 +03:00
Roman Gershman
93f6773297
chore: reduce pipelining latency by reusing existing shard fibers (#3494)
* chore: reduce pipelining latency by reusing existing shard fibers

To prove the benefits, run `./dfly_bench --pipeline=50   -n 20000  --ratio 0:1  --qps=0  --key_maximum=1`
Before: the average pipelining latency was 10ms
After: the average pipelining latency is 5ms.
Avg latency: pipelined_latency_usec / total_pipelined_squashed_commands

Also, improved counting of squashed commands - to count actual squashed ones.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-14 14:45:54 +03:00
Roman Gershman
a2e63f144c
fix: clang warnings (#3509)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-14 09:39:56 +00:00
Roman Gershman
fa0913e662
chore: introduce a secondary TaskQueue for shards (#3508)
Also allow the TaskQueue to support multiple consumer fibers.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-14 10:53:29 +03:00
Roman Gershman
5cfe4154cc
chore: split engine_shard file from engine_shard_set (#3507)
No functional changes besides that.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-13 22:27:46 +03:00
Kostas Kyrimis
0786fc83c1
fix: missing virtual destructors in ReplyBuilder2 (#3506) 2024-08-13 17:20:15 +03:00
Stepan Bagritsevich
c756023332
feat: Expose replica_reconnect_count for Prometheus metrics (#3370) 2024-08-13 12:34:01 +02:00
Kostas Kyrimis
3f5d4f890d
fix: sanitizers false positives (#3495)
* disable flaky tests

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-13 09:53:31 +03:00
Stepan Bagritsevich
930a496152
chore(generic_family): Fix bad data format error in the RESTORE command (#3501)
* chore(generic_family): Fix bad data format error in the RESTORE command

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* chore(generic_family): Remove the error reply for OpStatus::WRONG_TYPE in the RESTORE command, since it is no longer in use

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

---------

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
2024-08-12 12:16:06 +00:00
Roman Gershman
29a13893c2
feat: implement FT.TAGVALS (#3493)
* feat: implement FT.TAGVALS

Fixes #3491

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-11 22:53:25 +03:00
Roman Gershman
766b0ec86f
chore: add logs to debug tiered memory failures (#3499) 2024-08-11 22:52:58 +03:00
Kostas Kyrimis
b6d528cb5c
fix: HELLO AUTH with non default user (#3486)
* fix HELLO AUTH with non default user
* add test_auth_resp3_bug
* add decode_responses=True to acl tests and refactor
* fix test_default_user_bug

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-11 14:35:26 +03:00
Kostas Kyrimis
1c9e9c5922
fix: big value serialization corner cases (#3430)
There are some problematic flows. First we did not handle deletions, so all sorts of consistency issues could arise while calling DbSlice::Traverse() and DbSlice::Del(). Second, we did not handle FlushAll (same as before, Traverse() preempts and FlushAll() kicks in. Third we did not handle expirations.

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-11 14:17:32 +03:00
Vladislav
41ebb075a1
chore(facade): RedisReplyBuilder2 (extensions) (#3481)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-08-09 23:16:33 +03:00
Vladislav
63a4ad6de1
chore(facade): MCReplyBuilder2 (#3480) 2024-08-09 20:16:08 +03:00
Vladislav
19fb7aa158
chore(facade): RedisReplyBuilder2 base (#3475) 2024-08-09 15:26:36 +03:00
Roman Gershman
b9cafaab4b
fix: division by zero bug (#3482) 2024-08-09 09:49:29 +03:00
Borys
48a28c3ea3
refactor: set info_replication_valkey_compatible=true (#3467)
* refactor: set info_replication_valkey_compatible=true
* test: mark test_cluster_replication_migration as skipped because it's broken
2024-08-08 21:42:58 +03:00
Vladislav
5258bbacd1
chore(facade): Update SinkReplyBuilder2 (#3474) 2024-08-08 21:40:49 +03:00
Roman Gershman
fb7a6a724d
chore: make tiered_test more reliable (#3477) 2024-08-08 20:08:00 +03:00
Shahar Mike
b6b42c9f26
fix: Make replica's REPLCONF IP-ADDRESS optional (#3473)
**Background**

In v1.21.0 we introduced support for `--announce_ip` for replicas to
announce their public IP addresses.

Like Valkey, this uses `REPLCONF IP-ADDRESS` to announce their IP
address.

**The issue**

Older Dragonfly releases (<1.21) did not support this feature. The
master side simply returned an error for such `REPLCONF` attempts,
however the replica code failed the replication, resulting in
incompatible versions.

**The fix**

The fix is simple, just log an error if the master did not respect
`REPLCONF IP-ADDRESS`. We can make this non-optional in the future
again.

However, in addition, I added a regression test to make sure we are
backwards compatible with v1.19.2. We'll bump this up every once in a
while.
2024-08-08 17:22:30 +03:00
Vladislav
7b9bbc19d7
chore(server): Use parser more in list_family (#3461)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-08-08 12:16:33 +03:00
Shahar Mike
aa424c81af
feat: Allow pre-declaring Lua SHAs to run with undeclared keys (#3465)
* feat: Allow pre-declaring Lua SHAs to run with undeclared keys

By using `--lua_undeclared_keys_shas=SHA,SHA,SHA` users can now specify
which scripts should run globally (undeclared keys) without explicit
support from the scripts themselves.

Fixes #2442
2024-08-08 10:27:27 +03:00
Vladislav
1b1a83dc58
chore: SinkReplyBuilder2 with vec batching (#3454) 2024-08-07 18:34:52 +03:00
Vladislav
8587377a03
chore(server): Remove old blocking debug (#3460) 2024-08-07 16:52:09 +03:00
Roman Gershman
1cbfcd4912
chore: add timeout to replication sockets (#3434)
* chore: add timeout fo replication sockets

Master will stop the replication flow if writes could not progress for more than K millis.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Roman Gershman <romange@gmail.com>
Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
2024-08-07 16:33:03 +03:00
Roman Gershman
7c84b8e524
chore: change how we track memory_budget during evictions (#3457)
* chore: change how we track memory_budget during evictions

We compared memory_budget vs 0 before inserting a new item in DbSlice,
and retired cool pages if we are low on memory.

The problem - when we decide whether we allow growing a table, we estimate the possible object size increase due to the future table growth.
And the memory check described before was not consistent with the actual logic that rejected the insertion.

Moreover, the memory_budget tracking interaction with EvictionPolicy was over-complicated: we passed the memory_budget counter to the evp object
and then read it back, even though evp did not track object deletions memory impact during objects evictions.

Now, we remove the responsibility from evp to update memory_budget_ so it's solely updated by DbSlice.
We also update memory_budget_ during deletions, and when we pass it to evp, we add cool memory size as potential memory resource to avoid
rejections in case we have lots of cool memory.

Fixes #3456
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-07 15:43:45 +03:00
Stepan Bagritsevich
75452a7108
feat(json_family): Add support of the JSON legacy mode (#3284) 2024-08-06 18:04:45 +02:00
Roman Gershman
7df72fd6d0
chore: integrate quicklist changes from valkey (#3440)
The quicklist.* files are mostly equal to the versions at commit 0fc43edc6
Also, removed some unused code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-06 16:25:16 +03:00
Borys
070e7b02c6
fix: JSON.MSET command (#3459) 2024-08-06 15:37:03 +03:00
Roman Gershman
420046aac8
fix: properly seriailize meta buffer in SendStringArrInternal (#3455)
Fixes #3449 that was introduced by #3425

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-06 10:43:05 +03:00
Borys
faea4eef45
test: fix test_disconnect_replica (#3442) 2024-08-05 10:07:27 +03:00
Roman Gershman
6da445fcfe
feat: DEBUG REPLICA PAUSE now pauses fullsync (#3441)
Before that PAUSE paused the reconnection reconciler flow,
now it also stops the ongoing full sync replication if such exists.

In addition, this PR applies some clean-ups and removes redundant code

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-05 09:42:57 +03:00
Kostas Kyrimis
3f08a60148
chore: reset serialization_max_chunk_size to 0 (#3432)
* reset serialization_max_chunk_size to 0
* reword flag information

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-05 09:36:23 +03:00
Roman Gershman
9eacedf58e
chore: simplify master replication cancelation interface (#3439)
* chore: simplify master replication cancelation interface

Before that CancelReplication did too many things, moreover,
we had StopReplication that did the same.

This PR moves CancelReplication under ReplicaInfo struct,
and reduces code duplication around this change.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* Update src/server/dflycmd.cc

Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
Signed-off-by: Roman Gershman <romange@gmail.com>

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Roman Gershman <romange@gmail.com>
Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
2024-08-04 19:00:52 +00:00
Roman Gershman
8f7c36e4b3
chore: reorganize EngineShard::Heartbeat (#3437)
* chore: reorganize EngineShard::Heartbeat

1. Simplify CacheStats by using accessorts directly provided by DbSlice
2. Separate eviction for tiering as tiering can be done on replica.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-04 15:00:43 +03:00
Roman Gershman
cfd2273fb0
chore: improve replication locks (#3436)
* chore: improve replication locks

Allow non-exclusive, read-only access to Dfly::ReplicaInfo structure.
The most important change is in DflyCmd::CancelReplication, where before
it has locked ReplicaInfo mutex and then continued with locking the global mutex.
It is dangerous because most operation lock them in the opposite order.

Also rename ambigous GetReplicaInfo accessors to clearer names.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* chore: comments

* chore: comments

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-04 10:55:50 +00:00
Vladislav
2ef475865f
test(cluster): Migration replication test (#3417) 2024-08-04 12:45:02 +03:00
Shahar Mike
2aa0b70035
feat(server): Support replica-announce-ip/port (#3421)
* feat: Support `replica-announce-ip`/`port`

Before this PR, we only supported `cluster_announce_ip`.
It's basically the same feature, but used for cluster announcements
instead of replication.

This PR adds support for `replica-announce-ip` and
`replica-announce-port`, which can be set via new flags `--announce_ip=`
and `--announce_port=`. These flags apply to both cluster and replica
announcements.

Tested via running Sentinel, and making sure it is able to connect to
announced ip+port, while it can't connect to announced false /
unavailable ip+port.

Note: this PR deprecates `--cluster_announce_ip`, but continues to
support it. We will remove it in a future version.

Fixes #3380

* fix failing test

* destructure
2024-08-04 12:35:14 +03:00
Roman Gershman
c9ed3f7b2b
chore: retire TEST_EnableHeartBeat (#3435)
Now unit tests will run the same Hearbeat fiber like in prod.
The whole feature was redundant, with just few explicit settings of maxmemory_limit
I succeeeded to make all unit tests pass.

In addition, this change allows passing a global handler that is called by heartbeat from a single thread.
This is not used yet - preparation for the next PR to break hung up replication connections on a master.

Finally, this change has some non-functional clean-ups and warning fixes to improve code quality.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-03 20:17:23 +03:00
Vladislav
82298b8122
fix(server): Implement SCRIPT GC command (#3431)
* fix(server): Implement SCRIPT GC command
2024-08-02 23:49:51 +03:00
Roman Gershman
f652f10743
chore: optimize SendStringArrInternal even more (#3425)
Before - sending 200K items requires more than 12K send calls.
Now - requires less than 2K calls. Latency also went down though not by x6.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-02 14:53:20 +03:00
Roman Gershman
8622c27ce1
chore: expose metric that shows how many task submitters are blocked (#3427)
* chore: expose metric that shows how many task submitters are blocked

This should help us in identifying deadlocks quickly.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-01 21:27:15 +03:00
Roman Gershman
a0918de2d3
feat: Support non-root paths for json.merge (#3419)
* feat: Support non-root paths for json.merge

Pass path argument and rewrite the JSON.MERGE code similar to OpToggle
or other mutating functions. Currently works only with --experimental_flat_json=false.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* chore: comments

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-01 08:33:36 +00:00
Roman Gershman
0ad310717d
chore: Tiered fixes (#3401)
1. Add background offloading stats
2. remove direct_fd override - helio is already updated with default=false, so it's not needed anymore.
3. remove redundant tiered_storage_memory_margin flag

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-01 11:03:13 +03:00
Vladislav
e273015c0b
fix(connection): Count memchached pipelined commands (#3413) 2024-08-01 10:14:36 +03:00
Kostas Kyrimis
7e911c100a
fix: json.merge exception crash (#3409)
json.merge would throw an exception when the json object did not contain the element to replace because RecursiveMerge functions used &dest->at(k_v.key()) which threw the exception. Remove RecursiveMerge completely and use the one implemented in jsoncons lib.

* add test
* replace RecursiveMerge with mergepatch::apply_merge_patch
* add exception handling for that flow

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-31 17:03:36 +03:00
Borys
558a22d5b8
fix: crash with NS in multi/exec #3410 (#3415) 2024-07-31 10:06:32 +00:00
Kostas Kyrimis
aa02070e3d
chore: add db_slice lock to protect segments from preemptions (#3406)
DastTable::Traverse is error prone when the callback passed preempts because the segment might change. This is problematic and we need atomicity while traversing segments with preemption. The fix is to add Traverse in DbSlice and protect the traversal via ThreadLocalMutex.

* add ConditionFlag to DbSlice
* add Traverse in DbSlice and protect it with the ConditionFlag
* remove condition flag from snapshot
* remove condition flag from streamer

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-30 15:02:54 +03:00
Vladislav
f536f8afbd
chore: cancel slot migrations on shutdown (#3405) 2024-07-30 12:47:58 +03:00
Roman Gershman
e464990643
feat: stabilize non-coordinated omission mode (#3407)
* feat: stabilize non-coordinated omission mode

1. Our latency/RPS computations were off because we started measuring before drivers
   started running. Now, Run/Start phases are separated, so the start time is measured more precisely
   (after the start phase)
2. Introduced progress per connection - one of my discoveries is that driver
   connections progress with differrent pace when running in coordinated omission mode.
   This can reach x5 speed differrences. Now we measure and output fastest/slowest progress.
3. Coordinated omission is great when the Server Under Test is able to sustain the required RPS.
   But if the actual RPS is lower than the one is sent than the final latencies will be infinitely high.
   We fix it by introducing self-adjusting sleep interval, so if the actual RPS is lower
   we will increase the interval to be closer to the actual RPS.

Show p99 latency and maximum pending requests per connection.

Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
Signed-off-by: Roman Gershman <romange@gmail.com>

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Roman Gershman <romange@gmail.com>
Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
2024-07-30 11:55:43 +03:00
Shahar Mike
89a48a7aa8
chore: Support setting the value of replica-priority (#3400)
* chore: Support setting the value of `replica-priority`

This PR adds a small refactor to the way we set and get config names
which have dashes (`-`) and underscores (`_`).

Until now, words were separated by underscores because this is how our
flags library (absl) works. However, this is incompatible with Valkey,
which uses dashes as a word separator.

Once merged, we will support both underscores and dashes in config
names, but will only return the name with dashes. **This is a behavior
change**.

We're doing this in order to be compatible with `replica-priority` and
possibly other config names that Valkey uses.

* Flag restore

* normalize to '_'
2024-07-29 23:02:49 +03:00
Shahar Mike
7100168bab
chore: Don't print password to log on replica AUTH failure (#3403) 2024-07-29 22:36:39 +03:00
Roman Gershman
776bd79381
fix: reenable macos builds (#3399)
* fix: reenable macos builds

Also, add debug function that prints local state if deadlocks occure.

* fix: free cold memory for non-cache mode as well

* chore: disable FreeMemWithEvictionStep again

Because it heavily affects the performance when performing evictions.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-28 22:40:51 +03:00
Vladislav
1a8c12225b
chore(tiering): Move cool entry warmup to DbSlice (#3397)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-07-28 17:30:41 +03:00
Stepan Bagritsevich
28cfde0a27
fix: Fix unsupported object type rejson-rl in RedisInsight (#3384)
* fix: Fix unsupported object type rejson-rl in RedisInsight

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* fix(generic_family): fix case for the TYPE option in SCAN command

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* feat(generic_family_test): Add test for the Redis GUI

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* refactor: address comments

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* refactor: address comments 2

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* refactor: change variable name from obj_type_as_string to obj_type

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

---------

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
2024-07-27 19:05:00 +02:00
Roman Gershman
6b67f44e29
chore: tiering - make Modify work with cool storage (#3395)
1. Fully support tiered_experimental_cooling for all operations
2. Offset cool storage usage when computing memory pressure situations in Hearbeat.
3. Introduce realtime entry counting per db_slice and provide DCHECK to verify it vs the old approach.
   Later we will switch to realtime entry and free memory computations when computing bytes per object,
   and remove the old approach in CacheStats().
4. Show hit rate during the run of dfly_bench loadtest.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-27 14:31:29 +03:00
Kostas Kyrimis
9d16bd6f6e
fix(acl): remove none from acl categories (#3392)
None does not exist in Valkey and its entry was missing from the indexes we use to map categories to commands leading to an out of bounds access and causing a segfault.

* remove none from acl categories

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-26 09:27:29 +03:00
Roman Gershman
0a26a06065
chore: tiered fixes (#3393)
1. Use introsive::list for CoolQueue.
2. Make sure that we ignore cool memory usage when computing average object size to
   prevent evictions during dashtable growth attempts.
3. Remove items from the cool storage before evicting them from the dash table.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-25 23:38:44 +03:00
Kostas Kyrimis
79d7f57b67
fix: disable inline transactions when db_slice has registered callbacks (#3391)
Inline transactions do not acquire any locks and therefore they should not preempt. This is no longer true when db_slice has registered callbacks.

* disable inline transactions when db_slice has registered callbacks

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-25 16:06:35 +00:00
Kostas Kyrimis
a95cf2e857
chore: do not preempt on db_slice::RegisterOnChange (#3388)
For big value serialization it is required to support preemption when db_slice::RegisterOnChange is called to avoid UB when a code path is iterating over the change_cb_ and preempts because it serializes a big value. As this is problematic and can lead to data inconsistencies I replace the std::vector with std::list and bound the iteration of change_cb_ on paths that preempt.

* replace std::vector with std::list for change_cb_
* bound iteration of change_cb_ on paths that preempt

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-25 16:08:02 +03:00
Kostas Kyrimis
4b851be57a
fix: remove fiber guard from non atomic section (#3381)
We might preempt when we serialize a big value and the code in journal was protected by an atomic guard triggering a check failed.

* remove fiber guard from non atomic section
* move LocalBlockingCounter to common

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-25 16:06:35 +03:00
Roman Gershman
e2d65a0900
chore: reenable evictions upon insertion to avoid OOM rejections (#3387)
* chore: reenable evictions upon insertion to avoid OOM rejections

Before: when running dragonfly with --cache_mode we could get OOM rejections
even though the eviction policy allowed to evict items to free memory.
Ideally, dragonfly in cache mode should not respond with the OOM error.

This PR reuses the same Eviction step we have in the Heartbeat and conditionally applies it
during the insertion. In my test the OOM errors went from 500K to 0 and the server
still respected memory limit.

Also, remove the old heuristics that has never been used.

Test:

./dfly_bench --key_prefix=bar: -d 1024 --ratio=1:0 --qps=200 -n 3000
./dragonfly --dbfilename=  --proactor_threads=2 --maxmemory=600M --cache_mode

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-25 15:28:57 +03:00
Shahar Mike
fb4222d01e
fix: Fix test_take_over_seeder (#3385)
* fix: Fix `test_take_over_seeder`

There are a few issues with the test:

1. Not using the admin port, which could cause pause to deadlock
2. Not waiting for some of the `task`s (although that won't cause a
   failure)

But also in the product code:

1. We used to `std::move()` the same pointer multiple times
2. We assigned to the same status object from multiple threads

Hopefully this fixes the test. It used to fail every ~100 attempts on my
machine, now it's been >1,000 and they all passed.

* add comments

* remove shard_ptr param
2024-07-25 08:00:05 +00:00
Roman Gershman
181d356341
chore: update cached stats inside PollExecution (#3376)
* chore: update cached stats inside PollExecution
2024-07-25 10:46:03 +03:00
Roman Gershman
8a9c9adbc5
chore: introduce a cool queue that gradually retires cool items (#3377)
* chore: introduce a cool queue that gradually retires cool items

This PR introduces a new state in which the offloaded value is not freed from memory but instead stays
in the cool queue.

Upon Read we convert the cool value back to hot table and delete it from storage.
When we low on memory we retire oldest cool values until we are above the threshold.

The PR does not fully finish the feature but it is workable enough to start (load)testing.
Missing:
a) Handle Modify operations
b) Retire cool items in more cases where we are low on memory. Specifically, refrain from evictions as long as cool items exist.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-25 09:09:40 +03:00
Roman Gershman
02b72c9042
chore: dfly_bench - print ongoing error counts (#3382) 2024-07-24 22:13:11 +03:00
Kostas Kyrimis
52b29b302c
update: replication_acks_interval flag to 1000 (#3378)
* update replication_acks_interval flag to 1000

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-24 13:28:56 +00:00
Kostas Kyrimis
929222a7df
chore: add mem test for big values and default the flag (#3369)
* default serialization_max_chunk_size to 10 mb
* add test for big values
* small rename of enum to conform style guide

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-24 16:07:27 +03:00
Roman Gershman
03b3f86aed
chore: Track db_slice table memory instantly (#3375)
We update table_memory upon each deletion and insertion of an element.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-24 14:13:08 +03:00
Vladislav
f73c7d0e42
fix(transaction): Properly store block cancel status (#3371) 2024-07-24 14:05:00 +03:00
Stepan Bagritsevich
37cb247cd4
chore(replica): remove unused methods in the Replica class (#3374)
Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
2024-07-24 12:05:13 +02:00
Roman Gershman
499fa2268b
chore: simplify computation of used_mem_current (#3372)
* chore: simplify computation of used_mem_current

Before - each thread updated its own variable and then,
the global "used_mem_current" was updated by summing used memory from each thread.

Now, each thread updates used_mem_current directly. The code is simpler and also provides more precise
results more frequently.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-24 06:58:01 +00:00
Roman Gershman
eba722b774
chore: add a test for HeapSize() function (#3349) 2024-07-23 19:02:57 +03:00
Roman Gershman
c8a98fd110
chore: small fixes around tiering (#3368)
There are no changes in functionality here.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-23 16:00:50 +03:00
Roman Gershman
cd1f9d3923
chore: Introduce CoolQueue (#3365)
Also, add the according API to compact object.
Now external objects can be in two states: Cool and Offloaded.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-23 12:41:10 +03:00