jenkins-bot has submitted this change and it was merged.
Change subject: Try to reduce lock contention due to duplicated INSERTS
......................................................................
Try to reduce lock contention due to duplicated INSERTS
Change-Id: I875dcfd5a9f991f9f8a2fe8efba11dcc9394ef87
---
M WebVideoTranscode/WebVideoTranscode.php
1 file changed, 18 insertions(+), 2 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/WebVideoTranscode/WebVideoTranscode.php
b/WebVideoTranscode/WebVideoTranscode.php
index 829ff9d..f9ec430 100644
--- a/WebVideoTranscode/WebVideoTranscode.php
+++ b/WebVideoTranscode/WebVideoTranscode.php
@@ -363,6 +363,9 @@
/**
* Grabs sources from the remote repo via ApiQueryVideoInfo.php entry
point.
*
+ * TODO: This method could use some rethinking. See comments on PS1 of
+ * <https://gerrit.wikimedia.org/r/#/c/117916/>
+ *
* Because this works with commons regardless of whether
TimedMediaHandler is installed or not
* @param $file File
* @param $options array
@@ -392,7 +395,7 @@
'viprop' => 'derivatives',
'titles' => MWNamespace::getCanonicalName( NS_FILE )
.':'. $file->getTitle()->mTextform
);
-
+
$data = $file->repo->fetchImageQuery( $query );
if( isset( $data['warnings'] ) && isset(
$data['warnings']['query'] )
@@ -822,6 +825,8 @@
* @param $transcodeKey String transcode key
*/
public static function updateJobQueue( &$file, $transcodeKey ){
+ global $wgMemc;
+
wfProfileIn( __METHOD__ );
$fileName = $file->getTitle()->getDbKey();
@@ -831,7 +836,18 @@
$transcodeState = self::getTranscodeState( $file, $db );
// Check if the job has been added:
if( !isset( $transcodeState[ $transcodeKey ] )
- || is_null( $transcodeState[ $transcodeKey
]['time_addjob'] ) ) {
+ || is_null( $transcodeState[ $transcodeKey
]['time_addjob'] )
+ ) {
+ // Avoid lock wait timeout due to duplicated work
+ $cKey = wfMemcKey( 'transcode', md5( $fileName ),
$transcodeKey );
+ if ( !$wgMemc->lock( $cKey, 1 ) ) {
+ return; // assume another process is doing this
+ }
+ $unlocker = new ScopedCallback( function() use ( $cKey
) {
+ global $wgMemc;
+ $wgMemc->unlock( $cKey );
+ } );
+
// update the transcode state:
if( ! isset( $transcodeState[$transcodeKey] ) ){
// insert the transcode row with jobadd time
--
To view, visit https://gerrit.wikimedia.org/r/117916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I875dcfd5a9f991f9f8a2fe8efba11dcc9394ef87
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits