Modernized slave wait checks in recompressTracked.php
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 2 Oct 2015 00:18:46 +0000 (17:18 -0700)
committerOri.livneh <ori@wikimedia.org>
Fri, 2 Oct 2015 00:19:54 +0000 (00:19 +0000)
Change-Id: I5771af8135530677dc8223389f572896918c6b72

maintenance/storage/recompressTracked.php

index b213929..120ccb6 100644 (file)
@@ -365,7 +365,7 @@ class RecompressTracked {
                if ( $current == $end || $this->numBatches >= $this->reportingInterval ) {
                        $this->numBatches = 0;
                        $this->info( "$label: $current / $end" );
-                       $this->waitForSlaves();
+                       wfWaitForSlaves();
                }
        }
 
@@ -463,7 +463,7 @@ class RecompressTracked {
                                case 'quit':
                                        return;
                        }
-                       $this->waitForSlaves();
+                       wfWaitForSlaves();
                }
        }
 
@@ -530,7 +530,7 @@ class RecompressTracked {
                                        $this->debug( "$titleText: committing blob with " . $trx->getSize() . " items" );
                                        $trx->commit();
                                        $trx = new CgzCopyTransaction( $this, $this->pageBlobClass );
-                                       $this->waitForSlaves();
+                                       wfWaitForSlaves();
                                }
                        }
                        $startId = $row->bt_text_id;
@@ -613,7 +613,7 @@ class RecompressTracked {
                        foreach ( $res as $row ) {
                                $this->moveTextRow( $row->bt_text_id, $row->bt_new_url );
                                if ( $row->bt_text_id % 10 == 0 ) {
-                                       $this->waitForSlaves();
+                                       wfWaitForSlaves();
                                }
                        }
                        $startId = $row->bt_text_id;
@@ -681,26 +681,12 @@ class RecompressTracked {
                                $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
                                $trx->commit();
                                $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
-                               $this->waitForSlaves();
+                               wfWaitForSlaves();
                        }
                }
                $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
                $trx->commit();
        }
-
-       /**
-        * Wait for slaves (quietly)
-        */
-       function waitForSlaves() {
-               $lb = wfGetLB();
-               while ( true ) {
-                       list( $host, $maxLag ) = $lb->getMaxLag();
-                       if ( $maxLag < 2 ) {
-                               break;
-                       }
-                       sleep( 5 );
-               }
-       }
 }
 
 /**