Commit bc92374
Update-SqlPermission - Remove unnecessary SqlConnectionObject.Close() calls
The Close() calls were added as a workaround for SMO DataReader conflicts,
but modern SMO properly manages its own connection lifecycle - all Enum*
methods (EnumMembers, EnumServerPermissions, EnumDatabasePermissions, etc.)
open and close their DataReaders internally via SqlDataAdapter.Fill().
The calls were harmless with normal pooled connections (Close() returns
to the pool, next Open() gets a fresh connection) but catastrophic with
DAC connections: each Close() terminates the single DAC TCP slot, and
the reconnect attempt to ADMIN:server fails when the slot hasn't been
freed yet, generating "max 1 dedicated administrator connections" errors.
The worst case was the Close() pair inside the foreach ($role in
$sourceDb.Roles) loop - called once per role per database per login,
producing 30-40 DAC errors in the scenario reported in #10284.
Fixes #10284
(do Sync-DbaAvailabilityGroup)
Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>1 parent 27e4da9 commit bc92374
1 file changed
Lines changed: 0 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
| |||
132 | 128 | | |
133 | 129 | | |
134 | 130 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | 131 | | |
139 | 132 | | |
140 | 133 | | |
| |||
259 | 252 | | |
260 | 253 | | |
261 | 254 | | |
262 | | - | |
263 | | - | |
264 | 255 | | |
265 | 256 | | |
266 | 257 | | |
| |||
292 | 283 | | |
293 | 284 | | |
294 | 285 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | 286 | | |
299 | 287 | | |
300 | 288 | | |
| |||
355 | 343 | | |
356 | 344 | | |
357 | 345 | | |
358 | | - | |
359 | | - | |
360 | 346 | | |
361 | 347 | | |
362 | 348 | | |
| |||
375 | 361 | | |
376 | 362 | | |
377 | 363 | | |
378 | | - | |
379 | 364 | | |
380 | 365 | | |
381 | 366 | | |
| |||
0 commit comments