// This method runs after the new revisions were committed.
// Wait for the replica to catch up so they will all be counted.
$dbr->flushSnapshot( $fname );
- $lb->safeWaitForMasterPos( $dbr );
+ $lb->waitForMasterPos( $dbr );
}
$affectedInstances[0]->initEditCountInternal();
}
return false; // deleted?
}
- // Cut down on the time spent in safeWaitForMasterPos() in the critical section
+ // Cut down on the time spent in waitForMasterPos() in the critical section
$dbr = $lb->getConnection( DB_REPLICA, [ 'recentchanges' ] );
- if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$lb->waitForMasterPos( $dbr ) ) {
$this->setLastError( "Timed out while pre-waiting for replica DB to catch up" );
return false;
}
}
// Wait till replica DB is caught up so that jobs for this page see each others' changes
- if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$lb->waitForMasterPos( $dbr ) ) {
$this->setLastError( "Timed out while waiting for replica DB to catch up" );
return false;
}
$dbr = $loadBalancer->getConnection( DB_REPLICA, [ 'watchlist' ] );
// Wait before lock to try to reduce time waiting in the lock.
- if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$loadBalancer->waitForMasterPos( $dbr ) ) {
$this->setLastError( 'Timed out waiting for replica to catch up before lock' );
return false;
}
return false;
}
- if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$loadBalancer->waitForMasterPos( $dbr ) ) {
$this->setLastError( 'Timed out waiting for replica to catch up within lock' );
return false;
}
* @param DBMasterPos|bool $pos Master position; default: current position
* @param int $timeout Timeout in seconds [optional]
* @return bool Success
+ * @since 1.34
*/
- public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
+ public function waitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
/**
* Set a callback via IDatabase::setTransactionListener() on
return $conn->getLag();
}
- public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
+ public function waitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
$timeout = max( 1, $timeout ?: $this->waitTimeout );
if ( $this->getServerCount() <= 1 || !$conn->getLBInfo( 'replica' ) ) {
return $ok;
}
+ /**
+ * Wait for a replica DB to reach a specified master position
+ *
+ * This will connect to the master to get an accurate position if $pos is not given
+ *
+ * @param IDatabase $conn Replica DB
+ * @param DBMasterPos|bool $pos Master position; default: current position
+ * @param int $timeout Timeout in seconds [optional]
+ * @return bool Success
+ * @since 1.28
+ * @deprecated Since 1.34 Use waitForMasterPos() instead
+ */
+ public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
+ return $this->waitForMasterPos( $conn, $pos, $timeout );
+ }
+
public function setTransactionListener( $name, callable $callback = null ) {
if ( $callback ) {
$this->trxRecurringCallbacks[$name] = $callback;
*/
class WfShellExecTest extends MediaWikiTestCase {
public function testT69870() {
- $command = wfIsWindows()
- // 333 = 331 + CRLF
- ? ( 'for /l %i in (1, 1, 1001) do @echo ' . str_repeat( '*', 331 ) )
- : 'printf "%-333333s" "*"';
+ if ( wfIsWindows() ) {
+ // T209159: Anonymous pipe under Windows does not support asynchronous read and write,
+ // and the default buffer is too small (~4K), it is easy to be blocked.
+ $this->markTestSkipped(
+ 'T209159: Anonymous pipe under Windows cannot withstand such a large amount of data'
+ );
+ }
// Test several times because it involves a race condition that may randomly succeed or fail
for ( $i = 0; $i < 10; $i++ ) {
- $output = wfShellExec( $command );
+ $output = wfShellExec( 'printf "%-333333s" "*"' );
$this->assertEquals( 333333, strlen( $output ) );
}
}
}
public function testT69870() {
- $commandLine = wfIsWindows()
- // 333 = 331 + CRLF
- ? ( 'for /l %i in (1, 1, 1001) do @echo ' . str_repeat( '*', 331 ) )
- : 'printf "%-333333s" "*"';
+ if ( wfIsWindows() ) {
+ // T209159: Anonymous pipe under Windows does not support asynchronous read and write,
+ // and the default buffer is too small (~4K), it is easy to be blocked.
+ $this->markTestSkipped(
+ 'T209159: Anonymous pipe under Windows cannot withstand such a large amount of data'
+ );
+ }
// Test several times because it involves a race condition that may randomly succeed or fail
for ( $i = 0; $i < 10; $i++ ) {
$command = new Command();
- $output = $command->unsafeParams( $commandLine )
+ $output = $command->unsafeParams( 'printf "%-333333s" "*"' )
->execute()
->getStdout();
$this->assertEquals( 333333, strlen( $output ) );