Skip to content

Add XACT_STATE check after third-party proc calls (#695)#759

Merged
erikdarlingdata merged 4 commits intodevfrom
fix/695-doomed-transaction-xml-processors
Mar 30, 2026
Merged

Add XACT_STATE check after third-party proc calls (#695)#759
erikdarlingdata merged 4 commits intodevfrom
fix/695-doomed-transaction-xml-processors

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • process_deadlock_xml: Check XACT_STATE() after calling sp_BlitzLock — if the transaction is doomed, rollback and surface a meaningful error instead of "cannot be committed"
  • process_blocked_process_xml: Same fix for sp_HumanEventsBlockViewer

Related to #695 where a user saw the generic "cannot be committed" error from process_deadlock_xml with no way to diagnose the actual sp_BlitzLock failure.

Neither sp_WhoIsActive nor sp_HealthParser need this fix — they are not called inside a transaction.

Test plan

  • Deployed both procs to sql2022, ran successfully with @debug = 1
  • Verified query_snapshots_collector and collect_system_health_wrapper don't use transactions (no fix needed)

🤖 Generated with Claude Code

erikdarlingdata and others added 4 commits March 29, 2026 10:54
…755)

Phase 1 extraction of shared installation logic into Installer.Core class
library. InstallerGui and Installer.Tests now consume the shared library
instead of duplicating code. CLI Installer refactor is next.

New files:
- Installer.Core/InstallationService.cs — all static install/upgrade methods
- Installer.Core/DependencyInstaller.cs — community dependency downloads
- Installer.Core/ScriptProvider.cs — filesystem + embedded resource abstraction
- Installer.Core/Patterns.cs — shared regex patterns ([GeneratedRegex])
- Installer.Core/Models/ — InstallationProgress, ServerInfo, InstallationResult,
  UpgradeInfo, InstallationResultCode (enum mapping CLI exit codes 0-8)

Key changes:
- SQL scripts embedded as assembly resources for future Dashboard integration
- ScriptProvider.FromDirectory() for CLI/GUI, FromEmbeddedResources() for Dashboard
- AutoDiscover() searches filesystem then falls back to embedded
- Comprehensive [DEBUG] logging throughout all methods for GUI diagnostics
- upgrade.txt missing warning (was silently skipped, now logged)
- GenerateSummaryReport gains optional outputDirectory parameter

Retargeted:
- InstallerGui references Installer.Core, old InstallationService.cs deleted
- Installer.Tests targets net8.0 (was net8.0-windows), no WPF dependency
- Tests use ScriptProvider.FromDirectory() instead of raw file paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Program.cs rewritten from 2,122 lines to 1,172 lines (45% reduction).
All duplicated logic removed — CLI now delegates to Installer.Core for:

- Connection string building (InstallationService.BuildConnectionString)
- Connection testing (InstallationService.TestConnectionAsync)
- Script discovery (ScriptProvider.FromDirectory)
- SQL file execution (InstallationService.ExecuteInstallationAsync)
- Upgrade detection and execution (ExecuteAllUpgradesAsync)
- Uninstall (InstallationService.ExecuteUninstallAsync)
- Version detection (InstallationService.GetInstalledVersionAsync)
- Community dependencies (DependencyInstaller)
- Validation (InstallationService.RunValidationAsync)
- Installation history (InstallationService.LogInstallationHistoryAsync)
- Summary reports (InstallationService.GenerateSummaryReport)

What stays in Program.cs (console-specific):
- Argument parsing, interactive prompts, retry loop
- Console output helpers (WriteSuccess/WriteError/WriteWarning)
- ReadPassword, WaitForExit, CheckForInstallerUpdateAsync
- Error log generation (WriteErrorLog)

Fixes during review:
- Added missing exit code 8 (UpgradesFailed) to --help text
- Fixed encryption default label in error message (was "optional", is "mandatory")

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ollection_table (#756)

When calculate_deltas was called inside a collector's transaction and failed,
the CATCH block tried to INSERT into collection_log while the transaction was
doomed (XACT_STATE = -1), swallowing the real error with "The current transaction
cannot be committed." Same pattern in ensure_collection_table where INSERT
happened before ROLLBACK.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…695)

sp_BlitzLock and sp_HumanEventsBlockViewer can fail internally and doom
the caller's transaction. Without checking XACT_STATE after the call,
the next write attempt produces "cannot be committed" which swallows
the real error. Now we detect the doomed state, rollback, and surface
a meaningful error message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 8c9e8a0 into dev Mar 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant