lundi 20 novembre 2023

Viable solution to handling long running query in Java

I have a Spring API which invokes rest call to an enterprise payment platform which calls into JPM Chase. All is fine on that and when taken we save response in our SQL Server DB. Our Spring API is new solution which went live last week into production. For most part has been working well apart with decent response times apart from 3 instances. On 3 different days around same timeframe I spotted through datadog an instance of processPayment endpoint taking over 1 min to respond.

After looking at DataDog logs its easy to spot SQL Query where the issue occurs. However having gone through datadog metrics around this query it typically executes in under 40 milli-seconds. The select query is hitting one table which has clustered + non clustered indexing on table. I don't believe there is an issue here however there obviously is some locking happened on DB at this time occurred maybe not at application level could been DB script being executed to fix data. So question really here is around how application should behave:

  1. Should the API be altered in such a scenario to rollback payment OR Just wait for query to return and capture the response in DB
  2. Is there another viable idea?

Aucun commentaire:

Enregistrer un commentaire