Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table Locking caused by (DataLakeToSynapse_InsertIntoControlTableForCopy SPROC #246

Open
LJG5000 opened this issue Aug 10, 2023 · 0 comments

Comments

@LJG5000
Copy link

LJG5000 commented Aug 10, 2023

The CDM Utils created SPROC (DataLakeToSynapse_InsertIntoControlTableForCopy) used to insert new table records in the control table, is causing a table (not row) lock when attempting to do the insert. It does this because it is using a WHERE NOT EXISTS clause in the WHERE clause of the Insert.

The table lock is resulting in excessive wait times and causes the new record inserts to fail. This is issue is compounded because the function app needs to loop through all tables- so essentially hundred of queries checking if a row exists and effectively locking the table.

The stored procedure that does the insert into the control table is created by the CDM Utils function app. If the stored procedure is dropped or altered the, function app will automatically recreate it. Even if the function app web service is stopped, and the SPROC is recreated/altered, the function app will drop and recreate it with the original code at some point. So currently there is no way to modify the SPROC code except by modifying the function app- which is something I would like to avoid. The SPROC is called by the function app directly, so recreating it with another name would have no benefit.

An alternative approach is needed to avoid table locking such as:

IF (SELECT COUNT([TableName]) FROM [dbo].[DataLakeToSynapse_ControlTableForCopy]
WHERE [TableName]=@TableName)=0**

BEGIN

INSERT INTO [dbo].[DataLakeToSynapse_ControlTableForCopy](TableName, DataLocation,FileFormat, CDCDataLocation, MetadataLocation)
SELECT * FROM
(SELECT @TableName, @DataLocation, @fileformat, @CDCDataLocation, @MetadataLocation) as i (TableName, DataLocation, FileFormat, CDCDataLocation, MetadataLocation)

I am requesting assistance in the form of a change to the function app, or suggestions on how to avoid the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant