Page MenuHomePhabricator

enwiki: MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for 'SecurePoll' in 'content_models'
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
  • mwversion: 1.45.0-wmf.9
  • timestamp: 2025-07-13T06:50:33.197Z
  • phpversion: 8.1.32
  • reqId: b3165253-43e8-4708-88b3-a07ea636d8ed
  • Find reqId in Logstash
normalized_message
[{reqId}] {exception_url}   MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for 'SecurePoll' in 'content_models'
FrameLocationCall
from/srv/mediawiki/php-1.45.0-wmf.9/includes/Storage/NameTableStore.php(405)
#0/srv/mediawiki/php-1.45.0-wmf.9/includes/Storage/NameTableStore.php(165)MediaWiki\Storage\NameTableStore->store(string)
#1/srv/mediawiki/php-1.45.0-wmf.9/includes/Revision/RevisionStore.php(972)MediaWiki\Storage\NameTableStore->acquireId(string)
#2/srv/mediawiki/php-1.45.0-wmf.9/includes/Revision/RevisionStore.php(711)MediaWiki\Revision\RevisionStore->insertContentRowOn(MediaWiki\Revision\SlotRecord, Wikimedia\Rdbms\DatabaseMySQL, string)
#3/srv/mediawiki/php-1.45.0-wmf.9/includes/Revision/RevisionStore.php(669)MediaWiki\Revision\RevisionStore->insertSlotOn(Wikimedia\Rdbms\DatabaseMySQL, int, MediaWiki\Revision\SlotRecord, MediaWiki\Page\PageIdentityValue, array)
#4/srv/mediawiki/php-1.45.0-wmf.9/includes/Revision/RevisionStore.php(482)MediaWiki\Revision\RevisionStore->insertRevisionInternal(MediaWiki\Revision\MutableRevisionRecord, Wikimedia\Rdbms\DatabaseMySQL, MediaWiki\User\User, MediaWiki\CommentStore\CommentStoreComment, MediaWiki\Page\PageIdentityValue, int, int)
#5/srv/mediawiki/php-1.45.0-wmf.9/includes/libs/rdbms/database/Database.php(2293)MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Wikimedia\Rdbms\DatabaseMySQL, string)
#6/srv/mediawiki/php-1.45.0-wmf.9/includes/libs/rdbms/database/DBConnRef.php(127)Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#7/srv/mediawiki/php-1.45.0-wmf.9/includes/libs/rdbms/database/DBConnRef.php(661)Wikimedia\Rdbms\DBConnRef->__call(string, array)
#8/srv/mediawiki/php-1.45.0-wmf.9/includes/Revision/RevisionStore.php(490)Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure)
#9/srv/mediawiki/php-1.45.0-wmf.9/includes/Storage/PageUpdater.php(1576)MediaWiki\Revision\RevisionStore->insertRevisionOn(MediaWiki\Revision\MutableRevisionRecord, Wikimedia\Rdbms\DBConnRef)
#10/srv/mediawiki/php-1.45.0-wmf.9/includes/Storage/PageUpdater.php(986)MediaWiki\Storage\PageUpdater->doCreate(MediaWiki\CommentStore\CommentStoreComment)
#11/srv/mediawiki/php-1.45.0-wmf.9/extensions/SecurePoll/includes/TranslationRepo.php(106)MediaWiki\Storage\PageUpdater->saveRevision(MediaWiki\CommentStore\CommentStoreComment)
#12/srv/mediawiki/php-1.45.0-wmf.9/extensions/SecurePoll/includes/Pages/TranslatePage.php(306)MediaWiki\Extension\SecurePoll\TranslationRepo->setTranslation(MediaWiki\Extension\SecurePoll\Entities\Election, array, string, MediaWiki\User\User, string)
#13/srv/mediawiki/php-1.45.0-wmf.9/extensions/SecurePoll/includes/Pages/TranslatePage.php(150)MediaWiki\Extension\SecurePoll\Pages\TranslatePage->doSubmit(string)
#14/srv/mediawiki/php-1.45.0-wmf.9/extensions/SecurePoll/includes/SpecialSecurePoll.php(70)MediaWiki\Extension\SecurePoll\Pages\TranslatePage->execute(array)
#15/srv/mediawiki/php-1.45.0-wmf.9/includes/specialpage/SpecialPage.php(725)MediaWiki\Extension\SecurePoll\SpecialSecurePoll->execute(string)
#16/srv/mediawiki/php-1.45.0-wmf.9/includes/specialpage/SpecialPageFactory.php(1724)MediaWiki\SpecialPage\SpecialPage->run(string)
#17/srv/mediawiki/php-1.45.0-wmf.9/includes/actions/ActionEntryPoint.php(499)MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#18/srv/mediawiki/php-1.45.0-wmf.9/includes/actions/ActionEntryPoint.php(143)MediaWiki\Actions\ActionEntryPoint->performRequest()
#19/srv/mediawiki/php-1.45.0-wmf.9/includes/MediaWikiEntryPoint.php(198)MediaWiki\Actions\ActionEntryPoint->execute()
#20/srv/mediawiki/php-1.45.0-wmf.9/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#21/srv/mediawiki/w/index.php(3)require(string)
#22{main}
Impact
Notes

