Azure / Azure/azure-functions-sql-extension

Only take app lock out at beginning of transaction

Open
#983 1 comment 0 reactions 0 assignees View on GitHub
enhancement trigger
Dominant language
C#
Stars
130
Forks
71
Avg merge
4d 8h
Merged PRs (30d)
4

Description

Currently we call sp_getapplock at the beginning of every query we run. This shouldn't be necessary - the app locks we get are transaction level and so we only need to do that once at the beginning of a transaction. The benefit of this will mostly be to reduce the noise in the query logs - since the applock statement is a no-op after first getting it then it just clutters up the query logs (for example if an error happens).

Before doing this we need to verify that we can't get in a circumstance where the transaction is ended but queries can still execute, such as what happened here : https://github.com/Azure/azure-functions-sql-extension/pull/979 So ensuring that if an error ever occurs we rollback the transaction is critical - otherwise we could risk corruption of the state by running queries outside of a transaction (especially when that transaction was rolled back)

Contributor guide

Open the contributing guide

Research direction

Start by tracing where sp_getapplock is issued and how transaction boundaries and query execution are handled; verify the concern that queries cannot run after a transaction ends. Done means the lock is acquired only at transaction start, every error path rolls back before further queries can execute, and query logs no longer show repeated applock statements.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, sql
Domain
backend, database
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.