Thread safety when calling fetch_relation
まだ誰も着手していません。
評価
調査の方向性
lib/identity_cache/cached/recursive/association.rb の25〜42行目付近を、ガードと @dehydrated_relation の削除から読み始めてください。fetch_association の同時呼び出しを調査し、同時アクセス時に報告された NameError が発生しなくなっていることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Hi!
We utilize a global, in-memory cache with TTL for one of our models per process. We also wanted to use identity_cache so that the whole object tree is fetched with one network call.
However, we receive rare errors when we call fetch_association with the following stack trace:
NameError instance variable @dehydrated_relation not defined
/usr/local/bundle/ruby/3.3.0/gems/identity_cache-1.5.6/lib/identity_cache/cached/recursive/association.rb:34
/usr/local/bundle/ruby/3.3.0/gems/identity_cache-1.5.6/lib/identity_cache/cached/recursive/association.rb:19
which points to this piece of code:
Since the code has a guard clause: record.instance_variable_defined?(dehydrated_variable_name), the only way this can happen is that another thread is concurrently executing the same code and has already removed this instance variable.
Are you open to contributions to fix concurrency issues? So far we've only seen this error popping up dozens of times on ~50M requests, however, there might be more that we haven't seen yet or are failing silently 👀
- 主要言語
- Ruby
- スター
- 2k
- フォーク
- 175
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Shopify/identity_cache のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Shopify/identity_cache#555 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
Shopify/identity_cache#539 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
Shopify/identity_cache#535 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
Shopify/identity_cache#533 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
Shopify/identity_cache#525 · コメント 4 件 ·
Shopify/identity_cache の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
IHP-GmbH/IHP-Open-PDK#1266 ·
メンテナーはふだん 2 日以内に返信
-
Source Support
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
we-promise/sure#4056 ·
メンテナーはふだん 1 日以内に返信
-
Refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
valkey-io/valkey-glide-ruby#347 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 5 日以内に返信