Commit graph

94 commits

Author SHA1 Message Date
Roman Gershman
95147fbb59
fix: broken gha cache (#4951)
* fix: broken gha cache

Also fix some clang warnings.

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

* chore: comments

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-04-17 08:30:58 +03:00
Volodymyr Yavdoshenko
faf626eed4
fix: Remove the dfly logo print from pytest run #4682 (#4706)
fixed: https://github.com/dragonflydb/dragonfly/issues/4682
2025-03-06 10:27:58 +02:00
Volodymyr Yavdoshenko
386ab3902b
fix: ascii logo was added (#4524)
ascii logo was added
2025-02-10 09:29:28 +02:00
Roman Gershman
e39e68276e
chore: dragonfly connection refactorings (#4434)
1. Move socket read code into a dedicated function.
   Remove std:: prefix in the code.
2. Add an optional iouring bufring registration. Currently not being used and is disabled by default.
2025-01-09 13:55:00 +00:00
Roman Gershman
95cd9dfb4c
chore: update helio and improve our stack overflow resiliency (#4349)
1. Run CI/Regression tests with HELIO_STACK_CHECK=4096.
   This will crash if a fiber stack usage goes below this limit.
2. Increase shard queue stack size to 64KB
3. Increase fiber stack size to 40KB on Debug builds.
4. Updated helio has some changes around the TLS socket code.
   In addition we add a helper script to generate self-signed certificates helpful for local development work.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-12-23 08:13:45 +00:00
Roman Gershman
91caa940b9
chore: fix shutdown sequence in Dragonfly server (#4168)
1. Better logging in regtests
2. Release resources in dfly_main in more controlled manner.
3. Switch to ignoring signals when unregister signal handlers during the shutdown.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-24 10:35:00 +02:00
Roman Gershman
b8c2dd888a
chore: log exit code of failing dragonfly in tests (#4166)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-22 11:40:10 +02:00
Roman Gershman
581cfbf6c5
chore: allow slow and precise memory measurement of an object (#4160)
Specifically fixes "MEMORY USAGE" for lists.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-21 09:21:48 +02:00
Shahar Mike
cf2e94f374
chore: Add --allocator_tracker for default tracking (#3901)
* chore: Add `--allocator_tracker` for default tracking

Before, in order to use allocation tracker, one had to issue a `MEMORY
TRACK` command. This flag is identical to that, but allows starting
Dragonfly with certain ranges without issuing a command.

While here, fix a bug. Apparently, `absl::InlinedVector<>` has a bug in
the implementation of `max_size()` and so in practice we did not limit
the number of trackers. I switched to use `capacity()` instead, which I
tested and it works well.

Notes:
1. Currently the flag always add 100% "sampling", we can extend that in
   the future if need be
2. I added the flag in `dfly_main.cc` with custom initialization,
   because it's low level, and I couldn't get it reasonably working with
   changes only to `allocation_tracker.cc`

* fixes
2024-10-13 12:50:05 +03:00
Kostas Kyrimis
0cea5fe2ff
chrore: parse cgroup v2 (#3857)
* chrore: parse cgroup v2

* small parsing logic
2024-10-10 19:15:26 +03:00
Roman Gershman
6a13329523
fix: make sure dfly_bench reliably connects (#3802)
1. Issue ping upon connect, add a comment why.
2. log error if dfly_bench disconnects before all the requests were processed.
3. Refactor memcache parsing code into ParseMC function.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-26 23:28:20 +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
0ad310717d
chore: Tiered fixes (#3401)
1. Add background offloading stats
2. remove direct_fd override - helio is already updated with default=false, so it's not needed anymore.
3. remove redundant tiered_storage_memory_margin flag

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-01 11:03:13 +03:00
Roman Gershman
73e44a941e
chore: reset enable_direct_fd to avoid socket leakage in kernel (#3051)
The leakage can be identified by checking /proc/net/sockstat
Fixes #3045

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-05-16 09:44:53 +03:00
Roman Gershman
5bf7e3b146
chore: update helio together with new mimalloc version (#3040)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-05-13 12:48:05 +03:00
Shahar Mike
653086c910
fix(memcached): Register memcached listener to handle --maxclients (#2985)
* fix(memcached): Register memcached listener to handle `--maxclients`

We add other listeners to `listeners`, but we seem to have forgotten to
do that to the memcached listener.

* protocol() == REDIS
2024-05-01 22:46:16 +03:00
Roman Gershman
f7292de4e7
chore: Introduce fiber stack allocator (#2730)
1. Use clib malloc for allocating fiber stacks but reduce the fiber stack size.
   clib malloc uses default 4K OS pages when reserving memory from the OS.
   The reason for not using mi_malloc, because we use 2MB large OS pages with mimalloc.
   However, allocating stacks is one of the cases, when using smaller 4KB memory pages is actually more
   RSS efficient because memory pages become hot at better granularity.

2. Add "memory_fiberstack_vms_bytes" metric exposing fiber stack vm usage.
3. Fix macos dependencies & update ci versions.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-03-18 13:51:33 +02:00
Shahar Mike
b2bdb0f683
feat(server): Memory tracker (#2501)
* feat(server): Memory tracker

* PR comments
2024-01-30 12:44:07 +02:00
Shahar Mike
b777d31a98
feat(server): Add backlog flag for listen() (#2456)
* feat(server): Add `backlog` flag for `listen()`
2024-01-23 08:19:53 +00:00
Roman Gershman
e9453e62e4
fix: ignore unexpected contents for /sys/fs/cgroup/cpu.max (#2394)
Fixes #2391

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-01-10 11:17:37 +02:00
Roman Gershman
ddbdf63470
fix: relax the requirement for parsing successfully container limits (#2352)
We parse the container limits for heuristics that deduces memory/cpu capacities automatically.
It's ok if we fail on some less common systems since there are manual overrides that allows specifying these
limits explicitly.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-30 13:31:40 +02:00
Roman Gershman
700a65ece5
chore: refactor VersionMonitor into a separate file (#2326)
* chore: refactor VersionMonitor into a separate file
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-12-24 22:06:57 +02:00
Kostas Kyrimis
7b71b728c7
fix: small races on config registry and maxclients (#2078)
* fix small data race with maxclients
* make config::set an atomic operation
2023-10-31 09:26:15 +02:00
Roman Gershman
47d92fb010
fix: Correctly grow dense_set in the Reserve call (#2087)
Fixes #2066

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-29 08:39:33 +02:00
Roman Gershman
6e76f8e6cc
fix: logrotate for dragonfly logs (#1972)
The new logrotate settings assume that dragonfly closes a log file
once it grows to large. It never rotates file that is currently open for writing.

Specifically logrotate:

1. rotate only log files
2. skip those that are currently open by as process.
3. compresses using zstd which is more cpu efficient than gzip
4. does not truncate/create old files as 0-sized blobs - just renames them

Fixes #1935

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-09 20:08:37 +03:00
Roman Gershman
2876a9ecab
fix: make --help flag work for development builds (#2004)
Before that SOURCE_PATH_FROM_BUILD_ENV define has not been defined
for the development builds.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-10-09 19:44:14 +03:00
Kostas Kyrimis
945d3a39e4
chore(Http): change authed username to default and skip auth on metrics (#1950)
* Update Http auth with username default instead of user
* skip auth for /metrics page
* add/improve tests
* fix a bug with admin port requiring auth on http even if nopass was set
* update helio ref
* update listener class to contain its respective Role
* fix http init to only include admin and main listener
2023-10-03 10:45:37 +03:00
Kostas Kyrimis
38c4e3b588
chore(dfly_main): refactor to use RAII (#1981) 2023-10-02 20:47:38 +03:00
Kostas Kyrimis
8dd34b9ce3
fix: small typos on flags (#1953)
* Polish small typos on flags
2023-09-27 15:02:04 +00: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
Roy Jacobson
b55316c0e6
tests: choose open ports randomally (#1569)
* Implement changes to the testing infrastructure to use random ports
* Use psutil to find out the random ports
2023-09-18 10:23:49 +03:00
Kostas Kyrimis
0d20005528
fix: dfly_main small typo on unix_socket flag (#1853) 2023-09-13 16:52:44 +03:00
Aidarbek Suleimenov
04e88a1381
feat(server): Getting flags from the environment variables (#1810)
* flags from env variables

* querying environment vars

* remove includes

* refactor

* exit for unknown flag with DFLY_ prefix

* reflecting change in the test

* better tests

* refactor + new test case

* refactor test with inner class

* refactor

* revert back test flags as it might affect ci/cd

* fixing flags

* refactor

* remove includes

* refactor
2023-09-13 10:02:38 +00:00
Roman Gershman
36be222091
chore: add macos daily build (#1795)
It compiles most of the code though some linking problems still exist.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-06 09:35:11 +03:00
Roman Gershman
e8bf54e8bb
chore: dragonfly compiles on FreeBSD (#1789)
1. Do not use IOUring on non-linux systems.
2. Improve compatibility of the code for non-linux systems.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-03 14:11:08 +03:00
Kostas Kyrimis
866b9afe58
chore: remove locks from acl validation in the hot path (#1765)
* remove locking the registry when Validating users
* deep copies the acl categories in the connection context
* streamline updates to the acl categories via the proactor pool
2023-08-31 21:59:42 +03:00
Roy Jacobson
ed845fe526
feat(server): Support limiting the number of open connections. (#1670)
* feat(server): Support limiting the number of open connections.

* * Update helio after the small fix was merged to master
* Don't limit admin connections (and add a test case)

* Resolve CR comments
2023-08-27 11:30:16 +03:00
talbii
74fcd3ed06
fix: Correctly read container limits when running under k8s (#1692)
Signed-off-by: talbii <ido@dragonflydb.io>
2023-08-23 14:21:49 +03:00
Kostas Kyrimis
52442c444a
fix(VersionMonitor): request to update on older version (#1674) 2023-08-09 09:31:52 +00:00
Kostas Kyrimis
42a644a5e6
refactor(VersionMonitor): improve readability and add proper RAII to ssl_ctx (#1578)
* Add RAII for cleaning up ssl_ctx within version monitor
* Refactor some small parts of Run() to make it more readable
2023-07-26 07:24:31 +00:00
Kostas Kyrimis
1369b2d3f2
chore(VersionMonitor): replace std::vector with absl::InlinedVector (#1589) 2023-07-25 13:25:52 +03:00
Kostas Kyrimis
3bea87e36f
fix(VersionMonitor): improper version update to older version (#1577)
Add correct version comparison between VersionMonitor and the dfly server
2023-07-24 12:08:24 +00:00
Roman Gershman
0fe6e36f25
feat: introduce config set command (#1574)
feat: introduce "config set" command

Solves #1551. In detail, we introduce ConfigRegistry that holds
a curated set of flags that could be changed at run-time.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-20 15:55:39 +03:00
Kostas Kyrimis
4eb2012a8d
fix: add missing slash on startup for certain log_dir paths (#1500) 2023-07-06 19:26:37 +03:00
Roman Gershman
e71fae7eea
fix: avoid crashing dragonfly on parsing error of cgroups config (#1503)
Fixes #1502

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-02 12:11:44 +03:00
Roy Jacobson
52192e0596
fix(server): Initialize ServerFamily with all listeners. (#1485)
* fix(server): Initialize ServerFamily with all listeners.

- Add a test for CLIENT LIST which is the visible result of this.

* use std move
2023-07-02 10:01:54 +02:00
Kostas Kyrimis
08b46db28a
feat(log): On startup print info to stdout (#1448)
* feat(log): On startup print to stdout info

On dragonfly startup print:
1  Which file we are logging to and where
2. How to get more help with the flags (--help, --helpfull)
3. Doc links
2023-06-22 14:40:32 +03:00
Vladislav
fea4e1dd4d
fix: rename memcache to memcacheD (#1461)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-06-22 11:55:20 +03:00
adiholden
5e479ed967
feat(server): add unixsocketperm support (#1450)
* fetch helio Add support to set uds permissions

Signed-off-by: adi_holden <adi@dragonflydb.io>
2023-06-21 13:58:39 +03:00
talbii
e646476359
CGroup v1 detection (#1329)
Add support for cgroup v1 limit checking

For future reference: testing. In order to test this feature (both for
v1 and v2). To do this, create a cgroup and move Dragonfly into it
before running.

One way to do this is using a script, like: cat; ./dragonfly
--logtostderr

Enabling v1 (by default, you should have v2): Edit `/etc/default/grub`,
and look for `GRUB_CMDLINE_LINUX_DEFAULT`. Append to it
`systemd.unified_cgroup_hierarchy=0`, update GRUB using `sudo
updat-grub`, and reboot.

In v1, create a group `mycgroup` and add PID 1234 to it:

```
sudo mkdir -p /sys/fs/cgroup/memory/mycgroup
sudo bash -c "echo 8589934592 >
/sys/fs/cgroup/memory/mycgroup/memory.limit_in_bytes" # set mem limit to
8G
sudo bash -c "echo 1234 > /sys/fs/cgroup/memory/mycgroup/tasks" # assign
PID 1234 to this cgroup
```

In v2:

```
sudo mkdir -p /sys/fs/cgroup/mycgroup
sudo bash -c "echo 8589934592 > /sys/fs/cgroup/mycgroup/memory.max" #
set mem limit to 8G
sudo bash -c "echo 1234 > /sys/fs/cgroup/mycgroup/cgroup.procs" # assign
PID 1234 to this cgroup
```

then test by (using script example from before):

```
$ ./run.sh # contains: cat; ./dragonfly --logtostderr
[1] 1234
[1]  + 1234 suspended (tty input)  ./run.sh
fg
^D
<look for Dragonfly memory limit>
```

Signed-off-by: talbii <ido@dragonflydb.io>
2023-06-07 16:38:04 +03:00