Skip to content

event cache: running into unique constraint failures #4785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bnjbvr opened this issue Mar 11, 2025 · 1 comment · Fixed by #4779
Closed

event cache: running into unique constraint failures #4785

bnjbvr opened this issue Mar 11, 2025 · 1 comment · Fixed by #4779
Assignees

Comments

@bnjbvr
Copy link
Member

bnjbvr commented Mar 11, 2025

Running multiverse locally with a big test account that has some ignored users, I can easily trigger unique constraint failures, for room gaps:

  • start multiverse
  • let it run in the background for a couple minutes
  • shut it down
  • stash the rust logs somewhere
  • restart it
  • let it run in the background for a couple minutes

as it's triggering #4784, this will clear the storage. But! in the logs of the second run, I can see issues related to unique constraints failures:

2025-03-11T08:26:30.763163Z ERROR listen_task:handle_room_updates: matrix_sdk::event_cache: handling joined room update: UNIQUE constraint failed: gaps.room_id, gaps.chunk_id room_id=!abcdef:matrix.org

Blocker for #3280.

cc @Hywan

@Hywan Hywan self-assigned this Mar 11, 2025
bnjbvr added a commit that referenced this issue Mar 11, 2025
As opposed to WAL mode, foreign keys must be enabled for each database
connection, according to
https://www.sqlite.org/foreignkeys.html#fk_enable

Unfortunately, we can't track which connection objects have already
executed the pragma, so the safer we can do is enable it everytime we
try to acquire a connection from the pool.

Fixes #4785.
@bnjbvr bnjbvr assigned bnjbvr and unassigned Hywan Mar 11, 2025
@bnjbvr
Copy link
Member Author

bnjbvr commented Mar 11, 2025

Got a patch for this in #4779.

bnjbvr added a commit that referenced this issue Mar 11, 2025
As opposed to WAL mode, foreign keys must be enabled for each database
connection, according to
https://www.sqlite.org/foreignkeys.html#fk_enable

Unfortunately, we can't track which connection objects have already
executed the pragma, so the safer we can do is enable it everytime we
try to acquire a connection from the pool.

Fixes #4785.
bnjbvr added a commit that referenced this issue Mar 11, 2025
As opposed to WAL mode, foreign keys must be enabled for each database
connection, according to
https://www.sqlite.org/foreignkeys.html#fk_enable

Unfortunately, we can't track which connection objects have already
executed the pragma, so the safer we can do is enable it everytime we
try to acquire a connection from the pool.

Fixes #4785.
bnjbvr added a commit that referenced this issue Mar 11, 2025
As opposed to WAL mode, foreign keys must be enabled for each database
connection, according to
https://www.sqlite.org/foreignkeys.html#fk_enable

Unfortunately, we can't track which connection objects have already
executed the pragma, so the safer we can do is enable it everytime we
try to acquire a connection from the pool.

Fixes #4785.
@bnjbvr bnjbvr closed this as completed in 06d5fdb Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants