When I run unit tests on vagrant, I get this error:
[9541d85fcbb13499c016d90f] [no req] DBUnexpectedError from line 2629 of /vagrant/mediawiki/includes/libs/rdbms/database/Database.php: No atomic transaction is open (got Database::onTransactionPreCommitOrIdle).
This seems to be caused by duplicate key reporting: when running onTransactionPreCommitOrIdle, startAtomic calls getApproximateLagStatus which uses $this->srvCache. If $this->srvCache has reportDuplicate enabled, this causes transaction commit when executing doUpdate (which is executed synchronously because we're in CLI). This resets the mTrxLevel to 0 and this breaks endAtomic().