ownCloud アップデート時にタイムアウト(has gone away)で処理が止まってしまう場合の原因と対処法

occコマンドでownCloudのバージョンアップを行ったところタイムアウト「SQLSTATE[HY000]: General error: 2006 MySQL server has gone away」が起きアップデートを完了することが出来なかった。

アップデートコマンド実行とメッセージ

コマンド実行

% /usr/local/bin/php-7.0 ~/html/oc/occ upgrade -v

メッセージ

The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
ownCloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2020-03-28T14:36:25+00:00 Set log level to debug
2020-03-28T14:36:25+00:00 Repair step: Repair MySQL database engine
2020-03-28T14:36:25+00:00 Repair step: Repair MySQL collation
2020-03-28T14:36:25+00:00 Repair step: Repair SQLite autoincrement
2020-03-28T14:36:25+00:00 Repair step: Repair duplicate entries in oc_lucene_status
2020-03-28T14:36:25+00:00 Repair info: lucene_status table does not exist -> nothing to do
2020-03-28T14:36:25+00:00 Checking whether the database schema can be updated (this can take a long time depending on the database size)
2020-03-28T14:36:25+00:00  Checking table oc_appconfig
2020-03-28T14:36:26+00:00  Checking table oc_storages
2020-03-28T14:36:27+00:00  Checking table oc_mounts
2020-03-28T14:36:28+00:00  Checking table oc_mimetypes
2020-03-28T14:36:28+00:00  Checking table oc_filecache
2020-03-28T15:02:00+00:00 Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SET unique_checks=1':
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
2020-03-28T15:02:00+00:00 Update failed
2020-03-28T15:02:00+00:00 Maintenance mode is kept active
2020-03-28T15:02:00+00:00 Reset log level

原因調査

oc_filecache 確認

実行後のメッセージが “oc_filecache” のところで止まっていたので状況見てみるとレコード数(1千万レコード以上)・容量(9GB以上)ともにかなり肥大化してしまっていました…こちらのテーブルのレコードを削除した方がよさそうな状況でした。

対処法

oc_filecache のレコード削除

DELETE FROM oc_filecache;

ダメ元で一気に全レコードの削除を試みましたが、タイムアウトなど以下のエラーが発生しました。

 ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
 ERROR 2013 (HY000): Lost connection to MySQL server during query

面倒ですが、状況みながら10万レコード単位で全レコードを削除することにしました。(※計測していませんが数時間かかりました。)

アップデートコマンド再実行

コマンド実行

% /usr/local/bin/php-7.0 ~/html/oc/occ upgrade -v

