Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty cache sometimes create empty files.
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
gianiaz
Smarty Rookie


Joined: 14 Dec 2006
Posts: 25
Location: Italy

PostPosted: Tue Jan 07, 2014 3:52 pm    Post subject: Smarty cache sometimes create empty files. Reply with quote

Hi, I have a site running from a few years.

It was running on a php 5.2 and now it has been transferred on a server with php5.5.

The site has 1 main template that loads a number of tpl files. The main template it's not cached, but the modules are.

It was running well since the server change, now, randomly for some pages smarty generates an empty cache file, and the site shows only the main template.

I'm not here to ask why, but to ask help on how I have to debug the problem.

In the error log I can't see anything significant (I can see some strict standars warning).

I have upgraded to the latest smarty 2.X version.

Do you have any suggestion?
Back to top
View user's profile Send private message Visit poster's website
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Sat Jan 18, 2014 12:56 pm    Post subject: Reply with quote

We see the exact same error. PHP version 5.5.7. Smarty 2.6.28.

We would love to upgrade Smarty to version 3 but that would require a lot of work since Smarty 3 handles config-variablename collisions different (creates arrays instead of overwriting).
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Jan 18, 2014 1:10 pm    Post subject: Reply with quote

Do both servers use a PHP cache like ACP or other?
It could be the parameter settings of the PHP cache in php.ini.

But this is the only idea I have.
Back to top
View user's profile Send private message
gianiaz
Smarty Rookie


Joined: 14 Dec 2006
Posts: 25
Location: Italy

PostPosted: Sun Jan 19, 2014 2:06 pm    Post subject: Reply with quote

a link to phpinfo result:

https://www.dropbox.com/s/kvqth6363rjl7d0/phpinfo.html

php 5.5.6 and
smarty 2.6.28 (replaced 2.6.10)
Back to top
View user's profile Send private message Visit poster's website
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Mon Jan 20, 2014 9:46 am    Post subject: Reply with quote

It can be that our problems started when we changed from Apache to Nginx/FPM.

We don't use any PHP cache. Here is our php.ini regarding "cache":

pdo_mysql.cache_size = 2000
mysql.cache_size = 2000
mysqli.cache_size = 2000

session.cache_limiter = nocache
session.cache_expire = 180

soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5

[opcache]
;opcache.enable=0
;opcache.enable_cli=0
; The OPcache shared memory storage size.
;opcache.memory_consumption=64
;opcache.interned_strings_buffer=4
; The maximum number of keys (scripts) in the OPcache hash table.
;opcache.max_accelerated_files=2000
;opcache.max_wasted_percentage=5
; When this directive is enabled, the OPcache appends the current working
;opcache.use_cwd=1
; When disabled, you must reset the OPcache manually or restart the
;opcache.validate_timestamps=1
;opcache.revalidate_freq=2
;opcache.revalidate_path=0
;opcache.save_comments=1
;opcache.load_comments=1
;opcache.fast_shutdown=0
;opcache.enable_file_override=0
; A bitmask, where each bit enables or disables the appropriate OPcache
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
; The location of the OPcache blacklist file (wildcards allowed).
; Each OPcache blacklist file is a text file that holds the names of files
;opcache.blacklist_filename=
; Allows exclusion of large files from being cached. By default all files
; are cached.
;opcache.max_file_size=0
; Check the cache checksum each N requests.
;opcache.consistency_checks=0
; How long to wait (in seconds) for a scheduled restart to begin if the cache
;opcache.force_restart_timeout=180
; OPcache error_log file name. Empty string assumes "stderr".
;opcache.error_log=
; All OPcache errors go to the Web server log.
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
Back to top
View user's profile Send private message
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Sun Jan 26, 2014 3:37 pm    Post subject: Reply with quote

Actually I have now realized that OPCACHE is in fact enabled by default in PHP 5.5. So I tried to tweak the settings like this:

opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=8000
opcache.revalidate_freq=30
opcache.save_comments=0
opcache.fast_shutdown=1
opcache.validate_timestamps=1
opcache.enable_file_override=1

