Skip to content

[Host.Sql.Common] Accept migration locks acquired after waiting - #494

Merged
zarusz merged 1 commit into
masterfrom
feature/sql-migration-lock-result
Nov 2, 2026
Merged

zarusz merged 1 commit into
masterfrom
feature/sql-migration-lock-result

Conversation

@zarusz

@zarusz zarusz commented Nov 2, 2026

Copy link
Copy Markdown
Owner

When concurrent application instances provision the SQL schema, sp_getapplock can return 1 after successfully waiting for another instance to release the migration lock. The existing result == 0 check rejected that success, rolled back the transaction, and raised a misleading lock timeout.

Accept all nonnegative application-lock return codes in CommonSqlMigrationService. This fixes both SQL outbox migrations and SQL transport topology provisioning. Negative results remain failures, and the existing retry policy is unchanged. Update the outbox documentation and regenerate Markdown.

Add SQL Server integration coverage for immediate acquisition, acquisition after a confirmed server-side lock wait, and a genuine timeout followed by rollback and recovery after release. The contention test observes blocking through sys.dm_exec_requests rather than relying on an arbitrary delay.

Validation:

  • Confirmed the contention regression fails on the old code while immediate acquisition succeeds.
  • SQL outbox suite: 41 passed in Release.
  • SQL transport suite: 8 passed in Release.
  • Ran build/md-preprocessor.ps1 across all Markdown templates.

Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
@zarusz
zarusz merged commit 377f65e into master Nov 2, 2026
21 checks passed
@zarusz zarusz added this to the 3.6.1. milestone Nov 2, 2026
@zarusz
zarusz deleted the feature/sql-migration-lock-result branch November 2, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant