Repository navigation
サイドカーの鍵の待ちで tokio のワーカーを塞がない - #38
Merged
Merged
Conversation
再判定と ytdl はサイドカーの読み書きを std の Mutex で直列にしているが、 鍵の待ちを async の中で同期にしていたので、待つ間ワーカーが止まる。 CPU の少ない CI では rejudge_waits_for_the_shared_sidecar_lock が 鍵を放す側を進められずに止まった(v0.5.0 のリリースのジョブ)。 鍵を取って読んで書くまでを DownloaderEnv::with_sidecar_lock にまとめ、 spawn_blocking で回す。
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.
背景
v0.5.0 のリリースのワークフローで、rust ジョブの
rejudge_waits_for_the_shared_sidecar_lockが 30 分以上止まった(取り消した)。PR #37 の CI と v0.5.0-rc.1 では通っていた。手元でもtaskset -c 0で CPU を 1 つにすると 11 回中 10 回止まる。再判定と ytdl はサイドカー(
spindle-inbox.json)の読んで直して書くを std のMutexで直列にしているが、鍵の待ちを async の中で同期にしていたため、待つ間 tokio のワーカーが止まる。テストは鍵を持たせたまま再判定を走らせるので、CPU が少ないと鍵を放す側まで進めなくなっていた。本番でも、ytdl が鍵を持つ間に再判定のワーカーが止まりうる。変更
DownloaderEnv::with_sidecar_lockにまとめ、spawn_blockingで回すfinish_staging、再判定のupdate_sidecar/drop_stale_entriesをこれに乗せる(async にした)確認
taskset -c 0で当該テストが 15 回中 15 回通る(直す前は 11 回中 1 回)cargo test --workspace --locked(2273 件)/cargo clippy --all-targets -- -D warnings/cargo fmt --check