-
-
Notifications
You must be signed in to change notification settings - Fork 101
fix: Also migrate messages in PGP-contacts migration #6921
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
base: link2xt/pgp-contacts
Are you sure you want to change the base?
Conversation
Actually, the messages migration probably is the largest part of it - what took long is committing the SQL transaction. I need to do this in the background. |
I'm not exactly sure how to do this migration in the background. One way would be:
|
With only rewriting the last 10.000 messages, it still took almost 5s, I will try 5.000:
Edit: This measurement is not reliable, I lowered to 5000 msgs, and the migration took longer this time:
Edit 2: Another run with 5000 msgs:
Edit3: Actually, even without rewriting message-ids, the migration takes multiple seconds:
So, probably the PR here is fine, the problem is that the PGP-contacts migration is slow in general. Edit 4: Note that all of these were debug builds, and while we do optimize Sqlite in debg builds, maybe the LTO of release builds improves things a bit |
For 1:1 protected chats this can be solved by assigning to the pgp contact all recent messages until a For unprotected (even encrypted) chats this doesn't matter that much, preserving their encryption status (padlock) would be fine i think. |
Nothing bad can happen if a few old messages are assigned to a slightly-wrong PGP contact, so I think it's fine. And, keeping the complexity low and moving forward. |
c091d55
to
acc754a
Compare
It's fine if |
@@ -1239,7 +1240,11 @@ CREATE INDEX gossip_timestamp_index ON gossip_timestamp (chat_id, fingerprint); | |||
let start = Instant::now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this is the only place where we use Instant
, maybe it's better to measure time with tools::Time
as everywhere for uniformity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instant
is the easiest way to measure how long some operation takes, so, I think it's the best tool for the job here. We do use it in test_utils.rs
, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, Instant
should be the right way to measure time in the ideal world. And we don't run tests on Android. But e.g. Context::background_fetch()
uses tools::Time
to measure and log elapsed time. It should be at least documented somewhere, which clock to use and when.
"SELECT id, from_id, to_id | ||
FROM msgs | ||
WHERE id>? | ||
AND (param LIKE '%\nc=1%' OR param LIKE 'c=1%') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not GLOB \"*c=*\"
? GLOB is case-sensitive (though LIKE is also fine in this particular case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about GLOB, good to know! But since case-sensitivity doesn't matter here, I think it's fine to leave it as-is, since I tested it the way I wrote it, and would have to re-do this testing if I change it now.
FTR, SQL generally recommends to use '
rather than "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, but leaving this unresolved to maybe switch to GLOB if the PR will need retesting for some other reason
Yes, all messages that were in a chat together will still be in a chat together, in the order they had before. Only contact ids will be changed. |
02d55ac
to
c5ce09e
Compare
Previously, messages were not rewritten. This meant that all messages stayed with the old email-identified contact. github.com//pull/6916 made it very obvious that all messages sent into a group before the PGP-contacts migration got the email avatar. With this PR, all encrypted messages are rewritten to the PGP-contact identified by the current autocrypt key. It is not possible to find out which key was actually used to sign the message.
Co-authored-by: iequidoo <117991069+iequidoo@users.noreply.github.com>
Co-authored-by: iequidoo <117991069+iequidoo@users.noreply.github.com>
c5ce09e
to
4ad3333
Compare
Previously, messages were not rewritten. This meant that all messages stayed with the old email-identified contact.
#6916 made it very obvious that all messages sent into a group before the PGP-contacts migration got the email avatar.
With this PR, all encrypted messages are rewritten to the PGP-contact identified by the current autocrypt key. It is not possible to find out which key was actually used to sign the message.
For me, this prints:
which is slow, but the messages aren't actually the slowest part of it. We may want to try and show a spinner in the UI while the migration is being done, but let's first hear what others report as to how long this takes.