Skip to content

fix(dq): delete incident summary rows with their incident history - #37054

Merged
manerow merged 2 commits into
mainfrom
fix/test-case-incident-summary-cleanup
Nov 4, 2026
Merged

manerow merged 2 commits into
mainfrom
fix/test-case-incident-summary-cleanup

Conversation

@manerow

@manerow manerow commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

2.1.0 adds test_case_incident, a summary table with one row per incident (per stateId). The incident grouping reads it instead of folding the whole history in test_case_resolution_status_time_series. When an incident's history rows are deleted, its summary row stays behind:

  • PR Fix incident cleanup during recursive test-case deletion #36983 now deletes the incident history of a hard-deleted test case, one row at a time. The summary row survives.
  • The Data Retention app's weekly orphan sweep deletes history rows that lost their test case. The summary row survives.
  • The 2.1.0 upgrade script fills the table from all history, including incidents whose test case was hard-deleted before the upgrade.

Group counts join live test cases, so these rows usually stay hidden. They come back when a test case with the same name is created again: the old incident is counted in its group, while the drawer lists nothing for it.

What this PR changes

  1. Deleting a history row cleans up its summary. The incident DAO's deleteById deletes the summary row once the last history row of that stateId is gone. Every per-row delete goes through it, including the cleanup from PR Fix incident cleanup during recursive test-case deletion #36983.
  2. Data Retention sweeps leftover summary rows. Right after its orphan history sweep, it deletes summary rows that no longer have any history row, in batches. It is reported as orphan_test_case_incident. This also cleans up databases that already ran the 2.1.0 upgrade.
  3. The 2.1.0 backfill skips incidents without a test case. It only copies an incident whose latest record still has its parentOf link from a test case, the same rule the Data Retention sweep uses to find orphans. Databases already on an rc rerun the changed upsert, which is idempotent.

How it was tested

  • TestCaseResourceIT: both hard-delete tests from PR Fix incident cleanup during recursive test-case deletion #36983 (direct and recursive from the table) now also check that the summary row exists before the delete and is gone afterwards.
  • OrphanedTimeSeriesCleanupIT#testCaseIncidentOrphans: a summary row without history is deleted, and a live incident's summary row is kept.
  • Run locally on PostgreSQL + Elasticsearch: the two TestCaseResourceIT tests 2/2, OrphanedTimeSeriesCleanupIT 7/7, ReindexStatsIT 2/2, ReindexDocSurvivalIT 4/4, DataRetentionTest 5/5, TestCaseRepositoryTest 11/11. On MySQL: the two TestCaseResourceIT tests 2/2 and OrphanedTimeSeriesCleanupIT 7/7.
  • Fresh-install IT boots ran the changed 2.1.0 backfill on both databases. Run by hand on PostgreSQL 15 and MySQL 8 against one live and one orphan incident, the backfill copies only the live one.
  • Local runs had PR chore(deps): bump org.hibernate.validator:hibernate-validator from 8.0.6.Final to 9.1.4.Final #34336's hibernate-validator 9.1.4 bump undone, which is not part of this PR: with it, the in-JVM test server fails to start (NoClassDefFoundError: ConstraintValidatorFactoryImpl from Dropwizard).

Not in this PR

  • Old orphan history rows keep relying on the existing Data Retention sweep. No new migration.
  • An incident whose history is only partly deleted keeps its summary row as it is.

No linked issue: the gap was found while checking PR #36983 and its 2.0 backport PR #37003, and is fixed here directly (skip-pr-checks).

@manerow
manerow requested a review from a team as a code owner November 4, 2026 12:48
@manerow
manerow requested a review from TeddyCr November 4, 2026 12:48
@manerow manerow added the skip-pr-checks Bypass PR metadata validation check label Nov 4, 2026
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Nov 4, 2026
@gitar-bot

gitar-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Deleting incident summaries when history disappears and filtering migration backfills changes stored data, potentially losing summaries for incidents with missing links.

