Skip to content

[Server] Test the SIGTERM shutdown path in a forked JVM #2064

Open

Description

@shba24

What

Add an automated test for what happens when the server process gets SIGTERM. Today nothing fails if the shutdown hook in UnityCatalogServer.main, or the exec in bin/start-uc-server, is removed: UnityCatalogServerShutdownTest calls close() directly, so it never runs the JVM hook or the other libraries' own hooks at JVM exit.

Why

#2059 makes SIGTERM drain in-flight requests and then run close(). Two problems in that path only showed up by running the process and sending SIGTERM by hand:

  • Log4j's own JVM hook stopped logging while requests were still draining.
  • H2's own JVM hook closed the file database during the drain, so a request that touched the database after SIGTERM failed (fixed with DB_CLOSE_ON_EXIT=FALSE).

A test would catch these, and future regressions, in CI.

Suggested approach

A forked-JVM test in the server module:

  1. A small test main builds the server on an H2 file URL, with a credential vendor that waits a fixed time and then queries the database.
  2. The test starts it with ProcessBuilder, sends a request that reaches the slow vendor, then calls process.destroy() (SIGTERM) while the request is in flight.
  3. It asserts that the request returns 200 and that the process exits with code 143.

Raised in review of #2059.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions