You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/backup-restore/sql-server-vss-writer-logging.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,17 +20,17 @@ As [SQL Server Back up Applications - Volume Shadow Copy Service (VSS) and SQL W
20
20
21
21
## Overview
22
22
23
-
[!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] introduces a new Logging feature for its VSS Writer “SQLWriter” service. Its main characteristics are:
23
+
[!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] introduces a new Logging feature for its VSS Writer `SQLWriter` service. Its main characteristics are:
24
24
25
25
- It's on by default
26
26
- It's system-wide (it will trace SQL Writer activity against all SQL Server instances running on the server)
27
27
- It's text-based
28
-
- Its working directory is **C:\Program Files\Microsoft SQL Server\90\Shared**
28
+
- Its working directory is **`C:\Program Files\Microsoft SQL Server\90\Shared`**
29
29
- Within that directory:
30
-
- Logging takes place in file **SqlWriterLogger.txt**
31
-
- This file gets renamed to “SqlWriterLogger1.txt” when reaching a maximum size (by default 1 MB), with logging continuing in main SqlWriterLogger.txt.
32
-
- There's only one rollover file, so the second rollover would overwrite the existing SqlWriterLogger1.txt.
33
-
- Parameters are managed by file **SqlWriterConfig.ini**
30
+
- Logging takes place in file **`SqlWriterLogger.txt`**
31
+
- This file gets renamed to `SqlWriterLogger1.txt` when reaching a maximum size (by default 1 MB), with logging continuing in main `SqlWriterLogger.txt`.
32
+
- There's only one rollover file, so the second rollover would overwrite the existing `SqlWriterLogger1.txt`.
33
+
- Parameters are managed by file **`SqlWriterConfig.ini`**
34
34
35
35
SQL Writer being a [!INCLUDE[ssSQL11](../../includes/ssnoversion-md.md)] shared component, it has a single instance on a system and its major version will be the same as the highest major version of any installed [!INCLUDE[ssSQL11](../../includes/ssnoversion-md.md)] Instance. For example, if instances of, say,[!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)], [!INCLUDE[sssql15-md](../../includes/sssql16-md.md)] SP2 and [!INCLUDE[sssql19-md](../../includes/sssql19-md.md)] are collocated on the same system, the SQL Writer binary will be the one provided by [!INCLUDE[sssql19-md](../../includes/sssql19-md.md)] and will service all running instances from all major versions (even though its home directory remains under \90). Local instances and versions will benefit from the new [!INCLUDE[sssql19-md](../../includes/sssql19-md.md)] tracing described here. It also implies that only [!INCLUDE[sssql19-md](../../includes/sssql19-md.md)] cumulative updates will upgrade SQL Writer binaries in this situation.
36
36
@@ -39,7 +39,7 @@ SQL Writer being a [!INCLUDE[ssSQL11](../../includes/ssnoversion-md.md)] shared
39
39
40
40
## Basic Operations
41
41
42
-
You can benefit from the new logging without any manual change. You can open, or get a copy of, the main SqlWriterLogger.txt log file in “C:\Program Files\Microsoft SQL Server\90\Shared\”.
42
+
You can benefit from the new logging without any manual change. You can open, or get a copy of, the main `SqlWriterLogger.txt` log file in `C:\Program Files\Microsoft SQL Server\90\Shared\`.
43
43
The file will reflect all VSS events reaching SQL Writer, which would mainly be:
44
44
-`OnIdentify` events, as triggered by command `vssadmin list writers`
45
45
- Backup events
@@ -93,12 +93,12 @@ In order of appearance, we can see the following information is logged:
93
93
[01/12/2021 08:23:40, TID 464c] Skip User Instances Enumeration
94
94
```
95
95
96
-
OnIdentify is a common VSS operation. It's triggered by “vssadmin list writers” command. Most VSS requestors would start any VSS backup or restore operation by a “OnIdentify” event.
96
+
OnIdentify is a common VSS operation. It's triggered by `vssadmin list writers` command. Most VSS requestors would start any VSS backup or restore operation by a `OnIdentify` event.
97
97
98
98
Previously, only active profiler tracing would allow the DBA to detect such an event. With the new logging feature, each event will lead to the above entry.
99
99
100
100
In order of appearance, we can see the following information is logged:
101
-
- An explicit mention of the OnIdentify VSS event.
101
+
- An explicit mention of the `OnIdentify` VSS event.
102
102
- A list of all active (running) [!INCLUDE[ssSQL11](../../includes/ssnoversion-md.md)] instances, along with their instance name, major version, and Edition.
103
103
- The indication we didn’t attempt to list “User Instances” – a specific [!INCLUDE[ssSQL11](../../includes/ssnoversion-md.md)] feature also known as [LocalDB](/sql/database-engine/configure-windows/sql-server-express-localdb) and typically not involved on enterprise database servers.
104
104
@@ -138,29 +138,29 @@ In order of appearance, we can see the following information is logged:
138
138
This event leads to a more sizeable set of entries.
139
139
In order of appearance, we can see the following information is logged:
140
140
141
-
- A full “OnIdentify” section, which as already indicated often leads a backup.
141
+
- A full `OnIdentify` section, which as already indicated often leads a backup.
142
142
- Mention of every main VSS phase of backup, with pattern “Entering SQL Writer xxxx”.
143
-
- First one here being ‘Entering SQL Writer OnPrepareBackup.
143
+
- First one here being `Entering SQL Writer OnPrepareBackup`.
144
144
- A conspicuous entry indicating the start of a VSS SQL Backup
145
145
- (ID being the threadId that is doing the logging for that backup attempt in SQLWriter)
146
146
- The VSS backup API selected by the VSS requestor, “component” or “non-component / Volume”
147
147
- The count of Databases included in the component-list sent by VSS requestor, here a single DB (1).
148
148
- A confirmation that each Requestor-provided database name (here ‘db_on_G’) is found (or not found) on the [!INCLUDE[ssSQL11](../../includes/ssnoversion-md.md)] instance it’s been associated with by the VSS requestor (here default instance ‘GF19’).
149
-
- The Flavor of VSS backup requested. Usually VSS_BT_FULL or VSS_BT_COPY. See the VSS_BACKUP_TYPE enum.
150
-
- Another OnIdentify section
151
-
- More entries identifying main phases of VSS Backup (OnFreeze, OnThaw, OnPostSnapshot)
152
-
- A final OnIdentify Section.
153
-
- A final VSS phase report, which names makes it a useful “closing event”: OnBackupComplete.
149
+
- The Flavor of VSS backup requested. Usually `VSS_BT_FULL` or `VSS_BT_COPY`. See the [VSS_BACKUP_TYPE](/windows/win32/api/vss/ne-vss-vss_backup_type) enum.
150
+
- Another `OnIdentify` section
151
+
- More entries identifying main phases of VSS Backup (`OnFreeze`, `OnThaw`, `OnPostSnapshot`)
152
+
- A final `OnIdentify` Section.
153
+
- A final VSS phase report, which names makes it a useful “closing event”: `OnBackupComplete`.
154
154
155
155
These entries provide details on the VSS operations that were previously difficult to establish quickly and required advanced tracing to do so. A prime example is the "Component" or "non-Component" mode of any VSS backup request. With [!INCLUDE[ssql19-md](../../includes/sssql19-md.md)] SQL Writer, they're logged for every single VSS request by default and are easily accessible.
156
156
157
157
158
158
159
159
### Failure Situation: torn database
160
160
161
-
To illustrate the earlier statement that SQL Writer logging complements original EventLog architecture, let’s look at the entries associated to a well-known failure situation: a Torn Database. It can occur when a volume-based VSS backup attempts to snapshot a drive where only a subset of database files is present, as opposed to making sure all drives supporting the Databases Files are included in the snapshot set. SQL Writer will block it as per VSS conventions.
161
+
To illustrate the earlier statement that SQL Writer logging complements original EventLog architecture, let’s look at the entries associated to a well-known failure situation: a Torn Database. It can occur when a VSS backup attempts to create a snapshot set of volumes where only a partial set of files of a given database is included. SQL Writer will block it as per VSS conventions.
162
162
163
-
This extract is the content of **SqlWriterLogger.txt** for the operation:
163
+
This extract is the content of **`SqlWriterLogger.txt`** for the operation:
164
164
165
165
```txt
166
166
[01/11/2021 02:57:00, TID 5a88] Entering SQL Writer OnIdentify.
@@ -235,17 +235,17 @@ Context:
235
235
Process ID: 22628
236
236
```
237
237
238
-
Event Log is a better source of information on the error itself here. However, the SqlWriterLogger contents provide details on the backup request (a VSS_BT_FULL, non-component VSS backup request that failed during the OnPrepareSnapshot phase of SQL Writer). Any investigation of VSS errors involving SQL Server should therefore collect and review *both* sources.
238
+
Event Log is a better source of information on the error itself here. However, the SqlWriterLogger contents provide details on the backup request (a `VSS_BT_FULL`, non-component VSS backup request that failed during the `OnPrepareSnapshot` phase of SQL Writer). Any investigation of VSS errors involving SQL Server should therefore collect and review *both* sources.
239
239
240
240
## Modifying SQL Writer logging parameters
241
241
242
-
SQL Writer logging can be configured by editing the SqlWriterConfig.INI text file. The file itself contains a quick inline description of the available parameters, which we’ll review below.
242
+
SQL Writer logging can be configured by editing the `SqlWriterConfig.INI` text file. The file itself contains a quick inline description of the available parameters, which we’ll review below.
243
243
244
244
> [!IMPORTANT]
245
245
> The .ini file is under a Windows-Protected folder (Program Files). As such it requires elevated administrator privileges to edit. A double-click in explorer will open Notepad without elevation: it will allow the user to read the contents, but attempts to save any change will fail.
246
246
Either start Notepad as administrator and then open SqlWriterConfig.INI, or use a text editor which is able to prompt for elevation as needed at ‘save file’ time.
247
247
248
-
Duplicating the SqlWriterConfig.ini file comments here:
248
+
Duplicating the `SqlWriterConfig.ini` file comments here:
249
249
250
250
```txt
251
251
; EnableLogging = TRUE | FALSE(true is the default behavior)
@@ -256,10 +256,10 @@ Duplicating the SqlWriterConfig.ini file comments here:
256
256
```
257
257
258
258
-**EnableLogging** allows the user to disable the whole new logging feature, in the unlikely case it's needed.
259
-
-**TraceFile** would allow the user to change the path and filename of the trace file. It's not recommended to change it as the fixed location makes it easy to go straight to the right place on any SQL Server for DBAs and Logs Collection tools alike.
259
+
-**TraceFile** would allow the user to change the path and filename of the trace file. It's not recommended to change it as the default, well-known location makes it easy to go straight to the right place on any SQL Server.
260
260
-**Tracelevel** is the verbosity of the logging. More details further on.
261
-
-**TraceFileSizeMb** is the max file size before rollover. The .txt file uses UTF-8 encoding and consumes 2 bytes per character. Increasing this value is valid for instance with intense VSS activity or where it is required to retain long periods of log entries, or if non-default TraceLevels are enabled for long durations. The default 1-MB value with default TraceLevel should provide ample history for most situations.
262
-
-**ForceFlush** setting this option to TRUE would only be useful in the rare circumstances where the SQL Writer service would crash before it got the chance to flush its last log entries; otherwise keep the default value.
261
+
-**TraceFileSizeMb** is the max file size before rollover. The .txt file uses UTF-8 encoding and consumes 2 bytes per character. Increasing this value is valid for instance with intense VSS activity or where it is required to retain long periods of log entries, or if non-default `TraceLevel` values are enabled for long durations. The default 1-MB value with default `TraceLevel` should provide ample history for most situations.
262
+
-**ForceFlush** setting this option to `TRUE` would only be useful in the rare circumstances where the SQL Writer service would crash before it got the chance to flush its last log entries; otherwise keep the default value.
263
263
264
264
### Applying Changes
265
265
@@ -268,15 +268,15 @@ Any change to the settings requires a restart of SQL Writer service to activate.
268
268
> [!TIP]
269
269
>Restarting SQL Writer is extremely fast and can be done at will as SQL Writer doesn’t have any activity and doesn’t retain any stateful information in-between VSS calls. The only precaution is to avoid a restart while a VSS operation (backup, restore) is taking place.
270
270
271
-
SQL Writer will report active parameters in its log file upon (re)start, as can be seen in ‘Service Start’ sample extract.
271
+
SQL Writer will report active parameters in its log file upon (re)start, as can be seen in [Service Start](#service-start) sample extract.
272
272
273
273
## TraceLevel details
274
274
275
275
The INI file lists the following level: DEFAULT | MINIMAL | VERBOSE.
276
276
277
277
-**DEFAULT**: The default verbosity parameters should be adequate for most needs: refer to the [Review of typical logging entries](#review-of-typical-logging-entries) section to observe what is already generated by default. In addition to errors, successful VSS calls, along with VSS metadata, will be logged by default.
278
-
-**MINIMAL**: This level will retain the formatting of Default mode, and its events. It will also generate output in many key places of the code. Most notably it will log all the files and database iterations that are commonplace in the SQLWriter logic. It can increase the number of entries logged for each VSS operation (including mundane OnIdentify event) by a large margin, especially on instances hosting a large number of databases: every single physical file of every single Database may be reported more than once over the course of a VSS backup. This level only helps giving a more precise idea of the logical position of SQL Writer logic at the time of a failure, or for exploration purposes. It’s not useful to keep it active beyond momentary investigations, as it will greatly reduce the history depth of the default 1-MB file size as each operation will generate at least five times as many entries. Increasing the TraceFileSizeMb value may be relevant.
279
-
-**VERBOSE**: Currently this level reports the same events as Minimal, but prefixes each entry with source code object and methods descriptors. It makes the output wider (larger in size than Minimal) and less readable. The added information wouldn't be useful outside of interactions with Microsoft Support Services. The same comment as minimal would apply: keep this level active for long duration will greatly reduce the history depth of the default 1-MB file size as each operation will generate at least five times as many entries, and wider entries: increasing the TraceFileSizeMb value may be relevant.
278
+
-**MINIMAL**: This level will retain the formatting of `DEFAULT` mode, and its events. It will also generate output in many key places of the code. Most notably it will log all the files and database iterations that are commonplace in the SQLWriter logic. It can increase the number of entries logged for each VSS operation (including mundane OnIdentify event) by a large margin, especially on instances hosting a large number of databases: every single physical file of every single Database may be reported more than once over the course of a VSS backup. This level only helps giving a more precise idea of the logical position of SQL Writer logic at the time of a failure. It's also convenient for exploration purposes. It’s not useful to keep it active beyond momentary investigations, as the level of details will greatly reduce the history depth of the default 1-MB file size. Increasing the `TraceFileSizeMb` value may be relevant.
279
+
-**VERBOSE**: Currently this level reports the same events as `MINIMAL`, but prefixes each entry with source code object and methods descriptors. It makes the output wider (larger in size than Minimal) and less readable. The added information wouldn't be useful outside of interactions with Microsoft Support Services. The same comment as `MINIMAL` would apply: keep this level active for long duration will greatly reduce the history depth of the default 1-MB file size as each operation will generate at least five times as many entries, and wider entries: increasing the `TraceFileSizeMb` value may be relevant.
280
280
281
281
> [!NOTE]
282
282
> **MINIMAL** (and **VERBOSE**) level will *not* provide additional error details in case of failure, only additional *progress details* for each low level operation related to SQL Writer activities.
0 commit comments