You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/08/18 02:30:46 UTC
[I] [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start [seatunnel]
DanielLeens opened a new issue, #11846:
URL: https://github.com/apache/seatunnel/issues/11846
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue) and found no similar issues.
### What happened
The Zeta REST `/metrics` endpoint can answer `500 Internal Server Error` to a scraper that hits a member in the window between the member reaching STARTED (Jetty listener already accepting) and `CoordinatorService` finishing its wiring.
Mechanism, from source on current `dev`:
- `SeaTunnelServer.init()` starts Jetty synchronously, while `CoordinatorService` becomes active asynchronously.
- `MetricsServlet.doGet()` iterates `collectorRegistry.metricFamilySamples()` in a single pass with no per-collector isolation.
- Collectors such as `JobMetricExports.collect()` guard with check-then-act (`isMaster() && isCoordinatorReady()`) and then dereference coordinator-owned state; `SeaTunnelServer.getCoordinatorService()` throws `SeaTunnelEngineRetryableException` while the coordinator is still wiring up, and readiness can also flip between the check and the access.
- `ExceptionHandlingFilter.doFilter()` converts any escaping collector exception into a 500 whose JSON body embeds the full Java stack trace.
So one not-yet-ready collector aborts the whole scrape, and the scraper receives a 500 with an internal stack trace.
This was discovered through `MetricsApiTest#metricsApiTest` flaking in CI with `Expected status code <200> but was <500>` on at least five unrelated PRs (#10874, #10958, #10973, #11060, #11382). PR #11641 stabilizes that test by polling until the endpoint is serviceable — which is correct for the test, but it also means CI no longer surfaces this window. This issue exists so the production-side gap is tracked rather than silently absorbed by the test change (raised by @SEZ9 in the #11641 reviews).
### What you expected to happen
A freshly started (or re-electing) member should not answer `/metrics` with a 500 + stack trace during normal startup. Options worth evaluating:
1. Have each coordinator-dependent collector return an empty/partial metric family while its backing service is unavailable (the pattern `EngineStateStoreLogicalMetricExports` already follows), instead of throwing.
2. Isolate per-collector failures in `MetricsServlet` so one throwing collector degrades that collector's families instead of aborting the entire scrape.
3. Answer `503 Service Unavailable` (optionally with `Retry-After`) until `CoordinatorService` is ready — Prometheus records that as an explicit scrape failure with a clear cause rather than a server error.
Any of these also stops the endpoint from leaking internal stack traces to whatever can reach the scrape port.
### How to reproduce
Start a Zeta member with telemetry metrics and the HTTP listener enabled, and issue `GET /metrics` immediately after `createHazelcastInstance(...)` returns — before the coordinator finishes wiring. Intermittently returns 500 with a stack-trace body. The pre-#11641 version of `MetricsApiTest#metricsApiTest` is a ready-made reproducer (single un-retried GET right after startup).
### SeaTunnel Version
dev
### SeaTunnel Config
```conf
Not job-config related; engine REST/telemetry startup ordering.
```
### Running Command
```shell
See "How to reproduce".
```
### Error Exception
```log
Expected status code <200> but was <500>.
(500 body carries the collector's stack trace via ExceptionHandlingFilter)
```
### Zeta or Flink or Spark Version
Zeta
### Java or Scala Version
_No response_
### Screenshots
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #11846:
URL: https://github.com/apache/seatunnel/issues/11846#issuecomment-5385645093
Thanks for the detailed analysis with code paths and CI evidence (flakes on #10874, #10958, #10973, #11060, #11382). Confirming this is a valid production-side gap that PR #11641 only masks in tests; keeping this open to track a real fix.
Suggested direction: make collectors like JobMetricExports.collect() fail-soft — catch SeaTunnelEngineRetryableException (and readiness races) and return empty samples instead of throwing, so one unready collector cannot fail the entire scrape. Alternatively, have /metrics return 503 Service Unavailable (without a stack trace) until CoordinatorService is wired up.
Independent hardening: ExceptionHandlingFilter should not embed full Java stack traces in HTTP response bodies — log them server-side and return a generic error message. This is worth fixing regardless of the readiness race.
<!-- streview-comment:472 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on issue #11846:
URL: https://github.com/apache/seatunnel/issues/11846#issuecomment-6376382513
Closing this issue as completed after rechecking the original report and its resolution.
Both affected metrics collectors now handle the transient coordinator-unavailable lookup after their readiness checks, avoiding the reported startup-race `/metrics` 500 response while leaving unrelated exceptions visible.
Resolution evidence:
- [PR #11991](https://github.com/apache/seatunnel/pull/11991), merged into `dev` on 2026-08-31 ([merge commit `b4158f01ddf9`](https://github.com/apache/seatunnel/commit/b4158f01ddf9c3a1dda3a48a559d4ae6aec557d2)).
The corresponding implementation remains present in [`dev` at `14a27ac26a0a`](https://github.com/apache/seatunnel/commit/14a27ac26a0a71b56722f86cdf8ec2779094ceaf).
<!-- seatunnel-closure-audit:20261023:11846 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #11846:
URL: https://github.com/apache/seatunnel/issues/11846#issuecomment-5453918735
Thanks for opening `#11991`.
I rechecked current `dev` at `1ff72ceb3d2a823a0fca64ec009984d75e846c28`. The earlier non-blocking readiness guards from `#10841` are already on the branch, but the narrower race you are fixing is still real: a collector can pass the readiness check and then hit `getCoordinatorService()` after coordinator state changes, which still turns the scrape into a `/metrics` failure window.
So `#11991` is the right follow-up scope for the remaining gap. The merge bar here should stay narrow:
1. return empty samples only for this transient coordinator-startup race;
2. keep unexpected exceptions visible instead of masking unrelated bugs;
3. keep the regression coverage focused on the collectors that still cross this path.
Once the branch is green, this issue will be much closer to closure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start [seatunnel]
Posted by "hutiefang76 (via GitHub)" <gi...@apache.org>.
hutiefang76 commented on issue #11846:
URL: https://github.com/apache/seatunnel/issues/11846#issuecomment-5442202927
Opened #11991 with a narrow collector-side readiness guard and regression coverage for both affected collectors. The change returns no samples only when getCoordinatorService() raises SeaTunnelEngineRetryableException after the existing readiness check; unexpected exceptions still propagate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo closed issue #11846: [Bug] [Zeta] /metrics answers 500 with a stack-trace body while CoordinatorService is still wiring up after member start
URL: https://github.com/apache/seatunnel/issues/11846
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org