+
Skip to content

fix: Save msgs to key-contacts migration state and run migration periodically (#6956) #6981

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

Merged
merged 2 commits into from
Jul 9, 2025

Conversation

iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Jul 6, 2025

See commit messages. This makes #6956 non-blocker at least. But i wonder if we need a background process to convert messages: if i replace 10_000 with u64::MAX (i.e. convert all messages), the migration only takes extra 800 ms for my database. Please test on your dbs, maybe mine isn't huge enough.

EDIT: Added a background process to housekeeping(). Fix #6956

@iequidoo iequidoo requested review from link2xt and Hocuri July 6, 2025 20:02
@Hocuri
Copy link
Collaborator

Hocuri commented Jul 6, 2025

I measured again: without a limit, the migration takes 11.2s in total on my db (up from 5.6s when migrating only 10_000 messages). This result is similar to when I measured previous times (in previous measurements, without a limit, it took 13 resp. 14s, up from ~5 resp. 7 seconds with just 10_000 migrated messages).

Therefore, I do think that doing things in background here is worth the effort, also because on Android, migrations are done on the main thread, and the system will ask the user whether to kill DC if it takes too long.

@link2xt
Copy link
Collaborator

link2xt commented Jul 6, 2025

Instead of migrating 10k contacts, can we only keep the table creation inside the migration and move actual from_id updates to some other place? Beginning of the inbox loop, for example, or housekeeping (which is however not run frequently enough, maybe we should schedule it to run after migration at least). There, always migrate 1k messages starting from the highest row ID on each run, until we reach row id 0.

@iequidoo iequidoo marked this pull request as draft July 6, 2025 23:28
@iequidoo iequidoo force-pushed the iequidoo/msgs-migration-state branch from 7860582 to b6b8391 Compare July 7, 2025 14:19
@iequidoo

This comment was marked as outdated.

@iequidoo iequidoo marked this pull request as ready for review July 7, 2025 14:32
@iequidoo iequidoo changed the title fix: Save msgs to key-contacts migration state (#6956) fix: Save msgs to key-contacts migration state and run migration periodically (#6956) Jul 7, 2025
@iequidoo iequidoo force-pushed the iequidoo/msgs-migration-state branch from b6b8391 to c840c7f Compare July 7, 2025 14:45
@iequidoo iequidoo force-pushed the iequidoo/msgs-migration-state branch from c840c7f to 9ba9fd4 Compare July 8, 2025 10:33
@iequidoo iequidoo requested a review from link2xt July 8, 2025 10:35
iequidoo added 2 commits July 9, 2025 09:04
…LECT

+ Replace LIKE with GLOB, the latter is case-sensitive.
…odically (#6956)

Save:
- (old contact id) -> (new contact id) mapping.
- The message id starting from which all messages are already migrated.
Run the migration from `housekeeping()` for at least 500 ms and for >= 1000 messages per run.
@iequidoo iequidoo force-pushed the iequidoo/msgs-migration-state branch from 9ba9fd4 to 717015a Compare July 9, 2025 12:09
@iequidoo iequidoo merged commit 389649e into main Jul 9, 2025
18 checks passed
@iequidoo iequidoo deleted the iequidoo/msgs-migration-state branch July 9, 2025 12:10
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 this pull request may close these issues.

Convert all message senders after migration to key-contacts
3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载