Giter VIP home page Giter VIP logo

Comments (6)

hderms avatar hderms commented on May 27, 2024 1

will look into this

from pelikan.

thinkingfish avatar thinkingfish commented on May 27, 2024

I think we should aim for a solution that will handle more signals than SIGINT in the diff, which probably means using signal-hook based solutions. Here are considerations for saying that:

  1. Pelikan (legacy) and Twemcache both use SIGHUP to perform (nocopytruncate) log rotation, here's the code in Pelikan's C implementation as a reference;
  2. Memcached recognizes SIGHUP though it doesn't really do anything with it. It uses SIGUSR1 to perform graceful shutdown (typically when data is persisted on PMEM or extstore) instead of immediate shutdown.
  3. Redis uses SIGUSR1 to kill the background save thread that's writes to the AOFs (code).

SIGINT & SIGTERM are generally supported by all existing cache backend, so we should treat that as the baseline to match. ctrlc does support both, but given the above considerations, we probably need a general solution sooner rather than later.

from pelikan.

masih avatar masih commented on May 27, 2024

Thank you folks for your quick response on this issue. It would be fantastic if a simple handling of server termination via SIGINT is not blocked by a more sophisticated multi signal handling solution.

from pelikan.

hderms avatar hderms commented on May 27, 2024

w.r.t log rotation: @brayniac https://github.com/pelikan-io/rustcommon/blob/main/ringlog/src/outputs.rs#L80 it seems like ringlog automatically rotates files, but only if the size has been exceeded. If we wanted to force rotation (assuming we want to eventually emulate Pelikan legacy SIGHUP handling) would we want to modify Ringlog to have a forced rotation (i.e. regardless of whether size is exceeded)?

SIGHUP:

If we ever wanted to have SIGHUP force log rotation, a la Pelikan-legacy, it seems like we'd probably want to hold off on handling that signal via graceful shutdown

SIGUSR1:

SIGUSR1 seems like something worth handling similar to Redis once we have a persistence

SIGINT

We should use our current graceful shutdown

SIGTERM

We should use our current graceful shutdown

@thinkingfish since there isn't any persistence right now, then I'm assuming we don't want to do anything with SIGUSR1. Which then it seems like we have a few options currently:

  1. Handle SIGINT/SIGTERM/SIGHUP all through graceful shutdown
    a. violates potential desire to have SIGHUP do log rotation. If we changed SIGHUP to do log rotation in the future, that would presumably be considered a breaking change.
    b. this would be easy to do with ctrl-c by using the termination feature
  2. Handle only SIGINT through graceful shutdown
    a. we can do this using ctrl-c crate but not activating the termination feature
  3. Handle SIGINT and SIGTERM through graceful shutdown, but do nothing with SIGHUP until we have persistence
    a. we would have to use the signal-hook crate (or something equivalent) so we can specify which signals we want to do what with

from pelikan.

hderms avatar hderms commented on May 27, 2024

ok I have set up my PR https://github.com/pelikan-io/pelikan/pull/79/files/b0296bcf6882bf388175ee6153a138dde96fd4de..fb1513df7a0309651cf57d6d3d00772bad5ec8f8 to use signal-hook instead in the commits I linked and it isn't much more complex than ctrlc.

I'm not doing anything specific with SIGHUP at the moment as forced log rotation seems like a reasonable iterative enhancement and it wasn't clear to me if it was necessary with the Ringlog style automatic rotation (or even if it's currently exposed to the user at all as something they can initiate)

all it does currently is handle SIGINT/SIGTERM/SIGHUP on *nix style operating systems by prompting shutdown of listeners/workers over the admin channel

This solution will not work for Windows but Windows portability is not considered a priority for Pelikan

from pelikan.

masih avatar masih commented on May 27, 2024

Thank you all

from pelikan.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.