Use sync writes for replication of 'store' operations
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 26 Feb 2016 23:55:09 +0000 (15:55 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 27 Feb 2016 00:20:13 +0000 (00:20 +0000)
The local temporary file might not live long enough to be
copied into storage during post-send.

Bug: T128124
Change-Id: Ifb5260958db008ec8b9f4db90f95a42e5ecaeadc

includes/filebackend/FileBackendMultiWrite.php

index 132c4a6..2d27450 100644 (file)
@@ -199,7 +199,7 @@ class FileBackendMultiWrite extends FileBackend {
                                }
 
                                $realOps = $this->substOpBatchPaths( $ops, $backend );
-                               if ( $this->asyncWrites ) {
+                               if ( $this->asyncWrites && !$this->hasStoreOperation( $ops ) ) {
                                        // Bind $scopeLock to the callback to preserve locks
                                        DeferredUpdates::addCallableUpdate(
                                                function() use ( $backend, $realOps, $opts, $scopeLock ) {
@@ -467,6 +467,20 @@ class FileBackendMultiWrite extends FileBackend {
                );
        }
 
+       /**
+        * @param array $ops File operation batch map
+        * @return bool
+        */
+       protected function hasStoreOperation( array $ops ) {
+               foreach ( $ops as $op ) {
+                       if ( $op['op'] === 'store' ) {
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
        protected function doQuickOperationsInternal( array $ops ) {
                $status = Status::newGood();
                // Do the operations on the master backend; setting Status fields...
@@ -480,7 +494,7 @@ class FileBackendMultiWrite extends FileBackend {
                        }
 
                        $realOps = $this->substOpBatchPaths( $ops, $backend );
-                       if ( $this->asyncWrites ) {
+                       if ( $this->asyncWrites && !$this->hasStoreOperation( $ops ) ) {
                                DeferredUpdates::addCallableUpdate(
                                        function() use ( $backend, $realOps ) {
                                                $backend->doQuickOperations( $realOps );