Commit 23f064d
Get-DbaXESession - Close the cloned connection behind the XEStore
Every call cloned the SqlConnection for its XEStore and never closed
the clone: one sleeping session per call, held until the process exits.
Because the whole Extended Events family funnels through this command -
Start-DbaXESession even re-queries through it after every start - the
leak multiplied across Start, Stop, Remove, ConvertTo, Watch and the
Export commands. The first -CheckSleepingConnections full run flagged
Start-DbaXESession at +15, ConvertTo at +7 and Remove at +6.
The store connection is now disconnected after the sessions are
enumerated and emitted. The emitted objects keep their Store note
property working: SFC transparently reconnects from the pool when a
downstream command uses the store again, which the lab probe confirmed
for piped Start and Stop and a test now pins.
Measured on SQL03\SQL2019: three Get calls used to add three sessions
(regression test red on the unfixed command: expected 4, got 7), now
add none. Runner measurements of the family files: Start-DbaXESession
15 -> 7, Remove-DbaXESession 6 -> 2, ConvertTo-DbaXESession 7 -> 3.
The residue in Start comes from a different, smaller mechanism (the
reopened store of a piped object stays checked out once per pipeline)
and is left for a follow-up.
(do *XESession*)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 0473789 commit 23f064d
2 files changed
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
36 | 79 | | |
0 commit comments