Make UID clock drift error have more details.
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 3 Oct 2018 22:01:29 +0000 (18:01 -0400)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 3 Oct 2018 22:03:01 +0000 (18:03 -0400)
Change-Id: Ic682e48b06161c2a286f5da9016f4831ee72a31e

includes/utils/UIDGenerator.php

index 52740c9..4b5410e 100644 (file)
@@ -475,11 +475,12 @@ class UIDGenerator {
                // microtime() and gettimeofday() can drift from time() at least on Windows.
                // The drift is immediate for processes running while the system clock changes.
                // time() does not have this problem. See https://bugs.php.net/bug.php?id=42659.
-               if ( abs( time() - $time[0] ) >= 2 ) {
+               $drift = time() - $time[0];
+               if ( abs( $drift ) >= 2 ) {
                        // We don't want processes using too high or low timestamps to avoid duplicate
                        // UIDs and clock sequence number churn. This process should just be restarted.
                        flock( $handle, LOCK_UN ); // abort
-                       throw new RuntimeException( "Process clock is outdated or drifted." );
+                       throw new RuntimeException( "Process clock is outdated or drifted ({$drift}s)." );
                }
                // If microtime() is synced and a clock change was detected, then the clock went back
                if ( $clockChanged ) {