X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Finstaller%2FSqliteInstaller.php;h=37d91532d7bae8580b027db689dcf27dccabbeea;hp=a8abba9c08f4a37a17fe7caacbf9c04dae0fdbf9;hb=a469e81971a11b931716897d65e1fa3fdfe378e2;hpb=f2b8d2d23c2739150b43aab950ecbd5f8b900028 diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index a8abba9c08..37d91532d7 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -34,7 +34,7 @@ use Wikimedia\Rdbms\DBConnectionError; class SqliteInstaller extends DatabaseInstaller { public static $minimumVersion = '3.8.0'; - protected static $notMiniumumVerisonMessage = 'config-outdated-sqlite'; + protected static $notMinimumVerisonMessage = 'config-outdated-sqlite'; /** * @var DatabaseSqlite @@ -231,6 +231,7 @@ class SqliteInstaller extends DatabaseInstaller { $status->merge( $this->makeStubDBFile( $dir, $db ) ); $status->merge( $this->makeStubDBFile( $dir, "wikicache" ) ); $status->merge( $this->makeStubDBFile( $dir, "{$db}_l10n_cache" ) ); + $status->merge( $this->makeStubDBFile( $dir, "{$db}_jobqueue" ) ); if ( !$status->isOK() ) { return $status; } @@ -283,6 +284,39 @@ EOT; return Status::newFatal( 'config-sqlite-connection-error', $e->getMessage() ); } + # Create the job queue DB + try { + $conn = Database::factory( + 'sqlite', [ 'dbname' => "{$db}_jobqueue", 'dbDirectory' => $dir ] ); + # @todo: don't duplicate job definition, though it's very static + $sql = +<<query( $sql ); + $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(); } @@ -298,10 +332,8 @@ EOT; if ( !is_writable( $file ) ) { return Status::newFatal( 'config-sqlite-readonly', $file ); } - } else { - if ( file_put_contents( $file, '' ) === false ) { - return Status::newFatal( 'config-sqlite-cant-create-db', $file ); - } + } elseif ( file_put_contents( $file, '' ) === false ) { + return Status::newFatal( 'config-sqlite-cant-create-db', $file ); } return Status::newGood(); @@ -340,7 +372,9 @@ EOT; */ public function getLocalSettings() { $dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) ); - + // These tables have frequent writes and are thus split off from the main one. + // Since the code using these tables only uses transactions for writes then set + // them to using BEGIN IMMEDIATE. This avoids frequent lock errors on first write. return "# SQLite-specific settings \$wgSQLiteDataDir = \"{$dir}\"; \$wgObjectCaches[CACHE_DB] = [ @@ -350,7 +384,9 @@ EOT; 'type' => 'sqlite', 'dbname' => 'wikicache', 'tablePrefix' => '', + 'variables' => [ 'synchronous' => 'NORMAL' ], 'dbDirectory' => \$wgSQLiteDataDir, + 'trxMode' => 'IMMEDIATE', 'flags' => 0 ] ]; @@ -358,8 +394,22 @@ EOT; 'type' => 'sqlite', 'dbname' => \"{\$wgDBname}_l10n_cache\", 'tablePrefix' => '', + 'variables' => [ 'synchronous' => 'NORMAL' ], 'dbDirectory' => \$wgSQLiteDataDir, + 'trxMode' => 'IMMEDIATE', 'flags' => 0 +]; +\$wgJobTypeConf['default'] = [ + 'class' => 'JobQueueDB', + 'claimTTL' => 3600, + 'server' => [ + 'type' => 'sqlite', + 'dbname' => \"{\$wgDBname}_jobqueue\", + 'tablePrefix' => '', + 'dbDirectory' => \$wgSQLiteDataDir, + 'trxMode' => 'IMMEDIATE', + 'flags' => 0 + ] ];"; } }