Skip to content

Reducing calls to Ref Data within the start up of Resume#2027

Open
tvr-hmcts wants to merge 5 commits into
masterfrom
HDPI-5414-PerfTest-Env-Make-a-Claim-Baseline
Open

Reducing calls to Ref Data within the start up of Resume#2027
tvr-hmcts wants to merge 5 commits into
masterfrom
HDPI-5414-PerfTest-Env-Make-a-Claim-Baseline

Conversation

@tvr-hmcts

Copy link
Copy Markdown
Contributor

HDPI-5414

Note - this is first run at this ticket. As it has been highlighted further work is needed in other areas also from a performance perspective.

Highlighted in performance testing the start of the ResumePossessionClaim is not meeting SLAs. Identified the double call to Ref Data and have changed the approach there.

I profiled this within an integration test and the results of the change are presented in the Jira.

Ran further hibernate based statistics and only one db call is made for the draft data. We can consider additional work there if needed in the future as splitting this using projections.

Further large or more complex refactoring can/will be considered later also such as caching and parallel calls

…rformance issues in the start method.

This found only the single database connection for the retrieval of the draft.
@tvr-hmcts tvr-hmcts requested review from a team, guygrewal77, paddy-hmcts and sadmanrahh June 26, 2026 09:25
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

CCD diff summary

👉 Full report: https://github.com/hmcts/pcs-api/actions/runs/29080717697?check_suite_focus=true

No change

@hmcts-jenkins-j-to-z

Copy link
Copy Markdown
Contributor

Plan Result (aat)

⚠️ Resource Deletion will happen

This plan contains resource delete operation. Please check the plan result very carefully!

Plan: 0 to add, 0 to change, 1 to destroy.
  • Delete
    • module.postgresql.azurerm_postgresql_flexible_server_configuration.pgsql_server_config["pg_qs.query_capture_mode"]
Change Result (Click me)
  # module.postgresql.azurerm_postgresql_flexible_server_configuration.pgsql_server_config["pg_qs.query_capture_mode"] will be destroyed
  # (because key ["pg_qs.query_capture_mode"] is not in for_each map)
  - resource "azurerm_postgresql_flexible_server_configuration" "pgsql_server_config" {
      - id        = "/subscriptions/1c4f0704-a29e-403d-b719-b90c34ef14c9/resourceGroups/pcs-data-aat/providers/Microsoft.DBforPostgreSQL/flexibleServers/pcs-aat/configurations/pg_qs.query_capture_mode" -> null
      - name      = "pg_qs.query_capture_mode" -> null
      - server_id = "/subscriptions/1c4f0704-a29e-403d-b719-b90c34ef14c9/resourceGroups/pcs-data-aat/providers/Microsoft.DBforPostgreSQL/flexibleServers/pcs-aat" -> null
      - value     = "top" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

}

private PCSCase start(EventPayload<PCSCase, State> eventPayload) {
PCSCase start(EventPayload<PCSCase, State> eventPayload) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed from private to package-private? The tests call the registered CCD handler, not this method directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I placed an integration test against it at that point. I can switch it back as Im not pushing the integration test as I only used it within the profiling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if you could switch back, would be great!

caseData.setClaimantType(claimantTypeList);

contactPreferences.setOrganisationAddress(organisationService.getOrganisationAddressForCurrentUser());
contactPreferences.setOrganisationAddress(null != nameAndAddress ? nameAndAddress.address() : null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract using AddressUK orgAddress = nameAndAddress != null ? nameAndAddress.address() : null; to avoid the second null check and make the flow clearer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the pattern in the OrganisationDetailsService it is possible for it to fail and then continue - returning null on exception. Ive not changed that pattern, though perhaps that needs revisiting, so it is possible for the response (NameAndAddress) to be null.

}
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor- can we remove extra lines?

}

private PCSCase start(EventPayload<PCSCase, State> eventPayload) {
PCSCase start(EventPayload<PCSCase, State> eventPayload) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if you could switch back, would be great!


public NameAndAddress getNameAndAddressForCurrentUser() {
try {
UUID userId = resolveUserId();

@guygrewal77 guygrewal77 Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some missing code coverage in a method implemented outside of this PR - getOrganisationAddressForCurrentUser()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the rationale for this ticket is not really in this area per say but in how we use it. I will take bit more of a look though now as a stepping stone. I think this class and the OrganisationDetailsService may need a revisit in general and there is another ticket that may impact it also - though not in flight yet - https://tools.hmcts.net/jira/browse/HDPI-6650

@tvr-hmcts tvr-hmcts added enable_e2e_test Currently used to test the common e2e test call enable_e2e_regression For running regression suite labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aat/destroy enable_e2e_regression For running regression suite enable_e2e_test Currently used to test the common e2e test call ns:pcs prd:pcs rel:pcs-api-pr-2027

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants