Skip to content

Commit 934e0ca

Browse files
committed
fix(cache): Ensure unique global prefix per instanceid
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
1 parent 407cc43 commit 934e0ca

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/private/Memcache/Factory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ protected function getGlobalPrefix(): string {
119119
$versions = $appConfig->getAppInstalledVersions();
120120
}
121121
$versions['core'] = implode('.', $this->serverVersion->getVersion());
122-
$this->globalPrefix = hash('xxh128', implode(',', $versions));
122+
123+
// Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool)
124+
$instanceid = $config->getSystemValue('instanceid');
125+
$this->globalPrefix = hash('xxh128', $instanceid . implode(',', $versions));
123126
}
124127
return $this->globalPrefix;
125128
}
@@ -132,7 +135,10 @@ protected function getGlobalPrefix(): string {
132135
*/
133136
public function withServerVersionPrefix(\Closure $closure): void {
134137
$backupPrefix = $this->globalPrefix;
135-
$this->globalPrefix = hash('xxh128', implode('.', $this->serverVersion->getVersion()));
138+
139+
// Include instanceid in the prefix, in case multiple instances use the same cache (e.g. same FPM pool)
140+
$instanceid = \OCP\Server::get(SystemConfig::class)->getSystemValue('instanceid');
141+
$this->globalPrefix = hash('xxh128', $instanceid . implode('.', $this->serverVersion->getVersion()));
136142
$closure($this);
137143
$this->globalPrefix = $backupPrefix;
138144
}

0 commit comments

Comments
 (0)