diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 315af53cde0..32318e1834e 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -163,6 +163,26 @@ class ChronologyProtector implements LoggerAwareInterface { /** @var float|null */ private $wallClockOverride; + /** + * Whether we are assuming a semi-deterministic clientId. + * + * This is set to true on the majority of requests where a clientId wasn't set + * in a cookie or query param, i.e. when there were no recent writes in this + * browsing session. This is a temporary flag to determine whether and why + * a client might receive a clientId but then not send it back to the server + * on subsequent requests (i.e. due to cross-domain browser restrictions that + * we may have not known about as part of Multi-DC prep in T91820, or due to + * bot frameworks that may be ignoring cookies). + * + * We then use this flag to log a warning in lazyStartup() if there were in + * fact stored positions found under the assumed clientId. + * + * See also: + * + * @var bool + */ + private $hasImplicitClientId = false; + /** Seconds to store position write index cookies (safely less than POSITION_STORE_TTL) */ public const POSITION_COOKIE_TTL = 10; /** Seconds to store replication positions */ @@ -195,6 +215,7 @@ class ChronologyProtector implements LoggerAwareInterface { if ( isset( $client['clientId'] ) ) { $this->clientId = $client['clientId']; } else { + $this->hasImplicitClientId = true; $this->clientId = ( $secret != '' ) ? hash_hmac( 'md5', $client['ip'] . "\n" . $client['agent'], $secret ) : md5( $client['ip'] . "\n" . $client['agent'] ); @@ -462,6 +483,12 @@ class ChronologyProtector implements LoggerAwareInterface { ] + $this->clientLogInfo ); } } + + if ( $indexReached && $this->hasImplicitClientId ) { + $this->logger->warning( 'found position data under a presumed clientId (T314434)', [ + 'indexReached' => $indexReached + ] + $this->clientLogInfo ); + } } /**