facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.18k stars 2.99k forks source link

Memcached delete return value discrepancy #5121

Open marczych opened 9 years ago

marczych commented 9 years ago

I found a PHP5 incompatibility when writing tests for a caching library and boiled it down to this test:

vagrant@precise64:/vagrant$ cat test.php
<?php

class MemcachedTest extends PHPUnit_Framework_TestCase {
   public function testDelete() {
      $memcached = new Memcached();
      $memcached->addServer('localhost', 11211);
      $memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
      $memcached->setOption(Memcached::OPT_TCP_NODELAY, true);

      $this->assertFalse($memcached->delete("no_key"));

      $memcached->set('key', 'value');
      $memcached->get('key');
      $this->assertTrue($memcached->delete('key'));
      $this->assertFalse($memcached->delete('key'));
   }
}
vagrant@precise64:/vagrant$ php phpunit.phar test.php
PHPUnit 4.2.6 by Sebastian Bergmann.

.

Time: 9 ms, Memory: 5.00Mb

OK (1 test, 3 assertions)
vagrant@precise64:/vagrant$ sudo hhvm phpunit.phar test.php
[Fri Apr  3 06:33:46 2015] [hphp] [1714:7f0761d6cc00:0:000001] [] Possible bad config node: Eval.JitWarmupRequests
PHPUnit 4.2.6 by Sebastian Bergmann.

F

Time: 737 ms, Memory: 17.10Mb

There was 1 failure:

1) MemcachedTest::testDelete
Failed asserting that true is false.

/vagrant/test.php:15

FAILURES!
Tests: 1, Assertions: 3, Failures: 1.
vagrant@precise64:/vagrant$ hhvm --version
HipHop VM 3.4.0-dev (rel)
Compiler: heads/master-0-g850d4fddd26ee0c2a0022e390d6403ad9c4ecf79
Repo schema: 23aaab89219bb9d5009914de0d405cf694e2632e
Extension API: 20140829

Both of the Memcached options are required to make it fail as well as the get and set immediately prior.

photodude commented 8 years ago

I think I'm also seeing this issue with hhvm 3.13.1

1) JCacheStorageMemcachedTest::testCacheTimeout
Initial Store Failed
Failed asserting that false is true.
/tests/unit/core/case/cache.php:114
2) JCacheStorageMemcachedTest::testCacheRemove
Initial Store Failed
Failed asserting that false is true.
/tests/unit/core/case/cache.php:128
3) JCacheStorageMemcachedTest::testCacheClearGroup
Initial Store Failed
Failed asserting that false is true.
/tests/unit/core/case/cache.php:140
4) JCacheStorageMemcachedTest::testCacheClearNotGroup
Initial Store Failed
Failed asserting that false is true.
/tests/unit/core/case/cache.php:154