But it didn't help, we still get empty Smarty-cached files now and then. I will now try to exclude Smarty-files from OPCACHE using "opcache.blacklist_filename". Will get back soon with my findings.
Back to top
View user's profile Send private message
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Sun Jan 26, 2014 4:18 pm    Post subject: Reply with quote

Ok. First I tried to exclude Smarty-files from the OPCACHE with:

In php.ini:
opcache.blacklist_filename=/path/to/opcache_blacklist

File opcache_blacklist:
/path/to/smarty_templates_c/*.php

That didn't make any difference. Still getting empty cached Smarty-files.

Then I tried to disable OPCACHE with:
opcache.enable=0

Still no luck. Same errors from time to time... Sad
Back to top
View user's profile Send private message
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Wed Jan 29, 2014 12:30 pm    Post subject: Reply with quote

Anybody have an idea how to debug this error?

Or should we instead work with upgrade Smarty to version 3? I guess this error doesn't exist in Smarty 3 - or?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jan 29, 2014 8:48 pm    Post subject: Reply with quote

I have currently no idea what may cause the problem.
Is the cache file completely empty, or does it contain at least some control information and it does not just content which gets displayed?
Back to top
View user's profile Send private message
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Wed Jan 29, 2014 8:58 pm    Post subject: Reply with quote

No the file is not completely empty. The first part with some serialized data is there. But the HTML-part that should come after that is blank.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jan 29, 2014 9:12 pm    Post subject: Reply with quote

that means that Smarty went through the cache processing completely.

With not knowing the application and template logic it's hard to guess if some changed behavior of PHP5.5 could case the empty cache file. If you put the cache_lifetime to a low value like 5 seconds or so will calling the same page show this randomly very seldom or will it be reproduceable.

If you disable caching will you also see missing content?
Back to top
View user's profile Send private message
gianiaz
Smarty Rookie


Joined: 14 Dec 2006
Posts: 25
Location: Italy

PostPosted: Mon Feb 03, 2014 3:39 pm    Post subject: Reply with quote

Tried to put cache lifetime to 3 seconds and did refresh the page a lot of times, but I can't reproduce the error.

I would like to debug this, but I need some help.

If I want to automate the control and send an email when a 0 byte file is created what's the best spot in the code to put this check?

What data should I collect?

Thank you
Back to top
View user's profile Send private message Visit poster's website
gianiaz
Smarty Rookie


Joined: 14 Dec 2006
Posts: 25
Location: Italy

PostPosted: Wed Feb 05, 2014 2:17 pm    Post subject: Reply with quote

Found some empty files, this is an example:

Code:

314
a:4:{s:8:"template";a:5:{s:60:"/XXX/XXX/public_html/public/main_modules/news/news.tpl";b:1;s:18:"../adv/300x250.tpl";b:1;s:25:"common/menu_contenuto.tpl";b:1;s:23:"../adv/sociali_news.tpl";b:1;s:18:"../adv/468news.tpl";b:1;}s:9:"timestamp";i:1389104914;s:7:"expires";i:1389108514;s:13:"cache_serials";a:0:{}}


Still looking for help Smile
Back to top
View user's profile Send private message Visit poster's website
gianiaz
Smarty Rookie


Joined: 14 Dec 2006
Posts: 25
Location: Italy

PostPosted: Wed Feb 05, 2014 4:19 pm    Post subject: Reply with quote

Not a solution, but for now I've modified the fetch method to make an additional check on the content of the cache file, if it's empty I don't return nothing, and the code behave like the page is not in cache.
I've also modified the is_cached method to do the same check.
Back to top
View user's profile Send private message Visit poster's website
Moggia
Smarty Rookie


Joined: 24 Nov 2009
Posts: 11

PostPosted: Fri Feb 28, 2014 8:18 am    Post subject: Reply with quote

Gianiaz: Could you please post the code for your modifications? They sound like a good idea. We have been working a couple of weeks now with upgrading to Smarty 3 but I have seen this error even when using the latest Smarty - so we are not confident this upgrade will solve the error...
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP