Online ALTER COLUMN final Sch-M lock duration bounds under concurrent DML in SQL Server 2019
0 reputation · 12 Apr 2024, 01:47 UTC
Context
SQL Server 2016 introduced online ALTER COLUMN for certain data type changes, allowing concurrent reads and writes during the operation. For incompatible conversions (e.g., int to bigint), a data-copy phase occurs followed by a brief schema modification (Sch-M) lock to switch metadata.
Unresolved behavior
The documentation does not specify a maximum duration for the final Sch-M lock acquisition. The wait depends on transaction log flush, checkpoint activity, and any long-running transactions holding shared locks. Under heavy write load, this lock can extend to seconds, causing application timeouts — a gap for strict zero-downtime requirements.
Constraints
- No built-in
MAX_DURATIONor timeout option exists forALTER COLUMN(unlike resumable index rebuild). - Edition support: Enterprise/Developer in 2016-2017; Standard from 2019 CU1+.
- No DMV exposes real-time progress of the data-copy phase.
Questions
- Is there any documented upper bound or predictable worst-case for the final Sch-M lock duration during online
ALTER COLUMN? - Can the lock acquisition be programmatically bounded or aborted without third-party tools?
- What are the supported workarounds for guaranteeing zero-downtime schema changes when the Sch-M lock wait is unacceptable?