Master/Detail Add times out

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
JerryACSA
User
Posts: 15

Master/Detail Add times out

Post by JerryACSA »

This is what I did:

  1. Create very simple database on MS SQL Server:
    CREATE SCHEMA Test
    CREATE TABLE Test.MapMaster(ID int IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,FieldM int NOT NULL)
    CREATE TABLE Test.TblDetail(ID int IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,MasterID int NOT NULL REFERENCES Test.MapMaster(ID),FieldD int NOT NULL)
  2. Following instructions for ASP.NET Maker 2022 in "Tutorial - Master/Detail": https://aspnetmaker.dev/docs/#/masterdetail.html,
  3. Create relationship from MapMaster(ID) to TblDetail(MasterID).
  4. Check "Master/Detail Add (as Detail)" box for TblDetail.
  5. If needed, add line to Database_Connecting global server event:
    	connstr+="TrustServerCertificate=True;";
  6. Generate.
  7. Open Test site in Google Chrome.
  8. Click "Add Map Master/Tbl Detail".
  9. Type some numbers and click Add.

30 seconds later, the following message appears: "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding."

Further research shows that SQL Server is deadlocking on a key range, which appears to be caused by the web app using two separate sessions to add the new records to the database. One session is holding an exclusive KEY lock (possibly inserting the ID into MapMaster?) while the other session waits for a shared KEY lock on the same resource (possibly verifying that the MasterID being inserted into TblDetail exists in MapMaster?).

Removing the REFERENCES phrase from SQL and checking "Referential Integrity" instead in ASP.NET Maker 2022 gives the same error. It works with both of those removed, but that allows the database to become inconsistent so it's not a real solution.

Performing the above steps in ASP.NET Maker 2020 results in "Add succeeded". Do we need to do something different now or did something break between those versions?


MichaelG
User
Posts: 1095

Post by MichaelG »

You can disable UseTransaction for master/detail add by adding the following codes in the Page_Load server event of the master add page and see if it works.

UseTransaction = false;


JerryACSA
User
Posts: 15

Post by JerryACSA »

Yes that works. Thank you!


Post Reply