Skip to content

起動直後 150ms の probe 失敗でアカウントが一斉オフラインへ落ちる(数百 ms 後には同ホストへ到達できている) #989

Closed

Description

@pooza

報告

https://misskey.delmulin.com/notes/aq1i9vb7k2 の「アカウントも再読み込みしてしばらく投稿できなくなります」の部分。#988 と同じ起動セッションの観測。

観測(Sentry, 2026-08-18 09:27 JST / Android 16 / 1.57.0+170 / 6 アカウント)

restoreSessions の一斉 probe が 150 ms の窓で 5 件まとめて落ちている:

00:27:28.083  mulukhiya not found on foresdon.jp
00:27:28.098  mulukhiya not found on mstdn.delmulin.com
00:27:28.102  restoreSessions: transient failure for mastodon://***@foresdon.jp
00:27:28.138  restoreSessions: transient failure for misskey://***@misskey.delmulin.com
00:27:28.194  restoreSessions: transient failure for mastodon://***@mstdn.delmulin.com
00:27:28.226  restoreSessions: transient failure for mastodon://***@social.vivaldi.net
00:27:28.231  restoreSessions: transient failure for misskey://***@misskey.io
00:27:28.351  mulukhiya detected on misskey.delmulin.com (misskey v5.33.0)   ← 213ms 後には到達できている
00:27:28.377  startup: sessions restored in 415ms (accounts=1 skipped=0)

いずれも DioException [connection error]: The connection errored: Connection failed。タイムアウトではなく即時失敗(プロセス起動直後で connect(2) が即エラーを返す窓)で、misskey.delmulin.com は 213 ms 後の about probe に成功している。

結果として 6 アカウント中 1 件しか復元されず、残りは offline 表示 → 投稿不可。ramp-up の初回再試行は +2 秒(kOfflineRetryRampUp)なので、1 秒未満のグリッチが数秒〜(後段が詰まると)数十秒のオフラインへ増幅される。この起動では +54 秒の時点でまだ 1 件残っていた。

00:28:22.679  restoreSessions: 1 account(s) still unreachable after ramp-up; keeping retry loop running (60s interval)

以後 09:48 頃まで streaming の切断・再接続が続く(Failed host lookup: misskey.delmulin.com を含む)。

問題

初回 probe に即時リトライが無い。_probeForRestore は 1 回の失敗をそのまま retriable に畳んで offline へ降格し、あとは背景ループ(最短 +2 秒)に委ねている。端末側の回線が起き上がる前に起動した場合、これが必ず踏まれる。

https://github.com/pooza/capsicum/blob/develop/packages/capsicum/lib/src/provider/account_manager_provider.dart#L654

方針

関連

Activity

  1. added this to the v1.58 milestone on Aug 18, 2026
  2. added
    bug
    on Aug 18, 2026
  3. pooza commented on Aug 18, 2026

    @pooza
    OwnerAuthor

    cf43d2f1 で対応。

    isImmediateConnectFailure(connectionError / 素の SocketException のみ。timeout・badResponse・badCertificate は対象外)に限り、_probeForRestore が offline へ落とす前に kInitialProbeRetryDelay = 300ms 後に 1 回だけ試し直す。

    判断を 2 つ残した:

    • 待ちを長くしない。 restoreSessions は全アカウントを並列 probe しているので、ここで待った分がそのまま起動の遅延になる。ramp-up の代わりではなく前に挟む別物。
    • 分類・観測は初回の例外に対して行う。 2 度目の例外へ差し替えると「なぜ offline になったか」が 300ms 後の別の姿にすり替わる。

    回帰テストは test/immediate_connect_failure_test.dart。ホスト固有の分岐は入れていない。

    ⚠ 動作確認は取れない(起動直後の race で、狙って再現できない)。フィールドでの確認材料として restoreSessions: <key> recovered on immediate retry (300ms) を debugPrint に入れてある。Sentry の breadcrumb は console ログを拾うので、次に account_restore 系のイベントが来たときにこの行が出ているかで効いたか分かる。

  4. pooza commented on Aug 18, 2026

    @pooza
    OwnerAuthor

    起動直後の race で狙って再現できないため、動作確認は取らずに close する(検証困難なバグの扱い)。フィールドでの確認材料として restoreSessions: <key> recovered on immediate retry (300ms) を debugPrint に入れてあるので、次に account_restore 系の Sentry イベントが来たときに breadcrumb で効いたか分かる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions