bug(transport): bundle import throws on real MS SQL — user-initiated transaction under EnableRetryOnFailure #28
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High (Transport #24 bundle import is broken on any real SQL Server) · Area: Transport / Configuration Database · Found: ClusterClient→gRPC Phase 1 rig gating, 2026-07-23
What
BundleImporteropens a user-initiated transaction in its apply path:src/ZB.MOM.WW.ScadaBridge.Transport/Import/BundleImporter.cs:1298—await _dbContext.Database.BeginTransactionAsync(ct)while the central
ConfigurationDbcontext is configured with a retrying execution strategy:src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/ServiceCollectionExtensions.cs:33—sql.EnableRetryOnFailure(...)On real MS SQL,
SqlServerRetryingExecutionStrategyrejects user-initiated transactions (The configured execution strategy 'SqlServerRetryingExecutionStrategy' does not support user-initiated transactions), so every bundle import fails.Why the test suite is green
Transport.Testsuses the in-memory EF provider, which has no retrying execution strategy and whereBeginTransactionAsyncis a no-op — so the whole import suite passes while the production path is broken.Suggested fix
Wrap the transactional section in the context's execution strategy so the strategy owns the transaction:
Add a real-SQL integration test (or a fake with a retrying strategy) so the suite catches regressions of this class.
Fixed in
c4dcd9bc(on main @8524a7f7, pushed to origin). BundleImporter.ApplyAsync now runs the transactional apply through _dbContext.Database.CreateExecutionStrategy().ExecuteAsync, so the strategy owns the BeginTransaction→apply→Commit unit — no more user-initiated transaction under EnableRetryOnFailure. Regression test BundleImporterRetryingStrategyTests runs the import on SQLite under a retrying execution strategy: it fails with the exact production error ('...does not support user-initiated transactions.') on the pre-fix code and passes after. 104 Transport integration + 154 unit tests green.