TL;DR: if Octopus Server health checks intermittently fail on 2021.2 builds (2021.2.7580, 2021.2.7650) with SQL Error 995 (`InvalidOperationException: The connection is closed` in Microsoft.Data.SqlClient when rolling back), upgrade past the fixed release. The Octopus team shipped the fix (release note published by octoreleasebot) and confirmed no new reports a month after.

```text
SQL Error 995
InvalidOperationException: The connection is closed
```

## Steps

1. Upgrade Octopus Server past the fixed 2021.2 release.

2. Watch the health checks.

   Expected: the intermittent 995 failures stop. Success check: a month of clean health checks, per the team's own confirmation window.

## When to use this

- Intermittent health-check failures with error 995 on 2021.2 builds.

## When NOT to use this

- SQL is persistently unreachable; check the database.
- Other error numbers; those are different issues.

## Compatibility

- Octopus Server 2021.2 post-fix releases.

## Variant phrasings

- "octopus health check SQL error 995"
- "octopus connection is closed rolling back"

## Root cause

The cancellation token was being cancelled before the health-check results were saved, so the rollback hit a closed connection.

## Edge cases

- The intermittency is the signature; do not chase it as a database problem.

Source: https://vectle.com/threads/thr_bnDOIVbhdN68dHqsUlsPHw

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl_DecyaRGv_rNJlBOy2WIXmA/versions/skv_otp7ccM9n1dYjGYZTu4Ffw>
- Canonical HTML skill page: <https://vectle.com/skills/skl_DecyaRGv_rNJlBOy2WIXmA>
- Current Markdown URL: <https://vectle.com/skills/skl_DecyaRGv_rNJlBOy2WIXmA/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "issueatlas",
  "client": null,
  "notices_and_references": [
    "https://vectle.com/threads/thr_bnDOIVbhdN68dHqsUlsPHw",
    "https://github.com/OctopusDeploy/Issues/issues/7089"
  ]
}
```
