Retire known-endpoints scatter-gather and audit KnownEndpoints storage#5619
Draft
johnsimons wants to merge 1 commit into
Draft
Retire known-endpoints scatter-gather and audit KnownEndpoints storage#5619johnsimons wants to merge 1 commit into
johnsimons wants to merge 1 commit into
Conversation
Retire known-endpoints scatter-gather and audit KnownEndpoints storage
The audit instance's KnownEndpoint documents (and their LastSeen field)
were written on every ingested batch but only ever read back by the
/endpoints/known scatter-gather, which no shipping client depends on:
ServicePulse never calls the route, and ServiceInsight only consumes
identity fields that the primary can serve locally. Endpoint discovery
already flows to the primary via RegisterNewEndpoint queue messages,
so the remote query added nothing but edge cases (pre-4.5 endpoints
without a HostId, in-flight registrations, primary-deleted endpoints
still present in audit data).
- Primary GET /endpoints/known now serves from the in-memory endpoint
registry; GetKnownEndpointsApi is deleted
- PATCH /endpoints/{id} returns 404 for unknown endpoints instead of
crashing with KeyNotFoundException (500)
- Audit ingestion no longer records KnownEndpoint documents; the model,
RecordKnownEndpoint, and QueryKnownEndpoints are removed from the
persistence seam and both implementations
- The audit /endpoints/known route remains as a backwards-compatibility
stub returning an empty result so older primaries that still
scatter-gather get a valid response instead of a 404
Existing audit KnownEndpoint documents expire on their own via the
RavenDB @expires metadata; no migration is needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
While preparing the new EF persisters we traced what the audit instance's
KnownEndpointdocuments are actually for, and why the primary and audit instances each have their ownKnownEndpointwith different fields (MonitoredvsLastSeen).1. Audit
LastSeenis written but never read. AuditPersister keeps it updated to the maxProcessedAt, but the audit query strips it before returning, so no API, index, or query ever consumes it. It's a leftover from the pre-RavenDB5 retention cleaner (193c3cf, 2020) which deleted KnownEndpoints whereLastSeen < cutoff. Since RavenDB 5, retention is handled by the@expiresdocument metadata stamped on every store (RavenAuditIngestionUnitOfWork) —LastSeenplays no part.2. The primary already learns about every endpoint via messaging, not the scatter-gather. The audit instance pushes
RegisterNewEndpointmessages on first sight of an endpoint (DetectNewEndpointsFromAuditImportsEnricher); the primary persists it durably viaCreateIfNotExists, which never clobbers a user'sMonitoredchoice on re-announcement. The/endpoints/knownscatter-gather only contributed edge cases: pre-4.5 endpoints (noHostId, never pushed), in-flight registrations, and endpoints deleted from the primary but still present in audit data.3. The audit KnownEndpoints storage had exactly one writer and one reader. Writer: ingestion (
RecordKnownEndpoint). Reader: the audit/endpoints/knownroute serving the scatter-gather. TheRegisterNewEndpointpush doesn't touch the store (its dedup cache is in-memory only).4. No shipping client needs the remote data. ServicePulse never calls
/endpoints/known(the root document'sknown_endpoints_urlis parsed into a store and never read; all endpoint UI flows useGET /endpoints,PATCH/DELETE /endpoints/{id},heartbeats/stats,endpointssettings— all primary-local). ServiceInsight (supported until 2027-02-10) does call it viaDefaultServiceControl.GetEndpoints(), but only consumes identity fields (endpoint_details+host_display_name) that the primary serves locally — neverMonitoredorLastSeen.Removing this now means the audit EF persister needs no KnownEndpoints table at all.
What
Primary instance
GET /endpoints/knownserves from the in-memory endpoint registry (same response shape and query-stats headers);GetKnownEndpointsApideleted.PATCH /endpoints/{id}now returns 404 for endpoints the primary doesn't know, instead of throwingKeyNotFoundException(500) — theendpoints[id]?.in EndpointInstanceMonitoring never null-checks because the dictionary indexer throws first. Scatter-gathered ids from audit-only endpoints could previously trigger this.Audit instance
KnownEndpointdocuments;RecordKnownEndpoint,QueryKnownEndpoints, and theKnownEndpointmodel are removed from the persistence seam and the RavenDB/InMemory implementations.GET /endpoints/knownremains as a backwards-compatibility stub returning an empty list with zero-count stats headers, so older primaries that still scatter-gather merge an empty result rather than a 404. Deletable in a future major, after ServiceInsight's deprecation (2027-02-10).Compatibility
endpoints_urlis not shape-compatible, so the route and the root document'sknown_endpoints_urlmust stay until ServiceInsight is deprecated).KnownEndpointdocuments age out on their own via@expires— no migration./endpoints/known. Toggling those endpoints already failed with a 500 before this change.TrackInstances, mute/unmute, andHeartbeatEndpointSettingsSyncHostedServiceall operate on the primary store andGET /endpoints.