MODIFY FILE failed for database ‘tempdb’, file id 1. Size of file (41435136 KB) is greater than MAXSIZE (26214400 KB). (Microsoft SQL Server, Error: 5040)


Introduction:

In the dynamic realm of Azure SQL Managed Instances, configuring database file sizes is a routine task. However, challenges can arise, as I recently encountered while attempting to modify the Tempdb database file size. This blog post details the steps taken to address a perplexing error message that surfaced during this process.

Problem Statement:
The objective was straightforward: adjusting the maximum file size of the Tempdb database on an Azure SQL Managed Instance to 25 GB.

However, both through the graphical user interface (GUI) and Transact-SQL (T-SQL) commands, an error persisted:

TITLE: Microsoft SQL Server Management Studio
——————————
Alter failed for Database ‘tempdb’.  (Microsoft.SqlServer.Smo)
For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=16.100.47008.0&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Alter+Database&LinkId=20476
——————————
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
MODIFY FILE failed for database ‘tempdb’, file id 1. Size of file (41435136 KB) is greater than MAXSIZE (26214400 KB). (Microsoft SQL Server, Error: 5040)
For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver-5040-database-engine-error
——————————

The error surfaced when attempting the operation through the graphical user interface (GUI), and repeating the process using Transact-SQL (T-SQL) resulted in the identical error.

The error notification suggests that the existing size of the Tempdb database file (tempdev) exceeds the size I intended to establish. Contrary to this indication, the actual size of tempdev is only 16 MB, and my intention was to set the Maximum File size to 25 GB.

The error message indicates that the file size is reported as 41,435,136 KB, equivalent to 39.5 GB. Attempting to establish the Maximum file size of Tempdev below 39.5 GB resulted in an error. However, setting it to 40 GB proved successful.

This particular Azure SQL Managed Instance is of the Business Critical tier with 80 Vcores and includes 4 replicas. To delve deeper into the issue, I connected to the read replica of this managed instance through a query window, utilizing the ApplicationIntent=ReadOnly parameter.


I’ve established a connection to the user database JBSWiki to confirm that I am indeed connected to the Read Replica, as verified by executing the following query:

SELECT DATABASEPROPERTYEX(DB_NAME(), 'Updateability');

Upon execution, you will observe the result as READ_ONLY, affirming your connection to the Read Replica. It’s crucial to note that running the same query under the context of Tempdb will display READ_WRITE. To avoid confusion, ensure the query is executed on a user database to validate your connection to a Read Replica.

-> I executed below query to check the tempdb size on Read replica,

use tempdb
select file_id, type, type_desc, name, physical_name, size, max_size, growth, is_percent_growth from sys.database_files

-> Below is the output,

The size of tempdev on the read replica was configured at 39.5 GB, creating complications when attempting to adjust the Maximum file size on the Azure SQL Managed Instance. To address this, I reduced the size of tempdb on the read replica to 15 GB using DBCC SHRINKFILE. Following this adjustment, I successfully set the Maximum File size of the Tempdb data file to 25 GB.

Summary:
Navigating the nuances of database file sizes in an Azure SQL Managed Instance, particularly when dealing with read replicas, demands a comprehensive approach. Verifying the reported sizes, understanding the intricacies of database contexts, and proactive measures such as shrinking the Tempdb on read replicas are pivotal for resolving challenges like the ‘MODIFY FILE failed’ error. This journey underscores the significance of a meticulous troubleshooting process, ensuring a smooth configuration experience within the Azure SQL environment.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided β€œAS IS” with no warranties, and confers no rights.

Ensuring Always On: A Guide to Verifying Availability Replica Connections with T-SQL πŸš€

Introduction 🌐

In the dynamic realm of SQL Server high availability, maintaining the connectivity of Always On Availability Groups is paramount. This blog serves as a comprehensive guide to ensuring your Availability Replicas are securely connected through the utilization of a T-SQL script. Let’s embark on a journey to validate the heartbeat of your SQL Server infrastructure.

Requirement 🚦

Ensuring the seamless operation of Always On Availability Groups demands continuous monitoring of the connection status between replicas. This becomes particularly crucial in scenarios where maintaining high availability and minimizing downtime are non-negotiable. The T-SQL script provided below equips you with a diagnostic tool to assess the connection health of your Availability Replicas.

T-SQL Script πŸ”

Checking Availability Replica Connections:

select r.replica_server_name, r.endpoint_url,

rs.connected_state_desc, rs.last_connect_error_description,
rs.last_connect_error_number, rs.last_connect_error_timestamp
from sys.dm_hadr_availability_replica_states rs join sys.availability_replicas r
on rs.replica_id=r.replica_id
where rs.is_local=1

Script Explanation

  • replica_server_name: Identifies the name of the Availability Replica.
  • endpoint_url: Specifies the URL of the endpoint.
  • connected_state_desc: Describes the current state of the connection.
  • last_connect_error_description: Provides a description of the last connection error.
  • last_connect_error_number: Displays the error number of the last connection error.
  • last_connect_error_timestamp: Timestamp of the last connection error.

