Skip to content
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

sfAPCCache fail #125

Closed
zkiiito opened this issue May 14, 2016 · 13 comments
Closed

sfAPCCache fail #125

zkiiito opened this issue May 14, 2016 · 13 comments

Comments

@zkiiito
Copy link
Contributor

zkiiito commented May 14, 2016

The tests on travis run without apc enabled for cli, so the sfAPCCacheTest just skips itself.
If I enable it in php.ini, they fail, as you can see here

@mentalstring
Copy link
Contributor

Couldn't reproduce it with https://github.com/ingatlancom/symfony1/tree/sfAPCCache on any PHP version I have at hand. Even tried with PHP 5.3.29 like travis, but worked fine.

I suspect some APC configuration quirkiness so tried using the settings from travis apc.ini but still no luck.

Is anyone able to reproduce this outside of travis?

@zkiiito
Copy link
Contributor Author

zkiiito commented May 25, 2016

Is
apc.enable_cli = 1
in your php.ini? Without that, the tests are skipped.

@mentalstring
Copy link
Contributor

Yes,

sfAPCCache $ php -n -dextension=apc.so -d"apc.enable_cli=1" test/unit/cache/sfAPCCacheTest.php
1..64
# ->initialize()
# ->set() ->get() ->has()
ok 1 - ->set() returns true if data are stored in cache
ok 2 - ->get() retrieves data form the cache
ok 3 - ->has() returns true if the cache exists
ok 4 - ->set() takes a lifetime as its third argument
ok 5 - ->get() returns the default value if cache has expired
ok 6 - ->has() returns true if the cache exists
ok 7 - ->get() returns null if the cache does not exist
ok 8 - ->get() takes a default value as its second argument
ok 9 - ->has() returns false if the cache does not exist
ok 10 - ->set() overrides previous data stored in the cache
ok 11 - ->get() retrieves the latest data form the cache
ok 12 - ->set() false data are stored in the cache
ok 13 - ->has() returns true if the cache exists with false value
ok 14 - ->get() retrieves the latest data form the cache
ok 15 - ->get() does not return default value if false is stored
ok 16 - ->set() accepts a namespaced cache key
ok 17 - ->set() accepts a namespaced cache key
ok 18 - ->set() accepts a namespaced cache key
# ->clean()
ok 19 - ->clean() cleans old cache key if given the sfCache::OLD argument
ok 20 - ->clean() cleans old cache key if given the sfCache::OLD argument
ok 21 - ->clean() cleans all cache key if given the sfCache::ALL argument
ok 22 - ->clean() cleans all cache key if given the sfCache::ALL argument
ok 23 - ->clean() cleans all cache key if given no argument
ok 24 - ->clean() cleans all cache key if given no argument
# ->remove()
ok 25 - ->remove() takes a cache key as its first argument
ok 26 - ->remove() takes a cache key as its first argument
ok 27 - ->remove() takes a cache key as its first argument
# ->removePattern()
# *:bar:foo
ok 28 - ->removePattern() takes a pattern as its first argument
ok 29 - ->removePattern() takes a pattern as its first argument
ok 30 - ->removePattern() takes a pattern as its first argument
ok 31 - ->removePattern() takes a pattern as its first argument
# foo:bar:*
ok 32 - ->removePattern() takes a pattern as its first argument
ok 33 - ->removePattern() takes a pattern as its first argument
ok 34 - ->removePattern() takes a pattern as its first argument
ok 35 - ->removePattern() takes a pattern as its first argument
# foo:**:foo
ok 36 - ->removePattern() takes a pattern as its first argument
ok 37 - ->removePattern() takes a pattern as its first argument
ok 38 - ->removePattern() takes a pattern as its first argument
ok 39 - ->removePattern() takes a pattern as its first argument
# foo:bar:**
ok 40 - ->removePattern() takes a pattern as its first argument
ok 41 - ->removePattern() takes a pattern as its first argument
ok 42 - ->removePattern() takes a pattern as its first argument
ok 43 - ->removePattern() takes a pattern as its first argument
# **:bar
ok 44 - ->removePattern() takes a pattern as its first argument
ok 45 - ->removePattern() takes a pattern as its first argument
ok 46 - ->removePattern() takes a pattern as its first argument
ok 47 - ->removePattern() takes a pattern as its first argument
# **
ok 48 - ->removePattern() takes a pattern as its first argument
ok 49 - ->removePattern() takes a pattern as its first argument
ok 50 - ->removePattern() takes a pattern as its first argument
ok 51 - ->removePattern() takes a pattern as its first argument
# ->getTimeout()
ok 52 - ->getTimeout() returns the timeout time for a given cache key
ok 53 - ->getTimeout() returns the timeout time for a given cache key
ok 54 - ->getTimeout() returns the timeout time for a given cache key
ok 55 - ->getTimeout() returns the timeout time for a given cache key
ok 56 - ->getTimeout() returns the timeout time for a given cache key
ok 57 - ->getTimeout() returns 0 if the cache key does not exist
# ->getLastModified()
ok 58 - ->getLastModified() returns the last modified time for a given cache key
ok 59 - ->getLastModified() returns the last modified time for a given cache key
ok 60 - ->getLastModified() returns the last modified time for a given cache key
ok 61 - ->getLastModified() returns the last modified time for a given cache key
ok 62 - ->getLastModified() returns the last modified time for a given cache key
ok 63 - ->getLastModified() returns 0 if the cache key does not exist
# ->getMany()
ok 64 - ->getMany() gets many keys in one call
# Looks like everything went fine. 
sfAPCCache $ php -v
PHP 5.3.29-pl0-gentoo (cli) (built: Oct 11 2014 01:16:44) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies

Same with PHP 5.6 and PHP 7.0.

@mentalstring
Copy link
Contributor

The tests that fail seem to be where a negative ttl on apc_store is expected to remove the entry immediately, but doesn't. It might be related with this or krakjoe/apcu#167 (comment).

@zkiiito
Copy link
Contributor Author

zkiiito commented May 25, 2016

on my setup, php 5.3.10, it also fails the same tests, even if i'm disabling apc.use_request_time

@zkiiito
Copy link
Contributor Author

zkiiito commented May 25, 2016

apc version is 3.1.7

@mentalstring
Copy link
Contributor

APC 3.1.13

$ php -i|grep apc
apc.cache_by_default => On => On
apc.canonicalize => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.file_md5 => Off => Off
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.lazy_classes => Off => Off
apc.lazy_functions => Off => Off
apc.max_file_size => 1M => 1M
apc.mmap_file_mask => no value => no value
apc.num_files_hint => 1024 => 1024
apc.preload_path => no value => no value
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => default => default
apc.shm_segments => 1 => 1
apc.shm_size => 30M => 30M
apc.slam_defense => Off => Off
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 7200 => 7200
apc.use_request_time => On => On
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 7200 => 7200
apc.write_lock => On => On

@zkiiito
Copy link
Contributor Author

zkiiito commented May 25, 2016

https://www.diffchecker.com/c78vfj3l
mine is actually an ubuntu 12.04 with php&apc from packages

@mentalstring
Copy link
Contributor

Tried with your APC settings and the test still passed.

What's your output for

php -n -dextension=apc.so -d"apc.enable_cli=1"  -r "var_dump(apc_store('hello', 'h', -1)); var_dump(apc_exists('hello')); var_dump(apc_fetch('hello'));"

?

I get

bool(true)
bool(false)
bool(false)

Some more info on APC setup:

Version 3.1.13
APC Debugging Disabled
MMAP Support Enabled
MMAP File Mask no value
Locking type pthread mutex Locks
Serialization Support php
Revision $Revision: 327136 $

Are you able to try APC 3.1.13 on your system?

@zkiiito
Copy link
Contributor Author

zkiiito commented May 25, 2016

bool(true)
bool(true)
string(1) "h"

so it seems to be a bug in the apc version, I'll try to upgrade to test this

Version => 3.1.7
APC Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>  
Locking type => pthread mutex Locks
Serialization Support => broken
Revision => $Revision: 307215 $

@zkiiito
Copy link
Contributor Author

zkiiito commented May 25, 2016

no, I've updated

Version => 3.1.13
APC Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>  
Locking type => pthread read/write Locks
Serialization Support => broken
Revision => $Revision: 327136 $

and the output is still

bool(true)
bool(true)
string(1) "h"

@mentalstring
Copy link
Contributor

Well, the expected behavior of negative TTLs on apc_store to remove keys is not actually mentioned on the documentation. In fact, the key expiration does mention that the expired values are expunged from cache "on the next request".

Still, it seems to work fine on some setups and not on others which could be a bug on APC. Would be great to get @krakjoe to chime in on this as it seems something related with APC internals.

@thePanz
Copy link
Member

thePanz commented Jul 24, 2020

Closing as failures with APCu are (mostly) related to the incompatible acpu plugin: the plugin is using a new set of APIs, and the original cache was written to use the "old" ones.

Possible solutions:

  1. install apcu_bc plugin
  2. use https://github.com/FriendsOfSymfony1/CacheLegacyBridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants