Home > Blockchain >  Long running Task (Deadlock situation because of incorrect async call)
Long running Task (Deadlock situation because of incorrect async call)

Time:05-30

I have a notification project which notifies the user with an Excel report by email. To do it, the notification project calls Project A api endpoint, and Project A calls Project B endpoint which calls the stored procedure from MSSQL database. After debugging all of them sequentially, I found it works until 4 th step. Project B has the data from database. But it does not go back the Project A with data. As a result I have "Long running time task" message in my Notification project. I have been trying to figure out the reason behind it, but I could not. I have tested individually the project A api endpoints and project B endpoints in postman. Everything works. Even communication only between project A and B is also fine. But it stops working when the task starts from Notification project. At this moment, "EmailService_Interval" configuration in the Notification project is 1 minute. I have extended to 5 minutes, but I still have the same problem. Can somebody please point out the reason behind the problem and help me with suggestion. Thanks in advance!

enter image description here

CodePudding user response:

It is a deadlock problem, what I understood. Notification project calls project A synchronously, Project A calls Project B asynchronously. After debugging, I found that, Notifcation calls Project A by PostAsJsonAsync which is under a synchronous method. After refactoring and making the method async properly, now everything works. Thanks, @Fildor, for the comments which helped to go this direction.

  • Related