nextCloudを22.2.3から22.2.6にバージョンアップした時の記録

nextCloudを22.2.3から22.2.6にアップデートする際にセキュリティ&セットアップ警告に「最後のバックグラウンドジョブの実行は4ヶ月前を実行しました。何かがおかしいようです。」との表示を確認。
cronのバックグラウンドジョブが4ヶ月前に実行されたっきりらしい。

/var/www/nextcloud/cron.phpを見てみると、中身が空の状態になっていた。
バージョンアップをしたら解決するかと思い、22.2.3から22.2.6にしてみたがバックグラウンドジョブの問題は解決しない。
それどころか新たに以下のデータベースのエラーが発生した。

エラー内容


データベースにいくつかのインデックスがありません。大きなテーブルにインデックスを追加すると、自動的に追加されないまでに時間がかかる可能性があるためです。 "occ db:add-missing-indices"を実行することによって、インスタンスが実行し続けている間にそれらの欠けているインデックスを手動で追加することができます。 インデックスが追加されると、それらのテーブルへのクエリは通常はるかに速くなります。

  • テーブル "oc_filecache"のインデックス "fs_storage_path_prefix"が見つかりません。
  • テーブル "oc_filecache"のインデックス "fs_id_storage_size"が見つかりません。
  • テーブル "oc_properties"のインデックス "properties_pathonly_index"が見つかりません。
  • テーブル "oc_jobs"のインデックス "job_lastcheck_reserved"が見つかりません。

取り敢えずデータベースのエラー解決から手を付けてみる


nextCloudが配置されているディレクトリでocc db:add-missing-indicesを実行するも、

「Command 'occ' not found, but there are 21 similar ones.」

と表示されてしまう。

やり方を間違えていたようだ。
sudo -u www-data php /var/www/html/nextcloud/occ db:add-missing-indicesを実行してみる。
すると、


An unhandled exception has been thrown:
OC\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)


というメッセージが表示された。

どうやらメモリキャッシングに問題があるようだ。
管理者に移行して以下のファイルを開いてみる。

/etc/php/バージョン番号/cli/php.ini

ファイルを見てみると理由は分からないが設定したはずの「コマンドラインからのPHP実行時にAPCuを有効にする」という設定が消えていた。

そこで以下をファイルの末尾に追記。

apc.enable_cli=1

改めて、sudo -u www-data php /var/www/html/nextcloud/occ db:add-missing-indicesを実行してみる。
結果は以下のとおり。


Check indices of the share table.
Check indices of the filecache table.
Adding additional path index to the filecache table, this can take some time...
Filecache table updated successfully.
Adding additional size index to the filecache table, this can take some time...
Filecache table updated successfully.
Check indices of the twofactor_providers table.
Check indices of the login_flow_v2 table.
Check indices of the whats_new table.
Check indices of the cards table.
Check indices of the cards_properties table.
Check indices of the calendarobjects_props table.
Check indices of the schedulingobjects table.
Check indices of the oc_properties table.
Adding properties_pathonly_index index to the oc_properties table, this can take some time...
oc_properties table updated successfully.
Check indices of the oc_jobs table.
Adding job_lastcheck_reserved index to the oc_jobs table, this can take some time...
oc_properties table updated successfully.


nextCloudのセキュリティ&セットアップ警告を見ると、データベースのエラーが消えていた。
どうやら成功したらしい。

なお、バックグラウンドジョブのエラーはデータベースのエラー解決から数分おいて/var/www/html/nextcloud/cron.phpを確認してみたら、構築当初に書き込んだ設定(5分おきに実行)に戻っており問題は解決した。
何故当初/var/www/html/nextcloud/cron.phpの中身が空だったのかはっきりと原因は分からないが、やはりメモリキャッシングが怪しいと考えている。