Problem
I have 2 drupal installation on the same server, so i use setting prefix_key to avoid conflict at the cache generation.
But this setting set in settings.local.php like this :
$settings['memcache']['servers'] = ['127.0.0.1:11211' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = '';
it would seem this setting is not use to add or retrieve items into memcache.
Proposed resolution
I propose this patch to fix this problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 2701903-20.patch | 699 bytes | mcdruid |
| #17 | memcache-prefix-2701903-17.patch | 588 bytes | misc |
| #2 | edit_issue_setting-2701903-1.patch | 1.15 KB | egruel |
| #9 | edit_issue_setting-2701903-2.patch | 1.15 KB | egruel |
| #14 | memcache-prefix-2701903-1.patch | 581 bytes | lestat |
Comments
Comment #2
egruel commentedComment #3
egruel commentedComment #4
egruel commentedComment #5
ec0g commentedThanks @egruel. The patch seems to fix the issue. Tested on a multisite installation with 3 sites.
Comment #6
egruel commentedComment #7
misc commentedAs for @egruel's comment, settings this as RTBC.
Comment #8
damiankloip commentedThis looks good, aside from one thing, can you add a separator between the prefix and the key please? so:
This code must have been lost in the port to 8.x somehow.
Comment #9
egruel commentedOk I fix it.
Comment #10
egruel commentedComment #12
damiankloip commentedThanks, this has been committed and pushed!
Comment #14
lestat commentedSeems missed prefixing in hashed version. Now :
Instead of :
Comment #15
damiankloip commentedGood catch! Seems we need some additional test coverage to get this stuff...
Comment #16
anavarreComment #17
misc commentedSeems that patch need update.
Comment #19
damiankloip commentedCommitted the fix, leaving this open for tests.
Comment #20
mcdruid commentedThere's a problem with the implementation of the hashed keys here; at the moment when a key is going to be too long:
So the prefix and the key are both hashed, and we end up with keys which look something like this:
Whereas in the D7 branch, #1613622: Memcache not using urlencode on $prefix or $bin in dmemcache_key() when strlen($full_key) > 250 led to the keys being hashed like this:
So the prefix is preserved before the hash, and whatever characters remain within the key length limit are filled up with the original key.
Re-implementing that pattern in the D8 code gives us keys more like this:
The shorter keys may be more efficient, but the lack of any human-readable information in the fully-hashed keys is not helpful when it comes to debugging / performance analysis.
I propose that the longer more detailed keys are adopted in the D8 branch too; here's a patch which does that.
If shorter keys are desirable for performance reasons, the key length limit could be made configurable (like it is in D7).
Comment #21
misc commentedAgree - this should be the best way to handle the hash, keeping the meta data. But does not the key get to long with this patch?
Comment #22
mcdruid commentedNot unless I've made a mistake in re-implementing the code from the D7 branch :)
I may have confused things by replacing the real prefix in my example keys.
Here's how the logic should work:
So IIUC the last concatenation adds on as many characters of the original key as possible up to a total of 249 chars, keeping the whole thing within the limit.
Certainly a good candidate for a test though :)
Comment #23
webchickMarking as a beta blocker.
Comment #24
webchickComment #25
damiankloip commentedThis should be a separate issue. This was kept open for tests, not to implement a different change.
Comment #26
catchI've opened #2995457: Human readable hashed memcache keys. Updating the title to indicate this issue is for test coverage only.