Commit graph

49 commits

Author SHA1 Message Date
Roman Gershman
29cde99ca5
chore: pull latest helio (#4446)
This also pulls the latest abseil library 20240722.0
2025-01-13 15:23:08 +02:00
Roman Gershman
be96e6cf99
chore: change Namespaces to be a global pointer (#4032)
* chore: change Namespaces to be a global pointer

Before the namespaces object was defined globally.
However it has non-trivial d'tor that is being called after main exits.
It's quite dangerous to have global non-POD objects being defined globally.
For example, if we used LOG(INFO) inside the Clear function , that would crash dragonfly on exit.

Ths PR changes it to be a global pointer.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-10 10:45:53 +00:00
Shahar Mike
18ca61d29b
feat(namespaces): Initial support for multi-tenant (#3260)
* feat(namespaces): Initial support for multi-tenant #3050

This PR introduces a way to create multiple, separate and isolated
namespaces in Dragonfly. Each user can be associated with a single
namespace, and will not be able to interact with other namespaces.

This is still experimental, and lacks some important features, such as:
* Replication and RDB saving completely ignores non-default namespaces
* Defrag and statistics either use the default namespace or all
  namespaces without separation

To associate a user with a namespace, use the `ACL` command with the
`TENANT:<namespace>` flag:

```
ACL SETUSER user TENANT:namespace1 ON >user_pass +@all ~*
```

For more examples and up to date info check
`tests/dragonfly/acl_family_test.py` - specifically the
`test_namespaces` function.
2024-07-16 19:34:49 +03:00
Kostas Kyrimis
e1b03d605c
refactor: acl helpers and global tables (#3309)
* remove helper.h and helper.cc and move them to AclFamily class
* remove global tables from acl_commands_def and move them to AclFamily

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-07-15 15:41:13 +03:00
Roman Gershman
2ff7ff9841
chore: get rid of lock keys (#2894)
* chore: get rid of lock keys

1. Introduce LockTag a type representing the part of the key that is used for locking.
2. Hash keys once in each transaction.
3. Expose swap_memory_bytes metric.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-21 11:34:42 +03:00
Roman Gershman
8030ee96b5
chore: preparation step for lock fingerprints (#2899)
The main change here is introduction of the strong type LockTag
that differentiates from a string_view key.

Also, some testing improvements to improve the footprint of the next PR.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-16 19:23:50 +03:00
Shahar Mike
256e07f8ba
feat(server): Allow configuration of hashtag extraction (#2890)
* feat(server): Allow configuration of hashtag extraction

Before this PR: Hashtags, if enabled, meant the text between `{` and `}`
in the key (if exists and non-empty).

After this PR:

* Hashtags can _still_ be enabled / disabled
* Hashtag open / close char can be specified (and can be the same), like `:` popular with BullMQ
* Hashtag can include `N` closing tags to skip, like `{a}b}c}d` with `2` will return `a}b}c`.

This will allow some existing systems to migrate without code changes in
client code.
2024-04-14 15:09:41 +03:00
Roman Gershman
7e0536fd4c
chore: remove core/fibers (#2723)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-03-14 12:02:33 +00:00
adiholden
7b61b4a8fe
fix(tiering tests): introduce wait until tieting entries num EQ/GT (#2559)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-02-14 09:59:11 +02:00
Roman Gershman
bbe3d9303b
feat: introduce transaction statistics in the info output (#2328)
1. How many transactions we processed by type
2. How many transactions we processed by width (number of unique shards).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-23 13:18:49 +02:00
Yue Li
6905389d60
feat(server): Support CLIENT TRACKING subcommand (2/2) (#2280)
fixes https://github.com/dragonflydb/dragonfly/issues/2139

This is part two that implements the logic which notifies tracking clients by sending invalidation messages:

- The client tracking state is set by CLIENT TRACKING subcommand as well
as upon client disconnection.

- Track the keys of a readonly command by maintaining mapping that maps
keys to the sets of tracking clients.

- Send invalidation messages to clients when their tracked keys are
updated.

- Make PerformDeletion a member function of DbSlice, and send 
invalidation message within the function.

- Mock the function for sending invalidation message to avoid test
crash due to lack of real listener in the testing framework.

- Add functional (some) tests for client tracking based on the mocked interfaces.

---------

Signed-off-by: Yue Li <61070669+theyueli@users.noreply.github.com>
2023-12-21 04:40:21 -08:00
Roman Gershman
d88b2422de
chore: eliminate most of clang++ warnings (#2288)
Not all of them but 90% is done.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-11 12:47:53 +02:00
Shahar Mike
efeae543a1
fix(unittest): Init with dbfilename= before attempting to save (#2127)
This is a pretty recent regression.
2023-11-06 08:53:28 +02:00
Uku Loskit
6a75c6ddc5
feat: Implement slowlog (#1956)
Implement slowlog

Signed-off-by: Uku Loskit <ukuloskit@gmail.com>
2023-10-13 23:39:35 +03:00
Kostas Kyrimis
945d3a39e4
chore(Http): change authed username to default and skip auth on metrics (#1950)
* Update Http auth with username default instead of user
* skip auth for /metrics page
* add/improve tests
* fix a bug with admin port requiring auth on http even if nopass was set
* update helio ref
* update listener class to contain its respective Role
* fix http init to only include admin and main listener
2023-10-03 10:45:37 +03:00
Roman Gershman
c612a2be67
chore: Introduce basic deadlock detector for tests (#1896)
Also, fix IOUring dependency issue in tests on non-linux platforms.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-20 14:13:22 +03:00
Kostas Kyrimis
bbd4c6b636
feat(AclFamily): add acl commands (#1844) 2023-09-15 14:28:36 +03:00
adiholden
6aaa0ee072
feat(server): support multi eval in lock ahead mode (#1662)
* feat(server): support multi eval in lock ahead mode

1. remove validation to allow multi eval only in global script mode
2. send error if there is a mode conflict when running eval inside multi
3. reset uniqe_keys_ when transaction finishes
2023-08-27 09:13:22 +03:00
adiholden
f9a3e2811c
test(server): test transaction locked keys (#1669)
* test(server): test transaction locked keys

1. add test utility class that will add suspension to transaction
   execution.
2. add test for locked keys in transaction

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-08-09 12:52:13 +00:00
Shahar Mike
67a4c4e6cb
feat(server): Add --lock_on_hashtags mode. (#1611)
* feat(server): Add `--lock_on_hashtags` mode.

This new mode effectively locks hashtags (i.e. strings within {curly
braces}) instead of the full keys being used.
This can allow scripts to access undeclared keys if they all use a
common hashtag, like for the case of BullMQ.

To make sure this mode is tested, I added a way to specify flags via env
variables, and modified `ci.yml` to run all tests using this mode as well.
While at it, I also added `--cluster_mode=emulated` mode to CI.
2023-08-03 20:13:36 +03:00
Chaka
bc717a037d
feat(cluster): Implement CLUSTER SHARDS. (#1284)
Implementation includes support for both emulated mode and real cluster
mode.

Fixes #1276.
2023-05-24 15:53:19 +03:00
adiholden
f746dc4f9f
feat(cluster): dflycluster commands only under admin port (#1281)
* feat(cluster): dflycluster commands only under admin port

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-05-24 13:22:16 +03:00
Vladislav
19732fcd0c
fix: fix dispatch ordering (#1254)
Now `SUBSCRIBE` will respond synchronously.  The change is here so we:

1. Maintain the order in pipelined requests
2. Don't have a "race condition": subscribe needs to update channel store pointers on all threads. While it awaits for all threads to complete the callback, some of them might have done it earlier, so they can already start sending messages before the initial ack is sent

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-05-23 23:55:00 +03:00
Chaka
5df0d92c44
Enable unlock for all tests. (#1185) 2023-05-06 20:38:12 +03:00
Chaka
a2f68d1b3b
feat(server): Implement PFMERGE (#1180)
* feat(server): Implement PFMERGE.

* Disable lock check on failing tests.
2023-05-04 15:12:48 +03:00
Vladislav
71147c20a9
Dispatch queue memory optimizations (#1103)
Dispatch queue entry optimizations
2023-04-22 09:02:07 +03:00
Vladislav
c65073eca9
Refactor connection (#1098)
Refactors dragonfly connection class
2023-04-17 21:02:48 +03:00
Roman Gershman
c271e13176
chore: import fiber related primitives under dfly namespace (#1012)
This change removes most mentions of boost::fibers or util::fibers_ext.
Instead it introduces "core/fibers.h" file that incorporates most of
the primitives under dfly namespace. This is done in preparation to
switching from Boost.Fibers to helio native fibers.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-30 13:26:59 +03:00
Roman Gershman
12abe0bc12
chore: update helio dependency (#984)
Also remove direct references for boost fibers from the code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-24 18:04:05 +03:00
Roman Gershman
2ec3d48534 fix: data race during Publish in PubSub
The issue happens when SendMsgVecAsync is called with PubMessage that has
string_view objects referencing objects in stack. We replace string_view
with either string or shared_ptr<string>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-03-12 08:15:31 +02:00
Roman Gershman
5e5d211b03
fix(test): reduce flakiness of tiered_storage_test (#684)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-01-16 09:42:56 +02:00
Roman Gershman
63b83c5b99
chore: Add tiered_storage_test. (#613)
1. Support tiered deletion.
2. Add notion of tiered entity in "DEBUG OBJECT" output.

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

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-28 10:37:55 +02:00
Boaz Sade
6ec4cf078c
feat(server): memory defrag support - unit tests added to verify #448 (#523)
feat(server): active memory defrag task #448

Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
2022-12-04 16:00:12 +02:00
Boaz Sade
5e64ed1fe3
feat(server): simplify handling of the pub message handling (#465)
feat(server): sending message to subscriber using shared ptr to simplify code

Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
2022-11-08 15:04:31 +02:00
Roman Gershman
0925829afb feat(server): Introduce transaction clock.
Partially implements #6.
Before, each shard lazily updated its clock used for the expiry evaluation.
Now, the clock value is set during the transaction scheduling phase and is assigned
to each transaction. From now on DbSlice methods use this value when checking whether
the entry is expired via passed DbContext argument.

Also, implemented transactionally consistent TIME command and
verify that time is the same during the transaction. See
https://ably.com/blog/redis-keys-do-not-expire-atomically for motivation.

Still have not implemented any lamport style updates for background processes
(not sure if it's the right way to proceed).
2022-09-25 23:53:08 +03:00
Roman Gershman
de9369f518
chore(server): update license text (#312) 2022-09-19 09:01:10 +03:00
Vladislav
16b6b11cf2
feat(server): Implement MOVE command (#298)
* feat(server): Implement MOVE command

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Co-authored-by: Vladislav Oleshko <vlad@dragonflydb.io>
2022-09-18 20:57:12 +03:00
Roman Gershman
c8fe7ba28b fix(server): Fix serialization logic when returning an empty array.
1. Fix SendStringArr logic. Consolidate both string_view and string variants to using the same code.
2. Tighten the test framework so that it will test that the parser consumed the whole response.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-06-28 19:51:25 +03:00
Ryan Russell
4a8644559a
Fix Various Naming Conventions around Subscriber (#87)
* Fix `SubscribeMap`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* Fix `subscriber_arr`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* Fix `CopySubscribers`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* Fix `SubscriberMessagesLen`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* Fix remaining `subscribe` variants

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* Add Ryan Russell to Contributors

Signed-off-by: Ryan Russell <git@ryanrussell.org>
2022-06-04 05:07:13 +03:00
Roman Gershman
ec9754150f Implement PSUBSCRIBE/PUNSUBSCRIBE commands.
Add minimal tests.
2022-06-02 22:45:56 +03:00
Roman Gershman
9eb13b5163 Cover more type families with OOM checks 2022-05-19 12:00:47 +03:00
Roman Gershman
797c8121b1 Limit table growth according to maxmemory.
1. Make EngineShardSet to be a process singleton instead of a variable passed everywhere.
2. Implement a heuristic of updating free memory per shard.
3. Make sure that SET command returns OOM when a database reaches its limits.
2022-05-16 08:19:32 +03:00
Roman Gershman
ec64f4e9e1 Simplify testing framework. Run(...) now returns RespExpr instead of vector of RespExpr 2022-04-22 10:31:51 +03:00
Roman Gershman
6e5de7ac59 Passover cleanups.
1. Add ttl with reload test.
2. Removed several LOG(FATAL) messages and replaced them with error propagation.
3. Added scan test for all the options.
2022-04-13 11:52:59 +03:00
Roman Gershman
997d2dcb69 more work on rdb load.
1. Added support of loading of compressed strings.
2. Verified we load expiry info.
3. Extended supported expiry period to 4 years (previously I set 1 year).
2022-04-13 10:50:19 +03:00
Roman Gershman
cceb0d90ca Implement PEXPIREAT and tune expire dictionary 2022-03-12 21:51:35 +02:00
Roman Gershman
92475dd47a Unify mimalloc memory management 2022-03-10 19:29:41 +02:00
Roman Gershman
3f0fcbf99f Factor out client connections module into a separate library called facade 2022-03-03 01:59:29 +02:00
Roman Gershman
b8521828e3 Add Dockerfile for prod container. Reorganize source tree to be docker-build friendly. 2022-02-25 10:03:42 +02:00
Renamed from server/test_utils.h (Browse further)