Conclusion πŸŽ“

Regularly executing the provided T-SQL script on the Primary Replica allows for proactive identification and resolution of potential connectivity issues within your SQL Server Always On Availability Groups. Monitoring the connected state, error descriptions, and timestamps empowers database administrators to take preemptive actions, ensuring high availability and minimal disruptions.

In conclusion, this straightforward yet powerful script should be an integral part of your SQL Server maintenance toolkit. By embracing a proactive approach to availability, you safeguard the robustness of your database infrastructure, providing users with a seamless experience and guaranteeing the continuity of critical operations. πŸ›‘οΈ

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided β€œAS IS” with no warranties, and confers no rights.

SQL Server 2022 In-Place Upgrade fails with message install the .NET Framework 2.0 or 4.0

Introduction:
Upgrading SQL Server is a crucial task, ensuring your database stays up-to-date and secure. Recently, during an attempt to upgrade from SQL Server 2016 to SQL Server 2022, an unexpected error surfaced, hindering the process.

Error Encountered:
The upgrade process halted with the following error message: The Microsoft .NET Framework 2.0 or 4.0 must be installed on your computer before you can install Microsoft SQL Server 2022 Setup Support Files. Please install the .NET Framework 2.0 or 4.0 and then install Microsoft SQL Server 2022 Setup Support Files.”

Below error was found on the installation summary,

Feature: Database Engine Services
Status: Failed
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, and then try the setup process again.
Component name: SQL Server Setup Support Files
Component error code: -2147483648
Component log file: C:\Program Files\Microsoft SQL Server\160\Setup Bootstrap\Log\20231027_113110\SqlSupport_Cpu64_1.log
Error description: The Microsoft .NET Framework 2.0 or 4.0 must be installed on your computer before you can install Microsoft SQL Server 2022 Setup Support Files. Please install the .NET Framework 2.0 or 4.0 and then install Microsoft SQL Server 2022 Setup Support Files.
Error help link: https://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=16.0.1000.6&EvtType=SqlSupport.msi%40CA_ErrorPrereqDotNet20Or40%40-2147483648

-> Below message found on C:\Program Files\Microsoft SQL Server\160\Setup Bootstrap\Log\20231027_113110\SqlSupport_Cpu64_1.log,

MSI (s) (74:04) [12:15:03:056]: Doing action: CA_ErrorPrereqDotNet20Or40
Action ended 12:15:03: IsDotNet20Or40Installed. Return value 1.
Action start 12:15:03: CA_ErrorPrereqDotNet20Or40.
MSI (s) (74:04) [12:18:22:923]: Product: Microsoft SQL Server 2022 Setup (English) — The Microsoft .NET Framework 2.0 or 4.0 must be installed on your computer before you can install Microsoft SQL Server 2022 Setup Support Files. Please install the .NET Framework 2.0 or 4.0 and then install Microsoft SQL Server 2022 Setup Support Files.

The Microsoft .NET Framework 2.0 or 4.0 must be installed on your computer before you can install Microsoft SQL Server 2022 Setup Support Files. Please install the .NET Framework 2.0 or 4.0 and then install Microsoft SQL Server 2022 Setup Support Files.
Action ended 12:18:22: CA_ErrorPrereqDotNet20Or40. Return value 3.
Action ended 12:18:22: INSTALL. Return value 3.
Property(S): DiskPrompt = [1]
Property(S): InstallMode = Typical
Property(S): UpgradeCode = {DFF9DA09-88B8-4A80-BE2B-78A4DA9835FA}
Property(S): WelcomeBmp = WelcomeBmp
Property(S): OPENREADME = 1
Property(S): TARGETDIR = C:\

Investigation:
Upon inspection, the system seemingly met the .NET requirements, specifically version 4.8. Perplexed by this discrepancy, a closer examination of the server configuration was initiated.

Troubleshooting Steps:

  1. Service Disabling: Two services, namely Avecto Defendpoint Service and Defendpoint BeyondInsight, were identified as potential culprits. They were promptly stopped and disabled, eliminating possible conflicts.
  2. Administrative Run: The upgrade process was restarted with elevated privileges, utilizing “Run as Administrator” mode, ensuring comprehensive access and control.

Resolution:
Executing the upgrade with administrative privileges resolved the issue. The process completed successfully, and SQL Server 2022 was installed seamlessly, guaranteeing the continuity of database operations.

Conclusion:
In the realm of system upgrades, unexpected errors can pose challenges. Swift and strategic troubleshooting, such as disabling conflicting services and employing administrative privileges, can lead to successful resolutions. This experience underscores the importance of meticulous preparation and proactive problem-solving in the face of unforeseen obstacles. πŸš€

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided β€œAS IS” with no warranties, and confers no rights.