Is JSON::Coder intended to be thread safe ?
まだ誰も着手していません。
評価
調査の方向性
activesupport/lib/active_support/json/encoding.rb の JSON::Coder の共有された作成・再利用箇所から始め、続いて JSON::Coder#dump と #generate の JRuby 上での並行動作を調査します。提供されていれば、報告されたスレッドを使った再現を利用して競合状態を確認します。スレッドセーフティの契約が決定され、動作が文書化されるか回帰テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
In JRuby we hit a race condition: ActiveSupport uses a single shared JSON::Coder
instance and calls #dump on it from multiple threads.
ActiveSupport creates one shared Coder:
https://github.com/rails/rails/blob/v8.1.3.1/activesupport/lib/active_support/json/encoding.rb#L152
…and reuses it on every encode:
https://github.com/rails/rails/blob/v8.1.3.1/activesupport/lib/active_support/json/encoding.rb#L188
The error we got, on a flat object was
JSON::NestingError: nesting of 100 is too deep. Did you try to serialize objects with circular references?
Question: is a single JSON::Coder instance intended to be safe to call
concurrently from multiple threads (i.e. is #dump/#generate on one Coder
intended to be thread-safe)?
Versions: json 2.21.2 (java), JRuby 10.0.5.0, activesupport 8.1.3.1.
I have a small threaded reproduction I can add if useful.
- 主要言語
- Ruby
- スター
- 782
- フォーク
- 383
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 10
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/json のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
Output formatting differences between jRuby 10.0.0.1 and Ruby 3.4 when converting Float to JSON. オープンjruby
-
jruby
-
new feature
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
riscv/riscv-unified-db#2624 · リアクション 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100