Page MenuHomePhabricator

PDOException ('There is no active transaction') after upgrading SQLite database from 1.16.5 to 1.21.1 when user is set in wgDBuser
Closed, ResolvedPublic


Author: mail

I have a MediaWiki 1.16.5 up and running and tried to upgrade to 1.21.1. Steps done :

  • created a new directory in the Apache DocRoot (test-21)
  • extracted the 1.21.1 tarball into this new directory
  • copied all the additional extensions from the the old installation (test-16/extensions)
  • copied the LocalSettings.php from the old setup to the new one
  • copied the one SQLite database container file from the old setup to a new location
  • adapted the LocalSettings.php ($wgScriptPath, wgSQLiteDataDir)
  • opened the test-21/mw-config/ URL
  • followed the instructions up to and including the database upgrade

Everything worked fine without any errors. When following the link to open the Wiki itself, I get the following error:

Unexpected non-MediaWiki exception encountered, of type "PDOException"
exception 'PDOException' with message 'There is no active transaction' in K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\db\DatabaseSqlite.php:665
Stack trace:
#0 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\db\DatabaseSqlite.php(665): PDO->commit()
#1 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\db\Database.php(3032): DatabaseSqlite->doCommit('SqlBagOStuff::s...')
#2 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\objectcache\SqlBagOStuff.php(299): DatabaseBase->begin('SqlBagOStuff::s...')
#3 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\objectcache\BagOStuff.php(243): SqlBagOStuff->set('factwikidb:mess...', 1, 10)
#4 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\cache\MessageCache.php(576): BagOStuff->add('factwikidb:mess...', 1, 10)
#5 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\cache\MessageCache.php(330): MessageCache->lock('factwikidb:mess...')
#6 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\cache\MessageCache.php(710): MessageCache->load('en')
#7 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\cache\MessageCache.php(650): MessageCache->getMsgFromNamespace('Mainpage', 'en')
#8 K:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test-21\mediawiki-1.21.1\includes\Message.php(720): MessageCache->get('mainpage', true, Object(Language))

I also tried the following:

  • Installed the 1.21.1 and created a new SQLlite DB => was working fine
  • Upgrading in the same way as described above from 1.16.5 to 1.19.7 => was working fine
  • Upgrading then from 1.19.7 to 1.20.6 => was working fine
  • Upgrading then from 1.20.6 to 1.21.1 => FAILED AGAIN with the same type of error.

Version: 1.21.x
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:55 AM
bzimport set Reference to bz49254.
bzimport added a subscriber: Unknown Object (MLST).

mail wrote:

Problem seems to be solved. I added some traces in the Database.php and DatabaseSqlite.php and noticed, that the DatabaseSqlite::openFile() was called twice in the transaction. After some code reading I found this section in the Database::__construct:

if ( $user ) {
	$this->open( $server, $user, $password, $dbName );

I also found the counterpart in the DatabaseSqlite::__construct

function __construct( $server = false, $user = false, $password = false, $dbName = false, $flags = 0 ) {
  $this->mName = $dbName;
  parent::__construct( $server, $user, $password, $dbName, $flags );
  // parent doesn't open when $user is false, but we can work with $dbName
  if( $dbName ) {
    global $wgSharedDB;
    if( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) {

While checking the LocalSettings.php I noticed that the $wgDBuser has a user defined. After removing this, everything seems to work.

Well I checked again the settings in the 1.20.6 test setup (which was running after the upgrade) and here the$ wgDBuser was also defined

When comparing the code 1.20.6 to 1.21.1, the only difference is the PRAGMA setting in the constructor of the DatabaseSqlite:

$this->query( 'PRAGMA case_sensitive_like = 1' );

Summary: When you do not specify a user in wgDBuser, then everything is working fine.

Might be a good idea to check for it in the migration scripts...


Glad that you found out the reason, thanks for investigating!
Reopening this as the problem itself is not fixed in the codebase.

stefan.reinauer wrote:

I am seeing the same issue on some of my sqlite driven MediaWiki instances. However, removing $wgDBUser did not make the problem go away. Commenting out $this->query( 'PRAGMA case_sensitive_like = 1' ); did solve the problem however.

Change 90288 had a related patch set uploaded by Tim Starling:
Fix SQLite exception when $wgDBuser is set

Change 90288 merged by jenkins-bot:
Fix SQLite exception when $wgDBuser is set