Avoid updating the same oc_authtoken row twice#45026
Conversation
joshtrichards
left a comment
There was a problem hiding this comment.
Do you foresee any downsides here since we'd be bypassing the updateActivity() tolerance optimizations?
server/lib/private/Authentication/Token/PublicKeyTokenMapper.php
Lines 203 to 231 in acf8ea1
|
I don't see any additional risk there. The row is updated anways when this is being called and I also didn't see any hints on unnecessary further updates on query statistics of the high traffic instance where this finding originated from. |
…entation Signed-off-by: Julius Härtl <[email protected]>
…yways Signed-off-by: Julius Härtl <[email protected]>
8ec8d74 to
04780ae
Compare
|
Waiting with the merge since @ChristophWurst wanted to have another close look |
|
/backport to stable29 |
|
/backport to stable28 |
|
/backport to stable27 |
|
/backport to stable26 |
|
I've realized a logical issue where we now update the last_activity for tokens that are not active. E.g. Especially with the rotation and the password update we will see tokens/clients as active even if they have not connected. |
Addressed with #45411 |
Summary
Checking out query frequency on an instance I noticed that the following two queries roughly are happening quite frequently and checking the code I noticed that it might happen that we issue two update queries for the same row in a request.
If we update the last_checked value of a row anyways I think we could directly also set the last activity value to avoid double updates of that row.
This is triggered from
server/lib/private/User/Session.php
Lines 818 to 829 in ec5133b
I could verify this by manually
update oc_authtoken set last_check = 0, last_activity = 0;to simulate older timestampts and stepping through the next request with a debugger