"Class Piwik\Cache\Lazy does not exist" one one server in load-balanced pair

I’ve got a new Matomo installation on a pair of load-balanced servers. Let’s call them 4701 and 4702.

When I hit 4701 directly, Matomo works as expected.

When I hit 4702 directly, it fails with the error “Class Piwik\Cache\Lazy does not exist.”

When I hit the load balancer, it sometimes works and sometimes fails, which is what I’d expect given the different results.

I can’t find anything on 4701 that isn’t synced to 4702, with the exception of files in tmp/ which I assume are generated as needed. Can anyone suggest a cause for this problem? Thanks!

Hi William,

It looks like some files are not uploaded correctly, could you try re-upload all files on both servers?

I can’t upload directly to the secondary server. Files are rsynced from the primary to the secondary once a minute.

My first assumption was that something was being excluded from the sync that shouldn’t be (“cache” would be a pretty likely string to exclude, after all!). So I asked the sysadmins to check those rules and resync, and they did so. A diff of the two directories now shows that the only differences are in the tmp/ directory. Could that be a problem? I would expect tmp files to be generated as needed, and not need to be synced, but perhaps that’s not the case?

OK, I was able to work with the sysadmin and get access to do a direct upload. Here’s what we found:

  • If I manually upload files to the secondary server, it works! Hurray!
  • When rsync runs subsequently to update the secondary server, Matomo continues working.
  • However, if I delete the files and allow the server to be populated entirely by rsync, the error returns.

So it seems clear there’s something being lost in the rsync process…we just haven’t been able to figure out what’s causing it. The vendor/matomo/cache/Lazy.php file definitely exists, even if it’s being populated by rsync, but something prevents the class from being located.

Hi,

One quick guess would be to run the integrity checker on the second server.

php console diagnostics:run

Of course it might not run when the caching doesn’t work.

Thank you! That’ll come in handy.

Good news – we think we’re on the right track. The sysadmin had thought he had managed to fix the exclusion rules in his rsync script to make sure everything was being copied, but yesterday afternoon found that he’d missed something. He’s still working on it, but at least we can now verify that there are missing files, and I think he’s on track to getting the problem solved.

Once he’s got it working properly, I’ll post the script, just in case anyone else is trying to do something similar.

1 Like