Auto Close Configuration

Microsoft.SQLServer.2016.Database.Configuration.AutoClose (UnitMonitor)

Monitors the Auto Close setting for the database. Note: This monitor is disabled by default. Please use overrides to enable it when necessary.

Knowledge Base article:

Summary

This monitor checks the Auto Close setting for this database. Since this monitor is a part of an overall standards requirement, an alert would be generated if the setting does not meet the specified standard.

The AUTO_CLOSE option is useful for desktop databases because it allows for database files to be managed as regular files. They can be moved, copied to make backups, or even e-mailed to other users. However, When the database is set to AUTOCLOSE = ON, an operation that initiates an automatic database shutdown clears the plan cache for the instance of SQL Server. Clearing the plan cache causes a recompilation of all subsequent execution plans and can cause a sudden, temporary decrease in query performance

Database mirroring requires AUTO_CLOSE OFF.

Autoclose only makes sense were you are sure the application usage pattern will keep the database closed for relatively long periods. Some single-user apps and some multi-tenancy database hosting situations may benefit from AUTO_CLOSE ON. For all other usages, it is generally not a good idea unless you really understand the application behavior and usage patterns

  • Design / Implementation Note – From the BOL

  • If the database is not started, properties that the Microsoft SQL Server retrieves by accessing the database directly instead of retrieving the value from metadata will return NULL. That is, if the database has AUTO_CLOSE set to ON, or the database is otherwise offline.

Configuration

When the Auto Close setting is ON, the database is shut down cleanly and its resources are freed after the last user exits.

AUTO_CLOSE {ON | OFF}

Causes

A warning alert will be raised if the Auto Close option does not match the required setting. Out of the box, the monitor is configured to alert when this setting is set to “ON”.

Resolutions

This issue may be resolved by:

Alternatively, if this monitor is not of concern for this database:

Overrideable Parameters

Name

Description

Default Value

Alert Priority

Defines Alert Priority.

Normal

Alert Severity

Defines Alert Severity.

Warning

Disable Check for SQL Express

This may only be set to 'true' or 'false'. The workflow will not consider SQL Server Express edition if set to 'true'.

Yes

Enabled

Enables or disables the workflow.

No

Expected Value

Expected value of database configuration setting. To view the set of applicable values please refer to "Configuration" section of the knowledge base article of this monitor.

OFF

Generates Alerts

Defines whether the workflow generates an Alert.

Yes

Interval (seconds)

The recurring interval of time in seconds in which to run the workflow.

43200

Timeout (seconds)

Specifies the time the workflow is allowed to run before being closed and marked as failed.

300

Element properties:

TargetMicrosoft.SQLServer.2016.Database
Parent MonitorMicrosoft.SQLServer.2016.Database.AutomaticConfiguration
CategoryConfigurationHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2016.DBConfigurationStatus
RemotableTrue
AccessibilityPublic
Alert Message
MSSQL 2016: Auto Close Configuration Error
The Auto Close setting for database "{0}" in SQL instance "{1}" on computer "{2}" is not set according to best practice.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2016.Database.Configuration.AutoClose" Accessibility="Public" Enabled="false" Target="SQL2016Core!Microsoft.SQLServer.2016.Database" ParentMonitorID="Microsoft.SQLServer.2016.Database.AutomaticConfiguration" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2016.DBConfigurationStatus" ConfirmDelivery="false">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2016.Database.Configuration.AutoClose.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.Database"]/DatabaseName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.ServerRole"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="ConfigurationValueOK" MonitorTypeStateID="ConfigurationValueOK" HealthState="Success"/>
<OperationalState ID="ConfigurationValueNotOK" MonitorTypeStateID="ConfigurationValueNotOK" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<ConnectionString>$Target/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.DBEngine"]/ConnectionString$</ConnectionString>
<DatabaseName>$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.Database"]/DatabaseName$</DatabaseName>
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
<ConfigValue>AutoClose</ConfigValue>
<ExpectedValue>OFF</ExpectedValue>
<ExcludeOnExpress>true</ExcludeOnExpress>
<SQLSKU>$Target/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.DBEngine"]/Edition$</SQLSKU>
<TimeoutSeconds>300</TimeoutSeconds>
</Configuration>
</UnitMonitor>