Fix waiting for db to become available