From fc67e132ed84c55c2eaab863248be9d81d291b5b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 21:43:11 +0000 Subject: [PATCH 1/2] Initial plan From e14f9e659cc4aeabe12ce4bb9d74dcdee6bc48d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 21:47:42 +0000 Subject: [PATCH 2/2] fix: remediate cold-path JVM/Hibernate warmup latency after idle period Co-authored-by: yortch <4576246+yortch@users.noreply.github.com> Agent-Logs-Url: https://github.com/yortch/agentic-devops-demo/sessions/b05517c5-ccf6-4fad-831a-66d48e4f93a8 --- .../ThreeRiversBankApplication.java | 2 ++ .../service/WarmupService.java | 31 +++++++++++++++++++ backend/src/main/resources/application.yml | 11 ++++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/java/com/threeriversbank/service/WarmupService.java diff --git a/backend/src/main/java/com/threeriversbank/ThreeRiversBankApplication.java b/backend/src/main/java/com/threeriversbank/ThreeRiversBankApplication.java index f8fa18a..6a1737a 100644 --- a/backend/src/main/java/com/threeriversbank/ThreeRiversBankApplication.java +++ b/backend/src/main/java/com/threeriversbank/ThreeRiversBankApplication.java @@ -3,9 +3,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableFeignClients +@EnableScheduling public class ThreeRiversBankApplication { public static void main(String[] args) { diff --git a/backend/src/main/java/com/threeriversbank/service/WarmupService.java b/backend/src/main/java/com/threeriversbank/service/WarmupService.java new file mode 100644 index 0000000..3349b67 --- /dev/null +++ b/backend/src/main/java/com/threeriversbank/service/WarmupService.java @@ -0,0 +1,31 @@ +package com.threeriversbank.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +@Slf4j +public class WarmupService { + + private final CreditCardService creditCardService; + + /** + * Periodically calls getAllCreditCards() to keep the JVM hot, Hibernate query plan + * cache warm, and the H2 HikariCP connection pool active after idle periods. + * Runs every 5 minutes (300,000 ms) with a 1-minute (60,000 ms) initial delay. + * Delays are configurable via warmup.fixed-delay and warmup.initial-delay properties. + */ + @Scheduled(fixedDelayString = "${warmup.fixed-delay}", initialDelayString = "${warmup.initial-delay}") + public void warmup() { + log.debug("WarmupService: running scheduled warmup to keep JVM and Hibernate hot"); + try { + int count = creditCardService.getAllCreditCards().size(); + log.debug("WarmupService: warmup complete, {} cards loaded", count); + } catch (Exception e) { + log.warn("WarmupService: warmup query failed: {}", e.getMessage()); + } + } +} diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index d17d2c2..8974d86 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -7,6 +7,10 @@ spring: driver-class-name: org.h2.Driver username: sa password: + hikari: + connection-test-query: SELECT 1 + keepalive-time: 300000ms + idle-timeout: 600000ms h2: console: @@ -17,7 +21,7 @@ spring: database-platform: org.hibernate.dialect.H2Dialect hibernate: ddl-auto: create - show-sql: true + show-sql: false defer-datasource-initialization: true sql: @@ -80,3 +84,8 @@ springdoc: path: /api-docs swagger-ui: path: /swagger-ui.html + +# Warmup scheduler configuration +warmup: + fixed-delay: 300000 + initial-delay: 60000