Details

Request URL
https://en.wikipedia.org/w/index.php?title=Special:SecurePoll/translate/828/en&action=submit
Related Changes in Gerrit:

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Zabe renamed this task from Fatal exception of type "MediaWiki\Storage\NameTableAccessException" to MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for 'SecurePoll' in 'content_models'.Jul 13 2025, 11:05 AM
Zabe updated the task description. (Show Details)
Novem_Linguae added a subscriber: SD0001.

This bug occurs when I go to edit a translation on enwiki's test election, so is probably a blocker for English Wikipedia admin elections voting phase on July 22.

@SD0001, this is probably related to T378444 if you want to take a look.

Couldn't reproduce locally. T378444 sounds unrelated. There's currently no page in enwiki of SecurePoll content model, and the edit is trying to create it... and failing for some reason.

Timeline

Personally, I suspect T378444 (the MediaWiki namespace logging feature) + an enwiki configuration variable that is different from the defaults in our localhost environment.

When querying enwiki, "SecurePoll" is not appearing in the query SELECT * FROM content_models; Should it be appearing there? Is the fix to add some code that checks if the content model exists in the DB, and if it doesn't, do a one time add?

https://quarry.wmcloud.org/query/95518

image.png (1,094×741 px, 27 KB)

NameTableStore::store() is supposed to do it by itself, the first time a page with the content model is saved.

The statement in question is :

		$dbw->newInsertQueryBuilder()
			->insertInto( $this->table )
			->ignore()
			->row( $this->getFieldsToStore( $name ) )
			->caller( __METHOD__ )->execute();

Following this, $dbw->affectedRows() is inexplicably 0, and the select query to recheck if was inserted gives an empty result, leading to the exception.

Change #1169298 had a related patch set uploaded (by Novem Linguae; author: Novem Linguae):

[operations/mediawiki-config@master] Revert "initialiseSettings: set wgSecurePollUseMediaWikiNamespace = true for enwiki"

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

Another way to fix (workaround) this would be to create the row manually:

INSERT INTO content_models(model_name) VALUES ('SecurePoll');

Change #1169298 merged by jenkins-bot:

[operations/mediawiki-config@master] Revert "initialiseSettings: set wgSecurePollUseMediaWikiNamespace = true for enwiki"

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

