Skip to content

dblog_init_for_append panics after succesfull recover #15

@Raupinger

Description

@Raupinger

I have the following code in my setup()

if (SD.exists(db_filename)) {
      Serial.printf("recovering existing database at %s...", db_filename.c_str());
      res = recover_db(db_context, (String("/sd") + db_filename).c_str());
      if (!res) {
        set_db_file(fopen(db_filename.c_str(), "a+b"));
        res = dblog_init_for_append(&db_context);
      }
      Serial.println((res == 0) ? "successful" : "failed");
    }
recover_db is basically the same as in the examples (click to expand)
int recover_db( dblog_write_context &ctx, const char* filename) {
    dbFile = fopen(filename, "r+b");
    if (!&dbFile) {
        print_error(0);
        return 1;
    }
    int32_t page_size = dblog_read_page_size(&ctx);
    if (page_size < 512) {
        Serial.print(F("Error reading page size\n"));
        fclose(dbFile);
        return 2;
    }
    if (dblog_recover(&ctx)) {
        Serial.print(F("Error during recover\n"));
        fclose(dbFile);
        return 3;
    }
    fclose(dbFile);
    return 0;
}
I'm getting the following output:

Image

copying the file to my laptop and using sqlite_micro_logger_c to append works fine:

Image

opening the file with sqlite3 afterwards works and shows the added data

the database file: https://megastore.rz.uni-augsburg.de/get/eqVggTp9KG/

I've got an external debugger in the mail, but for now that's all the information i have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions