Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TagAwareAdapter over nonbinary memcached connections corrupts memcache. #27405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
palex-fpt opened this issue May 29, 2018 · 4 comments
Closed

Comments

@palex-fpt
Copy link

Symfony version(s) affected: 4.0.0

Description
TagAwareAdapter over nonbinary memcached connections corrupts memcache.

How to reproduce

	public function testTagAwareAdapterOverMemcached()
	{
		$nonbinaryMemcached = new \Memcached();
		$nonbinaryMemcached->addServer('memcached', 11211);
		$nonbinaryMemcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, false);
		$simpleCache = new MemcachedAdapter($nonbinaryMemcached);
		$tagAwareCache = new TagAwareAdapter($simpleCache);

		$simpleCache->save($simpleCache->getItem("simple")->set(1));

		// TagAwareAdapter corrupts nonbinary memcached
		$tagAwareCache->save($tagAwareCache->getItem("tagged")->set(1));

		$this->assertEquals(1, $simpleCache->getItem("simple")->get());
	}

Possible Solution
TagAwareAdapter uses '\0' in key names, that are incompatible with memcached in normal mode. Possible solution is to change key prefix.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 29, 2018

Yes, that's expected: non-binary protocol is too loose, just turn it on.

@palex-fpt
Copy link
Author

Actually we use mcrouter to balance memcache servers. It does not support binary protocol. It was surprise when cache starts randomly returns null values. Should it be mentioned in docs?

@nicolas-grekas
Copy link
Member

Hum, it could make sense actually to make it work in no-binary mode. We'd need to encode the keys using rawurlencode() I suppose. Would you like to give it a try?

@palex-fpt
Copy link
Author

ok. i'll try

palex-fpt pushed a commit to palex-fpt/symfony that referenced this issue May 30, 2018
palex-fpt pushed a commit to palex-fpt/symfony that referenced this issue May 30, 2018
palex-fpt pushed a commit to palex-fpt/symfony that referenced this issue May 31, 2018
palex-fpt pushed a commit to palex-fpt/symfony that referenced this issue Jun 5, 2018
nicolas-grekas added a commit that referenced this issue Jun 8, 2018
…upts memcache (Aleksey Prilipko)

This PR was merged into the 3.4 branch.

Discussion
----------

TagAwareAdapter over non-binary memcached connections corrupts memcache

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | #27405
| License       | MIT
| Doc PR        |

TagAwareAdapter uses non-ascii symbols in key names. It breaks memcached connections in non-binary mode.

Commits
-------

67d4e6d bug #27405 [Cache] TagAwareAdapter should not corrupt memcached connection in ascii mode
nicolas-grekas added a commit that referenced this issue Jun 8, 2018
* 3.4:
  [FrameworkBundle] decouple some cache-warmer's test from internal details
  bug #27405 [Cache] TagAwareAdapter should not corrupt memcached connection in ascii mode
  Remove released semaphore
nicolas-grekas added a commit that referenced this issue Jun 8, 2018
* 4.0:
  [FrameworkBundle] decouple some cache-warmer's test from internal details
  bug #27405 [Cache] TagAwareAdapter should not corrupt memcached connection in ascii mode
  Remove released semaphore
nicolas-grekas added a commit that referenced this issue Jun 8, 2018
* 4.1:
  [FrameworkBundle] decouple some cache-warmer's test from internal details
  bug #27405 [Cache] TagAwareAdapter should not corrupt memcached connection in ascii mode
  Remove released semaphore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants