The test ApiBlockTest::testReblockAutoblockedIp failed during gate checks of Gerrit change 1286509 with PostgreSQL. Examining the debug log, I found:
[rdbms] Wikimedia\Rdbms\Database::lock: failed to acquire lock 'postgres-mediawiki-unittest_:autoblock:127.0.0.1'
This lock is acquired with a timeout of zero, so parallel test execution can trigger this.
Tests use temporary tables, so most database actions are scoped to the session. The data that the lock is protecting is scoped to the session. However, named locks are held by a session, and acquiring one will automatically succeed if the session already holds the lock, so if the lock name was scoped to the session then it would be guaranteed to always be successfully acquired.
Database::unlock() already validates the lock name, so it would seem that there's not much value in actually issuing the query.