Fix race when the database did not exist before starting.

This might be relevant for all automated tests of fresh builds, i.e. also
Jenkins system tests.

Tests are in dbcore/37960-db-creation-race, see git log, make check.

BugzID: 37960