SidekiqからScheduler::VacuumSchedulerというのが起動されてるはずっぽい。
https://github.com/mastodon/mastodon/pull/19232/files#diff-b78cc43c5a45bcc68d66dfc8e0865a4f2d6a38eed9fe5e2c8c216c791ff12450
プレビューカードもメディアキャッシュと同じタイミングで消されるはずっぽい
https://github.com/mastodon/mastodon/pull/19232/files#diff-71be4dc19611bd70eef4fee16607a275bb40f876b5d4c0422e4283c9ace22695
この起動の時にはvacuum_schedulerは4:08に実行されるように設定されたのかな?うーむ。1日に1度じゃ実行されない可能性も高いな。
2022-10-21T19:31:06.834328+00:00 app web.1 - - pid=68 tid=74g INFO:
Booted Rails 6.1.7 application in production environment
Running in ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
See LICENSE and the LGPL-3.0 for licensing details.
Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
Loading Schedule
:
Scheduling vacuum_scheduler {"cron"=>"8 4 * * *", "class"=>"Scheduler::VacuumScheduler", "queue"=>"scheduler"}
:
Schedules Loaded
ちゃんと実行されて9秒弱で完了してた。
2022-10-22T04:08:00+00:00 pid=68 tid=6uk4 INFO: queueing Scheduler::VacuumScheduler (vacuum_scheduler)
2022-10-22T04:08:00+00:00 pid=68 tid=3fk2s class=Scheduler::VacuumScheduler jid=87af559ebd5589b76aca09b7 INFO: start
2022-10-22T04:08:09+00:00 pid=68 tid=3fk2s class=Scheduler::VacuumScheduler jid=87af559ebd5589b76aca09b7 elapsed=8.746 INFO: done
$ rails c
> ContentRetentionPolicy.current.media_cache_retention_period
=> nil
おやや?content_cache_retention_periodもbackups_retention_periodもnilだわね
(ブラウザの幅を狭くすると/admin/settings/content_retention へのリンクを見つけられなくなる気もする
Postgresにはたぶん期待どおりのデータ(yamlじゃなくて何だろう)が入っている
> SELECT var,value FROM settings WHERE var LIKE '%retention_period';
var | value
--------------------------------+----------
media_cache_retention_period | --- '14'+
|
backups_retention_period | --- '7' +
|
content_cache_retention_period | --- '' +
|
(3 rows)
app/models/content_retention_policy.rbを眺めながらRailsから読んでみる
$ rails c
> Setting.media_cache_retention_period
=> "14"
うん
> Setting.media_cache_retention_period.is_a?(Integer)
=> false
よねえ…
> ContentRetentionPolicy.current.media_cache_retention_period
=> nil
そうなるよなあ…
$ git diff master Gemfile
:
-gem 'rails-settings-cached', '~> 0.6'
+gem 'rails-settings-cached', '~> 0.6', git: 'https://github.com/zunda/rails-settings-cached.git', branch: 'v0.6.6-aliases-true'
:
これかなあ…
しかしapp/models/form/admin_settings.rbとかを眺めても*_retention_periodが文字ではなくて整数だっていう記述がないんだよな。
ローカルでバニラ丼を動かしてみて、問題が再現しないならrails-settings-cachedの改造が原因ぽいのでちゃんと読む、問題が再現するならapp/models/form/admin_settings.rbに整数の項目の記述を足す、てな感じでどうじゃろね
よし
> SELECT var,value FROM settings WHERE var LIKE '%retention_period';
var | value
--------------------------------+--------
content_cache_retention_period | --- ''+
|
media_cache_retention_period | --- 14+
|
backups_retention_period | --- 7 +
|
(3 rows)
> ContentRetentionPolicy.current.media_cache_retention_period
=> 14 days
ひさびさプルリクったよー。わーい!!
https://github.com/mastodon/mastodon/pull/19478