Page MenuHomePhabricator

Error "CAS update failed on user_touched the user to be saved is older than the current version." due to empty user_touched values in the user table
Open, Needs TriagePublic

Description

We had the need to restore an old 1.27.3 backup and after somewhat successful restoring the database and the images from a backup we get the following error when trying to log in:

a9b4f70a8d238d6da0f81c6c] /index.php/Special:UserLogin MWException from line 3809 of /var/www/mediawiki/code/includes/user/User.php: CAS update failed on user_touched for user ID '2' (read from slave); the version of the user to be saved is older than the current version.

Backtrace:

#0 /var/www/mediawiki/code/includes/session/SessionBackend.php(639): User->saveSettings()

Now there are dozens of entries in Phabricator when searching for CAS update failed on user_touched but i did not find an explanation what the reason for this behavior is and what sense to make of the error message. Where is the documentation for this?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 16 2020, 12:23 PM
Aklapper changed the task status from Open to Stalled.Mar 16 2020, 1:44 PM

We had the need to restore an old 1.27.3 backup

Into a MediaWiki 1.27.3 installation? Or which MediaWiki version?

and after somewhat successful restoring the database and the images from a backup

Which exact steps were taken?

#0 /var/www/mediawiki/code/includes/session/SessionBackend.php(639): User->saveSettings()

Is that the complete backtrace?

Where is the documentation for this?

I'm afraid there won't be documentation which covers each and every potential case why an error might be triggered by random code in a random extension.
For the start, does this still happen after disabling all non-default MediaWiki extensions?

You may need to set the user_touched field of the user table to the current timestamp (in case it's null or empty on the database, or if it has a future date). Check also the system clock (both from the database server and the application server) and be sure they're in sync

Yes - the environment is a Mediawiki 1.27.3 farm that is fully functional for half a dozen other wikis. Due to the farm aspect it won't be easy to switch off the extensions and we might have to retry the whole problem on a compatible other backup server where backups of the wikis run and the switching off will not harm production operations.

For the user table see the select below.

User 2 and 4 can't log in. For the others i do not have credentials but could try the maintainance/changePassword.php

select user_id,user_touched from user;
+---------+----------------+
| user_id | user_touched   |
+---------+----------------+
|       1 | 20160103160331 |
|       2 |                |
|       3 |                |
|       4 |                |
|       5 |                |
|       6 |                |
|       7 |                |
|       8 |                |
|       9 |                |
|      10 |                |
|      11 |                |
|      13 | 20160107082548 |
|      14 | 20160118204440 |
|      15 |                |
|      16 | 20160309172416 |
|      17 | 20170704143342 |
+---------+----------------+
16 rows in set (0.00 sec)

user_touched is a binary - how is this properly set with sql?

//I'm afraid there won't be documentation which covers each and every potential case why an error might be triggered by random code in a random extension.

I doubt an extension is the cause of the problem. For me it's more relevant that is a showstopper. Usually i love Mediawiki for being a software that will keep working even if part of the system or part of the pages are corrupted. Not being able to login is one of the rare cases that need a different approach. My hope would be that error messages from the "showstopper" category would be handled somewhere with an FAQ - a list of remedies or the like. The current Phabricator approach makes sifting thru the potential cases very hard. Also more often than not error messages are simply misleading.

@Ciencia_Al_Poder

update user set user_touched='20200316120000' where user_id='2';

worked like a charm - this workaround should IMHO be promoted more prominently ...

update user set user_touched='20200316120000' where hex(user_touched)='0000000000000000000000000000';

is a more general approach

this workaround should IMHO be promoted more prominently ...

Please feel very welcome to add an item to https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms !
Glad you found a workaround (and thanks @Ciencia_Al_Poder)!

Aklapper renamed this task from CAS update failed on user_touched the user to be saved is older than the current version. - What to do? to Error "CAS update failed on user_touched the user to be saved is older than the current version." due to empty user_touched values in the user table.Mar 16 2020, 2:32 PM
Aklapper changed the task status from Stalled to Open.
Aklapper added a project: MediaWiki-General.

Note: This page has been protected so that only autoconfirmed users can edit it. The latest log entry is provided below for reference:

I've removed the protection

Did you fiddle with the database to get those blanks there?

Seppl2013 added a comment.EditedMar 19 2020, 10:59 AM

Not that I'd know of. All i did was dumping / restoring the database with mysldump and mysql command line