Environment robots lookup is not cached when no setting has been saved, so the database is read on every request
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
src/Stott.Optimizely.RobotsHandler/Environments/EnvironmentRobotsService.csから始め、Getがリポジトリの結果がない場合をどのように処理するか、またSaveがキャッシュをどのようにクリアするかを追ってください。保存済みレコードがない環境用に無効化されたデフォルトモデルをキャッシュし、繰り返し検索してもリポジトリの読み取りが発生せず、その後の保存が反映されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Summary
EnvironmentRobotsService.Get(environmentName) only caches the result when the repository returns a record. If no Environment Robots setting has ever been saved for the current environment, EnvironmentRobotsRepository.Get returns null, nothing is cached, and the Dynamic Data Store is queried on every request that passes through RobotsHeaderMiddleware (and MetaRobotsTagHelper).
The admin UI shows each environment with all options unticked whether or not a record exists, so a site that has never used the feature looks correctly configured while running one uncached database read per request.
Affected versions
- Seen in 6.0.2.
- The same code is on
main(src/Stott.Optimizely.RobotsHandler/Environments/EnvironmentRobotsService.cs).
Code
environmentModel = repository.Value.Get(environmentName);
if (environmentModel is not null)
{
cacheHandler.Add(cacheKey, environmentModel);
}
return environmentModel;
Steps to reproduce
- Install the Robots Handler on a site and never save anything on the Environment Robots tab.
- Call
GET /stott.robotshandler/api/environment/listtwice. - Every environment comes back with a different
idon each call (they are generated byIncludeAllEnvironments), which shows no record is stored. - Each page request now runs
EnvironmentRobotsRepository.Getagainst the database, because thenullresult is never cached.
Impact
One small read per request is cheap on its own, but it adds a SQL connection request to every page and API call. We saw this on a DXP Preproduction instance (CMS 12, single instance) during SQL connection pool exhaustion: the sampled stack traces showed the pool timeout raised from RobotsHeaderMiddleware → EnvironmentRobotsRepository.Get on many requests. The add-on was not the root cause of the exhaustion, but the uncached read made it appear on every failing request and added to the connection demand.
Workaround
Save the current environment on the Environment Robots tab with all options unticked. The Save button stays disabled until something changes, so tick and untick an option first. After that, the record exists, is cached for 12 hours, and no X-Robots-Tag header is added.
Suggested fix
When the repository returns null, cache a default model for that environment (all options off, so IsEnabled is false) instead of nothing. The middleware and tag helper already skip a disabled model, so behaviour is unchanged and the cache covers the "never configured" case. Save already calls RemoveAll(), so a later save still takes effect straight away.
- 主要言語
- C#
- スター
- 3
- フォーク
- 5
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
GeekInTheNorth/Stott.Optimizely.RobotsHandler のほかの issue
-
Feature: Robots URL Rules再び着手できるかも @GeekInTheNorth が 158 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンCMS13 enhancement In Progress
GeekInTheNorth/Stott.Optimizely.RobotsHandler#88 · コメント 1 件 · 担当者 1 名 ·
-
Cosmetic enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
GeekInTheNorth/Stott.Optimizely.RobotsHandler の issue をすべて見る
似ている issue
-
effort:S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nightscout/nocturne#4930 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
reactiveui/ReactiveUI#4589 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 91/100
reactiveui/Akavache#1278 ·
メンテナーはふだん 1 日以内に返信
-
FOODPLANNER Subtask
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
aau-giraf/foodplanner-api#314 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
juandresrodca/AdminForge#70 ·
メンテナーはふだん 1 日以内に返信