Database Issue: The transaction log for database ‘db_name’ is full due to ‘ACTIVE_BACKUP_OR_RESTORE’.

Today, I was called in the early hours because the transaction log of one of the SQL Server 2016 database was full. I logged onto the SQL server instance via SQL Server Management Studio, and saw the following errors in the SQL Server error log:

The transaction log for database 'OLTPDB' is full
due to 'ACTIVE_BACKUP_OR_RESTORE'.

Reason for failure

This occurs because the full backup for the ‘OLTPDB’ database was still running, and as a result, the transaction log of this database was not freed up for reuse. This caused the transactions that were running against this database to fail.

Issue resolution

As we know, the portion of the transaction log file that is used during the full backup operation must be maintained while the full backup operation is running, which will also be backed up at the end of the full backup operation. That’s because the full database backup contains all the database data at the start of the full backup operation plus the transition log used until the end of the full backup operation. Therefore, to fix the issue, I had to manually increase the size of the transaction log file, to accommodate the high load against the database.

Windows policy Lock Pages in Memory option and SQL Server instance in VM

Memory

As we know, this Windows policy Lock Pages in Memory option determines which accounts can use a process to keep data in physical memory, preventing the Windows operating system from paging out a significant amount of data from physical memory to virtual memory on disk. This Windows policy is disabled by default. This Windows policy (Lock Pages in Memory option) must be enabled for SQL Server service account. That’s because, setting this option can increase the performance of SQL Server instance running on the virtual machine (VM) where paging memory to disk is expected. When not enabled, there is a risk that SQL Server buffer pool pages may be paged out from physical memory to virtual memory on disk.
*Note: Only applies to SQL Server instances running on the virtual machine (VM).

You can use the following Transact-SQL script to check whether or not this Windows policy is enabled for SQL Server Service Startup account:

SET NOCOUNT ON;

DECLARE @CMDShellFlag [bit] ,
		@CheckCommand [nvarchar](256);
		

DECLARE @xp_cmdshell_output TABLE
    (
      [output] [varchar](8000)
    );

IF NOT EXISTS ( SELECT  *
                FROM    [sys].[configurations]
                WHERE   [name] = N'xp_cmdshell'
                        AND [value_in_use] = 1 )
    BEGIN
		
        SET @CMDShellFlag = 1;

        EXEC [sp_configure] 'show advanced options', 1;

        RECONFIGURE;

        EXEC [sp_configure] 'xp_cmdshell', 1;

        RECONFIGURE;

        EXEC [sp_configure] 'show advanced options', 0;

        RECONFIGURE;
    END

SELECT  @CheckCommand = 'EXEC [master]..[xp_cmdshell]' + SPACE(1) + QUOTENAME('whoami /priv', '''');

INSERT INTO @xp_cmdshell_output
        ( [output] )
EXEC [sys].[sp_executesql] @CheckCommand;

IF EXISTS ( SELECT  *
            FROM    @xp_cmdshell_output
            WHERE   [output] LIKE '%SeLockMemoryPrivilege%enabled%' )
    SELECT  'Windows policy Lock Pages in Memory option is enabled' AS [Finding];
ELSE
    SELECT  'Windows policy Lock Pages in Memory option is disabled' AS [Finding]; 

IF @CMDShellFlag = 1
    BEGIN

        EXEC [sp_configure] 'show advanced options', 1;

        RECONFIGURE;

        EXEC [sp_configure] 'xp_cmdshell', 0;

        RECONFIGURE;

        EXEC [sp_configure] 'show advanced options', 0;

        RECONFIGURE;
    END

SET NOCOUNT OFF;

Here are instructions to enable Lock Pages in Memory option Windows policy:

  1. On the Start menu, click Run. In the Open box, type gpedit.msc.
  2. On the Local Group Policy Editor console, expand Computer Configuration, and then expand Windows Settings.
  3. Expand Security Settings, and then expand Local Policies.
  4. Select the User Rights Assignment folder. The policies will be displayed in the details pane.
  5. In the pane, double-click Lock pages in memory.
  6. In the Local Security Setting – Lock pages in memory dialog box, click Add User or Group.
  7. In the Select Users, Service Accounts, or Groups dialog box, add SQL Server Service Startup account.
  8. Restart SQL Server for this change to take effect.

For more information, refer to article “Enable the Lock Pages in Memory Option (Windows)” on the Microsoft Development Network website.

Very Important Note: You must also configure the following two server memory options, min server memory and max server memory, if you enable Windows policy Lock Pages in Memory option. That’s because these memory options help you to control the amount of server memory with SQL Server can consume. Ignoring this recommendation can severely reduce SQL Server performance and even prevent SQL Server from starting. For more information about how to configure these two memory options, refer to article “Server Memory Server Configuration Options” on the Microsoft Development Network website.

I hope you will find this post useful. 🙂

Have a nice week….

Basit

My articles published on SSWUG.org from March 2014 to July 2014

The following is the list of my articles published on SSWUG.org from March 2014 to July 2014. To read these articles, you must have SSWUG.org standard-level membership.

SSWUG.org logo


SQL Server 2014 Replication, Published on July 29, 2014

You use replication to move data between servers. Replication is important in distributed environments, when archiving data, and as an inexpensive way to support high availability.

This article explores the different types of replication, the components involved in replication, and the steps necessary to configure replication.


Microsoft SQL Server 2014: Database Engine key new features, Published on July 15, 2014

Earlier this year, Microsoft released SQL Server 2014. Like previous releases of SQL Server, Microsoft further enhances the SQL Server Database Engine. Microsoft not only improved existing SQL Server Database Engine features, but also introduces many new Database Engine features, including new in-memory OLTP engine (aka Hekaton), Buffer Pool Extension (BPE), Updateable Columnstore indexes, encryption for backups, Resource Governor enhancements for physical IO control, AlwaysOn enhancements, SQL Server Data Files in Windows Azure, Windows Azure Integrated Backups, new design for Cardinality Estimation, Incremental Statistics, Security enhancements, Transact-SQL enhancements, and so on. With the help of these new features of SQL Server 2014 Database Engine we can design, build and deploy mission-critical database applications.

This three part article series discusses in-detail the key new features of the Microsoft SQL Server 2014 Database Engine.


Developing Report Models, Published on July 8, 2014

A report model is a metadata description of a data source. It contains a business model of a data, a physical model of the underlying database, and a mapping between the two. The business model, also known as a semantic model, describes the data by using familiar business names, usually recorded in a business lexicon.

This article reviews the benefit of using report models.


Guidelines and Best Practices for developing and implementing a Reporting Solution, Published on June 6, 2014

Your reporting solution design should match technologies provided by Microsoft SQL Server™ 2014 Reporting Services to the requirements and abilities of users, and the requirements of the business. The documents that make up your reporting specification should also describe the purpose, data content, layout, and user interaction that are required for each report.

After you have an appropriate design in place, the next step is to develop the reports as effectively as possible by using appropriate tools that Microsoft SQL Server 2014 Data Tools (SSDT 2014) provides. SQL Server 2014 Data Tools (SSDT 2014) is a Microsoft Visual Studio environment with enhancements that are specific to business intelligence solutions. SQL Server 2014 Data Tools (also known as SSDT 2014) is included with Microsoft SQL Server™ 2014. You use SQL Server 2014 Data Tools for creating and managing solutions and projects for Reporting Services reports and report-related items. SQL Server 2014 Data Tools provides the Report Designer authoring environment. In Report Designer, you can open, modify, preview, save, and deploy report definitions, shared data sources, shared datasets, and report parts. For more information about SQL Server 2014 Data Tools solutions, projects, project templates, and configurations used for Reporting Services, and the views, menus, toolbars, and shortcuts that you can use in Report Designer, refer to SQL Server 2014 Books Online article “Reporting Services in SQL Server 2014 Data Tools (SSDT 2014)”.

This two part article series offers up some basic high-level guidelines, best practices and considerations for developing and implementing reporting solutions with SQL Server 2014 Data Tools (SSDT).


Handling blocks and deadlock in SQL Server, Published on May 15, 2014

A database server should be able to service requests from a large number of concurrent users. When a database server is servicing requests from many clients, there is a strong possibility that conflicts will occur because different processes request access to the same resources at the same time. A conflict in which one process is waiting for another to release a resource is called a block. Although in SQL Server a blocked process usually resolves itself when the first process releases the resource but there are times when a process holds a transaction lock and doesn’t release it.

This article offers up several options for troubleshooting and resolving blocks in SQL Server.


Understanding the purpose of SQL Server Agent, Published on April 21, 2014

The SQL Server Agent is a Windows service that runs scheduled jobs. A job is a set of one or more management tasks. The SQL Server Agent service depends on the SQL Server service.

This two part article series shows you how you can configure and manage SQL Server Agent service and jobs.


SQL Server Integration Service (SSIS): Import and Export wizards, Published on April 14, 2014

SQL Server includes SQL Server Integration Services (SSIS). SSIS is primarily a data transform and load utility, but its functionality goes beyond that. SSIS provides a flexible development environment that you can use to identify sources and destinations, processing actions, and decision logic. Several SQL Server data utilities, such as the Database Copy Wizard, are based on SSIS.

This article shows technique of importing and exporting data to and from SQL Server database using SQL Server Import and Export Wizard.


Diving deep into SQL Server Integration Services Transactions, Published on March 31, 2014

A transaction is a logical unit of work made up of one or more tasks. The concept of transaction usually applies to a relational database such as those in Microsoft SQL Server. However, in Integration Services, you can create a transaction that includes any task or container. In general, a transaction is considered to have four primary characteristics: atomicity, consistency, isolation, and durability (ACID).

This article provides an overview of transactions and there characteristics. It also shows how you can implement transactions in an SQL Server Integration Services packages.


I hope you will find these articles useful. 🙂

Have a good weekend!

Basit

Book: SQL Server 2014 Development Essentials

I am very happy to announce that my first book “SQL Server 2014 Development Essentials” has now been published by Packt Publishing.

SQL Server 2014 Development Essentials, ISBN: 9781782172550

SQL Server 2014 Development Essentials, ISBN: 9781782172550

SQL Server 2014 Development Essentials is an easy-to-follow yet comprehensive guide that is full of hands-on examples, which you can follow to successfully design, build, and deploy mission-critical database applications with SQL Server 2014. You can view and download the table of contents, sample chapter, code files and the preface of this title on Packt Publishing website here.

Who this book is for?

If you are a database developer, architect, or administrator who wants to learn how to design, implement, and deliver a successful database solution with SQL Server 2014, then this book is for you. This book will provide you with all the skills you need to successfully create, design, and deploy databases using SQL Server 2014. You will also learn how to add, modify, and delete data stored within a database. You will use Transact-SQL statements to create and manage advanced database objects that include scalar and table-valued functions, views, stored procedures, and triggers. Finally, you will learn about how SQL Server works, how indexes and statistics improve query performance, and the new SQL Server 2014 in-memory technologies.

From this book, you will learn:

  • Get introduced to SQL Server 2014’s new in-memory database engine
  • Understand SQL Server database architecture and relational database design
  • Use joins, subqueries, CTEs, and windowing functions to write advanced Transact-SQL queries
  • Learn about tools that let you monitor SQL Server database performance
  • Identify and troubleshoot blocks or deadlocks that might slow down a system
  • Design, create, and manage advanced database objects that include scalar and table-valued functions, views, stored procedures, and triggers
  • Use SQL Server 2014’s structured error handling blocks to handle errors that occur in the Transact-SQL batches and programmable objects

You can order it at Packt Publishing, Amazon UK, Amazon.com and Barnes & Noble. It will also be available at O’Reilly Media and Safari Books Online.

Please feel free to contact me via twitter (@BasitAali) or via email, if you have any questions or feedback about this book.

SQL Server 2014 Management tools

Management tools play a vital role in enterprise database management. This is because the well-integrated tools extend the administrator’s capabilities, whereas a random collection of tools can lead to confusion, operational mistakes, high training costs, and poor DBA productivity. To keep up with these demands of complex enterprise database management solutions, SQL Server 2014 includes updated management tools to make it easier for administrators to create, manage, and maintain SQL Server solutions.

Click here to read full article on SSWUG.org