メッセージ

 The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
 ownCloud or one of the apps require upgrade - only a limited number of commands are available
 You may use your browser or the occ upgrade command to do the upgrade
 2020-03-29T07:22:52+00:00 Set log level to debug
 2020-03-29T07:22:52+00:00 Repair step: Repair MySQL database engine
 2020-03-29T07:22:52+00:00 Repair step: Repair MySQL collation
 2020-03-29T07:22:52+00:00 Repair step: Repair SQLite autoincrement
 2020-03-29T07:22:52+00:00 Repair step: Repair duplicate entries in oc_lucene_status
 2020-03-29T07:22:52+00:00 Repair info: lucene_status table does not exist -> nothing to do
 2020-03-29T07:22:52+00:00 Checking whether the database schema can be updated (this can take a long time depending on the database size)
 2020-03-29T07:22:52+00:00  Checking table oc_appconfig
 2020-03-29T07:22:52+00:00  Checking table oc_storages
 2020-03-29T07:22:52+00:00  Checking table oc_mounts
 2020-03-29T07:22:52+00:00  Checking table oc_mimetypes
 2020-03-29T07:22:52+00:00  Checking table oc_filecache
 2020-03-29T07:22:52+00:00  Checking table oc_group_user
 2020-03-29T07:22:52+00:00  Checking table oc_group_admin
 2020-03-29T07:22:53+00:00  Checking table oc_groups
 2020-03-29T07:22:53+00:00  Checking table oc_preferences
 2020-03-29T07:22:53+00:00  Checking table oc_properties
 2020-03-29T07:22:53+00:00  Checking table oc_share
 2020-03-29T07:22:53+00:00  Checking table oc_jobs
 2020-03-29T07:22:53+00:00  Checking table oc_users
 2020-03-29T07:22:53+00:00  Checking table oc_authtoken
 2020-03-29T07:22:53+00:00  Checking table oc_vcategory
 2020-03-29T07:22:53+00:00  Checking table oc_vcategory_to_object
 2020-03-29T07:22:53+00:00  Checking table oc_systemtag
 2020-03-29T07:22:53+00:00  Checking table oc_systemtag_object_mapping
 2020-03-29T07:22:53+00:00  Checking table oc_systemtag_group
 2020-03-29T07:22:53+00:00  Checking table oc_privatedata
 2020-03-29T07:22:53+00:00  Checking table oc_file_locks
 2020-03-29T07:22:54+00:00  Checking table oc_comments
 2020-03-29T07:22:54+00:00  Checking table oc_comments_read_markers
 2020-03-29T07:22:54+00:00  Checking table oc_credentials
 2020-03-29T07:22:54+00:00 Checked database schema update
 2020-03-29T07:22:54+00:00 Checking updates of apps
 2020-03-29T07:22:54+00:00 Checked database schema update for apps
 2020-03-29T07:22:54+00:00 Updating database schema
 2020-03-29T07:22:54+00:00 Updated database
 2020-03-29T07:22:54+00:00 Repair step: Repair mime types
 2020-03-29T07:22:54+00:00 Repair step: Clear asset cache after upgrade
 2020-03-29T07:22:54+00:00 Repair info: Asset pipeline disabled -> nothing to do
 2020-03-29T07:22:54+00:00 Repair step: Detect file cache entries with path that does not match parent-child relationships
 2020-03-29T07:22:54+00:00 Repair step: Generate ETags for file where no ETag is present.
 2020-03-29T07:22:54+00:00 Repair info: ETags have been fixed for 0 files/folders.
 2020-03-29T07:22:54+00:00 Repair step: Clean tags and favorites
 2020-03-29T07:22:54+00:00 Repair info: 13 tags of deleted users have been removed.
 2020-03-29T07:22:54+00:00 Repair info: 62 tags for delete files have been removed.
 2020-03-29T07:22:54+00:00 Repair info: 0 tag entries for deleted tags have been removed.
 2020-03-29T07:22:54+00:00 Repair info: 41 tags with no entries have been removed.
 2020-03-29T07:22:54+00:00 Repair step: Drop old database tables
 2020-03-29T07:22:54+00:00 Drop old database tables
 2020-03-29T07:22:54+00:00 2020-03-29T07:22:54+00:00  Drop old database table: gallery_sharing                                                                                                                                                                                         2:54+00:00 2020-03-29T07:22:54+00:00  Drop old database table: locks                                                                                                                                                                                                                                                                                                                                                                                                                      2020-03-29T07:22:54+00:00
   9/28 [=========>]  32%  2020-03-29T07:22:54+00:00  Drop old database table: log                                                                                                                                                                                      
  10/28 [==========>]  35% 2020-03-29T07:22:54+00:00  Drop old database table: media_albums                                                                                                                                                                             
  11/28 [===========>]  39%2020-03-29T07:22:54+00:00  Drop old database table: media_artists                                                                                                                                                                            
  12/28 [============>]  422020-03-29T07:22:54+00:00  Drop old database table: media_sessions                                                                                                                                                                           
  13/28 [=============>]  42020-03-29T07:22:54+00:00  Drop old database table: media_songs                                                                                                                                                                              
  14/28 [==============>]  2020-03-29T07:22:54+00:00  Drop old database table: media_users                                                                                                                                                                              
  15/28 [===============>] 2020-03-29T07:22:54+00:00  Drop old database table: permissions                                                                                                                                                                              
  16/28 [================>]2020-03-29T07:22:54+00:00  Drop old database table: pictures_images_cache                                                                                                                                                                    
  17/28 [=================>2020-03-29T07:22:54+00:00  Drop old database table: principalgroups                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  18/28 [==================2020-03-29T07:22:54+00:00  Drop old database table: principals                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  19/28 [===================>]  67%                                                                                                                                                                                                                                                               2020-03-29T07:22:54+00:00  Drop old database table: queuedtasks                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  20/28 [====================>]  71%                                                                                                                                                                                                                                                              2020-03-29T07:22:54+00:00  Drop old database table: sharing                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  21/28 [=====================>]  75%                                                                                                                                                                                                                                                             2020-03-29T07:22:54+00:00  Drop old database table: clndr_calendars                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  22/28 [======================>]  78%                                                                                                                                                                                                                                                            2020-03-29T07:22:54+00:00  Drop old database table: clndr_objects                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  23/28 [=======================>]  82%                                                                                                                                                                                                                                                           2020-03-29T07:22:54+00:00  Drop old database table: clndr_share_event                                                                                                                                                                                                                                                                                                                                                                                                                                               
  24/28 [========================>]  85%                                                                                                                                                                                                                                                          2020-03-29T07:22:54+00:00  Drop old database table: clndr_share_calendar                                                                                                                                                                                                                                                                                                                                                                                                                                            
  25/28 [=========================>]  89%                                                                                                                                                                                                                                                         2020-03-29T07:22:54+00:00  Drop old database table: clndr_repeat                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 26/28 [==========================>]  92%                                                                                                                                                                                                                                                        2020-03-29T07:22:54+00:00  Drop old database table: contacts_addressbooks                                                                                                                                                                                                                                                                                                                                                                                                                                           
  27/28 [===========================>]  96%                                                                                                                                                                                                                                                       2020-03-29T07:22:54+00:00  Drop old database table: contacts_cards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  28/28 [============================] 100%                                                                                                                                                                                                                                                       2020-03-29T07:22:54+00:00  Done                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  28/28 [============================] 100%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2020-03-29T07:22:54+00:00
 2020-03-29T07:22:54+00:00 Repair step: Drop old background jobs
 2020-03-29T07:22:54+00:00 Repair step: Remove getetag entries in properties table
 2020-03-29T07:22:54+00:00 Repair info: Removed 0 unneeded "{DAV:}getetag" entries from properties table.
 2020-03-29T07:22:54+00:00 Repair step: Repair outdated OCS IDs
 2020-03-29T07:22:54+00:00 Repair step: Repair invalid shares
 2020-03-29T07:22:54+00:00 Repair info: Removed 18 shares where the parent did not exist
 2020-03-29T07:22:54+00:00 Repair step: Remove old share propagation app entries
 2020-03-29T07:22:54+00:00 Repair step: Remove old (< 9.0) calendar/contact shares 2020-03-29T07:22:54+00:00 Remove old (< 9.0) calendar/contact shares 2020-03-29T07:22:54+00:00 2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      0/4 [>-]   0%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  1/4 [=======>]  25%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 2/4 [==============>]  50%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  3/4 [=====================>]  75%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  4/4 [============================] 100%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                2020-03-29T07:22:54+00:00  Done                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  4/4 [============================] 100%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        2020-03-29T07:22:54+00:00
 2020-03-29T07:22:54+00:00 Repair step: Fix permissions so avatars can be stored again
 2020-03-29T07:22:54+00:00 Fix permissions so avatars can be stored again
 2020-03-29T07:22:54+00:00 2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  0/2 [>-]   0%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2020-03-29T07:22:54+00:00  Starting …                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  1/2 [==============>]  50%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             2020-03-29T07:22:54+00:00  Done                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  2/2 [============================] 100%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      2020-03-29T07:22:54+00:00
 2020-03-29T07:22:54+00:00 Repair step: Remove shares of a users root folder
 2020-03-29T07:22:54+00:00 Repair step: Repair unmerged shares
 2020-03-29T07:22:54+00:00 Starting code integrity check…
 2020-03-29T07:23:04+00:00 Finished code integrity check
 2020-03-29T07:23:04+00:00 Update successful
 2020-03-29T07:23:04+00:00 Maintenance mode is kept active
 2020-03-29T07:23:04+00:00 Reset log level

メンテ―モード解除

“oc_filecache” テーブルの全レコード削除後は問題なくアップデート処理が最後までいきました!

% /usr/local/bin/php-7.0 ~/html/oc/occ maintenance:mode --off

動作環境情報

CPI シェアードプランACE01
ownCloud 9.1.7 > 9.1.8
PHP 7.0

コメント

タイトルとURLをコピーしました