WordPress.org

Making WordPress.org

Changeset 8897


Ignore:
Timestamp:
05/30/2019 07:04:41 AM (8 months ago)
Author:
dd32
Message:

Plugin Directory: Search: Include some debug info in the search stampede code to isolate some cache bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php

    r6591 r8897  
    226226        $cache_key    = md5( $json_es_args );
    227227        $lock_key     = 'lock-' . $cache_key;
     228        $count_key    = 'count-' . $cache_key;
    228229
    229230        $response = wp_cache_get( $cache_key, self::CACHE_GROUP );
     
    232233        // Other processes will use the stale cached value if it's present, even for a while after the expiration time if a fresh value is still being fetched.
    233234        if ( wp_cache_add( $lock_key, 1, self::CACHE_GROUP, 15 ) ) {
     235            // Keep track of the number of concurrent requests for this key
     236            wp_cache_set( $count_key, 1, self::CACHE_GROUP, 60 );
    234237
    235238            // If the error volume is high, there's a proportionally lower chance that we'll actually attempt to hit the API.
     
    297300            // Stampede protection has kicked in, AND we have no stale cached value to display. That's bad - possibly indicates cache exhaustion
    298301            if ( false === $response ) {
    299                 trigger_error( 'Plugin directory search: no cached results available during stampede.', E_USER_WARNING );
     302                // Keep a track of how many cache stampede's happen per minute.
     303                wp_cache_incr( 'search-stampede-failures', 1, self::CACHE_GROUP ) || wp_cache_set( 'search-stampede-failures', 1, self::CACHE_GROUP, 60 );
     304
     305                // Include the number of times this branch has been hit
     306                $request_count = wp_cache_incr( $count_key, 1, self::CACHE_GROUP );
     307                trigger_error( 'Plugin directory search: no cached results available during stampede. Requests: ' . $request_count, E_USER_WARNING );
    300308            }
    301309        }
Note: See TracChangeset for help on using the changeset viewer.