Environment robots lookup is not cached when no setting has been saved, so the database is read on every request
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
Empieza en src/Stott.Optimizely.RobotsHandler/Environments/EnvironmentRobotsService.cs y sigue cómo Get gestiona un resultado inexistente del repositorio y cómo Save vacía la caché. Guarda en caché un modelo predeterminado desactivado para un entorno sin ningún registro guardado y confirma que las consultas repetidas evitan lecturas del repositorio y que las guardadas posteriores surten efecto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 3
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de GeekInTheNorth/Stott.Optimizely.RobotsHandler
-
Feature: Robots URL RulesQuizá libre de nuevo @GeekInTheNorth la tomó hace 158 días y no hay ningún pull request abierto. AbiertoCMS13 enhancement In Progress
GeekInTheNorth/Stott.Optimizely.RobotsHandler#88 · 1 comentario · 1 asignado ·
-
Cosmetic enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Todos los issues de GeekInTheNorth/Stott.Optimizely.RobotsHandler
Issues similares
-
effort:S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
nightscout/nocturne#4930 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
reactiveui/ReactiveUI#4589 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 91/100
reactiveui/Akavache#1278 ·
Los mantenedores suelen responder en 1 día
-
FOODPLANNER Subtask
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
aau-giraf/foodplanner-api#314 ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
juandresrodca/AdminForge#70 ·
Los mantenedores suelen responder en 1 día