Fix race when the database did not exist before starting.

 This is probably relevant for all automated tests of fresh builds, i.e. also Jenkins system tests.

Tests for this PR are in dbcore/37960-db-creation-race, see git log there, `make check`.

BugzID: 37960
I pondered whether we should drop the `{ok, Db} = ` part and agree that we should not. `ensure_exists` will not return successfully now unless the db does exist, and that's good.