Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Index Page Level Locking is Disable ERROR

DZone's Guide to

Index Page Level Locking is Disable ERROR

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Introduction

When we are working with a production database, sometimes we find a specific message in maintenance plan log.

The index [IndexName] on table [TableName]

cannot be reorganized because page level locking is disabled. 

This will cause our Index Reorganize steps to fail. In this article, we are trying to explain it and solve it.

Why this Error Occurs

By default, the page level locks should be enabled for Index. The main cause of this error is that the Index Reorganize step has hit an Index that has page lock disabled. This somehow your Index Page Lock is disabled.

How to Solve it

Finding the Table Name and Index Name where Page Lock is Disabled

 SELECT T.Name AS [Table Name], I.Name As [Index Name]
FROM  sys.indexes I
  LEFT OUTER JOIN sys.tables T
  ON I.object_id = t.object_id
WHERE  I.allow_page_locks = 0
  AND  T.Name IS NOT NULL;
Now Use Alter Statement to Allow Page Lock On
The syntax is mentioned below
 ALTER INDEX <Index_Name> ON <Table_Name>
SET (ALLOW_PAGE_LOCKS = ON);
To generate the Alter Script Automatically
 SELECT 'ALTER INDEX ' + I.Name + ' ON ' +  T.Name +
  ' SET (ALLOW_PAGE_LOCKS = ON)' As Command
FROM  sys.indexes I
  LEFT OUTER JOIN sys.tables T
  ON I.object_id = t.object_id
WHERE  I.allow_page_locks = 0
  AND T.Name IS NOT NULL;
Hope you like it.

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Published at DZone with permission of Joydeep Das, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}