• James

    (@harris1)


    I’m using the APC object-cache drop in and vastly speeds up requests. And this isn’t exactly a bug in it, but I think it’s the best place to fix it.

    The thing is wp_cache_set. It calls apc_store and that fails if APC is doing an expunge and probably more reasons. But no call to wp_cache_set actually handles that failure. Then the next wp_cache_get returns stale data.

    I patched object-cache.php to log when apc_store fails and tries to delete the stale entry:

    $result = apc_store( $key, $store_data, $expire );
    	if ($result === false) {
                apc_fetch($key, $success);
                if ($success) {
                    if (apc_delete( $key )) {
                        trigger_error("apc_store($key) failed, deleted old entry");
                    } else {
    	            trigger_error("apc_store($key) failed, apc_delete also failed. Corruption!");
    	        }
                } else {
    		trigger_error("apc_store($key) failed, would have been new entry");
    	    }
    	}
            return $result;

    My logs have several “apc_store($key) failed, deleted old entry” messages.

    Does this make sense? Thanks!

    https://wordpress.org/plugins/apc/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m having the same problem. Have you figured out a fix for it yet?

    Thread Starter James

    (@harris1)

    Kinda/sort of. I replaced the $result = apc_store( $key, $store_data, $expire ); line with the block of code above. The apc_delete call in the snippit clears the stale data, so WP will do a fresh query next request.

    But upgrading and tuning APC is important.

    slam_defense must be disabled since WP updates the same keys often. But in APC 3.1.3pl1 slam_defense cannot be disabled (check the source code, the ini setting is never used).

    APC 3.1.7 introduces read-write locks. Because how can shared memory work with out locks?

    APCu gives user data it’s own memory pool. If I understand correctly, with APC before “u”, the whole cache can be filled of PHP byte code and then every apc_store will fail.

    And APCu’s apc_store still fails if another process is doing an expunge. And we’re back at the workaround.

    Thanks for the reply, Harris. To use APCu, do you have to uninstall APC first? Or will installing APCu modify your APC installation?

    Thanks again.

    Thread Starter James

    (@harris1)

    I haven’t tried it yet, but my plan is to uninstall APC and install ZendOptimizerPlus and APCu instead.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘stale cache sort of bug’ is closed to new replies.