jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/351794 )
Change subject: Release connections as early as possible in CognateStore
......................................................................
Release connections as early as possible in CognateStore
Again not the cause, but every little helps.
insertPage now releases the read connection before
fetching a write connection rather than holding both for the whole
execution time of the method.
Bug: T164407
Change-Id: Ia1c6563da2a6eb614c16a872d7205c6c12a00d9c
---
M src/CognateStore.php
1 file changed, 6 insertions(+), 5 deletions(-)
Approvals:
WMDE-leszek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/CognateStore.php b/src/CognateStore.php
index 35a9251..da33ecf 100644
--- a/src/CognateStore.php
+++ b/src/CognateStore.php
@@ -57,7 +57,6 @@
* @return bool true on success, false if there was a key conflict
*/
public function insertPage( $dbName, LinkTarget $linkTarget ) {
- $dbw = $this->connectionManager->getWriteConnectionRef();
$dbr = $this->connectionManager->getReadConnectionRef();
list( $pagesToInsert, $titlesToInsert ) = $this->buildRows(
@@ -71,11 +70,13 @@
[ 'cgti_raw_key' => $this->getStringHash(
$linkTarget->getDBkey() ) ],
__METHOD__
);
+ $this->connectionManager->releaseConnection( $dbr );
if ( $row && $row->cgti_raw !== $linkTarget->getDBkey() ) {
return false;
}
+ $dbw = $this->connectionManager->getWriteConnectionRef();
if ( !$row ) {
$dbw->insert(
self::TITLES_TABLE_NAME,
@@ -144,6 +145,7 @@
],
__METHOD__
);
+ $this->connectionManager->releaseConnection( $dbr );
$linkDetails = [];
while ( $row = $result->fetchRow() ) {
@@ -179,6 +181,7 @@
],
__METHOD__
);
+ $this->connectionManager->releaseConnection( $dbr );
$sites = [];
while ( $row = $result->fetchRow() ) {
@@ -199,8 +202,6 @@
* e.g. [ [ 'site' => 'enwiktionary', 'namespace' => 0, 'title'
=> 'Berlin' ] ]
*/
public function insertPages( array $pageDetailsArray ) {
- $dbw = $this->connectionManager->getWriteConnectionRef();
-
$pagesToInsert = [];
$titlesToInsert = [];
foreach ( $pageDetailsArray as $pageDetails ) {
@@ -212,6 +213,7 @@
);
}
+ $dbw = $this->connectionManager->getWriteConnectionRef();
$dbw->insert(
self::TITLES_TABLE_NAME,
$titlesToInsert,
@@ -260,8 +262,6 @@
* e.g. 'enwiktionary' => 'en'
*/
public function insertSites( array $sites ) {
- $dbw = $this->connectionManager->getWriteConnectionRef();
-
$toInsert = [];
foreach ( $sites as $dbname => $interwikiPrefix ) {
$toInsert[] = [
@@ -271,6 +271,7 @@
];
}
+ $dbw = $this->connectionManager->getWriteConnectionRef();
$dbw->insert(
'cognate_sites',
$toInsert,
--
To view, visit https://gerrit.wikimedia.org/r/351794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1c6563da2a6eb614c16a872d7205c6c12a00d9c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cognate
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits