A Guide to (ADR) Accelerated Database Recovery in SQL Server 2019

accelerated database recovery in sql server 2019

Accelerated Database Recovery in SQL Server 2019: If any organization is using SQL Server then down time is an important part for it. Downtime can harm the productivity of any organization, which it can harm the organization’s revenue. That is why if a system failure occur it is important to minimize database recovery time. Keeping this in mind, Microsoft has introduced Accelerated Database Recovery (ADR) in SQL Server 2019, which significantly improves database availability by minimizing database recovery time.

Today in this blog post we will discuss the functionality of ADR, how database recovery works, and its benefits. You can use this helpful information to decide how to implement ADR in your SQL server environment.

The Current Database Recovery Process

The current SQL Server database recovery process use phase wise recovery model called as “ARIES“. There are 3 phases to recover a database from a failure.

  1. Analysis Phase
  2. Redo Phase
  3. Undo Phase

Explained in more detail in the following diagram.

accelerated database recovery in sql server 2019

1) Analysis Phase

This is the 1st phase in which, during recovery, SQL Server reads the transaction log forward, starting from either “the most recent checkpoint” or “the location of the oldest uncommitted data (called LSN)“. This process determines the completion status of each transaction at the time of the server shutdown.

2) Redo Phase

In 2nd phase, SQL Server rewinds to the last saved point (checkpoint) in the logbook. Then, it reads forward through the log, replaying all the successful updates (committed transactions) one by one, until the database is back to the state it was in before the crash. This forward scan ensures all the intended changes are applied.

3) Undo Phase

In the last phase, it goes back through its transaction log for each transaction that was still running. For each of these transactions, it erases the changes it made, essentially reversing its actions.

As you can see in the design, the time of database recovery after unexpected system failure (i.e., database shut down) is depend on the size of unfinished transactions or the transaction which was running till the database shut down. The database recovery has to rollback all those uncompleted transactions to put the database in the consistent state. The required time to rollback these transactions will be the same as it was running and the work it completed. Hence, the SQL Server process need longer time to recover the database if the transaction is running from a long time. Consequently, long-running operations like bulk inserts or large index builds can significantly extend recovery times. (Accelerated Database Recovery in SQL Server 2019)

Similarly, canceling or rolling back such extensive transactions can be equally time-consuming due to their reliance on the same undo mechanisms used in standard recovery.

Furthermore, long-running transactions prevent the truncation of the transaction log since their corresponding entries are crucial for potential future recoveries and rollbacks. This can lead to significant disk space consumption as transaction logs continue to grow in size.

Read More: 8 Tips and Techniques for Optimal Database Performance

The Accelerated Database Recovery Process (ADR)

What is accelerated database recovery in SQL Server?

ADR tackles these limitations by fundamentally revamping the database engine’s recovery process.

  • ADR eliminates the need to scan the entire transaction log for the oldest active transaction. Instead, it focuses only on changes since the last successful checkpoint. This ensures recovery time stays consistent and isn’t impacted by long-running operations.
  • Since processing the entire transaction log for rollback is no longer necessary, ADR allows for more aggressive truncation after checkpoints and backups. This translates to significant disk space savings.

On a technical level, ADR achieves these improvements by keeping track of all data modifications and focusing on quickly reversing “logical” operations. Any unfinished transactions at the time of a crash are automatically marked as aborted, rendering their changes irrelevant for future queries. While the basic recovery phases remain the same, ADR streamlines their operation for faster overall recovery. (Accelerated Database Recovery in SQL Server 2019)

The Accelerated Database Recovery has same 3 phases with slightly different than current recovery process in them:

accelerated database recovery in sql server 2019

Benefits of ADR

  • Reduced Downtime: ADR’s efficient recovery mechanism minimizes the time it takes to bring your database online after a crash or failure. This translates to less downtime, ensuring uninterrupted service for your applications and users.
  • Improved Availability: By minimizing downtime, ADR enhances database availability. This is particularly crucial for mission-critical applications that rely on constant access to real-time data.
  • Enhanced Performance: ADR streamlines the recovery process, freeing up system resources that would otherwise be consumed by lengthy log replays. This translates to improved overall database performance.
  • Faster Rollbacks: ADR expedites database rollbacks to a specific point in time. This is beneficial for scenarios where you need to undo unintended data modifications quickly.
  • Reduced Log Growth: ADR can help manage transaction log growth. Since it relies less on transaction logs for recovery, the need for frequent log backups and truncations diminishes.

Implementation Considerations for ADR

While ADR offers significant benefits, there are a few aspects to consider before implementation:

  • Compatibility: ADR is only available in SQL Server 2019 (15.x) and later versions, as well as Azure SQL Database and Azure SQL Managed Instance.
  • Automatic vs. Manual Enablement: ADR is enabled by default in Azure SQL Database and Azure SQL Managed Instance. On-premises deployments in SQL Server require manual activation using the ALTER DATABASE command.
  • Persistent Version Store (PVS) Management: The PVS consumes storage space within the database. It’s essential to monitor PVS size and implement strategies like cleanup routines to optimize storage utilization.
  • Long-Running Transactions: While ADR improves recovery speed, it’s still advisable to minimize the number of long-running transactions within your database. This helps maintain optimal performance. (Accelerated Database Recovery in SQL Server 2019)

Best Practices for Leveraging ADR

To maximize the benefits of ADR, here are some best practices to follow:

  • Monitor PVS Size: Regularly monitor the size of the PVS and establish cleanup procedures to prevent it from consuming excessive storage space.
  • Minimize Long-Running Transactions: Identify and refactor long-running transactions whenever possible. Shorter transactions translate to faster recovery times with ADR.
  • Maintain Backups: Although ADR streamlines recovery, it doesn’t replace the need for regular database backups. Maintain a robust backup strategy to safeguard your data in case of unforeseen circumstances.
  • Stay Updated: Keep your SQL Server instance updated with the latest service packs and cumulative updates to benefit from ongoing improvements and optimizations to ADR.

Real-World Scenarios Where ADR Shines

Here are some specific scenarios where ADR can significantly improve database operations:

  • E-commerce Applications: During peak shopping seasons, e-commerce applications experience a surge in transactions. Long-running transactions like order processing can significantly impact database availability. ADR minimizes recovery times, ensuring a smooth user experience even during peak traffic periods.
  • Financial Transactions: Financial institutions require real-time access to accurate data. ADR’s faster rollbacks allow for swift correction of any erroneous transactions, safeguarding financial integrity. (Accelerated Database Recovery in SQL Server 2019)
  • Data Warehouses and Analytics Platforms: Data warehouses and analytics platforms often involve complex queries and bulk data loads. ADR can expedite recovery after unexpected crashes during these operations, minimizing disruption to data analysis workflows.

Conclusion

Accelerated Database Recovery (ADR) is a game-changing feature in SQL Server 2019. By leveraging versioning and efficient recovery mechanisms, ADR significantly reduces database downtime, enhances availability, and improves overall database performance. For businesses that rely on continuous access to critical data, ADR is a valuable tool to ensure smooth operations and minimize the impact of unforeseen events.


FAQ: Accelerated Database Recovery in SQL Server 2019

What is the main benefit of ADR?

ADR’s primary benefit is reducing downtime after a database crash or failure. It achieves this by minimizing the time required for database recovery, allowing your applications to come back online faster.

Is ADR enabled by default?

ADR activation depends on your deployment environment:
Azure SQL Database and Azure SQL Managed Instance: ADR is automatically enabled and cannot be disabled.
On-premises SQL Server: You need to manually enable ADR using the ALTER DATABASE command.

Does ADR eliminate the need for database backups?

Absolutely not! ADR streamlines the recovery process, but it doesn’t replace the importance of regular database backups. Backups are crucial for safeguarding your data in case of unforeseen circumstances like hardware failures or accidental data deletion.

Leave a comment