ppy / osu-web

the browser-facing portion of osu!
https://osu.ppy.sh
GNU Affero General Public License v3.0
978 stars 382 forks source link

Clockworks backing sqlite file can cause development request timeouts #8420

Open peppy opened 2 years ago

peppy commented 2 years ago

In the fail scenario, after a few requests, all further requests would block, taking minutes to run (seemingly never timing out until the client closed connection). This would hit the fpm limit and stop all requests from being processed.

I believe the following error may explain the issue, but I'm also not 100% sure that this is the root cause and not a side effect of me restarting the docker deployment a few times rapidly.

[2021-12-07 05:31:33] local.ERROR: SQLSTATE[HY000]: General error: 5 database is locked {"userId":12,"exception":"[object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 5 database is locked at /app/vendor/itsgoingd/clockwork/Clockwork/Storage/SqlStorage.php:235)
[stacktrace]
#0 /app/vendor/itsgoingd/clockwork/Clockwork/Storage/SqlStorage.php(235): PDO->exec()
#1 /app/vendor/itsgoingd/clockwork/Clockwork/Storage/SqlStorage.php(268): Clockwork\\Storage\\SqlStorage->initialize()
#2 /app/vendor/itsgoingd/clockwork/Clockwork/Storage/SqlStorage.php(191): Clockwork\\Storage\\SqlStorage->query()
#3 /app/vendor/itsgoingd/clockwork/Clockwork/Clockwork.php(133): Clockwork\\Storage\\SqlStorage->store()
#4 /app/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkSupport.php(444): Clockwork\\Clockwork->storeRequest()
#5 /app/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkMiddleware.php(36): Clockwork\\Support\\Laravel\\ClockworkSupport->recordRequest()
#6 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(208): Clockwork\\Support\\Laravel\\ClockworkMiddleware->terminate()
#7 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(179): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware()
#8 /app/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->terminate()
#9 {main}

Regardless of above, deleting storage/clockwork.sqlite and the associated lock files fixes this. We might want to delete these on (docker) startup to avoid these kinds of issues?

notbakaneko commented 2 years ago

CLOCKWORK_STORAGE_EXPIRATION can be set in .env to set the expiry of logs in minutes; the default is 1 week

peppy commented 2 years ago

Hmmm, that seems super weird since I don't think I was actively using my dev environment enough to cause this to happen in just a week. But maybe I left a single chat open polling?

Could probably also change the default to 1 hour or something more sensible.