Skip to content

Fails to open database if opened at any point with a third party tool #119

Closed
@coltoneshaw

Description

@coltoneshaw

This may be an issue listed, i searched and couldn't find anything exact. Also posted in the sqlite library I use that pulls this package - m4heshd/better-sqlite3-multiple-ciphers#62

I seem to be having a problem when connecting to the database via SQLiteStudio, it breaks something. I assume it's my WAL archive.

Config when opening the db:

PRAGMA cipher='chacha20'
PRAGMA journal_mode = WAL
PRAGMA temp_store = memory
PRAGMA mmap_size = 30000000000
PRAGMA page_size = 32768
PRAGMA vacuum

Steps to break it:

  1. Start the electron application
  2. Set the password for the database
  3. Refresh the electron application
  4. Type the password in to unlock it, all works.
  5. close the electron application
  6. Connect to the database via SQLiteStudio
  7. Make a few queries on SQLiteStudio
  8. Disconnect from database in SQLiteStudio
  9. Start application again
  10. Type password to unlock (same as step 4 above)
  11. all queries from the application result in error: SqliteError: database disk image is malformed

Alternate steps to break (if the top has a fix, this is not relevant)

  1. Modify the config and remove the journal_mode = WAL
  2. Delete the database file, so it creates a new one
  3. Start the electron application
  4. Set the password, it fails here with error: SqliteError: database disk image is malformed`

Here it does not fail instantly, though. It actually does half the queries and then starts to fail.

BEGIN
[1] 12:08:43.585 › create table `peoplePossibleMatches` (`personMatchId` text not null, `peopleId` text not null, `confidence` integer not null);
[1] 12:08:43.585 › create unique index `peoplepossiblematches_personmatchid_peopleid_unique` on `peoplePossibleMatches` (`personMatchId`, `peopleId`)
[1] 12:08:43.586 › COMMIT
[1] 12:08:43.587 › select `name` from `sqlite_master` where `type` = 'table'
[1] 12:08:43.587 › select * from `migrations`
[1] 12:08:43.588 › [Database Knex Query] error: SqliteError: database disk image is malformed - Query String: 'select * from `migrations`'

Questions:

  1. How can I fix the above error, if it happens?
  2. Is there a way to not have SQLiteStudio break the database?

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