Skip to content

[Server] Wait for the client-facing port before reporting the server started - #1855

Merged
yili-db merged 1 commit into
unitycatalog:mainfrom
moomindani:fix/server-readiness-transcoder-port
Sep 10, 2026
Merged

yili-db merged 1 commit into
unitycatalog:mainfrom
moomindani:fix/server-readiness-transcoder-port

Conversation

@moomindani

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Fixes #1854.

The server reported itself started before the port clients use was listening. main awaited Armeria on port + 1 and then deployed the Vert.x URL transcoder for the client-facing port without awaiting it, and URLTranscoderVerticle.start() returned as soon as server.listen had been called. A bind failure on that port was logged at INFO and dropped, since deployVerticle's result was never inspected, so the process kept running and exited 0 while serving nothing on the port every client connects to.

The Python client suite hit the first half of this in CI (1 failed, 34 passed, the failure being the first test to issue a request), because its fixture waits for the internal port and then talks to the client-facing one.

Technical changes:

  • URLTranscoderVerticle takes the Promise<Void> form of start and completes it from the listen callback, so the deployment completes only once the port is bound and fails with the bind error otherwise.
  • UnityCatalogServer.main waits for that deployment and, if it fails, logs which port could not be bound, closes the server and rethrows. A server that cannot serve the port its clients use now exits non-zero instead of running half-up.
  • The three readiness probes that waited on the internal port -- clients/python/tests/conftest.py, tests/test_tutorial.py, tests/test_tarball_generation.py -- now probe the port those suites actually use. The fixed time.sleep calls that were masking the race in the latter two are left as they are; this change is about waiting for the right thing, not about retuning those waits.

Testing:

  • URLTranscoderVerticleTest.testDeploymentFailsWhenTheTranscodePortIsTaken occupies a port and asserts the deployment fails with a BindException. It fails on an unfixed tree, where the deployment reports success. The test class's awaitPort polling helper is gone: deployment now means the port is listening, which is what its comment used to work around.
  • build/sbt "server/testOnly io.unitycatalog.server.URLTranscoderVerticleTest" and build/sbt -J-Xmx2G "server/test".
  • Validated against a running server. HEAD / on the client-facing port answers 200, which is what the probes assert. With that port occupied by another process, the server now logs Failed to start the URL transcoder on port 8080, stops cleanly ("Unity Catalog server stopped.", pool cleanup) and exits 1, where before it stayed up on the internal port only.
  • Ran the Python client suite against a server started by bin/start-uc-server with the updated fixture: it came up and ran in 9.7s (3 failed, 32 passed); the three failures are bin/uc invocations, which need the CLI jar I had not built locally.

Backward compatibility: a deployment that could not bind the client-facing port used to leave the process running; it now fails the startup. That is the point of the change -- such a server cannot serve any client -- but it is a behaviour change for anyone who was starting the server with that port already in use.

…started

main awaited Armeria on port + 1 and then deployed the Vert.x URL transcoder
for the port clients use without awaiting it, and the verticle returned as soon
as listen had been called, so the server reported itself started while that port
was not yet accepting connections. A bind failure there was logged at INFO and
dropped, since the deployment result was never inspected, leaving the process
running and exiting 0 while serving nothing on the port every client connects
to.

The verticle now completes the deployment from its listen callback, and main
waits for it and fails the startup if the port cannot be bound. The three
readiness probes in the test harnesses waited on the internal port and then
talked to the client-facing one, which is how the Python client suite failed in
CI; they now probe the port they use.

Signed-off-by: Noritaka Sekiyama <[email protected]>

@tdas tdas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for fixing this corner case.

@yili-db
yili-db merged commit 23a0936 into unitycatalog:main Sep 10, 2026
18 checks passed
yili-db pushed a commit that referenced this pull request Oct 26, 2026
…L transcoder (#1979)

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

Today the launcher runs a Vert.x verticle on the client port. It
forwards every request over HTTP/1.1 to Armeria on `port + 1`. It does
one rewrite: Iceberg's nested-namespace separator `%1F` becomes `.`, in
the path and in query values. Unity Catalog has no nested namespaces, so
that rewrite doesn't make any request succeed. It only changes which
error a client gets for a name it could never resolve.

#1918 had to size the transcoder's connection pool to the JDBC pool, and
answer `/livez` in front of it, so a saturated proxy wouldn't become the
bottleneck. Removing the transcoder makes all of that unnecessary.

This change:
- removes `URLTranscoderVerticle` and the `vertx-core`, `vertx-web` and
`vertx-web-client` dependencies;
- binds Armeria to the `-p` port in `main`, instead of `port + 1`, and
closes the server if it can't start;
- binds the API port on all interfaces. Clients now connect to it
directly, and the loopback bind from #1750 only existed because the
transcoder sat in front;
- drops the `port + 1` handling from the observability-port check;
- updates `docs/server/observability.md`, which described the client
port and the internal `port + 1` API port.

**Reasons**

- **Simpler implementation:** the server runs as one Armeria process on
one port, with no Vert.x proxy in front.
  - About 410 lines go, including the transcoder and its 250-line test.
- **Removes the unused `\^_` transcoding:** Unity Catalog has no nested
namespaces, so rewriting `%1F` to `.` never made a request succeed.
- **Fewer dependencies:** `vertx-core`, `vertx-web` and
`vertx-web-client` are removed, so there are fewer libraries to patch
for CVEs.
- **No proxy pool to size:** the workarounds #1918 needed go away, i.e.
matching the proxy pool to JDBC and answering `/livez` in front of it.
- **Better tail latency under load:** cheap requests no longer queue for
a shared HTTP/1.1 connection pool or run through a single Vert.x thread.
- The saving per request is small, under a millisecond; the gain is
mostly in p99 under concurrency.
- **Fixes Datadog spans:** spans aren't closed properly, likely because
the Datadog agent doesn't support the Vert.x transcoder, so they stay
open until the client drops the idle connection about 30s later.
- **No more hidden proxy behaviour:** request and response bodies are no
longer held in memory, there are no unconfigurable timeouts, and the
code that caused bugs #1716 and #1855 is gone.
- **Real client addresses:** Armeria sees the caller's actual IP instead
of `127.0.0.1`, which helps logging and metrics.
- **HTTP/2 end to end:** HTTP/2 clients reach Armeria directly instead
of being downgraded to HTTP/1.1.

**Behavior changes**

- The server listens on one API port. Nothing binds `port + 1` any more.
- The API port is reachable from other machines again, as it was before
#1750. Deployments that put a network policy in front of it are
unaffected.
- `GET /v1/catalogs/{c}/namespaces/a%1Fb` and `GET
/v1/catalogs/{c}/namespaces?parent=a%1Fb` now return `404
NoSuchNamespaceException` instead of `400`. Neither form ever matched a
schema.
- The `hostname_pattern` label of `http_server_requests_total` now names
the `-p` port (`*:8080` by default) instead of `port + 1` (`*:8081`).
Dashboards or alerts that filter on `*:8081` need updating.
- One fewer hop and one fewer HTTP/1.1 connection pool per request.
HTTP/2 clients now reach Armeria directly.

No REST API, property, or CLI changes.

**Verification**

- `build/sbt javafmtAll`
- `build/sbt "server/testOnly
io.unitycatalog.server.ArmeriaServerBuilderTest
io.unitycatalog.server.UnityCatalogServerTest
io.unitycatalog.server.UnityCatalogServerShutdownTest
io.unitycatalog.server.EventLoopStallTest
io.unitycatalog.server.service.IcebergRestCatalogTest"`: 42 tests. The
first run had one `ServerPortBindException` on a random test port.
`IcebergRestCatalogTest` then passed 26/26 on rerun.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: s-maling-celonis <[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.

[Server] The server reports itself started before the client-facing port is listening

3 participants