Draft: Cache JIRA MR responses [RUN ALL RSPEC] [RUN AS-IF-FOSS]
What does this MR do?
Caches the rendered entities for the JIRA DVCS merge request endpoints so that we're not re-rendering identical data on every hit. This uses the new helpers introduced in !54975 (merged) to cache the output. These rely on the cache_key
provided by each record and an optional cache_context
to allow scoping of the keys further.
This doesn't scope the caches to each user (I've set cache_context
to nil
for this) as the filtering takes place before rendering, and no user-specific data is in the rendered entities. Should cut down the query count for these endpoints and also speed them up a bit. This endpoint has a tendency to generate quite large numbers of SQL queries (500-1000) and is hit quite regularly as part of the integration.
Resolves #325564 (closed)
Fixes #325696 (closed)
Rollout issue)
Feature flag (cached_api_jira_pulls
Performance
Before
{
"time": "2021-03-22T15:44:16.230Z",
"severity": "INFO",
"duration_s": 0.34919,
"db_duration_s": 0.04937,
"view_duration_s": 0.29982,
"status": 200,
"method": "GET",
"path": "/api/v3/repos/-/jira/pulls",
"params": [],
"host": "localhost",
"remote_ip": "127.0.0.1",
"ua": "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0",
"route": "/api/:version/repos/-/jira/pulls",
"user_id": 1,
"username": "root",
"queue_duration_s": 0.103792,
"db_count": 333,
"db_write_count": 0,
"db_cached_count": 216,
"cpu_s": 0.434001,
"correlation_id": "01F1D9QBX1F43M5R5ZH8T4S03N",
"meta.user": "root",
"meta.caller_id": "/api/:version/repos/-/jira/pulls",
"meta.remote_ip": "127.0.0.1",
"meta.feature_category": "integrations",
"meta.client_id": "user/1"
}
After
{
"time": "2021-03-22T15:44:18.077Z",
"severity": "INFO",
"duration_s": 0.01586,
"db_duration_s": 0.00298,
"view_duration_s": 0.01288,
"status": 200,
"method": "GET",
"path": "/api/v3/repos/-/jira/pulls",
"params": [],
"host": "localhost",
"remote_ip": "127.0.0.1",
"ua": "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0",
"route": "/api/:version/repos/-/jira/pulls",
"user_id": 1,
"username": "root",
"queue_duration_s": 0.071759,
"db_count": 9,
"db_write_count": 0,
"db_cached_count": 0,
"cpu_s": 0.076187,
"correlation_id": "01F1D9QE26BG255W9QJF5SJ8KG",
"meta.user": "root",
"meta.caller_id": "/api/:version/repos/-/jira/pulls",
"meta.remote_ip": "127.0.0.1",
"meta.feature_category": "integrations",
"meta.client_id": "user/1"
}
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because it's currently behind a feature flag
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team