Commit graph

73 commits

Author SHA1 Message Date
Roman Gershman
f428dc31be
fix: support loading of 7.x streams correctly (#4281)
Now rdb_load supports RDB_TYPE_STREAM_LISTPACKS, RDB_TYPE_STREAM_LISTPACKS_2 and RDB_TYPE_STREAM_LISTPACKS_3 formats.
rdb_save still saves with RDB_TYPE_STREAM_LISTPACKS format - we want to release the DF version that can load everything first, and
then update the replicaion format in the next versions.

Also, update rdb_test.cc

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-12-10 09:57:36 +02:00
Borys
935ae86c94
fix: RdbTest.LoadStream3 incorrect file usage (#4242)
fix: RdbTest.LoadStream3 used incorrect file
2024-12-02 17:58:18 +02:00
Borys
3327e1a908
feat: add ability reading stream_listpacks_2/3 rdb types (#4192)
* feat: add ability reading stream_listpacks_2/3 rdb types

* refactor: address comments
2024-11-26 16:43:30 +02:00
Roman Gershman
0e7ae34fe4
fix: enforce load limits when loading snapshot (#4136)
* fix: enforce load limits when loading snapshot

Prevent loading snapshots with used memory higher than max memory limit.

1. Store the used memory metadata only inside the summary file
2. Load the summary file before loading anything else, and if the used-memory is higher,
   abort the load.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-20 06:12:47 +02:00
Kostas Kyrimis
129ff0b0f7
chore: run memory decommit after snapshot load/save (#3828)
Sometimes for large values during snapshot loading/saving we allocate a lot of extra memory. For that, we might need to manually run memory decommit for mimalloc to release memory pages back to the OS. This PR addresses that by manually running memory decommit after each shard finishes loading or saving a snapshot.

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-06 08:19:24 +03:00
Andy Dunstall
4dbed3f8dd
feat(rdb_load): add support for loading huge streams (#3855)
* chore: remove RdbLoad Ltrace::arr nested vector

* feat(rdb_load): add support for loading huge streams
2024-10-05 07:19:03 +03:00
Andy Dunstall
a066579930
feat(rdb_load): add support for loading huge lists (#3850)
* feat(rdb_load): add support for loading huge lists

* feat(rdb_load): add EnsureObjEncoding
2024-10-02 15:24:39 +03:00
Andy Dunstall
e3214cb603
feat(rdb_load): add support for loading huge hmaps and zsets (#3823)
* feat(rdb_load): add support for loading huge hmaps

* feat(rdb_load): add support for loading huge zsets

* feat(rdb_load): log DFATAL when append fails
2024-10-01 09:52:52 +03:00
Andy Dunstall
520dea06bf
feat(rdb_load): add support for loading huge sets (#3807)
* feat(rdb_load): add support for loading huge sets
2024-09-29 10:25:30 +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
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
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
954780edd1
Remove check-fail in ExpireIfNeeded and introduce DFLY LOAD (#2699)
* chore: prevent crashing upon inconsistent expiry table

Also, introduce "DFLY LOAD <filename>" command in addition to "DEBUG LOAD"
as an official command to load snapshots into the running server.


---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-03-12 16:54:13 +02:00
adiholden
15b3fb13b6
fix(server): saving is not a server state (#2613)
* fix(server): saving is not a server state

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-02-19 15:20:48 +00:00
Kostas Kyrimis
795d00021d
fix: asan errors on unit tests (#2564)
* fix: asan errors on unit tests
2024-02-10 19:48:00 +02:00
Borys
7b61268533
feat(info): add new persistence section fields (#2396)
* feat(info): add new persistence section fields
implement #2386
added fields:
1) last_failed_save
2) last_error
3) last_failed_save_duration_sec
4) saving
5) current_save_duration_sec
2024-01-11 12:36:43 +02:00
Shahar Mike
d9886024d3
refactor(rdb): Expose default compression mode without direct flag (#2360)
* refactor(rdb): Expose default compression mode without direct flag

* fixes
2024-01-02 13:48:50 +00: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
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
Vladislav
e84d9a65d8
fix(server): Add additional metrics (#1975)
* fix(server): Clean up metrics collection
* feat(server): Replication memory metrics
* fix(server): Limit dispatch queue size

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-10-06 14:16:22 +03:00
Yue Li
a2457e3410
feat(streams): support entries_read and lag for XINFO GROUPS (#1952)
entries_read and lag have been added to the output of XINFO GROUPS since Redis 7.0. This patch supports both for Dragonfly. This patch also fixes a bug that incorrectly sets the initial value of entries_read when a consumer group is created.

fixes #1948
2023-09-28 01:35:19 -07: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
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
Abhradeep Chakraborty
c72aa6f5f2
fix(xinfo): send integer info in correct type (#1379)
Signed-off-by: Abhradeep Chakraborty <abhradeep@dragonflydb.io>
2023-06-09 20:11:23 +03:00
adiholden
891155c927
bug(server): fix debug populate keys (#1370)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-06-08 15:16:28 +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
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
Chaka
fa39c1890d
feat(server): Add support for PFADD and PFCOUNT (#1152)
* feat(server): Add support for PFADD and PFCOUNT

This version does not create sparse-encoded HLLs, however it is fully compatible with such ones created by Redis as it converts them to the dense encoding.

Note that PFMERGE is not yet implemented.

* Set small string optimization to be 2^13 instead of 2^15.

This will allow dense-encoded HLL to *not* fit within the small string,
which will make it contiguous in memory, thus GetSlice() will not
allocate.

---------

Signed-off-by: chakaz <chakaz@chakaz>
Co-authored-by: chakaz <chakaz@chakaz>
2023-04-30 00:50:11 +03:00
Roy Jacobson
246f6093db
feat(server): Save on shutdown (#1086)
* feat(server): Save snapshot on shutdown

* CR

* Change save on shutdown to be conditional on --dbfilename.

* Support SHUTDOWN [NO]SAVE and fix unit test

* Better wait for DB loading

* Fix DF format loading state bug

* Fix some fallout from auto save
2023-04-20 06:30:42 +02:00
adi_holden
dd03ce0cf0 -sfix(rdb_load): replica load expired keys 2023-03-15 13:12:39 +02:00
Vladislav
7b7e3ea9d4
test(rdb): Add json dump & restore test (#678) 2023-01-15 12:00:47 +03: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
Vladislav
2386b02234
feat(server): Use new journal format (#563) 2022-12-20 16:38:19 +03:00
Roman Gershman
23c902d8e9
chore: Update helio dependency (#553)
Switch to using fibers_ext::Fiber.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-09 16:43:41 +02:00
adiholden
ae9e3c45d9
Support lz4 compression (#545)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2022-12-08 09:41:55 +02:00
adiholden
c7974a4e80
bug(rdb loader): When reading from zstd uncompressed buf skip ensure … (#525)
* bug(rdb loader): When reading from zstd uncompressed buf skip ensure read flow

Signed-off-by: adi_holden <adi@dragonflydb.io>
2022-12-04 11:14:24 +02:00
adiholden
cf2ba8eb84
feat(rdb save): add unit test to save df with all compression levels (#517)
feat(rdb save): add unit test to save df with all comression levels

Signed-off-by: adi_holden <adi@dragonflydb.io>
2022-11-29 15:14:43 +02:00
Roman Gershman
cf779c08a4
chore(server): reduce iouring exposure across the codebase (#342)
Refactor RdbSnapshot and consolidate iouring linux file handling in a single place.
2022-10-02 22:53:52 +03:00
Roman Gershman
de9369f518
chore(server): update license text (#312) 2022-09-19 09:01:10 +03:00
Roman Gershman
7ed808d5d0 fix(rdb): Fix RDB load bug when loading hset 2022-09-18 13:15:39 +03:00
Braydn
7cc761134b
fix(server): Added RDB load / save for DenseSet (#297)
Signed-off-by: Braydn <braydn.moore@uwaterloo.ca>
2022-09-14 20:09:32 +03:00
Braydn
b8d791961e
feat(core): Added DenseSet and StringSet types (#268)
* feat(core): Added DenseSet & StringSet types with docs

- Improved documentation by adding labels to chain types & pointer tagging table
- Added potential improvements to the DenseSet types in the docs
- Added excalidraw save file for future editing
- Removed ambiguous overloading types
- Renamed iterators to be more clear


* feat(core): Cleaned up DenseSet and Docs
* feat(core): Made DenseSet more ergonomic
* feat(server): Integration of DenseSet into Server

- Integrated DenseSet with CompactObj and the Set Family commands

Signed-off-by: Braydn <braydn.moore@uwaterloo.ca>
2022-09-14 08:41:54 +03:00
Roman Gershman
55389d9be5
chore(rdb): move object creation during loading to shard threads. (#188)
Related to #159. Before this change, rdb loading thread has been creating all the redis objects as well.
Now we separate rdb file parsing and objects creation. File parsing phase produces a load trace of one or more binary blobs.
Those blobs are then passed to the threads that are responsible to manage the objects.
The second phase is object creation based on the trace that was passed. Finally those binary blobs are destroyed.
As a result, each thread creates objects using the memory allocator it owns and memory stats become consistent.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-07-04 19:08:13 +03:00
Roman Gershman
da3ae760d5 feat(stream): implement rdb save support for streams
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-06-18 20:08:09 +03:00
Roman Gershman
d1d64eb014 feat(streams): implement rdb load for streams
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-06-17 10:27:46 +03:00
Roman Gershman
d3f598eb88 More printings in rdb_test in order to catch the snapshotting bug 2022-06-02 12:32:10 +03:00