Page MenuHomePhabricator

Wikimedia\Rdbms\Database::normalizeUpsertKeys called with deprecated parameter style: the unique key array should be a string or array of string arrays
Closed, ResolvedPublic

Description

When I was running extensions/GrowthExperiments/maintenance/migrateMentorMenteeRelationship.php for cswiki, @Marostegui notified me that "we are getting a bunch of Wikimedia\Rdbms\Database::normalizeUpsertKeys called with deprecated parameter style: the unique key array should be a string or array of string arrays errors".

Stacktrace
from /srv/mediawiki/php-1.37.0-wmf.1/includes/libs/rdbms/database/Database.php(2245)
#0 /srv/mediawiki/php-1.37.0-wmf.1/includes/libs/rdbms/database/Database.php(3408): Wikimedia\Rdbms\Database->normalizeUpsertKeys(array)
#1 /srv/mediawiki/php-1.37.0-wmf.1/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->upsert(string, array, array, array, string)
#2 /srv/mediawiki/php-1.37.0-wmf.1/includes/libs/rdbms/database/DBConnRef.php(504): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#3 /srv/mediawiki/php-1.37.0-wmf.1/extensions/GrowthExperiments/includes/Mentorship/Store/DatabaseMentorStore.php(105): Wikimedia\Rdbms\DBConnRef->upsert(string, array, array, array, string)
#4 /srv/mediawiki/php-1.37.0-wmf.1/extensions/GrowthExperiments/includes/Mentorship/Store/DatabaseMentorStore.php(121): GrowthExperiments\Mentorship\Store\DatabaseMentorStore->setMentorForUserReal(User, User, string)
#5 /srv/mediawiki/php-1.37.0-wmf.1/extensions/GrowthExperiments/includes/Mentorship/Store/MentorStore.php(149): GrowthExperiments\Mentorship\Store\DatabaseMentorStore->setMentorForUserInternal(User, User, string)
#6 /srv/mediawiki/php-1.37.0-wmf.1/extensions/GrowthExperiments/includes/Mentorship/Store/SetUserMentorDatabaseJob.php(47): GrowthExperiments\Mentorship\Store\MentorStore->setMentorForUser(User, User, string)
#7 /srv/mediawiki/php-1.37.0-wmf.1/extensions/EventBus/includes/JobExecutor.php(79): GrowthExperiments\Mentorship\Store\SetUserMentorDatabaseJob->run()
#8 /srv/mediawiki/rpc/RunSingleJob.php(76): MediaWiki\Extension\EventBus\JobExecutor->execute(array)
#9 {main}

Logstash link: https://logstash.wikimedia.org/goto/004b938dedef4a372378b6b3460c78c7

Event Timeline

Urbanecm_WMF created this task.

Blocks the mentor/mentee migration, and logspam triggered by our team.

Change 681079 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] DatabaseMentorStore: Fix deprecation warning in upsert query

https://gerrit.wikimedia.org/r/681079

So apparently [ 'gemm_mentee_id', 'gemm_mentor_role' ] is normalized into [ [ 'gemm_mentee_id' ], [ 'gemm_mentor_role' ] ] which is incorrect (it would mean gemm_mentee_id and gemm_mentor_role are both unique keys). It doesn't really matter in this case because the MySQL implementation of the database layer ignores this parameter completely (it uses ON DUPLICATE KEY UPDATE while the generic implementation would make a normal UPDATE with the given unique keys and an INSERT if that doesn't update anything). A very error-prone pattern though so good job deprecating it; bad job not really documenting that it's deprecated.

Change 681079 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] DatabaseMentorStore: Fix deprecation warning in upsert query

https://gerrit.wikimedia.org/r/681079

Change 680860 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@wmf/1.37.0-wmf.1] DatabaseMentorStore: Fix deprecation warning in upsert query

https://gerrit.wikimedia.org/r/680860

Change 680860 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@wmf/1.37.0-wmf.1] DatabaseMentorStore: Fix deprecation warning in upsert query

https://gerrit.wikimedia.org/r/680860

Mentioned in SAL (#wikimedia-operations) [2021-04-19T18:02:19Z] <urbanecm@deploy1002> Synchronized php-1.37.0-wmf.1/extensions/GrowthExperiments/includes/Mentorship/Store/DatabaseMentorStore.php: 0233507470377f6ac45768e345cd2e359e5d0e57: DatabaseMentorStore: Fix deprecation warning in upsert query (T280525) (duration: 00m 57s)