Deletes incident summary rows together with their incident history, so orphaned summaries no longer resurface when a test case with the same name is recreated. Summary rows are cleaned up on each history delete and swept by Data Retention, and the 2.1.0 backfill skips incidents without a test case. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow
manerow merged commit 20569c1 into main Nov 4, 2026
64 of 69 checks passed
@manerow
manerow deleted the fix/test-case-incident-summary-cleanup branch November 4, 2026 15:10
mohityadav766 pushed a commit that referenced this pull request Nov 13, 2026
…e service-connection wipe, the parallel-lane timeout (#37725)

* test(it): fix 13 integration tests main has failed since merges skipped ITs

Each test was broken by a later PR whose behaviour change is intended and
recorded, but merged without the integration lanes running:

- IncidentGroupsIT x3, MetricMigrationIT: the 2.1.0 incident backfill now
  requires a testCase parentOf row (#37054); seed it like the write path does.
- TeamResourceIT x2: only admins add team roles (ADR 2026-10-30) and every
  CSV row needs EDIT_ALL on its own team (ADR 2026-11-02).
- DomainMoveApprovalAuthorizationIT, DomainReassignmentAuthorizationIT: a
  JSON Patch on the document root is refused with 400 (ADR 2026-11-03).
- AIContextMcpIT: a metric child the caller cannot view is dropped
  (ADR 2026-10-31); amend the 2026-10-29 record that said otherwise.
- OntologyDraftQueryIT: the release scope needs an active release first.
- TaskResourceIT: field paths end in tags/description (#37051).
- OntologyBulkIT: the two glossaries of one test shared a name.
- DataContractResourceIT x2: unknown imported fields are carried as
  source metadata, and an imported numeric-unsafe rule is stored as an
  embedded custom rule (ADR 2026-11-09).

* test(it): address self-review on the main IT fixes

Tighten the DataContract export assertion to the exporter's message, drop
the TeamResourceIT Javadoc clause the removed step proved, and note in the
metric ADR amendment that the VIEW_ALL expression filter has no caller in
the suite that can reach it.

* fix: keep a service's connection on a PUT that omits it; unblock the IT lanes

- ServiceEntityRepository: a PUT without `connection` now keeps the stored
  connection, as #32920 and issue #29494 intend and
  DatabaseServiceResourceIT.put_updateWithoutConnection_preservesExistingConnection_200
  asserts. Each generated service types its own setter, so the stored
  connection is copied in place through its JSON form. Stored ciphertext and
  vault references pass through storage unchanged
  (ADR 2026-10-29 service-connection-secrets-are-written-only-during-storage).
- NativeOntologyEveryPackInstallIT moves to the global-state lane. Its
  @isolated 11-15 minute install of every pack pushed the parallel lane past
  its 65 minute budget; the global-state lane runs beside it with headroom and
  every pack still installs on each merge (ADR 2026-11-06).
- DataProductDeleteRaceIT matches lock waiters by table on MySQL too: a run
  waited the full minute on a blocked statement that did not carry the data
  product's id.

* fix: an approval-held PUT without a connection must not clear it either

The approval gate staged a PUT that omits `connection` as `connection: null`,
so approving it would still delete the credentials. Services now declare
`connection` and `serviceAttributes` as fields a PUT keeps, matching the
updater. Records the decision and its security reasoning in
ADR 2026-11-13-a-put-that-omits-a-service-connection-keeps-the-stored-one.

SecretsManagerNullSecretIT covers both paths against the in-memory vault: a
direct PUT keeps the connection and its vault secrets, and a held PUT stages
no connection op (fails without the override). DataProductDeleteRaceIT moves
to the serial global-state lane and matches whole table names, so no other
test's lock wait can stand in for its own.

* docs(adr): state what an omitted connection lost before the fix, as tested

A red run of the old updater shows the service row losing its connection
while the vault entries were still present right after the PUT, so the record
no longer claims the vault entries were deleted.
yan-3005 added a commit that referenced this pull request Nov 16, 2026
…ipe (backport 2.1 #37725) (#37850)

* Fix every integration-test failure on main: 14 stale/broken tests, the service-connection wipe, the parallel-lane timeout (#37725)

* test(it): fix 13 integration tests main has failed since merges skipped ITs

Each test was broken by a later PR whose behaviour change is intended and
recorded, but merged without the integration lanes running:

- IncidentGroupsIT x3, MetricMigrationIT: the 2.1.0 incident backfill now
  requires a testCase parentOf row (#37054); seed it like the write path does.
- TeamResourceIT x2: only admins add team roles (ADR 2026-10-30) and every
  CSV row needs EDIT_ALL on its own team (ADR 2026-11-02).
- DomainMoveApprovalAuthorizationIT, DomainReassignmentAuthorizationIT: a
  JSON Patch on the document root is refused with 400 (ADR 2026-11-03).
- AIContextMcpIT: a metric child the caller cannot view is dropped
  (ADR 2026-10-31); amend the 2026-10-29 record that said otherwise.
- OntologyDraftQueryIT: the release scope needs an active release first.
- TaskResourceIT: field paths end in tags/description (#37051).
- OntologyBulkIT: the two glossaries of one test shared a name.
- DataContractResourceIT x2: unknown imported fields are carried as
  source metadata, and an imported numeric-unsafe rule is stored as an
  embedded custom rule (ADR 2026-11-09).

* test(it): address self-review on the main IT fixes

Tighten the DataContract export assertion to the exporter's message, drop
the TeamResourceIT Javadoc clause the removed step proved, and note in the
metric ADR amendment that the VIEW_ALL expression filter has no caller in
the suite that can reach it.

* fix: keep a service's connection on a PUT that omits it; unblock the IT lanes

- ServiceEntityRepository: a PUT without `connection` now keeps the stored
  connection, as #32920 and issue #29494 intend and
  DatabaseServiceResourceIT.put_updateWithoutConnection_preservesExistingConnection_200
  asserts. Each generated service types its own setter, so the stored
  connection is copied in place through its JSON form. Stored ciphertext and
  vault references pass through storage unchanged
  (ADR 2026-10-29 service-connection-secrets-are-written-only-during-storage).
- NativeOntologyEveryPackInstallIT moves to the global-state lane. Its
  @isolated 11-15 minute install of every pack pushed the parallel lane past
  its 65 minute budget; the global-state lane runs beside it with headroom and
  every pack still installs on each merge (ADR 2026-11-06).
- DataProductDeleteRaceIT matches lock waiters by table on MySQL too: a run
  waited the full minute on a blocked statement that did not carry the data
  product's id.

* fix: an approval-held PUT without a connection must not clear it either

The approval gate staged a PUT that omits `connection` as `connection: null`,
so approving it would still delete the credentials. Services now declare
`connection` and `serviceAttributes` as fields a PUT keeps, matching the
updater. Records the decision and its security reasoning in
ADR 2026-11-13-a-put-that-omits-a-service-connection-keeps-the-stored-one.

SecretsManagerNullSecretIT covers both paths against the in-memory vault: a
direct PUT keeps the connection and its vault secrets, and a held PUT stages
no connection op (fails without the override). DataProductDeleteRaceIT moves
to the serial global-state lane and matches whole table names, so no other
test's lock wait can stand in for its own.

* docs(adr): state what an omitted connection lost before the fix, as tested

A red run of the old updater shows the service row losing its connection
while the vault entries were still present right after the PUT, so the record
no longer claims the vault entries were deleted.

(cherry picked from commit a634c55)

* test(it): read MySQL lock waits from performance_schema in DataProductDeleteRaceIT

On CI the innodb_trx statement text never matched the blocked statements,
so each race step only ended when a request hit MySQL's 50s lock-wait
timeout, and one step outlived the 60s wait. data_lock_waits joined to
data_locks names the table each blocked transaction waits on, independent
of the statement text. Locally the three races now take 1.7-3.8s on MySQL
instead of about 50s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants