Commit graph

59 commits

Author SHA1 Message Date
Shahar Mike
ffce1cb796
chore: Add Lua force atomicity flag (#4523)
* chore: Add Lua force atomicity flag

We accidentally instructed Sidekiq to add `disable-atomicity` to their
script, despite them needing to run atomically.

This hack-ish PR adds a `--lua_force_atomicity_shas` flag to allow
specifying which SHAs are forced to run in an atomic fashion, even if
they are marked as non-atomic.

Fixes #4522

* fix build on clang
2025-01-29 16:35:39 +02:00
Roman Gershman
ff4add0c9e
chore: deprecate unneeded runtime flags (#4405)
Deprecate multi_exec_mode and track_exec_frequencies.
Remove duplicated call to EnterLameDuck (done also in Service::Shutdown()).

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-01-05 13:31:59 +00:00
Andy Dunstall
e05363995f
feat(server): add eval_ro and evalsha_ro (#4091) 2024-11-24 11:53:06 +00:00
adiholden
2d49a28c15
fix(server): handle running script load inside multi (#4074)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-11-10 09:34:40 +02:00
Borys
894bf4735b
fix: fix multi mget exec error message (#3662) 2024-09-06 13:06:02 +03:00
Vladislav
0e4e971ad9
chore(server): Fix watch (#3557) 2024-08-24 13:32:21 +03:00
Shahar Mike
5b546df94d
chore: Change Lua embedded flags syntax (#3517)
Background

We tried to be compatible with Valkey in their support of Lua flags, but we generally failed:

We are not really compatible with Valkey because our flags are different (we reject unknown flags, and Valkey flags are unknown to us)
The #!lua syntax doesn't work with Lua (# is not a comment), so scripts written for older versions of Redis can't be used with Dragonfly (i.e. they can't add Dragonfly flags and remain compatible with older Redis versions)
Changes

Instead of the previous syntax:

#!lua flags=allow-undeclared-keys,disable-atomicity

We now use this syntax:

--!df flags=allow-undeclared-keys,disable-atomicity
It is not backwards compatible (with older versions of Dragonfly), but it should be very easy to adapt to, and doesn't suffer from the disadvantages above.

Related to #3512
2024-08-15 08:04:20 +03:00
Kostas Kyrimis
3f5d4f890d
fix: sanitizers false positives (#3495)
* disable flaky tests

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-13 09:53:31 +03:00
Shahar Mike
aa424c81af
feat: Allow pre-declaring Lua SHAs to run with undeclared keys (#3465)
* feat: Allow pre-declaring Lua SHAs to run with undeclared keys

By using `--lua_undeclared_keys_shas=SHA,SHA,SHA` users can now specify
which scripts should run globally (undeclared keys) without explicit
support from the scripts themselves.

Fixes #2442
2024-08-08 10:27:27 +03:00
Borys
558a22d5b8
fix: crash with NS in multi/exec #3410 (#3415) 2024-07-31 10:06:32 +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
Vladislav
c34a78966a
fix(server): Fix SCAN deadlock (#3235) 2024-06-30 09:15:14 +03:00
Vladislav
0662b50578
fix(transaction): Don't transactionalize empty EVAL inside EXEC (#3231) 2024-06-28 15:36:18 +03:00
Kostas Kyrimis
86559a29db
fix(sanitizers): false positive fail on multi_test::Eval (#2896)
* disable false positives
2024-04-15 15:15:42 +03:00
adiholden
7580a88ca5
feat server: bring visibility to script errors (#2879)
* feat server: bring visibility to script errorד

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-04-11 11:25:41 +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
f3ba448106
chore: make usan asan optional and enable them on CI (#2631)
* add daily job to run unit tests with asan/usan
2024-03-04 11:00:46 +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
Vladislav
c987e64332
fix: handle null length strings in stored commands (#2518)
* fix: handle null length strings in stored commands

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

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-02-01 19:25:44 +03:00
Vladislav
07a6dc0712
feat(transaction): Independent out of order execution (#2426)
Previously, transactions would run out of order only when all shards determined that the keys locks were free. With this change, each shard might decide to run out of order independently if the locks are free. COORD_OOO is now deprecated and the OUT_OF_ORDER per-shard flag should is used to indicate it

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-01-22 10:38:10 +03:00
adiholden
a1d85b7cb2
feat(server): allow running memory commands under script (#2382)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-01-07 16:16:57 +02:00
Roman Gershman
1fb0a486ac
chore: transaction simplification (#2347)
chore: simplify transaction multi-locking

Also, add the ananlysis routine that determines whether the schewduled transaction is contended with other transaction in a
shard thread.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-31 17:02:12 +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
Vladislav
e273f7a2b8
fix(server): handle no-key-transactional commands in multi/exec (#2279)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-12-12 19:34:02 +03:00
Vladislav
0da488d99e
chore(eval): Don't crash on unsupported script commands (#2138)
* chore(eval): Don't crash on unsupported script commands

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-11-08 10:21:52 +02:00
Vladislav
39c1827fa7
fix(transaction): Reset reverse index in multi-tx (#2086)
* fix(transaction): Reset reverse index in multi-tx

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

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-10-30 17:22:35 +03:00
Shahar Mike
502efd80b2
fix(server): Correctly set expiration from Lua scripts (#2080)
We used to set `time_now_ms_` only in the non-squashed execution path.

Fixes #2034
2023-10-27 13:13:47 +03:00
Shahar Mike
b2e989a4fb
fix(server): Fix crash when connection uses multiple lua scripts (#2073) 2023-10-25 19:44:09 +00: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
Shahar Mike
2091f53777
opt(lua): Avoid separate hops for lock & unlock on single shard execution (#1900) 2023-09-22 14:09:17 +03:00
Shahar Mike
b91435e360
opt(lua): Coordinate single-shard Lua evals in remote thread (#1845)
* opt(lua): !!WIP!! Coordinate single-shard Lua evals in remote thread

This removes the need for an additional (and costly) Fiber.
2023-09-13 11:52:35 +03:00
adiholden
d1bce6978d
bug(server): multi cleanup on error (#1813)
the bug: when returning error on a command in multi tx we do not cleanup
the multi cntx
the fix: cleanup the cntx when error is returned

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-09-06 13:02:57 +00: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
Vladislav
16e512c60d
feat: Refactor command verification before execution (#1652)
* feat: Refactor verifications

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-08 12:36:31 +03:00
adiholden
366f50230b
bug(server): multi atomicity fix (#1593)
* bug(server): multi atomicity fix

The bug: when multi transaction run OOO we removed it from trasaction
queue, causing non atomic execution.
The fix: When we run multi transaction unless it is the head in txq we
remove it inside unlock multi from txq.

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-07-31 14:50:33 +03:00
Vladislav
1a65d5684b
fix: fix multi test (#1604)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-07-31 13:55:56 +03:00
Roman Gershman
a87711efc9
fix: Fix faulty logic that forces multi transactions to run as global (#1598)
The problem was with the logic inside Exec(...) that unconditinally
labeled multi transactions as global even if they did not contain any
EVAL calls.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-30 22:59:40 +03:00
adiholden
c411362693
bug(server): multi exec eval (#1541)
* The bug - if all commands inside multi trasaction are eval commands
	    and global scripts mode is on, we did ignored the trasaction
	    and run each eval separately.
*Fix - run all evals under multi inside the global lock
* Change multi eval run only if scripts are in global mode and multi
  mode is not non atomic
* Fix test flags setup
* Skip test ContendedList as it fails
* change default exec mode for txs to lock ahead
2023-07-23 09:09:21 +03:00
Vladislav
cfca751848
feat: global eval in exec (#1443)
Enables execution of global lua scripts inside multi/exec transactions if the defualt script config enables global execution for scripts. This change is only a fix and does not provide any safeguards against other execution scenarios (namely enabling globality with script flags). In the future, the proper execution mode should be determined more carefully by inspecting the scripts to be executed

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Co-authored-by: Kostas Kyrimis  <kostaskyrim@gmail.com>
2023-07-01 22:12:05 +03:00
Vladislav
737ca2e918 fix: script flags naming + add stick option (#1295)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-06-01 15:13:14 +03:00
Roy Jacobson
ad7b4cf368
chore: Add clang workflow to CI (#1220)
* chore: Add clang workflow to CI

* Small fixes/warnings

* Disable Werror for clang
2023-05-23 14:22:28 +03:00
Vladislav
2f6dbe45c0
fix: fix multi test (#1236)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-05-20 01:09:44 +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
89072228e5
Detect possible async calls in scripts (#1122)
Automatically detect possible async calls for lua scripts based on regex
2023-05-01 15:03:51 +03:00
Roman Gershman
b09a36d553
feat: ignore MULTI/EXEC if the transaction consists of EVAL commands (#1157)
feat: ignore MULTI/EXEC if the transaction consists of EVAL commands.

Together with `default_lua_config` solves #781.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-04-29 13:55:32 +02:00
Vladislav
015ed622c5
fix(server): Optimize StoredCmd (#1053)
Opmitize StoredCmd to allow inline storage
2023-04-11 10:14:36 +03:00
Vladislav
c29db83b7e
feat(server): Squashed exec (#1025)
Introduces squashed executor that allows squashing single-shard commands within multi transactions
2023-04-08 23:34:33 +03:00
Roman Gershman
2cfe1f84dc
feat: increase the flexibility of how to assign DF threads (#1042)
feat: increase the flexibility of how to assign threads in DF.

Specifically, introduce `conn_io_threads` and `conn_io_thread_start` flags that choose
which threads can handle I/O. In addition, introduce `num_shards` flag that may override
how many database shards exist in dragonfly process.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-04-07 14:50:25 +03:00