Page MenuHomePhabricator

Flaky test ApiBlockTest::testReblockAutoblockedIp
Closed, ResolvedPublic

Description

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.

Details

Event Timeline

Change #1294488 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] [rdbms] Don't acquire locks during PHPUnit tests

https://gerrit.wikimedia.org/r/1294488

It's the same, except that I don't agree with most of the comments there. My patch will fix that issue.

Change #1294488 merged by jenkins-bot:

[mediawiki/core@master] [rdbms] Don't acquire locks during PHPUnit tests

https://gerrit.wikimedia.org/r/1294488

matmarex assigned this task to tstarling.