Commit graph

137 commits

Author SHA1 Message Date
Boaz Sade
3efc5642bc
feat(server): adding matrices for memory defrag (#535)
feat(server): adding marices for memory defrag

Signed-off-by: Boaz Sade <boaz@dragonflydb.io>

Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
2022-12-06 10:18:23 +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
26b03145f9 feat(server): acrtive memory defrag high level flow
Signed-off-by: Boaz Sade <boaz@dragonflydb.io>
2022-11-30 14:27:59 +02:00
Roman Gershman
e43032842e
chore: tiered_storage - cleanups and refactorings. (#515)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-11-26 19:49:18 +02:00
Roman Gershman
2b87088121
fix(list): Fixes blpop failure. (#462)
The bug was that if two push operations where queued together in the tx queue,
and the first push awakes pending blpop, then the PollExecution function would continue with the
second push before switching to blpop, which contradicts the spec.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-11-05 14:43:11 +02:00
Roman Gershman
881e8a1b0c
chore(server): Add more logging in case of check fail 2022-10-04 07:20:45 +03: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
Roman Gershman
4e4ed63467
feat(server): tighten memory checks when inseting a new object. (#258)
Before this change Dragonfly evicted items only when it was low on memory and had to grow its main dictionary.
It is not enough because in many cases Dragonfly can grow in memory even when the main dictionary does not grow.
For example, when its dictionary is less than 90% utilized, but the newly added objects require lots of memory.

In addition, the dashtable adds additional segments, when other segments have enough available slots to fill the rest of the free memory.

This change adds another layer of defense that allows evicting items even when dictionary segments are not full.
The eviction is still local with respect to a segment. On my tests it seems that it's much harder to cross maxmemory limit than before.

In addition, we tightened the heuristic that allowes the dashtable to grow. Now it takes into account the average bytes per item
in order to project how much memory the full table takes before adding to it new segments.
This really improves dashtable utilization.

There are still things to improve:
1. the eviction behavior is rough. Once an insert does the eviction it tries to free enough objects to bring memory back.
   This may result in very spiky insertion/eviction patterns.
2. The eviction procedure, even though it's limited to a single segment, is quite heavy because it goes over all buckets
   in the segment. This may result in weird artifacts where we evict just enough to be under the limit, then add and evict
   again and so on.
3. Therefore, we may need a periodic eviction that will compliment this emergency eviction step.

Fixes #224 and partially addresses #256

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-08-26 15:00:08 +03:00
Roman Gershman
3bbdb8e4b1
feat(journal): Introduce basic journal support. (#211)
1. No entries data is written into a journal yet.
2. Introduced a state machine to start and stop journal using a new auxillary command "dfly".
3. string_family currently calls an universal command Journal::RecordEntry that should
   save the current key/value of that entry. Please note that we won't use it for all the operations
   because for some it's more efficient to record the action itself than the final value.
4. no locking information is recorded yet so atomicity of multi-key operations is not preserved for now.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-07-17 21:12:50 +03:00
Roman Gershman
05eb323a0d
fix(server): Fix #207 (#208)
1. Erase expiry data from the expire table in case of evictions.
2. Add test that covers the bug.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-07-15 15:14:20 +03:00
Roman Gershman
4ec2538204
fix(transaction): Fix rare deadlock case - fixes #150. (#155)
In rare cases a scheduled transaction is not scheduled correctly and we need
to remove it from the tx-queue in order to re-schedule. When we pull it from tx-queue
and it has been located at the head, we must poll-execute the next txs in the queue.

1. Fix the bug.
2. Improve verbosity loggings to make it easier to follow up on tx flow in release mode.
3. Introduce /txz handler that shows currently pending transactions in the queue.
4. Fix a typo in xdel() function.
5. Add a py-script that reproduces the bug.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-06-15 16:53:27 +03:00
Roman Gershman
d5f2c23922
Fixes #66. (#70)
* Fixes #66.

1. Introduce `hz` flag to control the frequency of periodically running tasks.
2. Update helio dependency.

* Fix CI caching for PRs.
2022-06-01 13:19:41 +03:00
Roman Gershman
bb7b205bff Switch to using absl flags 2022-05-30 06:45:09 +03:00
Roman Gershman
114e8bec5d Fixes #41.
1. Found dangling transaction pointers that where left in the watch queue. Fix the state machine there.
2. Improved transaction code a bit, merged duplicated code into RunInShard function, got rid of RunNoop.
3. Improved BPopper::Run flow.
4. Added 'DEBUG WATCH' command. Also 'DEBUG OBJECT' now returns shard id and the lock status of the object.
2022-05-27 12:20:01 +03:00
Roman Gershman
c7d1893478 Add more documentation about dashtable. Tune expiry heuristics a bit 2022-05-21 20:35:19 +03:00
Roman Gershman
439070d00d Few improvements.
1. Stabilized naming scheme for snapshot files.
   The behavior is determined by dbfilename flag.
   By default it's 'dump'. Dragonfly checks if the flag has an extension
   if not, it automatically saves timestamped files (dump*.rdb) and loads the latest file that is available.
   In case the flag has extension like 'dump.rdb' it fallbacks to redis behavior of loading and saving to the
   same file.

2. Updated the logo url.
2022-05-19 15:50:42 +03:00
Roman Gershman
5e4aa0a1a8 Handle OOM errors for more types. Fix clang warnings and errors 2022-05-18 21:53:49 +03:00
Roman Gershman
cfaf173236 Allow cache mode - intelligent eviction of less likely to be used items.
This id one by shifting right slots in a stash bucket of the full segment.
In addition, I added eviction related stats to memory and stats section.
I also updated README with the changes. Finally, I added a flag that allows
to disable http-admin console in dragonfly.
2022-05-16 19:39:17 +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
038868802f Add caching mode to dragonfly - part 1.
The heart of this feature is ability to bump up entries that has been searched for.
When we bump up an entry withing a dash-table it's moved out of stash buckets or to lower slot ids
within normal buckets. The entry they replace is moved to the place of bumped-up entries.
The next change will be to implement the actual eviction heuristic that will evict keys from the stash buckets.
This will give stash buckets an addition responsibility for caching mode - they will serve as a probation buffer
that holds low-priority or newly added items.
2022-05-15 21:03:56 +03:00
Roman Gershman
1f953a4ca8 Delete expired items in the background. 2022-05-12 15:52:58 +03:00
Roman Gershman
afd52d5571 Clean-ups in transaction code. 2022-04-29 15:50:20 +03:00
Roman Gershman
72e90bb729 More work on blocking commands like BLPOP.
Fixes #1 and fixes #24.
2022-04-27 10:42:35 +03:00
Roman Gershman
b74c5398a4 Add very initial code for tiered storage for strings 2022-04-19 08:31:23 +03:00
Roman Gershman
e5a3a83bae Organize code and make the write asynchronous 2022-04-14 21:31:31 +03:00
Roman Gershman
ad3bdbf499 Optional feature (POC) - store values on the external storage (SSD).
1. Add ExternalAllocator that provides files ranges to write to.
2. Add IoMgr that wraps files and allows sending asynchronous requests.
3. Add POC that writes string values when a new entry is added.
   The original values kept are still kept in memory.
2022-04-13 22:11:25 +03:00
Roman Gershman
abbefd0bc4 More bug fixes.
1. RENAME now unblocks blpop/brpop.
2. Fix a deadlock bug with blpop running with the same key multiple times.
2022-04-06 10:32:42 +03:00
Roman Gershman
1fc9f11e76 Bug fixes.
1. Fix crash when calling BLPOP on the same key several times.
2. Extend RENAME functionality to cover all data-types.
   Before that it worked only for strings and that also was incorrect.
2022-04-05 23:20:05 +03:00
Roman Gershman
c6e4e97865 List fixes.
1. Fix blocked_clients statistic.
2. Add HELLO decorator.
3. Non-list keys should not wake blpop/brpop commands.
4. Fix Info output whitespacing.
2022-04-05 18:45:58 +03:00
Roman Gershman
affabbaee7 Implement ongoing garbage collection of expired items 2022-03-14 02:16:51 +02:00
Roman Gershman
cceb0d90ca Implement PEXPIREAT and tune expire dictionary 2022-03-12 21:51:35 +02:00
Roman Gershman
770fe0fe47 Memory accounting
Bring back application level used-memory tracking.
Use internal mimalloc api for extracting comitted memory stats.
This is much better performance-wise because calling mi_heap_visit_blocks
becomes very slow for larger database sizes.
2022-03-11 01:25:01 +02:00
Roman Gershman
92475dd47a Unify mimalloc memory management 2022-03-10 19:29:41 +02:00
Roman Gershman
28a2db1044 Implement hset method 2022-03-02 19:06:49 +02:00
Roman Gershman
f255d17a72 Add decorators for commands like ROLE,BGSAVE,UNLINK. Improve memory usage tracking 2022-02-28 17:36:45 +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/engine_shard_set.cc (Browse further)