Skip to content

Handle SQLite errors during dashboard read cancellation - #20007

Open
James Newton-King (JamesNK) wants to merge 1 commit into
mainfrom
fix-dashboard-sqlite-cancellation
Open

Handle SQLite errors during dashboard read cancellation#20007
James Newton-King (JamesNK) wants to merge 1 commit into
mainfrom
fix-dashboard-sqlite-cancellation

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

Fixes an intermittent dashboard metrics failure where canceling a SQLite read during statement preparation could surface an unrelated SQLite error instead of normal cancellation.

SQLite usually reports SQLITE_INTERRUPT after sqlite3_interrupt, but cancellation during statement preparation can produce another SQLite error, such as expected 0 columns for '' but got 18. Treat any SQLite failure as cancellation when the caller's token is already canceled. SQLite failures continue to propagate normally when cancellation has not been requested.

Adds deterministic regression coverage for a non-SQLITE_INTERRUPT error racing with cancellation.

Validation:

  • SqliteTelemetryPersistenceTests: 19/19 passed
  • ChangeResource_MeterAndInstrumentNotOnNewResources_InstrumentCleared: passed after rebuild and in 25/25 repeated runs

Fixes #19742

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20007

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20007"

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Tests selector

9 / 99 PR test projects · 3 PR jobs · 1 advisory-only target, from 2 changed files.

Selected PR test projects (9 / 99)

Aspire.Cli.EndToEnd.Tests, Aspire.Dashboard.Components.Tests, Aspire.Dashboard.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Testing.Tests, Aspire.Managed.Tests, Aspire.Playground.Tests

Selected PR jobs (3)

cli-starter-validation, extension-e2e, polyglot

Advisory workflow impact (1)

  • deployment-e2e (schedule/dispatch-only)

How these were chosen — grouped by what changed

🔧 src/Aspire.Dashboard/Otlp/Storage/SqliteTelemetryRepository.cs (changed source)
7 via the project graph: Aspire.Dashboard.Components.Tests, Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.RemoteHost.Tests (2 hops), Aspire.Hosting.Testing.Tests, Aspire.Managed.Tests (2 hops), Aspire.Playground.Tests (2 hops)

📦 affected project Aspire.Managed
1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Dashboard.Tests/TelemetryRepositoryTests/SqliteTelemetryPersistenceTests.cs (changed test)
1 directly: Aspire.Dashboard.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Managed
deployment-e2e affected project Aspire.Managed
extension-e2e src/Aspire.Dashboard/Otlp/Storage/SqliteTelemetryRepository.cs
• affected project Aspire.Dashboard
polyglot affected project Aspire.Managed

Selection computed for commit efa158f.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The behavior change is narrowly scoped, matches the PR description, and includes focused regression coverage for the new cancellation translation behavior.

Pull request overview

Fixes an intermittent Aspire Dashboard SQLite metrics failure where cancellation during statement preparation could surface a non-cancellation SQLite error (e.g., column-count mismatch) instead of normal cancellation semantics.

Changes:

  • Update SqliteTelemetryRepository.RunReadAsync to translate any SqliteException into OperationCanceledException when the caller’s cancellation token is already canceled.
  • Add a deterministic regression test asserting that non-SQLITE_INTERRUPT SQLite errors are treated as cancellation when cancellation has been requested.
File summaries
File Description
tests/Aspire.Dashboard.Tests/TelemetryRepositoryTests/SqliteTelemetryPersistenceTests.cs Adds regression coverage for translating non-SQLITE_INTERRUPT SQLite errors to cancellation.
src/Aspire.Dashboard/Otlp/Storage/SqliteTelemetryRepository.cs Broadens cancellation translation logic from only SQLITE_INTERRUPT to any SqliteException when token is canceled.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants