javax.persistence.query.timeout with slowQuery repository for manual testing

This commit is contained in:
Sergey Matvienko 2021-07-06 20:51:11 +03:00
parent 228fddb8cd
commit d1855ee400
3 changed files with 16 additions and 0 deletions

View File

@ -472,6 +472,8 @@ spring:
repositories: repositories:
enabled: "true" enabled: "true"
jpa: jpa:
properties:
javax.persistence.query.timeout: "${JAVAX_PERSISTENCE_QUERY_TIMEOUT:29000}"
open-in-view: "false" open-in-view: "false"
hibernate: hibernate:
ddl-auto: "none" ddl-auto: "none"

View File

@ -241,4 +241,10 @@ public interface EventRepository extends PagingAndSortingRepository<EventEntity,
@Param("errorsOccurred") Integer errorsOccurred, @Param("errorsOccurred") Integer errorsOccurred,
Pageable pageable); Pageable pageable);
/**
* Sleep 3 second on JPA connection
* */
@Query(value = "select count(*) from pg_sleep(3)", nativeQuery = true)
Long slowQuery();
} }

View File

@ -144,6 +144,14 @@ public class JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implemen
@Override @Override
public PageData<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink) { public PageData<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink) {
log.warn("going to run slow query");
try {
eventRepository.slowQuery();
} catch (Exception e) {
log.error("slowQuery" , e);
throw e;
}
log.warn("finished slow query");
return DaoUtil.toPageData( return DaoUtil.toPageData(
eventRepository eventRepository
.findEventsByTenantIdAndEntityIdAndEventType( .findEventsByTenantIdAndEntityIdAndEventType(