Skip to content

The shutdown-hook WARNING (and the setting description) point at arcadedb.server.shutdownTimeout on the one path that ignores it #6981

Closed

Description

@ruispereira

Summary

The shutdown hook uses a hardcoded 2000ms wait when status == STARTING, and arcadedb.server.shutdownTimeout for every other status. That choice looks deliberate and I am not challenging it. What is wrong is that both user-facing texts point the operator at shutdownTimeout for exactly the start() case it does not govern: the WARNING message says to raise it, and the setting's own description names start() as a situation where it matters.

An operator who hits this raises a setting that cannot affect the path they are on. I did, before reading the source.

Where (HEAD 55e00aaa6)

server/src/main/java/com/arcadedb/server/ArcadeDBServer.java:544-556:

private void stopFromShutdownHook() {
  final long timeout = status == STATUS.STARTING
      ? SHUTDOWN_HOOK_STARTING_TIMEOUT_MS                                    // 2_000, line 116
      : configuration.getValueAsLong(GlobalConfiguration.SERVER_SHUTDOWN_TIMEOUT);

  if (!awaitLifecycleLock(lifecycleLock, timeout)) {
    LogManager.instance().log(this, Level.WARNING,
        """
        Could not acquire the server lifecycle lock within %dms while status is %s, ... Raise \
        arcadedb.server.shutdownTimeout if a legitimate shutdown needs longer.""",
        timeout, status);

The hint is emitted on both branches, but on the STARTING branch the named setting is the one value that provably had no effect.

engine/src/main/java/com/arcadedb/GlobalConfiguration.java:1315-1323 says the same thing:

Milliseconds the JVM shutdown hook waits for the server lifecycle lock before giving up ...
It only matters when another thread is inside start()/stop() when the shutdown signal arrives

"inside start()" is precisely when status == STARTING, i.e. when the hardcoded 2000ms is used instead.

How this showed up

A Kubernetes StatefulSet running 26.8.1 in a 3-node Raft cluster. A liveness probe with no initialDelaySeconds and no startupProbe killed the container mid-startup - our own chart's fault, not yours - and the log said:

Could not acquire the server lifecycle lock within 2000ms while status is STARTING, so the shutdown
hook is returning WITHOUT a graceful stop and the JVM will exit. ... Open databases were not closed
cleanly; the next open replays the WAL. Raise arcadedb.server.shutdownTimeout if a legitimate
shutdown needs longer.

The server already had arcadedb.server.shutdownTimeout = 60000 - visible in that same container's own config dump a few lines above. Following the hint would have changed nothing, and the unclean shutdown made each restart slower than the last (WAL replay on all three databases), so the pod went round six times before winning the race.

To be clear about attribution: the restart loop was caused by our probe configuration. The only thing I am reporting is that the diagnostic sent me to the wrong lever.

A secondary question on the same path

The javadoc at :534-536 justifies the short wait with "the server never came up, so there is nothing worth flushing". On this path the databases were already open - the log shows Gremlin registering them a second earlier - and the next boot reported Database 'X' was not closed properly last time for all three. So on this occasion there was something worth flushing, and the message itself says so ("Open databases were not closed cleanly") one clause before the javadoc's premise says there is not.

I am raising this as a question rather than a claim: is the 2000ms meant to cover the window after databases are open but before start() returns, or is that window an unintended gap? The "unkillable process" reasoning from #5418 argues for keeping a bound either way.

Suggested fix

Smallest version: make the hint conditional. On the STARTING branch say the wait is a fixed 2000ms that shutdownTimeout does not govern, and drop the "raise it" advice there. Amend the setting's description so it does not claim to cover start().

Larger version, if the gap above is real: give the STARTING wait its own setting (or let shutdownTimeout govern it with a low default), so an operator whose databases are open during a slow start can buy a clean close.

Scope / confidence

High on the misleading hint - the code path, the constant and both texts are quoted above, and I confirmed SERVER_SHUTDOWN_TIMEOUT has exactly one non-test reader (ArcadeDBServer.java:547), on the branch that excludes STARTING. Medium on the secondary question, which is why it is phrased as one.

Activity

  1. added this to the 26.9.1 milestone on Sep 1, 2026
  2. added
    server
    documentation
    on Sep 1, 2026
  3. added a commit that references this issue on Sep 1, 2026
  4. added 2 commits that reference this issue on Sep 1, 2026
  5. robfrank commented on Sep 2, 2026

    @robfrank
    Collaborator

    Fixed in #7013, released in the next build.

    You were right on both texts, and the diagnosis was precise enough that the fix landed exactly where you pointed. The shutdown-hook WARNING now builds its advice from the status it actually applied a bound for: while STARTING it tells you the 2000ms wait is a fixed bound that arcadedb.server.shutdownTimeout does not govern, and only the other branches keep the "raise it" advice. The setting's own description no longer claims to cover start(), and instead spells out what it does cover - a stop() in progress, or the tail of a start() that has already turned ONLINE but not yet released the lifecycle lock. So the log line and the setting can no longer send you to a lever that isn't connected to anything.

    On your secondary question - whether the 2000ms should cover the window after the databases are open but before start() returns - you identified something real, and it is deliberately still open. Your case (databases open, Gremlin already registering them, three unclean closes) is exactly the window where the javadoc's "nothing worth flushing" premise does not hold. That is a behavioural change rather than a wording one, so it was kept out of this fix and is tracked separately; the bound itself stays, since #5418's unkillable-process reasoning applies either way.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  6. robfrank commented on Sep 2, 2026

    @robfrank
    Collaborator

    Followed up on your secondary question: filed as #7025.

    You were right to raise it. Tracing startInternal() on main, loadDatabases() runs at line 314 while status = STATUS.ONLINE is only set at line 356 - so databases are open for that entire span (HTTP start, every plugin phase, HA bring-up) with the status still reading STARTING and the fixed 2000ms still in force. The javadoc's "nothing worth flushing" premise only holds for the first sixty lines of a window that is much longer than that, which is exactly what your cluster ran into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdocumentationserver

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions