Commit Graph

1331 Commits

Author SHA1 Message Date
Vladislav
b9e8a2c0da
chore: Connection fixes (#1663)
* chore: Connection safety checks

Signed-off-by: Vladislav <vlad@dragonflydb.io>
2023-08-09 17:57:41 +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
talbii
16c2353faf
introduce --replicaof flag (#1583)
* introduce `--replicaof` flag

Closes #1381.

The behvaiour of `--replicaof` is similar to `REPLICAOF`. On startup, the instance continuously attempts to connect to master. Stop using the normal `REPLICAOF NO ONE` command.

The flag expects format `<IPv4/host>:<port>` or `[<IPv6>]:<port>`.

---------

Signed-off-by: talbii <ido@dragonflydb.io>
Signed-off-by: talbii <41526934+talbii@users.noreply.github.com>
2023-08-09 14:42:08 +03:00
Shahar Mike
734401098c
opt(server): Execute lua on target shard, if it's 1 (#1639)
* opt(server): Execute lua on target shard, if it's 1

This will save hops by short-circuiting execution of commands.

* Reuse unique shard id from tx
Only switch threads for LOCK_AHEAD

* Signedness
2023-08-09 14:18:34 +03:00
adiholden
6d84515e08
feat(server): support config set for some flags (#1624)
1. add tcp_keepalive flag
2. support config set for the following flags: tcp_keepalive,dir,requirepass,masterauth
3. more print details when failing on dbfilename flag validation

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-08-09 14:16:42 +03:00
Kostas Kyrimis
52442c444a
fix(VersionMonitor): request to update on older version (#1674) 2023-08-09 09:31:52 +00:00
Roman Gershman
464fa30272
chore: Refactor SortedMap (#1666)
* chore: Refactor SortedMap

1. intoduce variant of Redis and Dragonfly implementation and
wrap each operation with a dedicated dispatcher operator.
The dragonfly implementation path is a noop and not implemented.

2. Introduce a very basic sorted_map_test around Add and move the unrelated old test
   from sorted_map_test to bptree_set_test.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-09 11:16:58 +03:00
Shahar Mike
3779837c5f
test(server): Run all unit tests with --force_epoll (#1672) 2023-08-09 11:00:46 +03:00
romange
db3721b6e2 chore(helm-chart): update to v1.8.0 2023-08-09 07:03:09 +00:00
adiholden
3565e80924
fix(server): update denyoom flag for all commands (#1651)
update denyoom flag for all commands
DENYOOM command flag marks which commands will be denied when memory usage crosses the "red zone".

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-08-09 09:42:26 +03:00
adiholden
116934b008
feat(server): add oom guard (#1650)
1. add flag maxmemory_ratio
2. When current used memory * maxmemory_ratio > maxmemory_limit denyoom
   commands will return oom error.

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-08-08 23:26:35 +03:00
Roman Gershman
7c99d2d111
chore: update helio (#1668)
Bring in all the latest stability fixes we did in helio.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-08 22:55:30 +03:00
Roy Jacobson
4001a94b22
chore: Add names to fibers that were missing them (#1667) 2023-08-08 13:01:50 +02: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
talbii
6b29a642bb
chore: Save snapshots as .tmp first to avoid file corruption (#1623)
* chore: Save snapshots as `.tmp` first to avoid file corruption

Snapshotting begins by saving to `<file-format>.ext.tmp` (for RDB this is a single file, for DFS multiple). *Only after* saving is done we rename the files to remove the `.tmp` extension.

---------

Signed-off-by: talbii <ido@dragonflydb.io>
2023-08-08 09:31:10 +00:00
Roman Gershman
8123ef05e4
feat: Add DeleteByScore method (#1664)
Implemented `DeleteRange(KeyT first, KeyT last, std::function<void(KeyT)> cb,
                         bool inclusive_first, bool inclusive_last)`

method. We need inclusive parameters because with doubles it harder to reduce
the query to a standard open-closed range.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-08 12:14:38 +03:00
Vladislav
7f1a2d9e38
fix(pytest): Raise exception if instance.stop timed out (#1660)
fix(pytest): Raise if instance.stop timed out

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-07 19:10:15 +03:00
Kostas Kyrimis
df771f9138
fix(rdb_load): load listpack encoded zset (#1646) 2023-08-07 09:13:15 +00:00
Roman Gershman
78bd49405a
feat: Add LowerBound and DeleteRangeByRank (#1655)
Also, fix Deletion bug inside DigRight function.
DeleteRangeByRank is implemented naively but it should be still
faster than zsl given that zsl needs to deallocate metadata per each item deleted.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-07 10:36:29 +03:00
Roman Gershman
12c893085c
chore: Iterate over bptree_set. (#1654)
* chore: Iterate over bptree_set.

Add iterate by rank functions.

For that we introduce BPTreePath::Next() and BPTreePath::Prev() functions
that allow iterating over immutable tree.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-06 22:34:05 +03:00
Vladislav
279d7cc068
feat: FtList, FtDropIndex and FtInfo (#1649)
* feat: FtList, FtDropIndex and FtInfo

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-06 22:01:58 +03:00
Roman Gershman
0f7214afc9
feat: add ScoreMap that maps sds strings to doubles (#1656)
This map should serve as a replacement for dict that currently is used internally by the SortedMap.
Specifically, it maps sds strings to scores to provide a reverse mapping.
It should be more efficient in memory and CPU - requires a single allocation to store both the
key and the value, in contrast to dict that needs two allocations.

In addition, it also reduces the object size needed for the zset score set:
zsl stores both the sds pointer and its double, i.e. requires 16 bytes not including the metadata.
By passing to bptree_set the internal ScoreMap objects that are allocated by ScoreMap::AddOrUpdate
we can just store 8-byte pointers, not including the bptree metadata.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-06 21:47:01 +03:00
Vladislav
6c343c55e8
feat: Use compressed sorted set for search (#1648)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-06 14:23:46 +03:00
Shahar Mike
5ccc519b5c
fix(server): Increase default timeout (#1653)
We saw some unrelated tests failing there.
2023-08-06 10:21:55 +00:00
Vladislav
3bc1e26050
feat: Use const ConnectionContext in VerifyCommand (#1633)
* feat: Use const ConnectionContext in VerifyCommand

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-06 11:02:43 +03:00
Vladislav
6faa530d42
fix: Add selective non-atomic squash dispatch (#1641)
fix: Add selecting non-atomic squash dispatch

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-06 10:08:55 +03:00
Dor Avrahami
25c34498ac
hotfix: snapshot endless loop on exit. (#1647)
Snapshot caused endless save loop on exit due to fiber not finishing.
The fix is to add a `break` to the `while` loop after `schedule_done_`
has notified.

Signed-off-by: Dor Avrahami <da19965@gmail.com>
2023-08-05 21:46:10 +03:00
Roman Gershman
fcd868a8d6
Add "DEBUG OBJHIST" (#1635)
feat: Introduce DEBUG OBJHIST command

Fixes #1618.
Also added to CompactObject::Size() OBJ_HASH case that was not handled before.

To get the statistics run `redis-cli --raw debug objhist`

It requires `--raw` because we send muilti-line output which
redis-cli escapes by default.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-04 19:55:23 +03:00
Roman Gershman
f40241ab0b
feat: Fix rank for delete operations (#1644)
Also add a benchmark test that shows 2-3 times better performance for Find
vs redis zslGetRank when number of items grows.
For Insert/Delete I expect the differrence be even bigger.

Benchmark                            Time             CPU   Iterations
----------------------------------------------------------------------
BM_FindRandomBPTree/1024         56000 ns        55996 ns        75079
BM_FindRandomBPTree/65536      9406738 ns      9406552 ns          450
BM_FindRandomBPTree/1048576  390559398 ns    390539398 ns           11
BM_FindRandomZSL/1024            87991 ns        87989 ns        49196
BM_FindRandomZSL/65536        17917190 ns     17916618 ns          196
BM_FindRandomZSL/1048576    1343231616 ns   1343130709 ns            3

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-04 14:51:43 +03:00
Roman Gershman
1e15caf038
feat: Add GetRank to bptree API (#1638)
It's a partial implementation for only the insertion API.
We add the "tree count" variable, present in each inner node. This variable is updated upon each insertion
along the insertion path.

Deletion api will follow up shortly.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-04 10:26:43 +03:00
Vladislav
a0da723628
fix: remove coordinator_index_ from tx & fix short circuit (#1640)
fix: remove coordinator_index_ from tx

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-03 22:43:43 +03:00
Shahar Mike
67a4c4e6cb
feat(server): Add --lock_on_hashtags mode. (#1611)
* feat(server): Add `--lock_on_hashtags` mode.

This new mode effectively locks hashtags (i.e. strings within {curly
braces}) instead of the full keys being used.
This can allow scripts to access undeclared keys if they all use a
common hashtag, like for the case of BullMQ.

To make sure this mode is tested, I added a way to specify flags via env
variables, and modified `ci.yml` to run all tests using this mode as well.
While at it, I also added `--cluster_mode=emulated` mode to CI.
2023-08-03 20:13:36 +03:00
Roy Jacobson
8040bed10f
Fix socket code in replication (#1622) 2023-08-03 17:01:56 +02:00
Vladislav
da17a39410
fix: remove empty hop for non-expiring transactions (#1605)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-03 16:26:58 +03:00
Kostas Kyrimis
3c345c1226
chore: update helio (#1634) 2023-08-03 15:09:26 +03:00
Shahar Mike
91c2ca8fb6
fix(server): Do not crash on parse error (#1631)
Fixes #1630
2023-08-03 05:25:43 +00:00
romange
3103c6b2ed chore(helm-chart): update to v1.7.1 2023-08-02 16:30:14 +00:00
Kostas Kyrimis
58f6ede503
chore: update helio (#1626)
* chore: update helio

* update helio
2023-08-02 13:52:20 +00:00
Roman Gershman
1d10d9383b
chore: disable multi-squashing (#1627) 2023-08-02 16:48:10 +03:00
Dor Avrahami
0b6c0bbe53
feat: support for cron expressions based snapshot (update). (#1620)
Requested by #1590.
Introducing a new flag --snapshot_cron, enabling users to use cronjob expressions to time snapshot saves.
Cronjob expressions are parsed using a third party library croncpp.
This PR continues #1599, updating cron expressions to crontab style,
up to minutes resolution instead of seconds.

Signed-off-by: Dor Avrahami <da19965@gmail.com>
2023-08-02 12:58:45 +03:00
Vladislav
844fe57dec
feat: Remove batch locks from non-atomic squashing (#1613)
feat: Remove batch locks from non-atomic squashing

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-02 09:16:47 +03:00
Shahar Mike
3b0bd212f4
fix(test): Fix failing tests. (#1612)
Solution is to wait until snapshot is ready, instead of hard coding a
sleep schedule. Also don't reuse files by other test cases.
2023-08-01 08:30:17 +00:00
Vladislav
3a4b3c97c8
fix: simplify ScheduleInShard (#1610)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-01 08:15:42 +03:00
Dor Avrahami
977fc18e25
feat: support for cron expressions based snapshot. (#1599)
Introducing a new flag `--snapshot_cron`, which enables users
to use cron expressions to time snapshot saves.

Signed-off-by: Dor Avrahami <da19965@gmail.com>
2023-07-31 20:26:01 +03:00
Vladislav
7673e027b6
fix: refactor RunCbOnFirstNonEmptyBlocking (#1608)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-07-31 18:34:23 +03:00
Roman Gershman
e14fa1d16c
Add delete functionality to the b+tree (#1607)
Add delete functionality to the b+tree.

Implemented  BPTree::Delete method.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-31 13:57:13 +00:00
Vladislav
eda941dca6
fix: add Transaction::Conclude (#1606)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-07-31 15:37:29 +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
Shahar Mike
ef55713dfc
feat(server): Use hashtags for sharding in emulated cluster mode. (#1602)
This PR would have been 1 line change instead of 11 files, but it
required some plumbing and refactoring:
* Now ClusterConfig is aware of emulated cluster mode
* As a result, this API was moved from ClusterFamily
* And so was the flag & its parsing
* ClusterFamily doesn't need is_emulated_cluster_ member
* ServerFamily no longer needs ClusterFamily* member (because the API is
  static)
* I also changed `ClusterConfig::IsClusterEnabled()` to
  `ClusterConfig::IsEnabled()` to be shorter
2023-07-31 13:55:47 +03:00