Skip to content

RFC: Socket activation support - #2004

Open
flyingmutant wants to merge 1 commit into
redis:unstablefrom
flyingmutant:socketact
Open

flyingmutant wants to merge 1 commit into
redis:unstablefrom
flyingmutant:socketact

Conversation

@flyingmutant

Copy link
Copy Markdown
Contributor

Should finally address #329. Please review.

Comment thread src/redis.c Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we really should check the return code here.

@mattsta mattsta self-assigned this Oct 7, 2014
@flyingmutant

Copy link
Copy Markdown
Contributor Author

@mattsta, any updates on this? I can rebase it if you prefer.

@mattsta

mattsta commented Oct 21, 2014

Copy link
Copy Markdown
Contributor

Good news!

[warning: this is more of an article than a comment reply]

First, thanks for creating the socket activation support. (At first, I had it confused for the watchdog support request (see #1562), so I thought this was a workaround for not needing to link against systemd libs directly.)

Your systemd socket activation environment variable inheriting magic works! I did rebase your commit at https://github.com/mattsta/redis/commits/sockact (the only conflict was a comment) and used it to test some use cases.

Note: this was also my first time doing anything with creating systemd services.

First of all: Redis is a network server. It really cares about things like how sockets and file descriptors are configured. By using systemd socket activation, you remove Redis's ability to manage inbound sockets and file descriptors by itself. So, you must configure your systemd unit properly or else nothing will work.

You can see the systemd files I used for the test (placed in /etc/systemd/system; refreshed by systemd daemon-reload; started by systemd start redis-demo; watched output by journalctl -u redis-demo).

Make double note of the NonBlocking=yes option in redis-demo.service. If NonBlocking is absent (default value of false), nothing inside Redis works. You can't connect. You can't shutdown. You can't do anything.

At least systemd does have a unified way of setting options like open file descriptors, run-as user/group, and various other network/kernel options not easily exposed to processes at runtime. We don't need to resort to manually ulimit calls anymore.

Bad news!

Redis improves performance by setting all sockets to TCP nodelay mode, but systemd only added NoDelay support about two months ago, so that feature is way too new to be in my system; so any usage of Redis with socket activation will have a performance impact due to no nodelay setting.

But, back to socket activation.

Socket activation lets systemd control the listening sockets and "activation" means when something connects to the socket for that process, systemd will automatically start the service if it is not running.

Why would we ever want Redis to just automatically start if it isn't running? It seems to work nicely if Redis has zero contents, but if you have a 50 GB file to load at startup, Redis will be delayed for minutes before it can do anything.

I also ran into a nice edge case: Redis Server A is a master. Redis Server B is replicating from Redis Server A. Do a systemctl stop redis-server-a. Know what happens? Redis Server B immediately noticed the connection is gone, tries to reconnect, then systemd re-spawns redis-server-a because of socket activation magic.

Marking a service administratively down should be enough to stop it from magically starting again. We shouldn't have to mask processes to stop random behaviors. :)

[I've looked at other DB servers and I don't see anybody using socket activation with mysql or postgres, because automatically starting a long-running, persistent, DB based on incoming network requests doesn't make much sense?]

Is it possible to have systemd control the socket without automatically starting services? So, just "socket" with no "activation?"

But, still, there's no reason to have systemd control the socket anyway. It really freaks out redis-cli when connected across the systemd service and then the underlying Redis server ends up not existing or not responding.

So... socket activation doesn't mean "zero downtime upgrades" or "processes don't notice your service restarts" semantics. Some clients will disconnect or timeout, other clients will just stall until the backend server becomes available again. systemd owning the socket doesn't enable any magic behavior there. (It's really easy to auto-reconnect or auto-retry with Redis too, so clients shouldn't need or rely on forever-persistent connections)

What Now?

I'm open to ideas, but I don't see how socket activation is useful for Redis. It's a neat feature mainly designed around replacing inetd or launching things on client machines like on-demand print servers. Nobody would run Redis from xinetd, so socket activation also seems kinda "out there" as far as useful ideas go with database network architecture.

systemd socket ownership can be slightly useful if you want to centralize your configurations (multiple IPs or domain sockets configured by your system, not your Redis config), but then Redis can't set options on sockets directly.

Overall?

The patch above works (or the already rebased version), but it lets users actually break Redis if they configure systemd units wrong since Redis can't control/initialize the network as it does now. Plus, no other database software seems to use socket activation.

Are there any valid use cases people can think of besides "it's a feature, so we should use the feature, because the feature exists and it needs to be used?"

[Addendum: also, with Redis Cluster there would be no way to use socket activation for all Redis Cluster inbound connections. Redis Cluster maintains another internal "server" for cluster-wide communication, and there's not a way to split two classes of "connections" across a unit configuration.]

@flyingmutant

Copy link
Copy Markdown
Contributor Author

I've updated the PR: it is a bit shorter and applies cleanly to current unstable.

@flyingmutant

Copy link
Copy Markdown
Contributor Author

Here is my look on the situation.

On one hand, all this patch does is it adds ability to inherit listening sockets to redis; it in no way ties redis to systemd. It is quite small — 5 files changed, 71 insertions(+), 5 deletions(-), completely backward compatible and does not introduce any dependencies. It is unlikely that it will significantly increase redis maintenance burden.

On the other hand, this patch allows people who use systemd as a primary system (machine/container) manager to:

  • do not configure explicit dependencies on redis (as it is always available from clients POV)
  • have transparent redis restarts or upgrades (edit)
  • have more parallel (potentially faster) system startup
  • use systemd socket files to configure redis listening sockets

Regarding the 50GB scenario: this patch does not pretend to enable the only and ultimate way of administering redis, nor does it force people with 50GB databases to change their habits. Instead I'd argue that there is a significant number of users who store in redis volumes of data that take seconds, not minutes, for redis to restart, thus making socket activation more useful and transparent.

Regarding your autostart «edge case»: as you can see here, systemctl stop redis-server-a is a pretty superficial operation. systemd even warns you:

Warning: Stopping redis-server-a.service, but it can still be activated by:
  redis-server-a.socket

What you should use is

systemctl disable redis-server-a.service
systemctl stop redis-server-a.service

I know nothing about Redis Cluster, so will not comment on that. Also, can you please be more specific about what exactly is not working with redis-cli?

@davidstrauss

Copy link
Copy Markdown

I'm not sure if I made this argument on the previous issue, but it's good for security and container management. You can listen on a socket and pass it to Redis, but revoke the ability for Redis to see the corresponding interface by using a network namespace (with a container or systemd service, for example). This is using socket activation as capability-based security, and it's a great alternative to namespaces-with-iptables-forwarding (LXC's approach) and selinux port labels (RHEL's approach). Running Redis with socket activation does not require starting it on the first connection; a socket-activated service can still start during boot, just getting its listener from the inherited fd.

If you limit the size of the Redis cache, you can set a bound on startup time. We run thousands of small Redis instances per host machine in systemd services, and we would love socket activation support.

We also start our MariaDB (MySQL) instances on-demand and are working on getting socket activation upstream.

@mattsta

mattsta commented Oct 22, 2014

Copy link
Copy Markdown
Contributor

[replying in a random order]

We also start our MariaDB (MySQL) instances on-demand and are working on getting socket activation upstream.

That's really useful to know. A bit crazy, but useful to know.

(Sidenote: I'm just reviewing and trying to understand things here—it's not up to me whether things get merged or not! plus, the great submitted code in this PR does work, so anybody can run this right now on their own.)

We run thousands of small Redis instances per host machine in systemd services, and we would love socket activation support.

How does your setup work (and why does it work that way)? I'd love to hear the use cases around it. We can support everybody better if we understand how people use our software. Many (most?) Redis users are completely "stealth" — they use Redis for very fast, sometimes very complicated, things, but never want to tell anybody about it. But, if we don't know what users are doing, we can't improve their use cases. Gotta share the love.

You can listen on a socket and pass it to Redis, but revoke the ability for Redis to see the corresponding interface by using a network namespace

Attempting to limit Redis's network view would break the current Cluster implementation because cluster runs two internal servers (one for regular Redis connections at port N, another for cluster node-to-node bus at port N+10000).

Heck, when I was trying to configure Redis with systemd, it took me a while to figure out nothing was working because I didn't specify NonBlocking=yes in the service configuration.

Regular Redis listens on up to 10 IPs (but the same port across all of them) combinations and up to one domain socket. Systemd still allows that.

Sentinel listens on one IP/port, but systemd could do something strange there if people started using sentinel across domain sockets or multiple IPs.

Redis Cluster listens on the regular "up to 10 IP/same-port combinations + domain socket" for client access plus it spawns another internal server that accepts different connections and has a different processing flow. Systemd can't support that "two servers in one process" kinda usage.

What you should use is

You'd think, but it doesn't work!

[root@novus system]# systemctl disable redis-demo.service
[root@novus system]# systemctl stop redis-demo
Warning: Stopping redis-demo, but it can still be activated by:
  redis-demo.socket

The docs say disable stops socket activation, but it doesn't work on my system. Everything still auto-starts when I run another redis-cli INFO.

[root@novus system]# systemctl --version
systemd 208
+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ

Now, it does work if we force-disable everything, but then systemd doesn't listen anywhere:

[root@novus system]# systemctl disable redis-demo.socket
[root@novus system]# systemctl stop redis-demo.socket
[root@novus system]# systemctl stop redis-demo
[root@novus system]# 

As soon as we re-enable the socket, it will auto-launch Redis on any connection (even with the redis service 'disabled').

[approaching the following from a Redis-only viewpoint; many of these talking points are generic "YAY SYSTEMD!" arguments]

do not configure explicit dependencies on redis (as it is always available from clients POV)

I think the "always available" talking point is a bit dubious. Clients should know how to reconnect. Network servers aren't magic "always available" things and, if software pretends they are, people will start writing software that breaks under non-glass-dome-deployed edge cases.

have transparent redis restarts or upgrades

Again, that's a really catchy talking point, but is it useful? Do clients not know how to reconnect if a connection failure happens?

If I'm in the middle of a connection and the server restarts, I still get:

Error: Connection reset by peer
Error: Connection reset by peer

So, there's no magic pixie dust saying "clients will never notice the server restarting."

have more parallel (potentially faster) system startup

That's not really a socket activation issue is it? That sounds just a regular dependency tree issue. (assuming your other software knows how to retry if it's started before the DB becomes available).

use systemd socket files to configure redis listening sockets

That is nice benefit, but it's also a drawback because the user must explicitly create compatible listening sockets (and systemd doesn't expose all the tuning knobs Redis uses internally).

There are two viewpoints here: the big server view of "we run 12 servers, each with 512 GB RAM" viewpoint and the super tiny "We run one server with 2,000 Redis instances" viewpoint. I tend to take the "Big, stable, company-runs-on-this" viewpoint, so the smaller use cases sometimes fall behind.

There is an interesting use case here for hosting providers: you could have hundreds of "waiting" Redis sockets, then you can auto-provision customers just by having them connect to their allowed port.

But, again, it's not up to me; there are 30 other high profile issues at the moment (everybody wants their own issue to be top priority of course), so... everybody gets to wait their turn.

Redis can benefit a lot from having systemd as a supervisor with setting system permissions (ulimit, set capabilities so root isn't needed, etc) and doing auto-restarts, but having opaque socket handoff doesn't seem like a benefit for Redis as an "it just works" reliable server.

@davidstrauss

Copy link
Copy Markdown

How does your setup work (and why does it work that way)? I'd love to hear the use cases around it. We can support everybody better if we understand how people use our software. Many (most?) Redis users are completely "stealth" — they use Redis for very fast, sometimes very complicated, things, but never want to tell anybody about it. But, if we don't know what users are doing, we can't improve their use cases. Gotta share the love.

We're Pantheon, a distributed platform for WordPress and Drupal site development and deployment. We offer a Redis instance (semi-containerized) for each development, testing, and live stack for each site on the platform. Not everyone actually opts to have Redis deployed for their project, but it's their option.

Drupal doesn't need a large Redis cache, only around a few hundred megabytes to be really effective. One of our partners just introduced Redis support for WordPress, and I'd expect similar needs for cache size.

Sentinel listens on one IP/port, but systemd could do something strange there if people started using sentinel across domain sockets or multiple IPs.

I'm not sure what you mean by that. After socket activation occurs and the daemon takes over the file descriptors, it should be indistinguishable from the daemon binding and listening itself.

Systemd can't support that "two servers in one process" kinda usage.

It should be able to. systemd sends multiple sockets configured for a daemon as a series of file descriptors, fd=3, 4, and so on. You can mix and match socket types, but they all need to be listed in the same socket unit. Connecting to any of them causes the service to start and all to be passed in.

Is it really two servers in one process? Or are they different processes? I must admit my Redis Cluster knowledge is limited.

The docs say disable stops socket activation, but it doesn't work on my system. Everything still auto-starts when I run another redis-cli INFO.

Can you point out where it says that in the docs? The behavior you've observed is the intended design, and the docs should be fixed to reflect that if they don't already. I'm a committer and can fix it directly.

Again, that's a really catchy talking point, but is it useful? Do clients not know how to reconnect if a connection failure happens?

Anyone saying that it's seamlessly transparent is just wrong. The listener socket stays open, but connection sockets don't. The only way to be completely transparent is for the daemon to support graceful shutdown, elegantly finishing any requests-in-motion and then shutting down. This works great for HTTP servers where persistence is a transparent optimization but not as well for protocols like the one for Redis.

That's not really a socket activation issue is it? That sounds just a regular dependency tree issue. (assuming your other software knows how to retry if it's started before the DB becomes available).

The person you're replying to is actually correct. You can often make services depend on the socket they want to connect to rather than the service. For example, you can have php-fpm.service (depending only on redis.socket) and redis.service start simultaneously. Any request going through PHP that tries to connect to Redis will hang until Redis is actually available. The behavior is correct in the sense of being error-free. More importantly, Redis and PHP will be online sooner because PHP didn't wait on Redis to finish starting.

That is nice benefit, but it's also a drawback because the user must explicitly create compatible listening sockets (and systemd doesn't expose all the tuning knobs Redis uses internally).

The benefit for us is integration with management tools that are systemd-aware.

There is an interesting use case here for hosting providers: you could have hundreds of "waiting" Redis sockets, then you can auto-provision customers just by having them connect to their allowed port.

This is sort of what we do: deploy services empty and stopped, only starting the sockets. It speeds up deployment in the same way as it speeds up parallel startup. We can say a container is "available" when the socket is up, which is quicker and more consistent than figuring out when the service is up.

@mattsta

mattsta commented Oct 22, 2014

Copy link
Copy Markdown
Contributor

Thanks for the quick and thorough reply!

Drupal doesn't need a large Redis cache,

Good point. There's always that "single purpose transient cache" use case I tend to forget in favor of larger "persistent, in-memory database" use cases.

After socket activation occurs and the daemon takes over the file descriptors, it should be indistinguishable from the daemon binding and listening itself.

Oh, I was just commenting on a Sentinel implementation detail. Sentinel always assumes it has exactly one IP/port, so I'm not sure what happens if you have systemd give it a unix domain socket file descriptor. (In some places, Redis looks up the IP of the connected file descriptor to use elsewhere).

Is it really two servers in one process? Or are they different processes? I must admit my Redis Cluster knowledge is limited.

By "two servers" I mean: Redis runs two accept loops for cluster mode. One is for Redis Clients to connect and run regular Redis text commands. That's the usual 'bind' or domain socket config. The other Redis Cluster instances connect to a special port and send binary-only commands in a completely different accept loop.

Redis would need a way to distinguish "this fd accepts client connections" vs. "this fd accepts cluster bus binary communication connections."

Also, having 100% inherited sockets means Redis listens to nothing on its own (explicit port 0 disables IP networking). Since Redis is listening to nothing on its own, it can't do the usual "port N + 10000" for cluster communication.

[Update: I just checked, and with port 0 + inherited sockets, Redis will listen on port 10,000 for cluster communication because 0 + 10000 = 10000 — but that will completely break Redis Cluster because other cluster nodes auto-calculate the peer N+10000 cluster port number based on the Redis client port they are given!]

Can you point out where it says that in the docs?

Maybe "docs" is too strong, but it's in a highly ranked page Google gave me (http://0pointer.de/blog/projects/three-levels-of-off):

You can disable a service. This unhooks a service from its activation triggers. That means, that depending on your service it will no longer be activated on boot, by socket or bus activation or by hardware plug (or any other trigger that applies to it).

(outdated?)

The benefit for us is integration with management tools that are systemd-aware.

Then I keep coming back to: socket activation is a fancy xinetd replacement, and nobody would think of running redis or mysql or postgres on-demand through xinetd.

which is quicker and more consistent than figuring out when the service is up.

That's the nice thing with Redis is: starting an empty Redis server takes almost no perceptible time!

So, all of this is probably a useful feature, but every mode of Redis can't be 100% socket activated currently. It's a great candidate for merging locally and running internally as long as you don't use Redis Cluster.

@davidstrauss

Copy link
Copy Markdown

Oh, I was just commenting on a Sentinel implementation detail. Sentinel always assumes it has exactly one IP/port, so I'm not sure what happens if you have systemd give it a unix domain socket file

An application should validate that the sockets its getting are functional for its needs. The correct way with socket activation is to inspect the socket you receive. You should also verify that you're getting a stream socket, if that's what you're expecting.

Redis would need a way to distinguish "this fd accepts client connections" vs. "this fd accepts cluster bus binary communication connections."

You have several options:

  1. Define an ordering of configuration, maybe client socket first and cluster socket second. The ordering of sockets configured in a socket unit determines which one arrives as fd=3, fd=4, etc.
  2. Check for some defined relationship, like the port of one socket being 10,000 higher than the other. Use the socket with the lower port for client communication and the higher one for clustering.
  3. Use redundant configuration so that Redis can look for an inherited socket matching expected configuration, and then use it there. This is how nginx and PHP-FPM handle inheriting sockets on configuration reload.
  4. Only support socket activation for non-clustered use.

Maybe "docs" is too strong, but it's in a highly ranked page Google gave me

Yes, that page is wrong, or at least outdated. I have a draft email to Lennart requesting corrections that I never finished and sent. :-/

Then I keep coming back to: socket activation is a fancy xinetd replacement, and nobody would think of running redis or mysql or postgres on-demand through xinetd.

But we're doing exactly that (on-request startup) for MariaDB (MySQL).

That's the nice thing with Redis is: starting an empty Redis server takes almost no perceptible time!

Empty Redis, yes, but not not-quite-empty Redis or other services we use. Starting the socket is a consistent way for us to say "this service is possible to connect to" without being daemon-specific.

@mattsta

mattsta commented Oct 22, 2014

Copy link
Copy Markdown
Contributor

Define an ordering of configuration, maybe client socket first and cluster socket second.

Yup. Redis is flexible though, in that it can accept a dynamic number of IPs and domain sockets to listen on for clients. So, we can't rely on static offsets. We'd need a new, and slightly ugly, config option specifying "cluster socket starts at fd offset X."

Check for some defined relationship, like the port of one socket being 10,000 higher than the other.

Yup. More possible things. It'll just take more code re-work than we have at the moment.

Use redundant configuration so that Redis can look for an inherited socket matching expected configuration

That's an interesting idea. "If already configured with our configuration, don't self-configure." It'll require more introspection of inherited things vs. requested configuration, but definitely possible.

Only support socket activation for non-clustered use.

Yup. That's essentially how it would work right now today with the code in this PR.

But we're doing exactly that (on-request startup) for MariaDB (MySQL).

But you are brilliant and/or crazy, so typical rules don't apply!

Starting the socket is a consistent way for us to say "this service is possible to connect to" without being daemon-specific.

Time to go write my own init system.

@davidstrauss

Copy link
Copy Markdown

Is there a reason why this has gone to the back burner again? The support works (within some constraints) and is a fairly isolated change that should only affect interested developers, admins, and distributions. Early 2016 will be Ubuntu's first LTS release with systemd, making almost all server-focused, long-term-supported Linux distributions compatible with using socket activation in about eight months.

@mitsuhiko

Copy link
Copy Markdown

I really, really want to see this being merged. Socket activation (or rather the ability to take over another socket) is also useful for some other uses of redis. In my case I want to automatically launch redis on a random port that is being selected by a unittest.

@stefanosc

Copy link
Copy Markdown

+1

@Jean-Daniel

Copy link
Copy Markdown

Other services that uses socket activation don't rely on systemd to properly configure the socket, but instead uses fcntl and friends to set non blocking mode and configure the socket as expected.

Why can't you do that here ?

@Glandos

Glandos commented Feb 26, 2022

Copy link
Copy Markdown

I'd like to bump this discussion. Socket activation is good on low-end system that don't need to have permanent redis server, since it hammers the CPU on idling (by opening /proc/XXX/stat every 100ms with a dozen gettimeofday in between). It will save both CPU and memory. E.g. on my server I need it for Nextcloud and rspamd, with a very low traffic, so redis can be started only on demand. I even wrote a little script to shutdown some unused services (https://framagit.org/Glandos/systemd-unneeded/) for that exact purpose.

It can be overcomed using systemd-socket-proxyd but honestly, this forces me to create two more units for a simple feature.

@eriksjolund

Copy link
Copy Markdown

A side-note: Container runtime support for socket activation has improved lately.
Podman version 3.4.0 (released September 2021)
supports running OCI containers (i.e. Docker containers) with socket activation.

I wrote a minimal demo for a MariaDB container. (That demo is not related to Redis though).

@yossigo

yossigo commented Mar 8, 2022

Copy link
Copy Markdown
Contributor

@eriksjolund @Glandos
Would it really make sense for Redis, as an in-memory data store, to be socket activated? I assume that to serve this purpose, it would also have to auto-shutdown at some point, so:

  • There's some load / save overhead on every activation / deactivation
  • When not running, Redis can't do things like expiration, etc.

I'm not very familiar with socket activation best practices (thinking about it in inetd terms, which probably does it injustice), but I wonder if it won't make more sense to optimize Redis to be more resource friendly when idle. In a way, that's already possible by tuning down the hz parameter - but I'm sure more can be done.

@eriksjolund

Copy link
Copy Markdown

@yossigo Maybe enabling socket activation would improve security?

I opened up a discussion thread in Podman GitHub repo

Disclaimer: I haven't used redis before, so I don't know if the redis server needs to
open up out-going connections to the network. If redis does not need that, I think adding the option --network=none to podman run will improve security. To do that socket activation support would be required in redis.

@Glandos

Glandos commented Mar 8, 2022 •

Copy link
Copy Markdown

The most general benefit is for system startup, when everything can be ordered correctly.
For low-end usage, this is more a niche, to avoid resource consumption when idling, but yes, optimizing Redis in this case is also a good way to go, for everyone.

In a way, that's already possible by tuning down the hz parameter - but I'm sure more can be done.
AH! Thanks for the tip, I already set it to 1. This is much better, even if in my case, I would like to set it to 0.1 ;)

@eriksjolund

eriksjolund commented Mar 8, 2022 •

Copy link
Copy Markdown

Another reason for adding socket activation support is that it would open up the possibility to upgrade the redis software version while running (i.e. active TCP connections would not need to be broken).
See podman-container-tools/podman#13348 (comment) for details how it could be implemented.
I plan to try it out some day to make a minimal demo (not related to Redis, though).

Of course, implementing this in Redis would be complicated, though. A sketch:

  1. When restarting, save the running state to a file (see sd_pid_notify_with_fds())
  2. A new socket activated Redis container would need to check if there is any file descriptor (see sd_listen_fds_with_names()) that has a running state saved. The data format of the saved state might change between different redis versions, so the newer versions would need to be able to read older data format versions.

@yossigo

yossigo commented Mar 8, 2022

Copy link
Copy Markdown
Contributor

@eriksjolund

Disclaimer: I haven't used redis before, so I don't know if the redis server needs to
open up out-going connections to the network. If redis does not need that, I think adding the option --network=none to podman run will improve security. To do that socket activation support would be required in redis.

It depends on how it is configured and used, but in the most general case where it's clustered or running as a replica then yes - it needs to establish outgoing connections.

Another reason for adding socket activation support is that it would open up the possibility to upgrade the redis software version while running (i.e. active TCP connections would not need to be broken).

This is interesting, but probably extremely difficult and not very practical in the case of Redis because there is a lot of dynamic client state involved. Also, because Redis is an in-memory data store, the most difficult part with crashes or restarts is the loss of data (in a crash) or the need to store to disk and then reload (in a restart) - that's typically more painful than the client side reconnect that's required.

@eriksjolund

eriksjolund commented Mar 8, 2022 •

Copy link
Copy Markdown

Also, because Redis is an in-memory data store, the most difficult part with crashes or restarts is the loss of data (in a crash) or the need to store to disk and then reload (in a restart)

The state would not have to be stored to disk. It could also be kept in memory.

systemd holds the file descriptor while the container is being restarted.

A quote from man sd_notify:
Application state can either be serialized to a file in /run/, or better, stored in a memory file descriptor. memfd_create(2)

@yossigo

yossigo commented Mar 8, 2022

Copy link
Copy Markdown
Contributor

@eriksjolund Just to clarify, I was referring to saving and loading the Redis dataset - not client state.

@eriksjolund

Copy link
Copy Markdown

@eriksjolund Just to clarify, I was referring to saving and loading the Redis dataset - not client state.

@yossigo
I think for systemd it does not matter what kind of information is stored.
In other words, it would not make any difference if the server process would store some general information or some information that is specific to a certain active client.
It is also possible to store multiple file descriptors. The file descriptors can later be referenced by the name that they were given when passed to systemd (see sd_pid_notify_with_fds().

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@MayCXC

MayCXC commented Sep 2, 2024 •

Copy link
Copy Markdown

I too would like to see this merged. It is a very beneficial way to get host networking performance in containerized environments, without actually resorting to use host networking. The need to serialize state for seamless restarts is also apparent, but a separate issue IMO.

Instead of a systemd specific approach based on LISTEN_FDS, I think that a config option fds 3 4 5 is more appropriate, along with a separate option tls-fds 6 7 8 for the fds of sockets used for TLS. In most cases, I would expect these to be used with port 0. This can work with systemd socket activation in most cases, and fancier configs can be generated from LISTEN_FDS and LISTEN_FDNAMES with a something like a shell script and envsubst if needed.

@yossigo would you expect a contribution with these configuration changes to be accepted? I need to implement it for myself, and it will not change any current redis behavior whatsoever, rather just enable it to run in bindless environments.

gabsow added a commit to gabsow/redis that referenced this pull request Jun 14, 2026
Bump the pinned RedisTimeSeries MODULE_VERSION from v8.8.0 to v8.9.80
in modules/redistimeseries/Makefile.

Note: v8.9.80 is the 8.10 LTS branch cut (targets Redis 8.10) and has
diverged from v8.8.0. Of the 37 commits reachable from v8.9.80 but not
v8.8.0, 7 are cherry-picks whose changes are already in v8.8.0 (verified
with `git cherry`); the 30 below are the genuinely new changes.

Changes (v8.8.0 -> v8.9.80):
- MOD-14124 — m commands acl (redis#1913)
- MOD-14250 — missing artifacts logs fix (redis#1932)
- MOD-14289 — Increase LibMR execution timeout for Valgrind builds (redis#1933)
- MOD-12726 — unique snapshot name + new output params for nighly event (redis#1937)
- MOD-14674 — oss refresh list (redis#1935)
- nightly build, upload snapshot artifact (redis#1954)
- MOD-14902 — existence check to prevent Timeseries crash when Redis is not aligned with new redis-core changes (redis#1940)
- MOD-14850 — Bump libmr (redis#1962)
- MOD-14715 — add apt retries/timeouts to Debian/Ubuntu Dockerfiles (redis#1965)
- MOD-15262 — Align TimeSeries with the RedisModule_GetUserUserName API changes (redis#1975)
- RED-180951 RED-180027 — fixing bugs and improving the code (redis#2004)
- MOD-14239 — Ignore known init-rdbchannel migration timeout under sanitizer (redis#1979)
- MOD-15105 — make one generic getUser function (redis#1981)
- MOD-15741 MOD-14091 — add dont-cache command tip to non-cacheable read commands (redis#2031)
- MOD-15731 — modules modernization alignment (redis#2027)
- MOD-15728 — Tal.ba/feat/blocking get (redis#2028)
- MOD-8187 — fix the aggregation bugs (fix reverse iterator) (redis#2036)
- MOD-15749 — Link to new version of LibMR with short-form CLUSTERSET and add tests (redis#2034)
- Fix REDISMODULE_MAIN typo + drop common.h forward-decl workarounds (redis#2044)
- CI: switch flow-linux arm64 runner to standard ubuntu-24.04-arm (redis#2048)
- MOD-15999 — Centralize Redis ref into a single source-of-truth file for CI (redis#2045)
- CI: trigger OSS cluster (multi-shard) benchmarks on demand (redis#2050)
- MOD-15899 — oom try calloc (redis#2051)
- MOD-8187 — fix non twa aggregation (redis#2053)
- MOD-16224 — Fix filter-blind neighbor lookups in EMPTY aggregation (redis#2056)
- MOD-15893 — Nrange new command (redis#2052)
- MOD-16160 — update blocking get syntax (redis#2054)
- MOD-16160 — Fix client-side cache tips for TS.BGET and TS.NRANGE/TS.NREVRANGE (redis#2057)
- Cut 8.10 LTS branch: bump version to 8.9.80, target Redis 8.10 (27484f7)
- Fix event-nightly CI on 8.10: read Redis ref from dedicated redis_ref field (redis#2058)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
YaacovHazan pushed a commit that referenced this pull request Jun 14, 2026
## Summary

Bumps the pinned `MODULE_VERSION` for **RedisTimeSeries** from `v8.8.0`
to `v8.9.80`. RedisBloom and RedisJSON are unchanged.

| Module          | From    | To       |
|-----------------|---------|----------|
| RedisTimeSeries | v8.8.0  | v8.9.80  |

> **Note:** `v8.9.80` is the **8.10 LTS branch cut** (targets Redis
8.10) and has diverged from `v8.8.0`. The `v8.8.0...v8.9.80` ancestry
diff contains 37 commits, but **7 are backports already shipped in
`v8.8.0`** (verified with `git cherry`, see below); the **30 genuinely
new** changes are listed here.

## Module changes ([v8.8.0 →
v8.9.80](RedisTimeSeries/RedisTimeSeries@v8.8.0...v8.9.80))

- MOD-14124 — m commands acl
([#1913](RedisTimeSeries/RedisTimeSeries#1913))
- MOD-14250 — missing artifacts logs fix
([#1932](RedisTimeSeries/RedisTimeSeries#1932))
- MOD-14289 — Increase LibMR execution timeout for Valgrind builds
([#1933](RedisTimeSeries/RedisTimeSeries#1933))
- MOD-12726 — unique snapshot name + new output params for nighly event
([#1937](RedisTimeSeries/RedisTimeSeries#1937))
- MOD-14674 — oss refresh list
([#1935](RedisTimeSeries/RedisTimeSeries#1935))
- nightly build, upload snapshot artifact
([#1954](RedisTimeSeries/RedisTimeSeries#1954))
- MOD-14902 — existence check to prevent Timeseries crash when Redis is
not aligned with new redis-core changes
([#1940](RedisTimeSeries/RedisTimeSeries#1940))
- MOD-14850 — Bump libmr
([#1962](RedisTimeSeries/RedisTimeSeries#1962))
- MOD-14715 — add apt retries/timeouts to Debian/Ubuntu Dockerfiles
([#1965](RedisTimeSeries/RedisTimeSeries#1965))
- MOD-15262 — Align TimeSeries with the RedisModule_GetUserUserName API
changes
([#1975](RedisTimeSeries/RedisTimeSeries#1975))
- RED-180951 RED-180027 — fixing bugs and improving the code
([#2004](RedisTimeSeries/RedisTimeSeries#2004))
- MOD-14239 — Ignore known init-rdbchannel migration timeout under
sanitizer
([#1979](RedisTimeSeries/RedisTimeSeries#1979))
- MOD-15105 — make one generic getUser function
([#1981](RedisTimeSeries/RedisTimeSeries#1981))
- MOD-15741 MOD-14091 — add dont-cache command tip to non-cacheable read
commands
([#2031](RedisTimeSeries/RedisTimeSeries#2031))
- MOD-15731 — modules modernization alignment
([#2027](RedisTimeSeries/RedisTimeSeries#2027))
- MOD-15728 — Tal.ba/feat/blocking get
([#2028](RedisTimeSeries/RedisTimeSeries#2028))
- MOD-8187 — fix the aggregation bugs (fix reverse iterator)
([#2036](RedisTimeSeries/RedisTimeSeries#2036))
- MOD-15749 — Link to new version of LibMR with short-form CLUSTERSET
and add tests
([#2034](RedisTimeSeries/RedisTimeSeries#2034))
- Fix REDISMODULE_MAIN typo + drop common.h forward-decl workarounds
([#2044](RedisTimeSeries/RedisTimeSeries#2044))
- CI: switch flow-linux arm64 runner to standard ubuntu-24.04-arm
([#2048](RedisTimeSeries/RedisTimeSeries#2048))
- MOD-15999 — Centralize Redis ref into a single source-of-truth file
for CI
([#2045](RedisTimeSeries/RedisTimeSeries#2045))
- CI: trigger OSS cluster (multi-shard) benchmarks on demand
([#2050](RedisTimeSeries/RedisTimeSeries#2050))
- MOD-15899 — oom try calloc
([#2051](RedisTimeSeries/RedisTimeSeries#2051))
- MOD-8187 — fix non twa aggregation
([#2053](RedisTimeSeries/RedisTimeSeries#2053))
- MOD-16224 — Fix filter-blind neighbor lookups in EMPTY aggregation
([#2056](RedisTimeSeries/RedisTimeSeries#2056))
- MOD-15893 — Nrange new command
([#2052](RedisTimeSeries/RedisTimeSeries#2052))
- MOD-16160 — update blocking get syntax
([#2054](RedisTimeSeries/RedisTimeSeries#2054))
- MOD-16160 — Fix client-side cache tips for TS.BGET and
TS.NRANGE/TS.NREVRANGE
([#2057](RedisTimeSeries/RedisTimeSeries#2057))
- Cut 8.10 LTS branch: bump version to 8.9.80, target Redis 8.10
([27484f7](RedisTimeSeries/RedisTimeSeries@27484f7))
- Fix event-nightly CI on 8.10: read Redis ref from dedicated redis_ref
field
([#2058](RedisTimeSeries/RedisTimeSeries#2058))

<details>
<summary>7 commits excluded — already shipped in v8.8.0 as
backports</summary>

These show up in the `v8.8.0...v8.9.80` ancestry diff with different
SHAs, but `git cherry` confirms their patch content is already in
`v8.8.0`: they were backported to the 8.8 release branch (the "in 8.8
via" PR below), so they are **not** new in this bump.

- MOD-9320 — Multiple aggregators single command
([#1916](RedisTimeSeries/RedisTimeSeries#1916))
→ in 8.8 via
[#1921](RedisTimeSeries/RedisTimeSeries#1921)
- MOD-9320 — rename AGGREGATION token in m commands
([#1926](RedisTimeSeries/RedisTimeSeries#1926))
→ in 8.8 via
[#1927](RedisTimeSeries/RedisTimeSeries#1927)
- MOD-13142 — Allow changing number of threads while pool hasn't started
([#1928](RedisTimeSeries/RedisTimeSeries#1928))
→ in 8.8 via
[#1934](RedisTimeSeries/RedisTimeSeries#1934)
- MOD-14439 — Detect cluster topology changes during a multi-shard
command
([#1930](RedisTimeSeries/RedisTimeSeries#1930))
→ in 8.8 under the same PR
- ci: skip Event CI when PR only changes src/version.h
([#1984](RedisTimeSeries/RedisTimeSeries#1984))
→ in 8.8 via
[#1986](RedisTimeSeries/RedisTimeSeries#1986)
- MOD-15020 — remove bionic os support
([#1983](RedisTimeSeries/RedisTimeSeries#1983))
→ in 8.8 via
[#1996](RedisTimeSeries/RedisTimeSeries#1996)
- MOD-14420 — fix count reducers return wrong NaN
([#2013](RedisTimeSeries/RedisTimeSeries#2013))
→ in 8.8 via
[#2016](RedisTimeSeries/RedisTimeSeries#2016)

</details>

## Test plan
- [ ] CI passes for RedisTimeSeries at the new pinned version
- [ ] `make all` builds RedisTimeSeries cleanly against `unstable`
- [ ] Module tests run under `make test`

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.