Kirby 3.9 get/fetch lock timeouts

Hello there,

my client and I have the following problem:

Kirby is checking the lock status of a page every 10 seconds. This is fine. When I change something on the page and the page gets ā€œlockedā€, everything still is fine. Every 10 seconds the lock status of the page gets requested and is 200 OK.

This is where it gets tricky:
After a while, changes still pending, the requests for the lock are running into timeouts…


And after some time ā€œJson response could not be parsed: Gateway timeoutā€ appears.

Shortly after this, I can’t access the page in the kirby panel (after a refresh) for a while (max 1 minute) (due to the lock file still there). The site just keeps loading.

Also during these timeouts, Kirby opens a new connection on nginx for each failed lock request while this is supposed to be 1 connection (since I’m the only one accessing it).

We use php 8 and Kirby 3.9. NGINX says 499 client closed request for the /lock requests. PHP-FPM gives me 500 internal server error after a minute (nginx 15:30 499, php-fpm 15:31 500)

I’m certain this has nothing to do with our nginx and php configuration but with how Kirby handles these lock requests.

Any ideas? Any suggestions?
I can provide more screenshots and details if requested (since I’m a new user, I can only add 1 in this post)

bs
Marc

Changed your user status.

@MarcJansen Could you please check your PHP error logs and maybe provide more information. Team guesses that this might be due to a server firewall…

Is this a new installation, or did this only happen after you made any changes?

This is not a new installation. This Kirby 3.9 got upgraded from Kirby 3.5.3

I try to provide more information. I have to make some changes to PHP Log Level. Also I’ll go check any firewall rules. But after some further testing this lock issue only occurs after working in the panel (make some changes, don’t save them, change tab without saving, come back etc.). While idling and not having any pending changes, Kirby can request lock hundred times without any issues.

Edit:
Just checked the rules. There is no firewall rule which could intervene here. We also use traefik as Ingress Controller and there is also no rule or circuit breaker which could intervene here.

Steps:
Made a change
Left it pending (not saving)
tabbed out
tabbed in
scrolled down

see console

After rechecking now, I got a rule in our traefik ingress which will kill requests taking longer than 45 seconds. The question now is, why does Kirby take so long for an answer? I can’t remove the rule… 45 seconds are already a long timespan. It would flood all connections with Kirby lock requests.

I also traced the call:

#Kirby\Cms\ContentLocks::handle is taking too long. (nearly 2 minutes)

Detailed stack:


I added max script duration to PHP.

[02-Mar-2023 12:14:05] WARNING: [pool www] child 48, script ā€˜/var/www/html/index.php’ (request: ā€œPOST /index.phpā€) execution timed out (36.174289 sec), terminating

[02-Mar-2023 12:14:05] WARNING: [pool www] child 48 exited on signal 15 (SIGTERM) after 340.027994 seconds from start

[02-Mar-2023 12:14:05] NOTICE: [pool www] child 60 started

Which also indicates, that the script/php takes too long.

Thanks for the additional information. It suggests that the call to flock() blocks because another thread/PHP worker tries to access the lock file at the same time. We haven’t seen this behavior of timed-out requests before, but I can try to help you debugging it.

What I find interesting is that it only happens once the user tabs out of the Panel. A few questions:

  • Are there multiple users in your Kirby installation?
  • When tabbing out, was the other tab unrelated to the Kirby installation?
  • Does it also occur in different browsers?
  • Does it also occur when using a fresh Starterkit installation on the same server setup?

Hello, sorry for my late reply:

I can answer the first 3 questions:

  • There are multiple users in our Kirby installation but the timeout occures with every user. We have users where multiple persons can login and we have users only for specific persons.

  • When tabbing out, the tab is unrelated to Kirby.

  • It does occur in firefox, safari and chrome, as far as I tested it.

Thank you for your reply. This suggests that the issue is caused by the site code and/or server setup.

Could you please first try setting up a fresh Starterkit on the same server setup to rule out issues with your site code?