Set the WRITE_SYNC flag for SessionBackend writes
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 28 Aug 2016 20:44:04 +0000 (13:44 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 28 Aug 2016 20:44:04 +0000 (13:44 -0700)
Session writes should be seen in all datacenters so users do not
randomly end up logged on the next page view on a GET request
after login. Sticky DC cookies help, but not for cross domain
redirects or page views.

Change-Id: Id533fa1b867680e6386060efa4878ad1b4638c18

includes/session/SessionBackend.php

index 264e1ae..0439b36 100644 (file)
@@ -716,6 +716,8 @@ final class SessionBackend {
                        }
                }
 
+               $flags = $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY;
+               $flags |= CachedBagOStuff::WRITE_SYNC; // write to all datacenters
                $this->store->set(
                        wfMemcKey( 'MWSession', (string)$this->id ),
                        [
@@ -723,7 +725,7 @@ final class SessionBackend {
                                'metadata' => $metadata,
                        ],
                        $metadata['expires'],
-                       $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY
+                       $flags
                );
 
                $this->metaDirty = false;