音声合成失敗時のキャッシュ汚染を修正#42
Merged
MORIMORI0317 merged 3 commits intoJun 6, 2026
Merged
Conversation
合成に失敗したテキストが再起動まで無音になる問題を修正する。 - 例外完了したFutureをlocalCachesから除去し再合成を可能にする - 空音声をキャッシュせず例外として扱う - ロード失敗時にuseLockを解放しタイムアウト破棄を機能させる - グローバルキャッシュのlock/unlockをtry/finallyで確実化 - LocalCache.disposeの削除判定の逆ロジックを修正 - キャッシュ破棄時の例外を握りつぶさずログ出力する
振る舞いは変えずに内部構造を整理する。 - createLocalCacheをcreateViaGlobalCache/createViaLocalSourceに分割 - 空音声チェックをEMPTY_AUDIO_MESSAGE定数とvalidateNonEmptyに集約 - CachedVoiceTrackLoaderのloadTackをloadTrackに改名
決定論的だったローカルキャッシュファイルパスを世代番号付きにし、disposeのdeleteが新世代のファイルを削除する競合を防止。あわせてグローバルキャッシュのヒット経路でも空データ検証を行うよう修正し、パス構築をstaticメソッドへ切り出して副作用なしでテスト可能にした。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
音声合成に失敗したテキストが、Bot再起動まで永久に無音になる問題(キャッシュ汚染)を修正する。
updateQueue()が該当メッセージをスキップするためBot全体は停止しないが、繰り返し使う定型句が一度のタイムアウト等で無言化していた。失敗時のキャッシュ汚染修正
CompletableFutureがlocalCachesに残り続け、同一 (エンジン+テキスト+話者) ハッシュが永久失敗していた問題を修正。whenCompleteで例外時に条件付きremoveし再合成を可能にするCachedVoiceTrackLoader.dispose()を呼びuseLockを解放。これがないとuseLockCountが減らず、空キャッシュがタイムアウト破棄もされず残っていたlock/unlockを try/finally で囲み、途中例外時のロックリークを防ぐ (将来のRedis実装向け)exceptionallyでログ出力破棄と再生成の競合修正 (追加)
<hash>) を世代番号付き (<hash>-<世代>) に変更。TTL破棄中のdispose()のdeleteが、同一キーで再生成された新世代のファイルを削除してしまう競合を防ぐgca.getが既存の空エントリ (旧バージョンや別インスタンスが残した0バイト) を返すヒット経路でもFiles.write直前に検証を追加localCacheFileへ切り出し、キャッシュフォルダ削除を伴わずに命名規則を検証可能にするテスト
CacheManagerTestを追加。世代番号が異なれば一意なパスを返すこと、ファイル名がキーのハッシュを接頭辞に持つことを検証