mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fts_integration.rs setup() applies migration 0001, which contains CREATE EXTENSION IF NOT EXISTS pgcrypto. pg_extension is database- global with a unique index on extname; IF NOT EXISTS is a check-then- insert, not an atomic upsert. When 18 tests run in parallel, the first wave all see the extension as absent, all attempt the insert, and all but one hit SQLSTATE 23505 (duplicate key on pg_extension_name_index). Fix: take a session-level pg_advisory_lock on the admin connection before the extension create, release it after. This serializes the install across all parallel test workers so exactly one does the real CREATE; the rest treat it as a no-op on lock acquisition. The advisory lock is released automatically when the session ends. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>