Repository navigation
ISSUE #30151 - Incident Grouping Endpoint - #30367
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
🔴 Playwright Results — 3 test failure(s)✅ 4527 passed · ❌ 3 failed · 🟡 29 flaky · ⏭️ 102 skipped
Genuine Failures (failed on all attempts)❌
|
| -- the approvedById guard in 2.0.0). | ||
|
|
||
| -- Index the stateId partition used by the incident grouping endpoint (/testCaseIncidentStatus/incidentGroups) | ||
| SET @ddl = ( |
There was a problem hiding this comment.
@TeddyCr btw I avoid the queries like this. It assumes the db user configured for OM will have permissions on information_schema.
| @@ -1,4 +1,4 @@ | |||
| FROM mysql/mysql-server:latest | |||
| FROM mysql:8.0 | |||
|
|
Code Review 👍 Approved with suggestions 2 resolved / 3 findingsAdds the grouped incident backend for the redesigned Incident Manager, including incident group endpoints, bulk updates, failure summaries, and necessary database indexes. Consider adding an id tie-breaker to getLatestRecordBatchInternal to prevent non-deterministic results when timestamps tie. 💡 Edge Case: getLatestRecordBatch query lacks the MAX(id) tie-breaker📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java:10357-10369 The new ✅ 2 resolved✅ Performance: Missing (assignee, timestamp) index the assignee filter relies on
✅ Performance: Per-group entity resolution is an N+1 over the page
🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source |




Describe your changes:
Fixes #30151
I worked on the Incident Manager "Grouped Incidents" backend because the incident manager redesign needs incidents normalized into triageable groups (by table, test definition, or test-case owner) instead of a flat alert list, and the existing APIs could neither serve the grouped view nor scale to catalogs with deep incident history.
New API surface
GET /v1/dataQuality/testCases/testCaseIncidentStatus/incidentGroups— distinct open incidents grouped bytable,testDefinition, orowner. Each group carries the full row the UI renders:incidentCount, most-criticalseverity, triage-rankedstatus(Assigned > Ack > New), currentassignees+assigneeCount,firstSeen/lastSeen, and an 8-buckettrendwith aRising/Falling/Steadydirection (the "recurring" signal). Filters: open statuses, current assignee, test case, domain, and acreatedAt/updatedAtdate range; sortable and paginated with opaque cursors.testDefinition,owner(direct user/team owner of the test case), and a repairedassignee— so every group row can open its exact incident population.PUT /v1/dataQuality/testCases/testCaseIncidentStatus/bulk— bulk status/severity changes for up to 100 incidents per call (the UI's "Set status / Set severity on selection"), following the platform'sBulkOperationResultpattern with per-entry validation, authorization, and success/failure detail.failureSummarydenormalized onto every incident record at write time (failed result → incident task payload → sync handler), so incident listings can show the failure reason without a per-incident result lookup (no N+1).Fixes shipped along the way (all found by tests or scale-testing this feature)
startTs/endTsreportedpaging.total: 0(the count query evaluatedtimestamp BETWEEN NULL AND NULL), which also suppressed theaftercursor. Fixed inEntityTimeSeriesRepositoryfor all time-series entities.assigneefilter silently returned nothing: the genericassigneeparam had been repurposed by the task listing (name-hash →ASSIGNED_TOrelationships). The incident list now maps it to a column comparison (incidentAssignee).docker/mysql/Dockerfile_mysqlwas pinned to the discontinuedmysql/mysql-server:latest(frozen at 8.0.32, which crash-loops on a purge-thread FK assertion on case-insensitive filesystems). Swapped to the maintainedmysql:8.0.Type of change:
High-level design:
Query architecture. An incident is a
stateIdchain of status records intest_case_resolution_status_time_series. The grouping query reduces the chain in achainCTE (GROUP BY stateIdover the new(stateId, timestamp)index for first/last timestamps) and joins back on the last timestamp for the current status/assignee/severity — deliberately avoidingROW_NUMBER/MIN/MAXwindow functions, which materialize three buffered passes over the whole table at scale. One SQL round-trip serves the entire page: the group total rides onCOUNT(*) OVER ()and the per-group trend timestamps ride onJSON_ARRAYAGG/JSON_AGG(chosen overGROUP_CONCAT/STRING_AGGbecause JSON aggregates have nogroup_concat_max_len-style cap that would silently truncate a large group's trend). Trend bucketing and direction stay in Java (TestCaseResolutionStatusRepository), keeping the SQL dialect-free.Layering. All SQL lives in
CollectionDAO.TestCaseResolutionStatusTimeSeriesDAO— the CTE templates, the dialect-specific@Defineexpressions (severityExpr,assigneesExpr,createdAtAgg, dimension joins), and the parts assembly that splicesListFilteroutput into the right sub-query. The repository holds only orchestration and business mapping (rank→status, trend buckets, entity-reference resolution); the resource holds request parsing/auth.addOriginEntityFQNJoinmoved from the repository into the DAO to complete the separation.Write-time denormalization.
failureSummaryis captured when a failed test result opens an incident: the result text travels throughgetOrCreateIncidentinto the Task payload's existingfailureReasonfield, andIncidentTcrsSyncHandlerstamps it onto every TCRS record of the chain. Read paths never join to test results. Records predating the change are not backfilled (the field is optional).Bulk endpoint. One-pass shape borrowed from
EntityResource.processBulkRequest: all referenced test cases resolve via a singlefindEntityByNamesbatch and the caller reference resolves once; the per-entry loop then authorizes and creates with zero lookups. Synchronous by design — the caller is an interactive selection capped at 100 entries that needs inline per-entry results; theasync/202 path can be added if a bot-scale consumer appears.Alternatives considered and rejected
STRAIGHT_JOINhints for the chain join: measured slower than the optimizer's plan; SQL stays hint-free and portable.latest=trueslow path), but it is a migration + dual-write + backfill feature of its own; deliberately left as follow-up.Migrations / rollout. Additive only: 2.1.0 native migrations add four indexes —
(stateId, timestamp),(entityFQNHash, timestamp), and(assignee, timestamp)on the time-series table, and(id)ontest_case(which predates thePRIMARY KEY(id)convention; the relationship join had no index target). New schema fields are optional; no data migration. Themysql:8.0image swap affects fresh dev environments on next image build; volumes initialized by 8.0.32 upgrade in place.Tests:
Use cases covered
Steadywith all activity in the first bucketcreatedAt/updatedAtdate ranges; count-sorted ascending/descendingbefore/afterarithmetic and correct behavior past the end of the listlatest=true— with 404 on unknown filter targetsUnit tests
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepositoryTest.java(15 tests; join-builder tests follow the helper to its new DAO location)Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IncidentGroupsIT.java— 27 tests covering everything under "Use cases" above, run green on both PostgreSQL and MySQL (the SQL uses dialect-specific aggregate/JSON expressions, so both matter). New behaviors were RED-verified: each test was shown to fail with the feature toggled off (null aggregates, unfiltered result sets, 405 on the bulk path, missing failure summary,total=0paging) before going green.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
docker/development, MySQL) with the branch build; verified the 2.1.0 migrations create all four new indexes on a fresh volume.paging.after→offset), totals without time ranges, the repaired assignee filter (2.1 s → 40 ms after its index), andRising/Falling/Steadytrend variety across groups with different incident time profiles.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Greptile Summary
This PR adds grouped incident management for data quality failures. The main changes are:
Confidence Score: 5/5
The latest changes look safe to merge.
Important Files Changed
Reviews (11): Last reviewed commit: "chore: fix migration" | Re-trigger Greptile
Context used (3)