Skip to content

SQLite error in _migrate_to_v3()  #2163

@mdosch

Description

@mdosch

I realized I sometimes get old messages from a year ago replayed instead of more recent messages when opening a chat.
When looking in the error logs I found a lot of these:

2026-05-05T20:09:51.847229+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
2026-05-05T20:10:01.425463+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
2026-05-05T20:11:12.853284+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
2026-05-05T20:11:34.653412+02: 00255105: prof: ERR: [OMEMO][STORE] SG_ERR_INVALID_KEY_ID
2026-05-05T20:12:21.256679+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
2026-05-05T20:12:55.195326+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
2026-05-05T20:13:38.516691+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
2026-05-05T20:15:09.686811+02: 00255105: prof: ERR: SQLite error in _add_to_db() (prepare): ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint

When looking for the first occurrence of db issues I found this:

2026-04-11T17:01:34.263737+02: 00066757: conn: DBG: Q_ADD: 0x561a4078b280
2026-04-11T17:01:34.276203+02: 00066757: prof: DBG: [Keyfile]: free /home/martin/.local/share/profanity/accounts
2026-04-11T17:01:34.279811+02: 00066757: prof: DBG: [Keyfile]: free /home/martin/.local/share/profanity/accounts
2026-04-11T17:01:34.280915+02: 00066757: prof: DBG: _check_available_space_for_db_migration(): Available space on disk: 210532432 KB; DB size: 127748 KB
2026-04-11T17:01:37.831491+02: 00066757: prof: ERR: SQLite error in _migrate_to_v3() on statement 8: UNIQUE constraint failed: DbVersion.version
2026-04-11T17:01:38.290543+02: 00066757: prof: ERR: Unknown SQLite error in log_database_init().
2026-04-11T17:01:38.290621+02: 00066757: conn: DBG: QUEUED:
2026-04-11T17:01:38.290633+02: 00066757: conn: DBG: Q_ADD: 0x561a405862c0
2026-04-11T17:01:38.290758+02: 00066757: prof: INF: REDACTED logged in successfully

Expected Behavior

Probably the DB should have migrated successfully on the first startup with the new scheme.

Current Behavior

DB is failing to upgrade.

Possible Solution

No idea.

Steps to Reproduce (for bugs)

No idea.

Context

Environment

OS: Debian Unstable
DE/WM: Sway
VTE: foot

profanity --version
Profanity, version 0.18.0
Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.
Copyright (C) 2019 - 2026 Michael Vetter <jubalh@iodoru.org>.
License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Build information:
XMPP library: libstrophe
Desktop notification support: Enabled
OTR support: Disabled
PGP support: Enabled (libgpgme 2.0.1)
OMEMO support: Enabled
C plugins: Enabled
Python plugins: Disabled
GTK icons/clipboard: Enabled
GDK Pixbuf: Disabled

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions