Andreas Wolter
  • Consulting & Services
    • SQL Server Security Assessment by Andreas Wolter
    • SQL Server Health Check
    • Performance Analysis
    • SQL Server Discovery
    • Air-Gapped SQL Server
  • My Customers
  • About
    • Conferences
    • Certifications
    • Training
  • Blog
  • Contact
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu

Blocking when missing Permissions – The strange case of the blocked index rebuild

Blocking when missing Permissions

The strange case of the blocked index rebuild

Recently, a client drew my attention to a blocking problem he could not make any sense of.

After a brief analysis, the scenario can be described quite simply:

Session 1) (SPID 69 in my example)

A user carries out an update statement on a table within an explicit transaction, but which fails due to the lack of required permissions. The transaction, however, remains open. (The is of course the actual problem, as one will conclude at the end. A basic error processing is essential.)

Session 2) (SPID 67)

In the meantime, an index rebuild is running via a maintenance job. And this one is stuck due to a block which was caused by the previously described session.

Part 1: blocked index rebuild

What kind of a blocking can be maintained by a non-executable update statement? – That is a reasonable question.

You can see the set locks through session 1, identified via the DMV sys.dm_tran_locks, here:

First, one will probably notice that the table has received an IX. – Even though further below in the hierarchy no further lock was set, nor could be set! There are no further locks at page or key level as would be the case otherwise in a successful update.

Parallel to this, metadata locks stand out: these are at the schema of the table (5) and the database principal dbo. We will get to this in the 2nd part further below.

Which of these is causing the blocking?

Those who have dealt with index rebuilds know that these set an Sch-M Lock (schema modification lock). And this particular lock type isn’t compatible with any other lock mode! (https://technet.microsoft.com/en-us/library/ms172925(v=sql.110).aspx )

Accordingly, we see the following locks and wait states:

Blocked_Index_Rebuild

(Session 69 was tried by the update, session 67 tries the index rebuild)

For those indulging in a professional monitoring tool, it is a little bit easier to interpret via SQLSentry Blocking monitor:

As you will notice, the Sch-M Lock actually waits for the release and is blocked until the end of the lock of the transaction with the failed update keeping the IX-lock at table level.

By the way, this is also the decisive difference to Index Reorganize. (hint)

Part 2: The key question: Could one simply grant permissions via a GRANT UPDATE directly for the table, then have the 1st transaction repeat the update command, and expect that in so doing their locks disappear and continue the index rebuild as a result?

The command for this would be:

GRANT UPDATE

ON SQL_Demos.Transactions

TO SQLUserX

 

According to the documentation, permissions will immediately become “active” and do not require a login again.

The answer is nonetheless: No, in this particular case it does not work like this.

Why?

The problem is the Sch-M-Lock in the table („OBJECT“).

A GRANT UPDATE at object level requires a Sch-S-Lock in the table.

The following blocking chain is created (the crucial lines are highlighted in yellow):

(#1 is created by the update attempt, #2 by the index rebuild that now has to wait, and #3 by the GRANT waiting for it)

Here, it is worth relaunching the SQLSentry Blockade monitor again:

But those who got used to the Best Practice of granting permissions only at scheme level (also see: Schema-design for SQL Server: recommendations for Schema design with security in mind) also avoid these locks at object level!:

GRANT UPDATE

ON SCHEMA::SQL_Demos

TO SQLUserX

The locks for this hence are at scheme and database-principal-level, and thus not in the way.

The principal for testing has the principal-ID 5, and also, my test scheme happens to have the ID 5.

For insiders: Object-ID 29 belongs to the internal system table sysprivs that contains the database permissions.

It would be even better to work exclusively with roles and schemas.

Adding the user to a role retroactively looks like this at lock-level:

In other words: Also no problem for continuing to work in the table.

As one can recognize by the high number, the Principal-ID 16391 belongs to the built-in database roles, in this case the db_datawriter role.

I hope this analysis of a rather rare scenario was interesting to some of you.

Andreas

(Still-owner of Sarpedon Quality Lab® (http://andreas-wolter.com/de-1809_news_senior_program_manager_microsoft_sql_server_security_team/ ))

Unexplained blocking or slow maintenance jobs? I help with performance troubleshooting and root cause analysis, including the less obvious causes.

Get Help with SQL Server Performance

Tags: Deadlocks & Blocking - Permissions

Categories: Security - Performance

Share
  • Share on Facebook
  • Share on X
  • Share on LinkedIn
2 replies
  1. Trayce Jordan says:
    25. October 2018 at 12:41

    Wow. Totally makes sense after you walked us through it, but i never would have expected that. Fantastisch!!

    Reply
    • Andreas Wolter says:
      25. October 2018 at 22:31

      Happy to hear that I could get some by surprise. I also never thought of that before.

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Security Assessment Community Edition

Learn about my free Community Edition script.

Recent
  • Sample result in SSMS: local NTLM connections over shared memory from SQL01, and NTLM connections over TCP from a reporting server, an ETL server and a workstation
    NTLM Deprecation and SQL Server: How to Find NTLM Connections...18. November 2026 - 17:01in: Security
  • SQL Server Consolidation: $3M+ in Projected Savings and...30. September 2026 - 15:47in: Architecture & High Availability, Security
  • Using a Database Server as a Honeypot for Threat Detect...18. September 2026 - 16:00in: Security
  • Azure Arc for SQL Server: “Least Privilege” Mode Still...8. September 2026 - 15:56in: Security
  • When SIEM Enrichment Becomes False Attribution3. September 2026 - 14:26in: Security
Comments
  • Thanks Scott. Goof feedback. NETSTAT is a useful addition,...21. November 2026 - 15:44 by Andreas Wolter
  • I would go a little deeper with how to troubleshoot SQL...21. November 2026 - 15:15 by Scott O
  • Protecting database data at rest is essential for maintaining...21. October 2026 - 2:23 by Viska
  • Thanks Now Microsoft could document them as well, and put...19. August 2026 - 16:26 by Andreas Wolter
  • List of Action_IDs for Filter https://sqlquantumleap.com/reference/server-audit-filter-values-for-action_id/ Great...18. August 2026 - 0:59 by Peter Dünsch

Articles

Analysis Services Auditing Availability Groups Azure Best Practices Certification Columnstore Consolidation Deadlocks & Blocking Encryption Extended Events Get-SqlSafe In-Memory OLTP Indexing Least Privilege PASS Summit Patching Performance Analysis Permissions Privilege Escalation Reporting Services Security Principles Spatial Data SQLBits SQL Injection SQLSaturday SQL Server 2012 SQL Server 2014 SQL Server 2016 SQL Server 2022 SQL Server 2025 SQL Trace & Profiler sysadmin & Server Roles Threat Detection Vulnerabilities Workshop & PreCon
© 2026 Andreas WolterContactImprintPrivacy PolicyLinkedInRSS
Link to: Time for a new challenge: Senior Program Manager Microsoft SQL Server Security Team Link to: Time for a new challenge: Senior Program Manager Microsoft SQL Server Security Team Time for a new challenge: Senior Program Manager Microsoft SQL Server Security... Link to: Farewell to the German PASS association Link to: Farewell to the German PASS association 1810_Conferences_Worldwide_Andreas_WolterFarewell to the German PASS association
Scroll to top Scroll to top Scroll to top
Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}