You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
check-alerts worker: 13 error spans (mongodb.create, NamespaceExists) every minute because mongoose autoCreate is still on #3308
Our self-hosted HyperDX sends its own telemetry to a collector, so we see what the check-alerts worker does. Every minute its trace contains 13 failed spans named mongodb.create with the status message "Collection already exists", one per model: hyperdx.alerts, alerthistories, connections, dashboards, favorites, pinnedfilters, presetdashboardfilters, savedsearches, sources, teams, teaminvites, users and webhooks. On an idle instance that adds up to roughly 19 000 error spans a day, and the Service Dashboard shows a 55 % client error rate for the hyperdx service. Nothing is actually broken, alerts still run.
The cause, as far as I can tell from the code: DefaultAlertProvider.init() opens a new connection on every run (connectDB with autoIndex false) and asyncDispose() closes it again. Mongoose still has autoCreate on, so on every fresh connection Model.init() calls createCollection for each model. The collections exist, MongoDB answers NamespaceExists (code 48), Mongoose ignores that error, but the OpenTelemetry mongodb instrumentation has already recorded a failed command.
PR #2887 turned autoIndex off in that worker for the same reason (the API service owns the schema). Passing autoCreate: false alongside it should remove the 13 commands per run. Happy to open that PR if you want it.
Steps to reproduce
Run the hyperdx image with HYPERDX_API_KEY and OTEL_EXPORTER_OTLP_ENDPOINT pointing at a collector.
Wait a minute for the check-alerts cron.
Search traces for StatusCode:Error – 13 mongodb.create spans per minute.
How are you running HyperDX?
Self-hosted, image hyperdx/hyperdx:2.40.0 with mongo:5.0.32 as rootless Podman containers; own ClickHouse 26.8 and OpenTelemetry Collector 0.162.0 on separate hosts.
Where does it show up?
In the traces of the hyperdx service itself (Search with source Traces, Service Dashboard). Not a UI bug.
I reproduced this against a local MongoDB 5: with autoCreate on (Mongoose default), each worker reconnect re-sends createCollection for every model and they fail with "already exists". Passing autoCreate: false alongside the existing autoIndex: false in the check-alerts provider's connectDB call removes them (0 create commands across reconnects). I have the change ready with a unit test and a changeset; happy to open a PR if you'd like to accept one (or @sobcvogl if you'd prefer to do it, no problem).
Activity
AmineBenzaazaa commentedon Oct 22, 2026
I reproduced this against a local MongoDB 5: with autoCreate on (Mongoose default), each worker reconnect re-sends createCollection for every model and they fail with "already exists". Passing autoCreate: false alongside the existing autoIndex: false in the check-alerts provider's connectDB call removes them (0 create commands across reconnects). I have the change ready with a unit test and a changeset; happy to open a PR if you'd like to accept one (or @sobcvogl if you'd prefer to do it, no problem).