Commit graph

196 commits

Author SHA1 Message Date
Kostas Kyrimis
e103254cf9
chore: add tx queue head debug info in AnalyzeTxQueue (#4026)
* add tx queue head debug info in AnalyzeTxQueue

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-11-04 09:41:18 +02:00
Roman Gershman
4aa0ca1ef7
chore: get rid of MutableSlice (#3952)
* chore: get rid of MutableSlice

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

* chore: comments

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-23 21:50:39 +03:00
Roman Gershman
5d2c308c99
chore: schedule chains (#3819)
Use intrusive queue that allows batching of scheduling calls instead of handling each call separately.
This optimizations improves latency and throughput by 3-5%
In addition, we expose batching statistics in info transaction block.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-11 22:41:31 +03:00
Kostas Kyrimis
c1e9d510a3
chore: lock keys for optimistic transactions (#3865)
We do not acquire any locks for transactions that are executing optimistically. However, this is problematic for callbacks that need to preempt (e.g. because a journal is active).

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-08 14:25:36 +03:00
Roman Gershman
70ad113e4b
chore: ScheduleInternal refactoring (#3794)
A small refactoring to improve the flow of ScheduleInternal() as well as
to prepare it for the next change that will reduce the CPU load from the shard queue.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-26 08:14:26 +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
Vladislav
0e4e971ad9
chore(server): Fix watch (#3557) 2024-08-24 13:32:21 +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
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
Vladislav
f73c7d0e42
fix(transaction): Properly store block cancel status (#3371) 2024-07-24 14:05:00 +03:00
Vladislav
759631e9ed
fix(transaction): Fix namespace access (#3364)
Our area of attack during concurrent transaction access is the call to DisarmInShard and DisarmInShardWhen, which only access is_armed - an atomic varible. It is not safe to arbitrarily call GetNamespace() if we write to it in InitBase

Solution: Don't write to it post first initialization
2024-07-23 11:25:04 +03:00
Vladislav
be59b5eeb4
chore: Make KeyIndex iterable (#3326) 2024-07-19 14:23:46 +03:00
Roman Gershman
b9f8671df9
chore(tiering): add protection against overruning memory budget (#3327)
chore(tiering): Introduce second chance replacement strategy

Introduce hot/cold replacement strategy https://www.geeksforgeeks.org/second-chance-or-clock-page-replacement-policy/

Also, add protection against overruning memory budget
Finally, cancel in-flight offloading requests for entries that were looked up.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-18 03:52:43 -04: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
Vladislav
22756eeb81
fix(migration): Use transactions! (#3266)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-07-16 14:06:34 +03:00
Shahar Mike
d7351b315e
refactor: Use DbContext, OpArgs and Transaction to access DbSlice (#3311)
This is a refactor that will put us closer to adding namespaces, see
included `docs/namespaces.md`
2024-07-12 08:13:16 +03:00
Roman Gershman
b61c722f84
chore: Add 'memory arena show' command (#3298)
* chore: Add 'memory arena show' command

Its output goes to stdout.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-10 07:20:17 +00:00
adiholden
ccada875e0
feat(server): master stop sending exec opcode to replica (#3289)
* feat server: master stop sending exec opcode to replica

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-07-09 14:48:31 +03:00
Borys
d75c79ce5c
fix: fix RegisterOnChange methods for journal and db_slice (#3171)
* fix: fix RegisterOnChange methods for journal and db_slice. Call db_slice and journal callbacks atomically. Made a hack to avoid deadlock during SAVE
2024-06-20 12:37:37 +03:00
Vladislav
e45c1e92a2
chore: Refactor string span management (#3165)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-06-18 10:37:32 +03:00
Vladislav
c08719117c
feat(json): MSET (#3167)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-06-13 12:33:24 +03:00
Kostas Kyrimis
7f9a13bb50
fix: lua and client tracking (#3163)
* add missing tracking_cb_ invkoe in RunSquashedMultiCb
* add test
2024-06-11 16:24:44 +03:00
Kostas Kyrimis
0edcbc80ef
chore: recommit client tracking (#3136)
* bring back client tracking
* disable all client commands in squashing
* allow all client commands in multi/exec block
2024-06-07 15:34:44 +03:00
Roman Gershman
9f09104c61
chore: get rid of kv_args and replace it with slices to full_args (#3101)
* Revert "Revert "chore: get rid of kv_args and replace it with slices to full_… (#3024)"

This reverts commit 25e6930ac3.

Fixing the performance bug caused by applying equality operator
on two spans inside ShardArgs::Iterator::operator==

---------

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-06-05 14:25:26 +03:00
adiholden
2a5a53f1d9
Revert "refactor client tracking, fix atomicity, squashing and multi/… (#3122)
Revert "refactor client tracking, fix atomicity, squashing and multi/exec (#2970)"

This reverts commit b1063f7823.
2024-06-04 10:34:32 +03:00
Kostas Kyrimis
b1063f7823
refactor client tracking, fix atomicity, squashing and multi/exec (#2970)
* add partial support for CLIENT CACHING TRUE (only to be used with TRACKING OPTIN)
* add OPTIN to CLIENT TRACKING command
* refactor client tracking to respect transactional atomicity
* fixed multi/exec and disabled squashing with client tracking
* add tests
2024-06-03 22:14:30 +03:00
adiholden
b2213b05d1
fix(replication): fullsync phase write to sync on noop (#3084)
* fix replication: fullsync phase write to sync on noop

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-05-27 17:52:07 +03:00
Roman Gershman
25e6930ac3
Revert "chore: get rid of kv_args and replace it with slices to full_… (#3024)
Revert "chore: get rid of kv_args and replace it with slices to full_args (#2942)"

This reverts commit de0e5cb0bd.
2024-05-08 03:01:37 +03:00
adiholden
dd80d06be5
fix(server): non auto journal write after callback finish (#3016)
fix server: non auto journal write after callback finish

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-05-06 17:18:51 +03:00
Roman Gershman
de0e5cb0bd
chore: get rid of kv_args and replace it with slices to full_args (#2942)
The main change is in tx_base.* where we introduce ShardArgs slice that
is only forward iterable. It allows us to go over sub-ranges of the full arguments
slice or read an index of any of its elements.

Since ShardArgs provide now indices into the original argument list we do not need to build the reverse index in transactions.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-05-06 15:53:30 +03:00
Roman Gershman
9bda5b1d4b
chore: another preparation commit to get rid of kv_args in transaction (#2996)
This changes Entry::Payload to struct instead of variant.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-05-02 09:59:45 +03:00
Roman Gershman
89b1d7d52a
chore: Introduce ShardArgs as a distinct type (#2952)
Done in preparation to make ShardArgs a smart iterable type,
but currently it's just a wrapper aroung ArgSlice.
Also refactored common.{h,cc} into tx_base.{h,cc}

In addition, fixed a bug in key tracking, where we wrongly created weak_ref
in a shard thread instead of doing this in the coordinator thread.
Finally, identified another bug (not fixed yet) where we track all the arguments
instead of tracking keys only.

Besides this, no functional changes around the moved code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-24 13:36:34 +03:00
Borys
2230397a12
refactor: add cluster namespace (#2948)
* refactor: add cluster namespace, remove extra includes
2024-04-22 21:45:43 +03:00
Roman Gershman
3d609504d0
chore: adjust transaction code to keystep/3 commands (#2941) 2024-04-21 14:20:57 +00: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
9b9c32c91d
chore: Remove Schedule() call (#2938)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-21 11:32:44 +03:00
Vladislav
64d963dbbe
fix(transaction): Use FinishHop in schedule (#2911) 2024-04-17 09:24:27 +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
Vladislav
0693846d9b
chore(blocking): Remove faulty DCHECK (#2898)
* chore(blocking): Remove faulty DCHECK

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-04-12 22:11:47 +03:00
Roman Gershman
da5c51d1dd
chore: LockTable tracks fingerprints of keys (#2839)
* chore: LockTable tracks fingerprints of keys

It's a first step that will probably simplify dependencies in many places
where we need to keep key strings for that. A second step will be to reduce the CPU load
of multi-key operations like MSET and precompute Fingerprints once.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-10 17:52:53 +03:00
adiholden
b1e688b33f
bug(server): set connection flags block/pause flag on all blocking commands (#2816)
* bug((server)): set connecttion blocking and puash flags on all blocking commands

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-04-09 09:49:33 +03:00
Vladislav
fbc55bb82d
feat(transaction): Idempotent callbacks (immediate runs) (#2453)
This commit generalizes the machanism of running transaction callbacks during scheduling, removing the need for specialized ScheduleUniqueShard/RunQuickie. Instead, transactions can be run now during ScheduleInShard - called "immediate" runs - if the transaction is concluding and either only a single shard is active or the operation can be safely repeated if scheduling failed (idempotent commands, like MGET).

Updates transaction stats to mirror the new changes more closely.

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-04-03 23:06:57 +03:00
Kostas Kyrimis
b2e2ad6e04
feat(server): check master journal lsn in replica (#2778)
Send journal lsn to replica and compare the lsn value against number of records received in replica side

Signed-off-by: kostas <kostas@dragonflydb.io>
Co-authored-by: adi_holden <adi@dragonflydb.io>
2024-04-01 17:51:31 +03:00
Vladislav
3aa4a29834
chore(transaction): Introduce RunCallback (#2760)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-03-22 16:02:02 +03:00
Vladislav
9c6e6a96b7
fix(transaction): Replace with armed sync point (#2708)
1. Replaces run_barrier as a synchronization point with is_armed + an embedded blocking counter for awaiting running jobs
2. Replaces IsArmedInShard + GetLocalMask + is_armed.exchange chain with a single DisarmInShard() / DisarmInShardWhen

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-03-14 14:40:32 +00:00
Vladislav
292c5bcd71
chore: little transaction cleanup (#2608)
Make renabled_autojournal a regular bool, simplify CancelShardCb logic

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

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-03-08 09:50:09 +03:00
adiholden
7e4527098b
fix(server): client pause work while blocking commands run (#2584)
fix #2576
fix #2661

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-02-28 11:07:03 +00:00
Vladislav
1b51e82e55
chore(transaction): Add debug stats for fail printing (#2600)
* chore(transaction): Add debug stats for per shard data

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-02-18 15:36:14 +03:00
Vladislav
4d4fed6fec
chore(transaction): Untie scheduling from multi status (#2590)
* chore(transaction): Untie scheduling from multi status

Idea: We decide whether we have to schedule not based on our multi status (atomic multi), but solely based on the fact if COORD_SCHED is set

Goal: Being able to use ScheduleSingleHop()/Schedule() for multi transactions, and thus later allow single hop multi transactions
---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-02-18 12:25:57 +03:00
Vladislav
bbbcddfdd6
chore(transaction): Copy poll flags (#2596)
* chore(transaction): Copy poll flags

Copying poll flags prevents concurrent data access to PerShardData::local_mask when dispatching poll tasks
---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-02-15 11:55:02 +03:00