Mentioned in SAL (#wikimedia-operations) [2025-07-15T20:07:26Z] <zabe@deploy1003> Started scap sync-world: Backport for [[gerrit:1169298|Revert "initialiseSettings: set wgSecurePollUseMediaWikiNamespace = true for enwiki" (T398080 T399372)]]

Mentioned in SAL (#wikimedia-operations) [2025-07-15T20:09:36Z] <zabe@deploy1003> novemlinguae, zabe: Backport for [[gerrit:1169298|Revert "initialiseSettings: set wgSecurePollUseMediaWikiNamespace = true for enwiki" (T398080 T399372)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

When running the query without the IGNORE, it first failed with Duplicate entry '9' for key 'PRIMARY' but then it worked. This sounds like autoincremental counter was wrong.

1> $dbw->newInsertQueryBuilder()->insertInto( 'content_models' )->row( [ 'model_name' => 'SecurePoll' ] )->execute()
2
3 Wikimedia\Rdbms\DBQueryError Error 1062: Duplicate entry '9' for key 'PRIMARY'
4Function: Wikimedia\Rdbms\InsertQueryBuilder
5Query: INSERT INTO `content_models` (model_name) VALUES ('SecurePoll').
6
7> $dbw->newInsertQueryBuilder()->insertInto( 'content_models' )->row( [ 'model_name' => 'SecurePoll' ] )->execute()
8= null
9
10>

We now have the following content models.

wikiadmin2023@10.64.48.169(enwiki)> select * from content_models;
+----------+------------------------+
| model_id | model_name             |
+----------+------------------------+
|        5 | MassMessageListContent |
|        3 | Scribunto              |
|       10 | SecurePoll             |
|        4 | css                    |
|        9 | flow-board             |
|        2 | javascript             |
|        8 | json                   |
|        6 | sanitized-css          |
|        7 | text                   |
|        1 | wikitext               |
+----------+------------------------+
10 rows in set (0.001 sec)

wikiadmin2023@10.64.48.169(enwiki)>
Novem_Linguae raised the priority of this task from High to Needs Triage.Jul 15 2025, 8:27 PM

Lowering priority. Is no longer blocking enwiki administrator elections because we ran the query INSERT INTO content_models (model_name) VALUES ('SecurePoll'). Still needs to stay open though to investigate and fix root cause.

Ok on dewiki the autoincrement value is also at 1 for some replicas. So I would guess, that it was also wrong for the enwiki primary?

wikiadmin2023@10.64.0.89(dewiki)> select * from content_models;
+----------+------------------------+
| model_id | model_name             |
+----------+------------------------+
|        7 | MassMessageListContent |
|        4 | Scribunto              |
|        2 | css                    |
|        3 | javascript             |
|        5 | json                   |
|        6 | sanitized-css          |
|        8 | text                   |
|        1 | wikitext               |
+----------+------------------------+
8 rows in set (0.001 sec)

wikiadmin2023@10.64.0.89(dewiki)>
zabe@deploy1003:~$ sql dewiki
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 54431557
Server version: 10.11.13-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

wikiadmin2023@10.64.0.48(dewiki)> SELECT `AUTO_INCREMENT` FROM  INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dewiki' AND   TABLE_NAME   = 'content_models';
+----------------+
| AUTO_INCREMENT |
+----------------+
|              9 |
+----------------+
1 row in set (0.001 sec)

wikiadmin2023@10.64.0.48(dewiki)> exit
Bye
zabe@deploy1003:~$ sql dewiki
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 28842213
Server version: 10.11.13-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

wikiadmin2023@10.64.135.11(dewiki)> SELECT `AUTO_INCREMENT` FROM  INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dewiki' AND   TABLE_NAME   = 'content_models';
+----------------+
| AUTO_INCREMENT |
+----------------+
|              1 |
+----------------+
1 row in set (0.001 sec)

wikiadmin2023@10.64.135.11(dewiki)>
Novem_Linguae renamed this task from MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for 'SecurePoll' in 'content_models' to enwiki: MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for 'SecurePoll' in 'content_models'.Aug 12 2025, 9:25 AM
Novem_Linguae closed this task as Resolved.
Novem_Linguae claimed this task.

Resolving this one because the scope of this one is enwiki only and enwiki has been fixed. See parent ticket for more fixing that is needed for other databases.