nextcloud-server/lib/private/Authentication
Christoph Wurst 7dd7256cfe
Prevent duplicate auth token activity updates
The auth token activity logic works as follows
* Read auth token
* Compare last activity time stamp to current time
* Update auth token activity if it's older than x seconds

This works fine in isolation but with concurrency that means that
occasionally the same token is read simultaneously by two processes and
both of these processes will trigger an update of the same row.
Affectively the second update doesn't add much value. It might set the
time stamp to the exact same time stamp or one a few seconds later. But
the last activity is no precise science, we don't need this accuracy.

This patch changes the UPDATE query to include the expected value in a
comparison with the current data. This results in an affected row when
the data in the DB still has an old time stamp, but won't affect a row
if the time stamp is (nearly) up to date.

This is a micro optimization and will possibly not show any significant
performance improvement. Yet in setups with a DB cluster it means that
the write node has to send fewer changes to the read nodes due to the
lower number of actual changes.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-10-22 09:32:22 +07:00
..
Events Update php licenses 2021-06-04 22:02:41 +07:00
Exceptions Update php licenses 2021-06-04 22:02:41 +07:00
Listeners prevent the invalidation of pw based authn tokens on a pw less login 2021-07-16 14:31:06 +07:00
Login Update php licenses 2021-06-04 22:02:41 +07:00
LoginCredentials Update php licenses 2021-06-04 22:02:41 +07:00
Notifications Update php licenses 2021-06-04 22:02:41 +07:00
Token Prevent duplicate auth token activity updates 2021-10-22 09:32:22 +07:00
TwoFactorAuth Update php licenses 2021-06-04 22:02:41 +07:00
WebAuthn Properly cleanup entries of WebAuthn on user deletion 2021-06-18 09:42:32 +07:00