Page MenuHomePhabricator

DBTransactionSizeError: Transaction spent {time}s in writes, exceeding the 3s limit
Open, Needs TriagePublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):
On betacommons:

action	globalpreferences
format	json
change	userjs-BawlTackOnEchoGlobal={"1656080881662_0":{"icon":"svgBawlBlackCopyIcon","user":"AJ","link":"","msg":"copy"}}
token	[redacted]

What happens?:

{"globalpreferences":"success"}

[YrXKTcDtZadeuZa146t7CgAAAA0] /w/api.php Wikimedia\Rdbms\DBTransactionSizeError: Transaction spent {time}s in writes, exceeding the 3s limit

Backtrace:

from /srv/mediawiki/php-master/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1701)
#0 /srv/mediawiki/php-master/includes/libs/rdbms/lbfactory/LBFactory.php(320): Wikimedia\Rdbms\LoadBalancer->approvePrimaryChanges(array, string)
#1 /srv/mediawiki/php-master/includes/MediaWiki.php(679): Wikimedia\Rdbms\LBFactory->commitPrimaryChanges(string, array)
#2 /srv/mediawiki/php-master/includes/api/ApiMain.php(901): MediaWiki::preOutputCommit(DerivativeContext)
#3 /srv/mediawiki/php-master/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#4 /srv/mediawiki/php-master/api.php(90): ApiMain->execute()
#5 /srv/mediawiki/php-master/api.php(45): wfApiMain()
#6 /srv/mediawiki/w/api.php(3): require(string)
#7 {

What should have happened instead?:
Just success.

Event Timeline

Marostegui added a subscriber: Marostegui.

We (DBAs) cannot really do much about it, if the write takes longer than 3 seconds, MW aborts it. Maybe Platform Engineering can help.
All our masters look fine at the moment.

I should have checked if it really failed or not, but if it did, why did it say {"globalpreferences":"success"}?

I'm thinking maybe this is a kind of edit conflict, my script changes two different preferences at practically the same time. I wouldn't expect an issue since it's not the same preference, but maybe it's an issue anyway.

On top of that, beta cluster has its own issues and might be related to many of its problem. It can be still reproducible in production but I haven't seen that.

I'm thinking maybe this is a kind of edit conflict, my script changes two different preferences at practically the same time. I wouldn't expect an issue since it's not the same preference, but maybe it's an issue anyway.

Point 1:
The preferences are handled as one. To change one preference all preferences of the userid are read from the database, the change is applied to that data and the according changes on the database are done with DELETE + INSERT. It seems the global preferences is using REPLACE + needed DELETE, not sure if that makes different on locking.

Point 2:
According to the Etiquete https://www.mediawiki.org/wiki/API:Etiquette avoid parallel requests, just combine both in one query to improve performance

I'm thinking maybe this is a kind of edit conflict, my script changes two different preferences at practically the same time. I wouldn't expect an issue since it's not the same preference, but maybe it's an issue anyway.

Point 1:
The preferences are handled as one. To change one preference all preferences of the userid are read from the database, the change is applied to that data and the according changes on the database are done with DELETE + INSERT. It seems the global preferences is using REPLACE + needed DELETE, not sure if that makes different on locking.

Point 2:
According to the Etiquete https://www.mediawiki.org/wiki/API:Etiquette avoid parallel requests, just combine both in one query to improve performance

That's not always an option. (though I try to do that more now) If one preference needs to be updated and you know that MAYBE further down the code you'll change another, what would you do? You don't know yet if you'll be going down that path.

When the user marks individual notifications as read in quick succession within my script (and these notifications are stored as a preference), what am I supposed to do? Can't predict if the human is going to click another thing.

I'm now trying to queue these things which introduces its own problems. Edit: I think that's working now.

Besides, when the user enables/disables https://www.mediawiki.org/wiki/Extension:CodeEditor or https://www.mediawiki.org/wiki/Extension:CodeMirror a preference is updated beyond my control.

MusikAnimal added a subscriber: MusikAnimal.

Until we see an error in production, I think it's safe to assume this probably isn't an issue with GlobalPreferences, specifically. Please correct me and/or re-tag if anyone feels otherwise!