I have part six of my interminable series on near-zero downtime deployments:
The locking story is not the same as with the primary and unique key constraints. First, there’s one extra piece: the transition will block access to
dbo.LookupTable
as well as the table we create the constraint on. That’s to keep us from deleting rows in our lookup table before the key is in place.Second, the locks begin as soon as we hit F5. Even
SELECT
statements get blocked requesting aLCK_M_SCH_S
lock. Bad news, people.So what can we do to get around this problem? Two routes: the ineffectual way and the ugly way.
Despite my being a ray of sunshine here, you should still check this out. It’s shorter than the average Russian novel, at least.