The combination of OSIV (Open Session In View) with network delay (RTT (round-trip time) between the app and Azure MySQL) can cause this.
Disable OSIV, it should significantly reduce Measure A times
spring:
jpa:
open-in-view: false
Also, to avoid Spring AOP overhead issues, I would recommend using TransactionTemplate instead of @Transactional annotation.
@Component
@RequiredArgsConstructor
class TransactionalTestingService {
private final ShopTenantProvider provider;
private final TransactionTemplate transactionTemplate;
public Object doSomething() {
// Measure B start
final List<ShopTenant> result = transactionTemplate.execute(r -> provider.getAll());
// Measure B stop
return result;
}
}