jenkins-bot has submitted this change and it was merged.

Change subject: Made the SQLite installer make a separate objectcache DB
......................................................................


Made the SQLite installer make a separate objectcache DB

* This avoids severe lock contention if CACHE_DB is used and also makes
  cache sharing between wikis simple (keys are always prefixed as needed).

Bug: T89180
Change-Id: I864272af099a9ebe2b3648e2714d2ccdee20305d
---
M includes/installer/SqliteInstaller.php
1 file changed, 55 insertions(+), 7 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/installer/SqliteInstaller.php 
b/includes/installer/SqliteInstaller.php
index 37fba15..1e7e969 100644
--- a/includes/installer/SqliteInstaller.php
+++ b/includes/installer/SqliteInstaller.php
@@ -226,6 +226,49 @@
                }
 
                $db = $this->getVar( 'wgDBname' );
+
+               # Make the main and cache stub DB files
+               $status = Status::newGood();
+               $status->merge( $this->makeStubDBFile( $dir, $db ) );
+               $status->merge( $this->makeStubDBFile( $dir, "wikicache" ) );
+               if ( !$status->isOK() ) {
+                       return $status;
+               }
+
+               # Nuke the unused settings for clarity
+               $this->setVar( 'wgDBserver', '' );
+               $this->setVar( 'wgDBuser', '' );
+               $this->setVar( 'wgDBpassword', '' );
+               $this->setupSchemaVars();
+
+               # Create the global cache DB
+               try {
+                       global $wgSQLiteDataDir;
+                       # @todo FIXME: setting globals kind of sucks
+                       $wgSQLiteDataDir = $dir;
+                       $conn = DatabaseBase::factory( 'sqlite', array( 
'dbname' => "wikicache" ) );
+                       # @todo: don't duplicate objectcache definition, though 
it's very simple
+                       $sql =
+<<<EOT
+       CREATE TABLE IF NOT EXISTS objectcache (
+         keyname BLOB NOT NULL default '' PRIMARY KEY,
+         value BLOB,
+         exptime TEXT
+       )
+EOT;
+                       $conn->query( $sql );
+                       $conn->query( "CREATE INDEX IF NOT EXISTS exptime ON 
objectcache (exptime)" );
+                       $conn->query( "PRAGMA journal_mode=WAL" ); // this is 
permanent
+                       $conn->close();
+               } catch ( DBConnectionError $e ) {
+                       return Status::newFatal( 
'config-sqlite-connection-error', $e->getMessage() );
+               }
+
+               # Open the main DB
+               return $this->getConnection();
+       }
+
+       protected function makeStubDBFile( $dir, $db ) {
                $file = DatabaseSqlite::generateFileName( $dir, $db );
                if ( file_exists( $file ) ) {
                        if ( !is_writable( $file ) ) {
@@ -236,13 +279,8 @@
                                return Status::newFatal( 
'config-sqlite-cant-create-db', $file );
                        }
                }
-               // nuke the unused settings for clarity
-               $this->setVar( 'wgDBserver', '' );
-               $this->setVar( 'wgDBuser', '' );
-               $this->setVar( 'wgDBpassword', '' );
-               $this->setupSchemaVars();
 
-               return $this->getConnection();
+               return Status::newGood();
        }
 
        /**
@@ -280,6 +318,16 @@
                $dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 
'wgSQLiteDataDir' ) );
 
                return "# SQLite-specific settings
-\$wgSQLiteDataDir = \"{$dir}\";";
+\$wgSQLiteDataDir = \"{$dir}\";
+\$wgObjectCaches[CACHE_DB] = array(
+       'class' => 'SqlBagOStuff',
+       'loggroup' => 'SQLBagOStuff',
+       'server' => array(
+               'type' => 'sqlite',
+               'dbname' => 'wikicache',
+               'tablePrefix' => '',
+               'flags' => 0
+       )
+);";
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/192476
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I864272af099a9ebe2b3648e2714d2ccdee20305d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: Waldir <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to