エラー1 NoMethodError: undefined method `account' for nil:NilClass
特定ユーザーでデータ アーカイブのエクスポートに失敗
mastodon-sidekiq-1 | 2023-04-10T15:22:26.680Z pid=7 tid=evsb class=BackupWorker jid=cfb54fb03dd8f7e491e2a0ae elapsed=1.633 INFO: fail
mastodon-sidekiq-1 | 2023-04-10T15:22:26.681Z pid=7 tid=evsb WARN: {"context":"Job raised exception","job":{"retry":5,"queue":"pull","backtrace":true,"dead":false,"args":[16],"class":"BackupWorker","jid":"cfb54fb03dd8f7e491e2a0ae","created_at":1681139618.3241477,"enqueued_at":1681140145.0470257,"error_message":"undefined method `account' for nil:NilClass","error_class":"NoMethodError","failed_at":1681139623.3585796,"retry_count":4,"error_backtrace":"eJxtjM0KwjAQhF+l5NKLuBa8NIgvIhI3aSyh+Vk2W8G3t60oCJ7mg5n5LgoK\nCSSsUoaSAYkgBgvoJDyCPGm2IDiahBlHz3u2uuuOOuTm5lyrdn/uxL76LJ7r\nj+XD5ttvsrfLxuKmZqE7l2SqoMx1tZ/COswY9bSEj2fdH7aDILXq+gLrbkS7\n","retried_at":1681139838.9553432}}
mastodon-sidekiq-1 | 2023-04-10T15:22:26.681Z pid=7 tid=evsb WARN: NoMethodError: undefined method `account' for nil:NilClass
mastodon-sidekiq-1 | 2023-04-10T15:22:26.681Z pid=7 tid=evsb WARN: /opt/mastodon/app/lib/activitypub/tag_manager.rb:114:in `cc'
関連
https://github.com/mastodon/mastodon/issues/12424
エラー2 undefined method `account_id' for nil:NilClass (NoMethodError)
特定ユーザーでホーム・リストタイムラインのフィードを再構築するときにエラーになる
$ bin/tootctl feeds build [USERNAME]
/opt/mastodon/app/lib/feed_manager.rb:539:in `block in build_crutches': undefined method `account_id' for nil:NilClass (NoMethodError)
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/delegation.rb:88:in `each'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/delegation.rb:88:in `each'
from /opt/mastodon/app/lib/feed_manager.rb:534:in `flat_map'
from /opt/mastodon/app/lib/feed_manager.rb:534:in `build_crutches'
from /opt/mastodon/app/lib/feed_manager.rb:257:in `block in populate_home'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:71:in `block (2 levels) in find_each'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:71:in `each'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:71:in `block in find_each'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:138:in `block in find_in_batches'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:245:in `block in in_batches'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:229:in `loop'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:229:in `in_batches'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:137:in `find_in_batches'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7.2/lib/active_record/relation/batches.rb:70:in `find_each'
from /opt/mastodon/app/lib/feed_manager.rb:245:in `populate_home'
from /opt/mastodon/app/services/precompute_feed_service.rb:7:in `call'
from /opt/mastodon/lib/mastodon/feeds_cli.rb:44:in `build'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:116:in `invoke'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:243:in `block in subcommand'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
from bin/tootctl:9:in `block in <main>'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/chewy-7.2.4/lib/chewy/strategy.rb:57:in `wrap'
from /opt/mastodon/vendor/bundle/ruby/3.0.0/gems/chewy-7.2.4/lib/chewy.rb:154:in `strategy'
from bin/tootctl:8:in `<main>'
解決方法
原因
リブログ元投稿が削除されると自分のリブログも削除されるが、何らかの原因で削除されず、上記のようにエラーとなるようです。
なので、原因のリブログを削除することで対応しました。
「リブログ」は Mastodon の「ブースト」、
「ステータス」は Mastodon の「トゥート」または「投稿」と思ってもらえればよさそうです。
It seems like the line choked on a status that was a reblog of a status that was deleted. Normally if the original status is deleted then so are the reblogs. Either something is wrong with foreign key constraints and an ID value has been left over in reblog_of_id, or it's some kind of race condition issue, or something else.
削除されたステータスのリブログであるステータスに、ラインが詰まったようです。通常、元のステータスが削除されれば、リブログも削除されます。外部キー制約に問題があり、reblog_of_idにID値が残っているのか、レースコンディションの問題なのか、それとも他の問題なのか、どちらかです。
必ずバックアップを用意して、リストアできる状態で作業してください。
エラーが発生するユーザーのアカウントIDかつ、リブログ投稿(reblog_of_id
が NULL
ではない)でクエリーして、その中から問題のリブログ投稿を探します。
アカウントID を取得
curl https://INSTANCE/api/v1/accounts/lookup?acct=USERNAME
SELECT uri FROM public.statuses
WHERE reblog_of_id IS NOT NULL AND
account_id = 'xxxxxxxxxxxxxxxxxx'
該当ユーザーのリブログ一覧が表示されると思います。
表示される URL を一つずつブラウザで開いてJSONが返ってこない(エラーになる)投稿を手動で探しました。
問題の投稿を特定したら(バックアップした上で)レコードごと削除して解決しました。
私の環境ではこれでデータエクスポート(バックアップ)及びタイムラインの再構築が正常に行われるようになりました。
問題が必ずしもこれで解決するかわかりませんが、なかなか解決しない場合に試してみてください。
解決後に記憶をもとに記載しているため、抜けや間違った記述、わかりにくい記述があればコメントにてご指摘していただけますと幸いです。