Page MenuHomePhabricator

"Potential cache slam averted" error
Closed, ResolvedPublic

Description

I'm seeing the following error appearing a fair bit in our PHP logs:

[11-Jun-2014 04:16:45 UTC] [2014-06-11 14:16:45] ERROR 2: apc_store(): Potential cache slam averted for key 'phabricator.setup.issues' at [/usr/src/libphutil/src/cache/PhutilKeyValueCacheAPC.php:38]
[11-Jun-2014 04:16:45 UTC]   #0 apc_store(phabricator.setup.issues, 0, 0) called at [/usr/src/libphutil/src/cache/PhutilKeyValueCacheAPC.php:38]
[11-Jun-2014 04:16:45 UTC]   #1 PhutilKeyValueCacheAPC::setKeys(Array { phabricator.setup.issues => 0 }, null) called at [/usr/src/libphutil/src/cache/PhutilKeyValueCacheProxy.php:27]
[11-Jun-2014 04:16:45 UTC]   #2 PhutilKeyValueCacheProxy::setKeys(Array { phabricator.setup.issues => 0 }, null) called at [/usr/src/libphutil/src/cache/PhutilKeyValueCacheProfiler.php:78]
[11-Jun-2014 04:16:45 UTC]   #3 PhutilKeyValueCacheProfiler::setKeys(Array { phabricator.setup.issues => 0 }, null) called at [/usr/src/libphutil/src/cache/PhutilKeyValueCacheStack.php:114]
[11-Jun-2014 04:16:45 UTC]   #4 PhutilKeyValueCacheStack::setKeys(Array { phabricator.setup.issues => 0 }, null) called at [/usr/src/libphutil/src/cache/PhutilKeyValueCache.php:60]
[11-Jun-2014 04:16:45 UTC]   #5 PhutilKeyValueCache::setKey(phabricator.setup.issues, 0) called at [/usr/src/phabricator/src/applications/config/check/PhabricatorSetupCheck.php:37]
[11-Jun-2014 04:16:45 UTC]   #6 PhabricatorSetupCheck::setOpenSetupIssueCount(0) called at [/usr/src/phabricator/src/applications/config/check/PhabricatorSetupCheck.php:82]
[11-Jun-2014 04:16:45 UTC]   #7 PhabricatorSetupCheck::willProcessRequest() called at [/usr/src/phabricator/webroot/index.php:38]

Event Timeline

joshuaspence assigned this task to epriestley.
joshuaspence raised the priority of this task from to Needs Triage.
joshuaspence updated the task description. (Show Details)
joshuaspence added a project: Phabricator.
joshuaspence added a subscriber: joshuaspence.

It's probably related to this PHP bug.

You can probably set apc.slam_defense = 0 in php.ini to quiet this. I don't think APC slam defense is ever useful in Phabricator.

Thanks @epriestley... do you know what slam defense is? I can't quite get my head around it.

It prints a lot of warnings to the log.

I think the idea is that if you're writing large / high-contention cache keys with a lot of processes, you can churn the cache a lot and do more work than necessary, and you'd theoretically be better off only writing, say, 10% of the time so that the cache fills gradually over the first few minutes of server uptime rather than completely filling several hundred times as requests are processed immediately after startup.

At Facebook, there was a real enough effect here that we would bring up the webserver, make a request that loaded every file into APC, do some other cache filling and preloading, and only then open up firewall rules to allow requests through.

However, in Phabricator (and I think most other applications, especially if they don't put much data in APC) I think this is pretty pointless. In particular, we're storing like a few bytes of data in phabricator.setup.issues, and churning that isn't an issue.

Gotcha, thanks for clarifying.