Page MenuHomePhabricator

MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for '*' in 'content_models'
Open, Needs TriagePublicPRODUCTION ERROR

Description

Steps to replicate the issue (include links if applicable):

  • figure out a content model that has no pages on your wiki yet (for example, MediaWiki:Test.vue if your content_models table doesn't have vue yet)
  • create a page with that content model

What happens?:

  • MediaWiki\Storage\NameTableAccessException: No insert possible but primary DB didn't give us a record for '*' in 'content_models'
  • page is not created
  • no changes are made to the content_models table

What should have happened instead?:

  • no exception
  • page is created
  • a row is added to the content_models table

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Related Objects

Event Timeline

The IGNORE in NameTableStore is problematic I think.

Relevant NameTableStore.php code:

		$dbw->newInsertQueryBuilder()
			->insertInto( $this->table )
			->ignore() // <----- the IGNORE statement that Ladsgroup mentioned
			->row( $this->getFieldsToStore( $name ) )
			->caller( __METHOD__ )->execute();

		if ( $dbw->affectedRows() > 0 ) {
			$id = $dbw->insertId();
			// ...
		}

		// ...

		$id = $dbw->newSelectQueryBuilder()
			->select( [ 'id' => $this->idField ] )
			->from( $this->table )
			->where( [ $this->nameField => $name ] )
			->caller( __METHOD__ )->fetchField();

		if ( $id === false ) {
			// Insert failed due to IGNORE flag, but DB_PRIMARY didn't give us the data
			$m = "No insert possible but primary DB didn't give us a record for " .
				"'{$name}' in '{$this->table}'";
			$this->logger->error( $m );
			throw new NameTableAccessException( $m );
		}
Restricted Application changed the subtype of this task from "Bug Report" to "Production Error". · View Herald TranscriptMay 11 2026, 9:09 PM
Error
  • mwversion: 1.47.0-wmf.1
  • timestamp: 2026-05-11T15:47:16.574Z
  • phpversion: 8.3.30
  • reqId: f0f371b6-15a9-4ae0-9e73-fc61d81f757a
  • 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 'vue' in 'content_models'
FrameLocationCall
from/srv/mediawiki/php-1.47.0-wmf.1/includes/Storage/NameTableStore.php(365)
#0/srv/mediawiki/php-1.47.0-wmf.1/includes/Storage/NameTableStore.php(125)MediaWiki\Storage\NameTableStore->store(string)
#1/srv/mediawiki/php-1.47.0-wmf.1/includes/Revision/RevisionStore.php(922)MediaWiki\Storage\NameTableStore->acquireId(string)
#2/srv/mediawiki/php-1.47.0-wmf.1/includes/Revision/RevisionStore.php(662)MediaWiki\Revision\RevisionStore->insertContentRowOn(MediaWiki\Revision\SlotRecord, Wikimedia\Rdbms\DatabaseMySQL, string)
#3/srv/mediawiki/php-1.47.0-wmf.1/includes/Revision/RevisionStore.php(620)MediaWiki\Revision\RevisionStore->insertSlotOn(Wikimedia\Rdbms\DatabaseMySQL, int, MediaWiki\Revision\SlotRecord, MediaWiki\Page\PageIdentityValue, array)
#4/srv/mediawiki/php-1.47.0-wmf.1/includes/Revision/RevisionStore.php(432)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.47.0-wmf.1/includes/libs/Rdbms/Database/Database.php(2328)MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Wikimedia\Rdbms\DatabaseMySQL, string)
#6/srv/mediawiki/php-1.47.0-wmf.1/includes/libs/Rdbms/Database/DBConnRef.php(129)Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#7/srv/mediawiki/php-1.47.0-wmf.1/includes/libs/Rdbms/Database/DBConnRef.php(766)Wikimedia\Rdbms\DBConnRef->__call(string, array)
#8/srv/mediawiki/php-1.47.0-wmf.1/includes/Revision/RevisionStore.php(423)Wikimedia\Rdbms\DBConnRef->doAtomicSection(string, Closure)
#9/srv/mediawiki/php-1.47.0-wmf.1/includes/Storage/PageUpdater.php(1462)MediaWiki\Revision\RevisionStore->insertRevisionOn(MediaWiki\Revision\MutableRevisionRecord, Wikimedia\Rdbms\DBConnRef)
#10/srv/mediawiki/php-1.47.0-wmf.1/includes/Storage/PageUpdater.php(878)MediaWiki\Storage\PageUpdater->doCreate(MediaWiki\CommentStore\CommentStoreComment)
#11/srv/mediawiki/php-1.47.0-wmf.1/includes/PageEdit/PageEdit.php(375)MediaWiki\Storage\PageUpdater->saveRevision(MediaWiki\CommentStore\CommentStoreComment, int)
#12/srv/mediawiki/php-1.47.0-wmf.1/includes/PageEdit/PageEdit.php(96)MediaWiki\PageEdit\PageEdit->doEdit()
#13/srv/mediawiki/php-1.47.0-wmf.1/includes/EditPage/EditPage.php(2044)MediaWiki\PageEdit\PageEdit->edit()
#14/srv/mediawiki/php-1.47.0-wmf.1/includes/EditPage/EditPage.php(1703)MediaWiki\EditPage\EditPage->internalAttemptSave(null, bool, bool)
#15/srv/mediawiki/php-1.47.0-wmf.1/includes/EditPage/EditPage.php(631)MediaWiki\EditPage\EditPage->attemptSave(null)
#16/srv/mediawiki/php-1.47.0-wmf.1/includes/Actions/EditAction.php(55)MediaWiki\EditPage\EditPage->edit()
#17/srv/mediawiki/php-1.47.0-wmf.1/includes/Actions/SubmitAction.php(29)MediaWiki\Actions\EditAction->show()
#18/srv/mediawiki/php-1.47.0-wmf.1/includes/Actions/ActionEntryPoint.php(753)MediaWiki\Actions\SubmitAction->show()
#19/srv/mediawiki/php-1.47.0-wmf.1/includes/Actions/ActionEntryPoint.php(511)MediaWiki\Actions\ActionEntryPoint->performAction(MediaWiki\Page\Article, MediaWiki\Title\Title)
#20/srv/mediawiki/php-1.47.0-wmf.1/includes/Actions/ActionEntryPoint.php(145)MediaWiki\Actions\ActionEntryPoint->performRequest()
#21/srv/mediawiki/php-1.47.0-wmf.1/includes/MediaWikiEntryPoint.php(180)MediaWiki\Actions\ActionEntryPoint->execute()
#22/srv/mediawiki/php-1.47.0-wmf.1/index.php(44)MediaWiki\MediaWikiEntryPoint->run()
#23/srv/mediawiki/w/index.php(3)require(string)
#24{main}

https://it.wikipedia.org/w/index.php?action=submit&title=*

Error

I'm not sure if this "empty cache" log entry is relevant or not, so I'll include it too:

  • mwversion: 1.47.0-wmf.1
  • timestamp: 2026-05-11T15:47:16.458Z
  • phpversion: 8.3.30
  • reqId: f0f371b6-15a9-4ae0-9e73-fc61d81f757a
  • Find reqId in Logstash
normalized_message
Empty cache for key '{key}' but not for user.
exception.trace

https://it.wikipedia.org/w/index.php?action=submit&title=*

I was unable to reproduce this in localhost. I tried the normal way, and also by messing with the structure of the content_models table (removing primary key, removing auto increment, setting auto increment wrong). This is a production only bug. Perhaps because we have DB replicas and my localhost just has one MariaDB primary.

Not sure if that’s because of anyone’s action, but it now works. Probably still worth investigating though