https://cirrus-ci.com/task/5603470202896384?logs=ci#L2681
batch.reset();
    if (!complete) {
        error = _("Error Unable to read all records in the database");
        return false;
    }
    // Close this database and delete the file
    fspath db_path = fsPathFromString(m_database->Filename());
    fspath db_dir = db_path.parent_path();
    m_database->Close();
    fsremove(db_path);
    // Make new DB
    DatabaseOptions opts;
    opts.require_create = true;
    opts.require_format = DatabaseFormatSQLITE;
    DatabaseStatus db_status;
    stdunique_ptr<WalletDatabase> new_db = MakeDatabase(db_dir, opts, db_status, error);
    assert(new_db); // This is to prevent doing anything further with this . The original file was deleted, but a backup exists.
    m_databreset();
    m_database = stdmove(new_db);
    // Write existing records into the new DB
    batch = m_database->MakeBatch();
    bool began = batch->TxnBegin();
    assert(began); // This is a critical error, the new db could not be written to. The original db exists as a backup, but we should not continue execution.
    for (const auto& [key, value]  records) {
        CDataStream ss_key(key, SER_DISK, CLIENT_VERSION);
        CDataStream ss_value(value, SER_DISK, CLIENT_VERSION);
        if (!batch->Write(ss_key, ss_value)) {
            batch->TxnAbort();
            m_database->Close();
            fsremove(m_database->Filename());