Commit graph

99 commits

Author SHA1 Message Date
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
Shahar Mike
4fdb1a5c63
chore: On invalid TTL, print the TTL first (#3306)
Before this change we first printed the value, which could be long
resulting in the TTL not appearing in the log due to max line length

If the TTL is invalid, we should print it first to see what value it has
2024-07-11 09:53:01 +03:00
Vladislav
2bf4451ec7
fix(tiering): Throttle snapshot load (#3249) 2024-07-04 17:10:23 +03:00
Roman Gershman
6498f88619
chore: a small cleanup (#3140)
* chore: a small cleanup

No functional changes.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-06-06 15:16:52 +03:00
Roman Gershman
5bf7e3b146
chore: update helio together with new mimalloc version (#3040)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-05-13 12:48:05 +03:00
Vladislav
5979fd1cb9
chore(tiering): Move files and move kb literal to common (#2868)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-04-11 16:37:29 +03:00
Roman Gershman
57d567639c
chore: serialize SBF (#2846)
* chore: serialize SBF

SAVE/LOAD supports SBF now. Also fixes MallocUsed for SBF.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-09 09:57:24 +03:00
Shahar Mike
e2b5d48837
feat(json): Deserialize ReJSON format (#2725)
* feat(json): Deserialize ReJSON format

This PR adds support for Redis-based JSON RDB format deserialization.
Since Redis uses ReJSON as a module, serialization is slightly different
from other types, but overall it's not a big change once we know where
all bits should be.

While this change knows how to _read_ Redis-based JSON keys, it does not
_save_ them in Redis format. That will be in a different PR.

This PR also ignores unknown (non-keys) module data instead of failing the load.

Fixes #2718

* Cleanup

* Add tests

* Skip unsupported modules

* Small refactor
2024-03-14 17:23:31 +02:00
Roman Gershman
d709f2a911
chore: improve compatibility of EXPIRE functions with Redis (#2696)
* chore: improve compatibility of EXPIRE functions with Redis

Also, provide a module name if stumbled upon module data that can not be loaded
by dragonfly.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-03-12 13:50:08 +02:00
Vladislav
a3dc9382bb
chore: Pull helio with new BlockingCounter (#2711)
Pull helio with new BlockingCounter and fix all usages to use -> operator

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-03-11 08:03:18 +00:00
Kostas Kyrimis
58dda3bc4b
fix(rdb_load): EnsureRead(min) requesting more bytes than min (#2604)
* fixes EnsureRead(min) to request exactly min bytes
2024-02-19 14:41:25 +02:00
Roman Gershman
fa75360227
chore: get rid of object.c and robj* in cc code (#2610)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-18 16:52:23 +02:00
Roman Gershman
d802a2181a
chore: consolidate json code under core/json (#2609)
Fix linker dependencies - now dfly_core depends on jsonpath.
jsonpath does not depend on CompactObject anymore.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-18 09:22:34 +00:00
Roman Gershman
1ba59e9179
chore: remove ImportRObj routine and reduce reliance on object.c (#2607)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-18 10:07:00 +02:00
Roman Gershman
6aafe3dc5e
chore: cleanup of redis implementation of sets/hashmaps (#2605)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-17 18:35:28 +02:00
Roman Gershman
336d6ff181
Update helio (#2538)
chore: UpdateHelio dependency

Add support for asan/ubsan checkers in our dev environment.
Remove more clang warnings.

Once we fix all the problems we will enable them in our CI as well.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-06 11:57:26 +02:00
Roman Gershman
ea5955962e
chore: switch json object to pmr allocator (#2483)
* chore: switch json object to pmr allocator

1. Move json object creation code to the shard-thread inside rdb_load
2. Now json_family never references "json" type, always dfly::JsonType
3. Switch JsonType to pmr::json.
4. Make sure we pass the correct memory_resource when creating json object from string.

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

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-01-26 12:47:46 +02:00
Kostas Kyrimis
517be2005e
refactor: return OpResult in DbSlice::AddOrFind instead of throwing std::bad_alloc (#2427)
* return OpResult in AddOrFind instead of throwing bad_alloc
* small refactor
2024-01-23 14:16:03 +02:00
Vladislav
1fb3c74933
fix(rdb): Remove transaction from pre/post load search index rebuild (#2419) 2024-01-16 10:08:16 +03:00
Roman Gershman
b3e0722d01
chore: fix our release pipeline (#2408)
* chore: fix our release pipeline

Also remove alpine prod.wip file that has not been used and unlikely will be for prod.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-01-14 17:31:59 +02:00
Shahar Mike
34986fc52e
feat(server): Account for RObj concrete objects (#2324)
* feat(server): Account for RObj concrete objects

* proper `delete`
2023-12-22 09:20:41 +02:00
Shahar Mike
dcedd1645e
feat(server): Convert DbSlice's AddOr* to return AutoUpdater (#2290)
* fix(server): Use AutoUpdater with AddOr* methods

* Remove explicit calls

* `operator=`

* return *this

* PostUpdate twice

* exp it

* bitops

* remove explicit `Run()`

* Explicitly `delete` copy ops

* Remove `AddOrSkip()`
2023-12-17 15:00:10 +02:00
Shahar Mike
d15bcf8392
fix(server): Save element expirations for hash sets & sets (#2223)
* fix(server): Save element expirations for hash sets

* Add support for sets

* Fixes

* Fixes
2023-11-30 14:08:04 +02:00
Borys
1ec1b997a0
feat: add support for sticky keys in rdb #251 (#2166)
* feat: add support for sticky keys in rdb
2023-11-14 14:02:14 +02:00
Vladislav
46292968ad
fix(search): Fix replication (#2159)
* fix(search): Support replication

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-11-13 11:58:54 +03:00
Roman Gershman
47d92fb010
fix: Correctly grow dense_set in the Reserve call (#2087)
Fixes #2066

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-29 08:39:33 +02:00
Kostas Kyrimis
cbba6f4e11
fix(acl/admin_port): skip acl validation on admin port (#1997)
* skip all acl related functionality on admin port
2023-10-10 08:28:07 +03:00
Roman Gershman
4be9551806
chore: adjust verbosity level 1 not be over-verbose in prod (#1974)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-01 14:31:39 +03:00
Roy Jacobson
d50b492e1f
feat(replication): First iteration on partial sync. (#1836)
First iteration on partial sync.
2023-09-26 10:35:50 +03:00
Roman Gershman
8d1474aeac
fix: improve performance of listpack sorted sets (#1885)
1. Cherry-pick changes from Redis 7 that encode integer scores more efficiently
2. Introduces optimization that first checks if the new element should be the last
   for listpack sorted sets.
3. Consolidates listpack related constants and tightens usage for listpack.
4. Introduce MEMORY USAGE command.
5. Introduce a small delay before decommitting memory pages back to OS.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-19 19:52:34 +03:00
Roy Jacobson
db21b735f6
feat(replication): Use a ring buffer with messages to serve replication. (#1835)
* feat(replication): Use a ring buffer with messages to serve replication.

* Fix libraries dep graph

* Address PR feedback

* nits

* add a comment

* Lower the default log length
2023-09-18 13:59:41 +03:00
Roman Gershman
36be222091
chore: add macos daily build (#1795)
It compiles most of the code though some linking problems still exist.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-06 09:35:11 +03:00
adiholden
ac3b8b2b74
fix(server): Dont apply memory limit when loading/replicating (#1760)
* fix(server): Dont apply memory limit when loading/replicating

When loading a snapshot created by the same server configuration (memory and
number of shards) we will create a different dash table segment directory tree, because the
tree shape is related to the order of entries insertion. Therefore when loading data from
snapshot or from replication the conservative memory checks might fail as the new tree might
have more segments. Because we dont want to fail loading a snapshot from the same server
configuration we disable this checks on loading and replication.

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-09-03 11:24:52 +03:00
adiholden
901d3fff58
fix(server): rdb loader catch bad alloc (#1748)
While loading rdb snapshot, if oom is reached a bad alloc exception is thrown. Now we
catch it and write warning to log and fali loader.

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-08-27 13:48:41 +03:00
Vladislav
84871b8dce
feat: search index persistence (#1721)
* feat: WIP search index persistence

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

* Update src/server/search/doc_index.cc

Co-authored-by: Kostas Kyrimis  <kostaskyrim@gmail.com>
Signed-off-by: Vladislav <vladislav.oleshko@gmail.com>

* fix: foxes

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Signed-off-by: Vladislav <vladislav.oleshko@gmail.com>
Co-authored-by: Kostas Kyrimis <kostaskyrim@gmail.com>
2023-08-24 13:41:10 +03:00
Roman Gershman
ec22e73a28
chore: several improvements around sorted map (#1699)
* chore: several improvements around sorted map

1. Pass memory_resource to sorted_map.
2. Get rid of GetDict leaky accessor in SortedMap and introduce a proper
   Scan method.
3. Introduce correct BPTree type inside SortedMap::DFImpl.
4. Added a test for bptree_test that covers sds comparison
   (apparently, sdscmp can return values outside of [-1, 1] range).
   Fixed bptree code to support a proper spec for three-way comparison.
5. Expose pointers to internal objects allocated by score_map so we could insert them
   into bptree.

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

* chore: fix comments

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

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-15 18:08:59 +03:00
Kostas Kyrimis
df771f9138
fix(rdb_load): load listpack encoded zset (#1646) 2023-08-07 09:13:15 +00:00
Kostas Kyrimis
82965279a2
chore(rdb): support rdb version 11 (#1579)
* Bump up RDB_VERSION to 11
* Update RDB_JSON value to 30
* Fix HT being serialized to the wrong type
* Serialize HT as LIST_PACK
* Add support for deserializing SET_LISTPACK
2023-07-29 18:15:13 +03:00
Roy Jacobson
3b6b0f5436
fix(rdb): Fix loading of small integers and remove code duplication (#1571)
* fix(rdb): Fix loading of small integers and remove code duplication

* Add a test
2023-07-19 14:21:14 +02:00
Roman Gershman
e5be30cc79
chore: introduce sorted_map (#1558)
Consolidate skiplist based zset functionality into a dedicated class
called SortedMap. The code is adapted from t_zset.c
The old code in t_zset.c is deleted.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-18 09:56:45 +03:00
Roman Gershman
2c04311cc3
chore: Remove robj reference from zset_family (#1554)
This is pure refactoring PR that does not change any functionality besides
prohibiting using AsRobj/SyncRobj functions for compact objects of type
OBJ_ZSET. This is needed in case we decide in the future to implement our own
zset type.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-17 09:34:12 +03:00
Chaka
5234f77727
fix(replication): Restart replication upon receiving FLUSHALL during full sync (#1347)
Fixes #1231
2023-06-06 12:26:47 +03:00
Roman Gershman
e2cc44162c fix: fix crash when inserting to listpack an empty value. (#1324)
fix: fix crash when inserting to listpack empty value.

We can not pass null pointers to listpack.
Fixes #1305 and probably fixes #1290

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-06-01 15:13:18 +03:00
Roy Jacobson
cbb2afc792
feat: Use journal LSNs for absolute replication offsets (#1242)
* feat: Use journal LSNs for absolute replication offsets

* 1 - Address small CR comments
2 - Simplify the offset accounting so that we send the correct offset
    in `SliceSnapshot::Stop` instead of counting in RdbLoader. This
    allows us to revert the changes to slice journaling of EXEC
    commands, for example.

* Store int with absl::little_endian

* Document the offset management
2023-05-22 15:34:32 +03:00
Roy Jacobson
a1a8acb155
opt: Slightly less allocations in OpaqueObjLoader::CreateHMap (#1227)
Moves the temporary variable outside the loop so we can reuse the buffer.

Signed-off-by: Roy Jacobson <roy@dragonflydb.io>
2023-05-17 11:44:46 +03:00
Roman Gershman
fcb1c7bd55
fix: bugs in rdb code (#1079)
1. Pull newest helio that fixes 32-bit overflow in IoBuf.
2. Allow responsiveness when loading huge sets and maps.
3. Break array of blobs into segments of limited size so that
   we won't allocate billion byte arrays when handling large (h)sets.
   It reduces pressure on allocator when loading millions of items.

Fixes #1076.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Co-authored-by: Roy Jacobson <roy@dragonflydb.io>
2023-04-13 13:26:58 +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
Vladislav
9f0e269a12
feat(server): Specify script flags with shebang (#944)
* feat(server): Specify script flags with shebang

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

* fix(server): Ignore erros with no-writes flag

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-03-19 08:10:24 +02:00
chakaz
9add31e20f Get DragonDB to compile with clang.
While at it, fix some compile warnings, 2 of them are actual bugs
(missing virtual d'tor).

Signed-off-by: chakaz <chakaz@chakaz>
2023-03-18 11:02:37 +02:00
adi_holden
dd03ce0cf0 -sfix(rdb_load): replica load expired keys 2023-03-15 13:12:39 +02:00