XF 2.0 Admin change > Truncate xf_css_cache > DeadlockException > pages served without CSS

rebelde

Active member
Just upgraded from 1.5 to 2.0 yesterday.

With quite a few changes in the admin, such as changing the Date format for a language, this is what happens:

This happens many, many times: TRUNCATE TABLE xf_css_cache > "system lock"
And these get all backed up: INSERT INTO xf_css_cache (style_id, language_id, title, ... "Waiting for table metadata lock"
Leading to hundreds of these error messages:
XF\Db\DeadlockException: MySQL query error [1213]: Deadlock found when trying to get lock; try restarting transaction src/XF/Db/AbstractStatement.php:212​
And pages served without CSS!!! (For a few seconds.)

I could live with the first problems, but serving pages to visitors without CSS embarrasses me.

I've searched and see the recommendation to not worry about it, but this seem to be too frequent. Am I doing something wrong?
 
The xf_css_cache table is something of a malfeature if you have caching setup, as it just increases database contention for no gain.

My (free) Redis Cache add-on disables the touching of the xf_css_cache table which saves a lot of unexpected writes and thus the deadlocks when trying to purge it. (Obviously requires redis)
 
Thanks, Xon. You are great. I am not sure that I am ready to dive into Redis today. Maybe next week. Glad to know at least this option exists.
if you have caching setup
Even without caching set up. From what I can see so far the only way to avoid this is your cache.

Thanks again!
 
  • Like
Reactions: Xon
Back
Top Bottom