-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Don't user upsert to persist new one time keys #2053
Conversation
Instead we no-op duplicate one time key uploads, an error if the key_id already exists but encodes a different key.
Oh, I suppose I should raise a more helpful exception |
(I'm now raising a slightly more helpful exception) |
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.
can we change it to include the algorithm in the table key?
# First we check if we have already persisted any of the keys. | ||
rows = yield self._simple_select_many_batch( | ||
table="e2e_one_time_keys_json", | ||
column="key_id", |
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.
technically the algorithm is part of the key - so it's valid to have an "ed25519:aaaaa" as well as a "rot13:aaaaa". I rather hope the index reflects that, but haven't checked...
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.
Oh bleurgh, thanks, have changed.
# We are protected from race between lookup and insertion due to | ||
# a unique constraint. If there is a race of two calls to | ||
# `add_e2e_one_time_keys` then they'll conflict and we will only | ||
# insert one set. |
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.
... and throw a 500 or something, presumably? I suppose that's fine because the client should retry on the 500 and hit the api again, at which point the lookup should conclude that it's all fine.
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.
Yup.
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.
lgtm
modulo test failures. what's all that about? |
Whoops, look like I was a crank. Hopefully fixed now. |
Instead we no-op duplicate one time key uploads, an error if the key_id
already exists but encodes a different key.