Microsoft sql server I/o basics: Chapter 2


Microsoft SQL Server 2005 Enhancements



Yüklə 0,61 Mb.
səhifə5/7
tarix16.08.2018
ölçüsü0,61 Mb.
#63142
1   2   3   4   5   6   7

Microsoft SQL Server 2005 Enhancements


The following section outlines the core I/O enhancements made in SQL Server 2005.
Checksum

SQL Server 2005 introduces the ability to checksum data pages, log blocks, and backups. For details on checksum capabilities and usage, see the ALTER DATABASE topic in the PAGE_VERIFY section in SQL Server 2005 Books Online.

The expansion of hardware capabilities along with the increased use of virus protection, caching mechanisms, and other advanced filter drivers increase the complexity of the I/O subsystem and expand the point-of-failure possibilities. Microsoft SQL Server 2005 and Microsoft Exchange Server products provide checksum capabilities to enhance data protection.

The checksum algorithm used by SQL Server 2005 is the same algorithm used by Microsoft Exchange Server. The SQL Server algorithm has an additional rotation to detect sector swaps.

Microsoft Exchange Server introduced checksum capabilities several years ago with great success. Search the Microsoft Knowledge Base for more information about error message -1018, which indicates a checksum failure for the Exchange Server product. The following is an excerpt from the Exchange Server Knowledge Base article  KB151789.

“When you perform a transaction with the Jet database, the information store or the directory store writes the transaction to a transaction log file (Edb*.log in Mdbdata or Dsadata). The transaction is then committed to the Jet database. During this process, the Jet engine calculates the page's checksum value to be written, records it in the page header, and then requests that the file system writes the 4-KB page of data to the database on disk.

Even after you restore from a known good backup, however, the -1018 errors may appear again unless the root causes of the physical data write problems are resolved.”



The checksum algorithm is not an ECC or CRC32 implementation but a much less CPU-intensive calculation that avoids affecting database throughput.

The data page and log throughput affects are limited by the buffer pool caching and read-ahead designs. This enables the writes and reads to be done out-of-critical-band when it is possible.


Writes

SQL Server data pages are typically written to disk by the checkpoint or lazy writer processing.

  • SQL Server determines when to run checkpoint activity based on the sp_configure ‘recovery interval’ goal and the amount of log space currently being used.

  • SQL Server 2005 determines when to write dirty pages from the buffer pool cache based on memory pressure and time of last access of the page.

Checksums are calculated immediately before the data page or log block is written to disk. SQL Server tries to perform writes in groups and in a background manner whenever possible to avoid directly affecting user queries. The caching of data pages and grouping of log records helps remove much, if not all, of the command latency associated with a write operation. As described, the checksum calculation activity can frequently be done out-of-band from the original request, thereby reducing any direct affect checksum may add to the write.

Note: The model database is checksum (page audit) enabled. Therefore, all new databases created in SQL Server 2005 are checksum enabled to maximize data protection.
Reads

When a page or log block is read from disk, the checksum (page audit) value is calculated and compared to the checksum value that was stored on the page or log block. If the values do not match, the data is considered to be damaged and an error message is generated.

SQL Server uses read-ahead logic to avoid query stalls caused by I/O waits. The read-ahead design tries to keep the physical reads and checksum comparisons out of the critical path of the active query, decreasing the performance effects of checksum activity.


Damage

The checksum is designed to detect whether one or more bits of the data unexpectedly changed; it was not designed to correct problems.

The checksum is calculated immediately before the write to disk and verified immediately after the physical read from disk. If damage is detected, this indicates a serious I/O subsystem data integrity problem and the I/O subsystem should be thoroughly checked for problems. A failure indicates that data being written to and retrieved from stable media did not maintain its integrity.

Disk drives, caches, filter drivers, memory, CPUs, and other components should be reviewed in complete detail if the system reports checksum failures. Be cautious of power outages as well.

PAGE_VERIFY usage

The ALTER DATABASE command is used to change the database’s PAGE_VERIFY protection settings. There are three possible settings; NONE, CHECKSUM, and TORN_PAGE_DETECTION. The database maintains the verification setting. A status value in each page header indicates the type of protection and verification values stored when data was written to stable media.

Similar checksumming activity occurs for log block writes and reads when CHECKSUM protection is enabled. Log writes and reads always use a parity bit design (torn protection) to mark the valid blocks in the log. An additional checksum of the log block is new and is applied only when the database checksum verification option is enabled.

The following table outlines the verification actions SQL Server 2005 performs based on the database’s PAGE_VERIFY option and the page’s status value, which is located in the page header. Some of the actions in this table might not seem correct because the page’s status value on a read appears to override the database’s current setting. However, on a read the possible verify action is determined from the page header status and not from the current database setting.

For example, a checksum cannot be checked on the read if the checksum wasn’t calculated and stored during the write of the page.




Page Header Setting

Actions Before Write

Actions After Read

NONE

The status of the page header is set to NONE for page verify protection.

This maximizes performance but provides NO physical integrity protection beyond that provided by the I/O subsystem itself. This is not a recommended setting and should be used with caution. Backup plans are especially important for databases that are set to the page verify option of NONE.




The page was not stored with any protection values, so no verification occurs during a read.

Page Header Status = NONE

Database’s Page_Verify Setting

Protection Check

NONE

NONE

TORN

NONE

CHECKSUM

NONE



CHECKSUM

The checksum formula is applied to the 8 KB data page. The page header checksum value is updated and the page header status is set to CHECKSUM. The page is then written to stable media.

Checksum protection uses the most CPU cycles of the three options because it must examine all bits on the page. However, the algorithm has been tuned and the resulting affect is minimal. Checksum is the default database setting in SQL Server 2005.



If a page is read that was written with either checksum or torn page protection, verification occurs for the type of protection indicated in the page header.

Page Header Status = CHECKSUM

Database’s Page_Verify Setting

Protection Check

NONE

NONE

TORN

CHECKSUM

CHECKSUM

CHECKSUM



TORN

The TORN page protection is established by writing a 2-bit value in the lowest order 2 bits of each 512 byte sector of the page. The page header is updated with the torn bit tracking information and the page header’s verify status is set to TORN. The page is then written to disk.

Because the TORN protection uses only 2 bits in each sector of the 8 KB page, it requires less CPU cycles but provides far less protection than checksum.



If a page is read that was written with either checksum or torn page protection, verification occurs for the type of protection indicated in the page header.

Page Header Status = TORN

Database’s Page_Verify Setting

Protection Check

NONE

NONE

TORN

TORN

CHECKSUM

TORN




Note:
SQL Server does not rewrite all database pages in response to an ALTER DATABASE PAGE_VERIFY change. The PAGE_VERIFY option can be changed over time, and pages written to disk will reflect the option that was in effect at the time they were written. Therefore, the database can have pages in any one of the three available verification states.

There is no single command that establishes a PAGE_VERIFY option and applies it to all pages of the database. This includes backup and restore.



  • Backup and restore operations maintain the same physical data integrity as the original database. Backup and restore operations do provide a checksum option but this is different from the PAGE_VERIFY option.

  • Rebuilding clustered indexes in the database can dirty most of the data and index pages and achieve broad page protection establishment. However, heaps, text/image, stored procedures, stored assemblies, and others are not dirtied by a clustered index rebuild operation.

  • Only reuse of the transaction log blocks with the appropriate protection can apply the specified protection to the log blocks.

The only way to make sure that all user data pages contain the desired page verification protection is to copy all data, at the row level, to a new database that was created by using the appropriate page verification option.

Yüklə 0,61 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə