Welcome to MSDN Blogs Sign in | Join | Help

SQL Server 2008 SP1 CU 7 and RTM CU10 Released

This week we released cumulative updates for both RTM (RTM based CU 10) and SP1 (SP1 based CU 7) of SQL Server 2008.

·         Build 2766: Cumulative update package 7 for SQL Server 2008 Service Pack 1 http://support.microsoft.com/kb/979065/en-us

·         Build 1835: Cumulative update package 10 for SQL Server 2008 http://support.microsoft.com/kb/979064/en-us

 

Since support for SQL Server 2008 RTM ends 4/13/2010 you should make sure you are on at least SP1 of SQL Server 2008 ASAP.

 

Remember that you can slipstream SP1 and SP1 based CUs into your initial RTM setup files for new installs. You can find an example here: http://blogs.msdn.com/cindygross/archive/2010/01/21/how-to-slipstream-sp1-based-cu5-into-sql-server-2008.aspx

 

References

·         End of lifecycle information for SQL Server 2008 RTM can be found here: http://blogs.msdn.com/sqlreleaseservices/archive/2009/10/08/end-of-service-pack-support-for-sql-server-2005-sp2-and-sql-server-2008-rtm.aspx

 

Product

Version

SP

Mainstream Support End Date

Extended Support End Date

Options / Notes

SQL Server

2008

RTM

(SP0)

04/13/2010

Not Applicable

Technical support ends as of 04/13/2010; options for technical and/or hotfix support after this date:

ð  Continue with self-help

ð  Upgrade to SQL Server 2008 SP1

ð  Custom support agreement

 

·         A list of all available CUs can be found here: http://blogs.msdn.com/sqlreleaseservices/

 

What version do you have now?

·         321185  How to identify your SQL Server version and edition http://support.microsoft.com/default.aspx?scid=kb;EN-US;321185

·         http://www.sqlteam.com/article/sql-server-versions

·         http://sqlserverbuilds.blogspot.com/

·         http://sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx

Posted by CindyGross | 0 Comments
Filed under: ,

What do those "IO requests taking longer than 15 seconds" messages on my SQL box mean?

You may be sometimes seeing stuck/stalled IO messages on one or more of your SQL Server boxes. This is something it is important to understand so I am providing some background information on it.

 

Here is the message you may see in the SQL error log:

SQL Server has encountered xxx occurrence(s) of IO requests taking longer than 15 seconds to complete on file [mdf_or_ldf_file_path_name] in database [dbname] (dbid). The OS file handle is 0x.... The offset of the latest long IO is: 0x....”.

 

The message indicates that SQL Server has been waiting on at least one I/O for 15 seconds or longer. The exact number of times you have exceeded this time for the specified file since the last message is included in the message. The messages will not be written more than once every five minutes. Keep in mind that read IOs on an average system should take no more than 10-20ms and writes should take no more than 3-5ms (the exact acceptable values vary depending on your business needs and technical configuration). So anything measured in seconds indicates a serious performance problem. The problem is NOT within SQL Server, this message indicates SQL has sent off an IO request and has waited more than 15 seconds for a response. The problem is somewhere in the disk IO subsystem. For example, the disk IO subsystem may have more load than it is designed to handle, there is a "bad" hardware or firmware somewhere along the path, filter drivers such as anti-virus software are interfering, your file layout is not optimal, or some IO subsystem setting such as HBA queue depth is not set optimally.

 

Though the root cause is IO, you can see other symptoms that are a side effect and may lead you down the wrong troubleshooting path. For example, if enough IO is backed up behind the stalled IO then you may see blocking in SQL Server (because locks that are usually taken for very short periods of time are now held for seconds), new connections may not be allowed, and the CPU usage can increase (because many threads are waiting), and a clustered SQL Server can fail over (because the IsAlive checks which are just SQL queries fail to complete like all the other queued queries). You may see other errors returned to the user or in the various logs, such as timeouts.

 

There are two ways to approach this problem. You can either reduce the IO on the system (change indexes or queries or archive data for example) or you can make the underlying system able to handle the IO load (fix hardware/firmware problems, change configurations, add disks or controllers, change the file layout, etc.).

 

Background:

·         897284  Diagnostics in SQL Server 2000 SP4 and in later versions help detect stalled and stuck I/O operations

http://support.microsoft.com/default.aspx?scid=kb;EN-US;897284

·         Detecting and Resolving Stalled and Stuck I/O Issues in SQL Server 2000 SP 4 http://msdn.microsoft.com/en-us/library/aa175396(SQL.80).aspx

 

Troubleshooting:

·         Every Windows 2003 SP1 or SP2 system should have this storport fix: 941276  A Windows Server 2003-based computer stops responding when the system is under a heavy load and when the Storport driver is being used http://support.microsoft.com/default.aspx?scid=kb;EN-US;941276

·         Use PerfMon to look at the disk counters for sec/read, sec/write, bytes/sec, current disk queue length, reads/sec, writes/sec

·         Collect data from sys.dm_io_virtual_file_stats and sys.dm_io_pending_io_requests.

·         Ask your storage admins to monitor the entire IO subsystem from the Windows system all the way through to the underlying disks.

How to Rename SQL Server

How to rename a SQL Server varies a bit depending on the SQL version, whether it is clustered or not, and whether you want to rename the server/virtual server part of the name (works except for SQL 2000 clusters) or the instance part of the name (requires a reinstall). Also, you do not want to try renaming a server involved in replication as it will break replication (you have to drop/recreate all replication after a rename), and there are extra steps if mirroring is involved (stop mirroring before the rename, change configuration after). Be very careful to include the keyword "local" in the sp_addserver part of the steps (applies only to stand alone systems) and check @@SERVERNAME afterwards to make sure you have completed the steps correctly.

 

SQL 2008:

·         How to: Rename a SQL Server Failover Cluster Instance http://msdn.microsoft.com/en-us/library/ms178083.aspx

·         How to: Rename a Computer that Hosts a Stand-Alone Instance of SQL Server http://msdn.microsoft.com/en-us/library/ms143799.aspx

 

SQL 2005:

·         How to: Rename a SQL Server 2005 Virtual Server http://msdn.microsoft.com/en-us/library/ms178083(SQL.90).aspx

·         How to: Rename a Computer that Hosts a Stand-Alone Instance of SQL Server 2005 http://msdn.microsoft.com/en-us/library/ms143799(SQL.90).aspx

 

SQL 2000:

·         The SQL Server Network Name resource cannot be renamed http://support.microsoft.com/kb/307336

·         Renaming a Server http://msdn.microsoft.com/en-us/library/aa197071(SQL.80).aspx

 

From the BOL topics we can see that you can NOT rename the instance part of the name in SQL Server 2000, 2005, or 2008:

 

SQL 2005 cluster:

"The name of the virtual server is always the same as the name of the SQL Network Name (the SQL Virtual Server Network Name). Although you can change the name of the virtual server, you cannot change the instance name. For example, you can change a virtual server named VS1\instance1 to some other name, such as SQL35\instance1, but the instance portion of the name, instance1, will remain unchanged."

 

SQL 2005 standalone:

"These steps can be used only to rename the part of the instance name that corresponds to the computer name. For example, you can change a computer named MB1 that hosts an instance of SQL Server named Instance1 to another name, such as MB2. However, the instance portion of the name, Instance1, will remain unchanged. In this example, the \\ComputerName\InstanceName would be changed from \\MB1\Instance1 to \\MB2\Instance1."

 

SQL 2008 cluster:

"Although you can change the name of the virtual server, you cannot change the instance name. For example, you can change a virtual server named VS1\instance1 to some other name, such as SQL35\instance1, but the instance portion of the name, instance1, will remain unchanged."

 

SQL 2008 standalone:

"The following steps cannot be used to rename an instance of SQL Server. They can be used only to rename the part of the instance name that corresponds to the computer name. For example, you can change a computer named MB1 that hosts an instance of SQL Server named Instance1 to another name, such as MB2. However, the instance part of the name, Instance1, will remain unchanged. In this example, the \\ComputerName\InstanceName would be changed from \\MB1\Instance1 to \\MB2\Instance1."

 

 

Posted by CindyGross | 0 Comments
Filed under: ,

SQL DAC

When you start SQL Server (2005+) it creates a separate "Dedicated Administrator Connection" or DAC using a special TCP port. One sysadmin at a time can connect with this DAC connection by specifying Admin:ServerName\Instance. From SQLCMD you can either prefix the server name with Admin: or you can use the /A switch. From SSMS you can use Admin: to make a "Query Editor" connection but you cannot use it in Object Explorer. DAC should only be used when other connection methods fail and you must collect information or think you might be able to kill some SPIDs to improve the situation. On a local connection you can always use DAC (as long as you are a sysadmin and no one else is using it) but for remote connections (and all connections to a cluster are considered remote) you must have enabled remote connections for DAC:

EXEC sp_configure 'remote admin connection', 1

RECONFIGURE

 

If you want to see who if anyone is connected using DAC, try this query:

SELECT dec.local_tcp_port AS DAC_Port, des.login_name AS LoginName, des.nt_domain AS NTDomain,

      des.nt_user_name AS NTUserName, dec.session_id AS SPID,

      dec.connect_time AS ConnectTime, dec.last_read AS LastRead, dec.last_write AS LastWrite,

      des.host_name AS HostName, dec.client_net_address AS ClientIP, des.program_name AS AppName,

      e.state AS EndpointState, e.is_admin_endpoint AS IsAdminEndpoint

      FROM sys.dm_exec_connections dec

      JOIN sys.endpoints e ON e.endpoint_id = dec.endpoint_id

      JOIN sys.dm_exec_sessions des ON des.session_id = dec.session_id

      WHERE e.name = 'Dedicated Admin Connection'

 

If you have any Express Editions, you have to use trace flag 7806 to enable DAC for Express.

 

Using a Dedicated Administrator Connection

http://msdn.microsoft.com/en-us/library/ms189595.aspx

 

How to: Use the Dedicated Administrator Connection with SQL Server Management Studio

http://msdn.microsoft.com/en-us/library/ms178068.aspx

Remote Desktop Options

You probably use remote desktop to connect to your servers or other desktops. You may see Remote Desktop referred to as RDP, RDS, or MSTSC. One common concern is how to resize the remote desktop connection. You can use mstsc.exe to open your connection and pass /f for full screen. You can also pass in the specific pixel count with /w: and /h:. If you have multiple monitors on both the local and remote machines, you can use /span to be able to use both monitors. If you prefer the GUI, when you launch mstsc.exe, click on the options button. On the display tab you have a slider bar of less...more for size. Something else you may find useful is making your local desktop drives available on your RDP session. On the "local resources" tab click on "more" and then check "drives" in the white box. Back on the general tab you can choose to save the current connection settings and use them again.

 

If you want to see what documented options are available from the command line run mstsc.exe /? and take a look at the popup window. Alternatively you can look at this site: http://technet.microsoft.com/en-us/library/cc753907(WS.10).aspx.

 

Additional RDP/MSTSC resources:

·         Remote Desktop Services (Terminal Services) Team Blog http://blogs.msdn.com/rds/default.aspx

·         Remote Desktop scripting http://blogs.msdn.com/rds/archive/2009/11/04/announcing-the-launch-of-remote-desktop-services-script-center-to-ease-management.aspx,  http://technet.microsoft.com/en-us/scriptcenter/ee364707.aspx

·         MSTSC.EXE - no more /console switch in RDC 6.1 http://blogs.technet.com/askperf/archive/2008/01/04/mstsc-exe-no-more-console-switch-in-rdc-6-1.aspx

Posted by CindyGross | 0 Comments
Filed under:

SQL 2008 R2 Developer Kit now available!

You can download a free developer kit for SQL Server 2008 R2 (there's also one available for SQL 2008, the link is at the bottom of the R2 download page). Each kit has videos, samples, labs, and more to help you learn about new features. For instance, I can open the FILESTREAM.HTM page and have access to a presentation and two demos. So download it today and start learning about new features!

http://blogs.msdn.com/rdoherty/archive/2010/02/03/announcing-the-sql-server-2008-r2-update-for-developers-training-kit.aspx

How to slipstream SP1 based CU5 into SQL Server 2008

Starting with SQL Server 2008 SP1 you can “slipstream” SP1 and/or SP1 + SP1 based CUs to avoid a multi-step installation process.

 

http://blogs.msdn.com/petersad/archive/2009/04/16/create-a-merged-slipstream-drop-containing-sql-server-2008-server-pack-1-and-a-cumulative-update-cu-based-on-server-pack-1.aspx

 

To install a slipstreamed instance with SQL08+SP1+SP1-based-CU5 I followed these steps based on the above blog by Peter Saddow:

1)      You will probably want to rename the directory (and therefore update the CUSource entry in the Defaultsetup.ini files) to indicate exactly which CU you have slipstreamed.

2)      Instead of the blog reference in his step 1, you can optionally follow the more official KB 955392, choosing option/procedure 2 (Create a merged drop) to create the slipstream files of RTM+SP1.

a.       To make sure I got the commands exactly right I cut/pasted them into a .cmd file and ran that.

b.      Do NOT do step 7 “Start the Setup program” because you still need to add the CU files.

3)      Download your CU of choice which is likely different than what is listed in the blog. For SP1 based CU5 you will download the first file (SQL_Server_2008_SP1_Cumlative_Update_5) from http://support.microsoft.com/kb/975977.

4)      For CU5, run 399273_intl_x64_zip.exe, 399273_intl_ia64_zip.exe, and 399273_intl_ia64_zip.exe to extract the files SQLServer2008-KB975977-{architecture}.exe (which are the actual setup files for each architecture). You will need the password from the hotfix email you got from the 975977 link/email.

5)      In the blog’s step 4 which tells you to extract files from the setup files, use your actual KB number. For SP1-based-CU5 the KB is 975977 so the commands will be SQLServer2008-KB975977-{architecture}.exe /x:c:\SQLServer2008_FullSP1_CU\CU

6)      Run setup with the “run as admin” option on Windows 2008/Vista/Windows 7.

7)      If you later move the setup files to a different location you will need to update the Defaultsetup.ini file in each of the architecture directories (x86, x64, ia64).

How to Find the Amount of Fragmentation on Your SQL Server Instance

Need to find the amount of fragmentation in all your indexes in all databases for a given instance of SQL Server 2005 or later? You can use the undocumented/unsupported sp_MSforeachdb to loop through all the databases. For more information on fragmentation see my previous blog http://blogs.msdn.com/cindygross/archive/2009/11/20/sql-server-and-fragmentation.aspx.

-- Cindy Gross 2009

-- find fragmentation on all indexes in all databases on this instances

-- to find fragmentation on just one db comment out the exec master... line and the last quote

-- you must use the db_id() rather than NULL as the first parameter of the DMV or it will try to do a join across all dbs

SELECT @@SERVERNAME, @@VERSION, GETDATE() as BatchStartTime

exec master.sys.sp_MSforeachdb ' USE [?];

DECLARE @starttime datetime, @endtime datetime

SELECT @starttime = GETDATE()

SELECT db_name() as CurrentDB, @starttime as DBStartTime

SELECT db_name() as DatabaseName, OBJECT_NAME (a.object_id, DB_ID()) as ObjectName,

a.index_id, b.name as IndexName,

avg_fragmentation_in_percent, page_count, index_depth, index_type_desc, alloc_unit_type_desc

-- , record_count, avg_page_space_used_in_percent --(null in limited)

FROM sys.dm_db_index_physical_stats (db_id(), NULL, NULL, NULL, NULL) AS a

JOIN sys.indexes AS b

ON a.object_id = b.object_id AND a.index_id = b.index_id

--WHERE index_id > 0 -- exclude heaps

ORDER BY DatabaseName asc, avg_fragmentation_in_percent desc, ObjectName asc, IndexName asc

SELECT @endtime = GETDATE()

SELECT @starttime as StartTime, @endtime as EndTime, DATEDIFF(MINUTE,@starttime,@endtime) as TotalMinutes

'

How and Why to Enable Instant File Initialization

See my new blog post (written with Denzil Ribeiro) about "How and Why to Enable Instant File Initialization" on our PFE blog. Keep an eye on the PFE blog for more posts from my team in the near future.

 

Professional SQL Server 2008 Internals and Troubleshooting

Our new book, Professional SQL Server 2008 Internals and Troubleshooting, will be shipping soon! Order now! :-) Christian Bolton, Justin Langford, Brent Ozar, and James Rowland-Jones have each written several chapters in this book. Steven Wort, Jonathan Kehayias and I each contributed a chapter as well. The 1st half of the book introduces you to how things work within SQL Server at a level that will make it easier to understand the rest of the book. The 2nd half of the book focuses on troubleshooting common SQL Server problems.

Download the first chapter and find out more about the book here: http://sqlservertroubleshooting.com/.

 Chapters include:

  1. SQL Server Architecture
  2. Understanding Memory
  3. SQL Server Waits and Extended Events
  4. Working with Storage
  5. CPU and Query Processing
  6. Locking and Latches
  7. Knowing Tempdb
  8. Defining Your Approach to Troubleshooting
  9. Viewing Server Performance with PerfMon and the PAL Tool
  10. Tracing SQL Server with SQL Trace and Profiler
  11. Consolidating Data Collection with SQLDiag and the PerfStats Script
  12. Introducing RML Utilities for Stress Testing and Trace File Analysis
  13. Bringing It All Together with SQL Nexus
  14. Using Management Studio Reports and the Performance Dashboard
  15. Using SQL Server Management Data Warehouse
  16. Shortcuts to Efficient Data Collection and Quick Analysis

Posted by CindyGross | 0 Comments

Latest SQL Server 2005 Cumulative Updates - SP2 based CU17, SP3 based CU7

There are two new cumulative updates (CUs) available for SQL Server 2005 as of today.

·         SQL Server 2005 SP2 based CU17 (9.00.3356). This is the last SP2 based CU as SP2 will no longer be supported after 1/12/2010. KB = Cumulative update package 17 for SQL Server 2005 Service Pack 2 http://support.microsoft.com/kb/976952

·         SQL Server 2005 SP3 based CU7 (9.00.4273). KB = Cumulative update package 7 for SQL Server 2005 Service Pack 3 http://support.microsoft.com/kb/976951

 

This announcement will also be posted on:

·         SQL Release Services Blog

·         SQL Support Center  

·         Microsoft TechNet: SQL Server

·         MSDN:  SQL Server DevCenter

 

Other updates

·         Upgrade Advisor latest update http://www.microsoft.com/downloads/details.aspx?familyid=1470e86b-7e05-4322-a677-95ab44f12d75&displaylang=en

·         Feature Pack latest update http://www.microsoft.com/downloads/details.aspx?FamilyID=536FD7D5-013F-49BC-9FC7-77DEDE4BB075&displaylang=en  

·         System table map http://www.microsoft.com/downloads/thankyou.aspx?familyId=2ec9e842-40be-4321-9b56-92fd3860fb32&displayLang=en&oRef=

·         BOL latest update http://www.microsoft.com/downloads/details.aspx?FamilyId=BE6A2C5D-00DF-4220-B133-29C1E0B6585F&displaylang=en

·         Samples/Sample DBs latest update http://www.codeplex.com/Wikipage?ProjectName=SqlServerSamples

 

Recent CUs/Rollups

SP3 based

·         Cumulative update package 7 for SQL Server 2005 Service Pack 3 (4273) http://support.microsoft.com/kb/976951

·         Cumulative update package 6 for SQL Server 2005 Service Pack 3 (4266) http://support.microsoft.com/kb/974648

·         Cumulative update package 5 for SQL Server 2005 Service Pack 3 (4230) http://support.microsoft.com/kb/972511

·         Cumulative update package 4 for SQL Server 2005 Service Pack 3 (4226) http://support.microsoft.com/kb/970279

·         Cumulative update package 3 for SQL Server 2005 Service Pack 3 (4220) http://support.microsoft.com/kb/967909

·         Cumulative update package 2 for SQL Server 2005 Service Pack 3 (4211) http://support.microsoft.com/kb/961930

·         Cumulative update package 1 for SQL Server 2005 Service Pack 3 (4207) http://support.microsoft.com/kb/959195/

SP2 based

·         Cumulative update package 17 for SQL Server 2005 Service Pack 2 (3356) http://support.microsoft.com/kb/976952

·         Cumulative update package 16 for SQL Server 2005 Service Pack 2 (3355)http://support.microsoft.com/kb/974647

·         Cumulative update package 15 for SQL Server 2005 Service Pack 2 (3330) http://support.microsoft.com/kb/972510  

·         Cumulative update package 14 for SQL Server 2005 Service Pack 2 (3328) http://support.microsoft.com/kb/970278  

·         Cumulative update package 13 for SQL Server 2005 Service Pack 2 (3325) http://support.microsoft.com/kb/967908

·         Cumulative update package 12 for SQL Server 2005 Service Pack 2 (3315) http://support.microsoft.com/kb/962970

·         Cumulative update package 11 for SQL Server 2005 Service Pack 2 (3301) http://support.microsoft.com/kb/958735

·         Cumulative update package 10 for SQL Server 2005 Service Pack 2 (3294) http://support.microsoft.com/kb/956854

 

References

·         SP3: http://www.microsoft.com/downloads/details.aspx?FamilyID=AE7387C3-348C-4FAA-8AE5-949FDFBE59C4&displaylang=en

·         SP3 Readme: http://www.microsoft.com/downloads/details.aspx?FamilyID=851C39EE-6F9D-47D9-8ECC-44AC1E9DC182&displaylang=en

·         SP3 release notes: http://download.microsoft.com/download/5/7/1/5718A94A-3931-457B-8567-AA0995E34870/ReleaseNotesSQL2005SP3.htm

960598  The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 3 was released http://support.microsoft.com/default.aspx?scid=kb;EN-US;960598

SQL Server's Default Trace

Are you familiar with SQL Server's default trace setting? It can be helpful with finding basic who/when type information on major events. For example, you may want to know who was creating and dropping databases on a given instance.

 

SQL Server has a couple of options that might help you find out more about when/by who the database is being created and dropped. One is Policy Based Management but you would need to configure it ahead of time. Another option is to run a profiler trace that captures information such as CREATE, ALTER, DROP DATABASE. Some of the DMVs might have the execution information if you capture it fast enough after it happens. XEvents can be used in SQL 2008 to find all sorts of information. However, the one that might be most appropriate in this case is the Default Trace.

 

1)      Make sure the default trace is enabled in your configuration options for this instance. If it is not enabled, you can enable it through the sp_configure settings.

-- Check to see if the default trace is enabled (0=off, 1=on)

EXEC sp_configure 'default trace enabled'

GO

-- Enabled the default trace

EXEC sp_configure 'default trace enabled', 1

GO

RECONFIGURE

2)      The trace files will eventually overwrite themselves, so check for the output soon after the problem occurs (perhaps make periodic copies of the files). They will be under the log directory where SQL Server is installed. For example, for my SQL 2008 instance named WASH the output files are in C:\Program Files\Microsoft SQL Server\MSSQL10.WASH\MSSQL\Log. The files will be named log_xxx.trc and there will be up to 5 of them.  

3)      Find the trace which covers the time period when the database was created or dropped. You can either open it in the Profiler GUI or you can use the query below to pull out the appropriate data. Look for the create and/or drop events and see who executed them from what workstation and at what time. Some applications will send their "application name" so you may be able to tell that as well.

 

Key Points:

·         You cannot control what is captured by the default trace, how many files it captures before rolling over, or anything other options. Your only option is to turn it on or off. If you want a similar trace that differs in any way you can create your own and configure it to start when SQL Server starts (or whatever time period is appropriate).

·         The trace file name/number will continue to increase until you delete the files.

·         The trace does NOT capture all events, it is very lightweight.

 

References:

·         SQL Server 2008 Internals - Chapter 1 page 73

·         Searching for a Trace - Solving the mystery of SQL Server 2005's default trace enabled option http://www.sqlmag.com/Articles/ArticleID/48939/pg/1/1.html

·         SQL Server Default Trace http://blogs.technet.com/beatrice/archive/2008/04/29/sql-server-default-trace.aspx

·         Default Trace in SQL Server 2005 http://blogs.technet.com/vipulshah/archive/2007/04/16/default-trace-in-sql-server-2005.aspx

·         Default Trace in SQL Server 2005 http://www.mssqltips.com/tip.asp?tip=1111

 

Query:

-- Example of using the default trace to find out more about who/when/why a database is dropped or created

 

-- Get current file name for existing traces

SELECT * FROM ::fn_trace_getinfo(0)

 

-- CHANGE THIS VALUE to the current file name

DECLARE @Path nvarchar(2000)

SELECT  @Path = 'C:\Program Files\Microsoft SQL Server\MSSQL10.WASH\MSSQL\Log\log_120.trc'

 

-- Get information most relevant to CREATE/DROP database

SELECT SPID, LoginName, NTUserName, NTDomainName, HostName, ApplicationName, StartTime, ServerName, DatabaseName

      ,CASE EventClass

            WHEN 46 THEN 'CREATE'

            WHEN 47 THEN 'DROP'

            ELSE 'OTHER'

       END AS EventClass

      , CASE ObjectType

            WHEN 16964 THEN 'DATABASE'

            ELSE 'OTHER'

       END AS ObjectType

      --,*

FROM fn_trace_gettable

(@Path, default)

WHERE ObjectType = 16964 /* Database */ AND EventSubClass = 1 /* Committed */

ORDER BY StartTime

GO

 

/* BOL

 

== Event Class

46 Object:Created

 Indicates that an object has been created, such as for CREATE INDEX, CREATE TABLE, and CREATE DATABASE statements.

47 Object:Deleted

 Indicates that an object has been deleted, such as in DROP INDEX and DROP TABLE statements.

 

 == Object Type

 16964 Database

 

== EventSubClass

 int Type of event subclass.

0=Begin

1=Commit

2=Rollback

 */

 

Posted by CindyGross | 0 Comments
Filed under: , , ,

Backing up a corrupted SQL Server database

I had a question about how to do a backup and skip a corrupted block of data. First, DO NOT DO IT unless you absolutely have to, such as when you are taking a backup prior to trying to fix the corruption (which means you should be on the phone with Microsoft PSS). If you do skip corrupted data you have to consider the backup to be very suspect.

 

Do not ever ignore any indication of data inconsistency in the database. If you have corrupted data it is almost certainly a problem caused by something below the SQL Server level. If it happened once, chances are it will happen again... and again.... and again until the source of the problem is fixed. This means the instant you have any indication of a corrupt SQL Server database you should immediately ask for low-level hardware diagnostics and a thorough review of all logs (event viewer, SQL, hardware, etc.). Double check that if write caching is enabled on the hardware that it is battery backed and the battery is healthy. Double check that all firmware is up to date. Run a DBCC CHECKDB WITH ALL_ERRORMSGS and pay very close attention to the output. Find the source of your corruption and fix it.

 

There is a parameter CONTINUE_AFTER_ERROR for BACKUP and RESTORE, but it is a last ditch command that should only be used as a last resort. One example would be if it's the only way to get a backup before you attempt to repair the corruption. It does not always work, it depends on what the error is. If you actually have to restore a database backup taken with this option, then you MUST fix the corruption before allowing users, applications, or other production processes back into the database. From BOL:

"We strongly recommend that you reserve using the CONTINUE_AFTER_ERROR option until you have exhausted all alternatives."

"At the end of a restore sequence that continues despite errors, you may be able to repair the database with DBCC CHECKDB. For CHECKDB to run most consistently after using RESTORE CONTINUE_AFTER_ERROR, we recommend that you use the WITH TABLOCK option in your DBCC CHECKDB command."

"Use NO_TRUNCATE or CONTINUE_AFTER_ERROR only if you are backing up the tail of a damaged database."

 

Some suggestions:

·         For every 2005/2008 database, SET PAGE_VERIFY=CHECKSUM (in 2005 this cannot be turned on for TempDB, but it can be turned on for TempDB in 2008). For SQL Server 2000 set TORN_PAGE_DETECTION=ON. When upgrading from 2000 to newer versions set TORN_PAGE_DETECTION=OFF and SET PAGE_VERIFY=CHECKSUM.

·         For databases with CHECKSUM enabled, use the WITH CHECKSUM command on all backups.

·         Implement a "standards" or "best practices" document to handle corruption on each version of SQL Server.

·         Review your disaster recovery plans and upcoming testing. Testing of a full recovery of various scenarios should be done periodically. Some people think once a year is enough, others say monthly or quarterly is often enough. Having backups is not good enough, we have to know that they can be restored. There are also scenarios where backups are not the best way to recover from a problem.

 

Some great info from the person who wrote CHECKDB:

http://sqlskills.com/blogs/paul/post/Example-20002005-corrupt-databases-and-some-more-info-on-backup-restore-page-checksums-and-IO-errors.aspx

http://sqlskills.com/BLOGS/PAUL/category/Corruption.aspx

Compilation of SQL Server TempDB IO Best Practices

It is important to optimize TempDB for good performance. In particular, I am focusing on how to allocate files.

 

TempDB is a unique database in several ways. The ones most relevant to this discussion are:

·         It is often one of the busiest databases on an instance. This means the performance of TempDB is critical to your instance's overall performance.

·         It is recreated as a copy of model each time SQL Server starts, taking all the properties of model except for the location, number, and size of its data and log files.

·         TempDB has a very high rate of create/drop object activity. This means the system metadata related to object creation/deletion is heavily used.

·         Slightly different logging and latching behavior.

 

General recommendations:

·         Pre-size TempDB appropriately. Leave autogrow on with instant file initialization enabled, but try to configure the database so that it never hits an autogrow event. Make sure the autogrow growth increment is appropriate.

·         Follow general IO recommendations for fast IO.

·         If your TempDB experiences metadata contention (waitresource = 2:1:1 or 2:1:3), you should split out your data onto multiple files. Generally you will want somewhere between 1/4 and 1 file per physical core. If you don't want to wait to see if any metadata contention occurs you may want to start out with around 1/4 to 1/2 the number of data files as CPUs up to about 8 files. If you think you might need more than 8 files we should do some testing first to see what the impact is. For example, if you have 8 physical CPUs you may want to start with 2-4 data files and monitor for metadata contention.

·         All TempDB data files should be of equal size.

·         As with any database, your TempDB performance may improve if you spread it out over multiple drives. This only helps if each drive or mount point is truly a separate IO path. Whether each TempDB will have a measurable improvement from using multiple drives depends on the specific system.

·         In general you only need one log file. If you need to have multiple log files because you don't have enough disk space on one drive that is fine, but there is no direct benefit from having the log on multiple files or drives.

·         On SQL Server 2000 and more rarely on SQL Server 2005 or later you may want to enable trace flag -T1118.

·         Avoid shrinking TempDB (or any database) files unless you are very certain you will never need the space again.

 

References:

·         Working with tempdb in SQL Server 2005 http://technet.microsoft.com/en-us/library/cc966545.aspx

o   "Divide tempdb into multiple data files of equal size. These multiple files don’t necessarily be on different disks/spindles unless you are also encountering I/O bottlenecks as well. The general recommendation is to have one file per CPU because only one thread is active per CPU at one time."

o   "Having too many files increases the cost of file switching, requires more IAM pages, and increases the manageability overhead."

·         How many files should a database have? - Part 1: OLAP workloads http://sqlcat.com/technicalnotes/archive/2008/03/07/How-many-files-should-a-database-have-part-1-olap-workloads.aspx

o   If you have too many files you can end up with smaller IO block sizes and decreased performance under extremely heavy load.

o   If you have too few files you can end up with decreased performance to GAM/SGAM contention (generally the problem you see in TempDB) or PFS contention (extremely heavy inserts).

o   The more files you have per database the longer it takes to do database recovery (bringing a database online, such as during SQL Server startup). This can become a problem with hundreds of files.

·         SQL Server Urban Legends Discussed http://blogs.msdn.com/psssql/archive/2007/02/21/sql-server-urban-legends-discussed.aspx

o   " SQL Server uses asynchronous I/O allowing any worker to issue an I/O requests regardless of the number and size of the database files or what scheduler is involved."

o   " Tempdb is the database with the highest level of create and drop actions and under high stress the allocation pages, syscolumns and sysobjects can become bottlenecks.   SQL Server 2005 reduces contention with the ‘cached temp table’ feature and allocation contention skip ahead actions."

·         Concurrency enhancements for the tempdb database http://support.microsoft.com/kb/328551

o   Note that this was originally written for SQL Server 2000 (the applies to section only lists 2000) and there are some tweaks/considerations for later versions that are not covered completely in this article. For example, -T1118 is not only much less necessary on SQL Server 2005+, it can in some cases cause problems.

·         FIX: Blocking and performance problems may occur when you enable trace flag 1118 in SQL Server 2005 if the temporary table creation workload is high http://support.microsoft.com/default.aspx?scid=kb;EN-US;936185

o   If you have SP2 based CU2 or later you will not see the problems described in this article. Also, on SP2 based CU2 or higher you are much less likely to even need -T1118 on a heavily used TempDB.

o   " This hotfix significantly reduces the need to force uniform allocations by using trace flag 1118. If you apply the fix and are still encountering TEMPDB contention, consider also turning on trace flag 1118."

·         Misconceptions around TF 1118 http://sqlskills.com/BLOGS/PAUL/post/Misconceptions-around-TF-1118.aspx

o   " turn on TF1118, which makes the first 8 data pages in the temp table come from a dedicated extent "

o   "Instead of a 1-1 mapping between processor cores and tempdb data files (*IF* there's latch contention), now you don't need so many - so the recommendation from the SQL team is the number of data files should be 1/4 to 1/2 the number of processor cores (again, only *IF* you have latch contention). The SQL CAT team has also found that in 2005 and 2008, there's usually no gain from having more than 8 tempdb data files, even for systems with larger numbers of processor cores. Warning: generalization - your mileage may vary - don't post a comment saying this is wrong because your system benefits from 12 data files. It's a generalization, to which there are always exceptions."

·         Storage Top 10 Best Practices http://sqlcat.com/top10lists/archive/2007/11/21/storage-top-10-best-practices.aspx  

o   "Make sure to move TEMPDB to adequate storage and pre-size after installing SQL Server. "

o   "Performance may benefit if TEMPDB is placed on RAID 1+0 (dependent on TEMPDB usage). "

o   "It is recommended to have .25 to 1 data files (per filegroup) for each CPU on the host server. "

o   "This is especially true for TEMPDB where the recommendation is 1 data file per CPU. "

o   "Dual core counts as 2 CPUs; logical procs (hyperthreading) do not. "

o   "Data files should be of equal size – SQL Server uses a proportional fill algorithm that favors allocations in files with more free space.

o   "Pre-size data and log files. "

o   "Do not rely on AUTOGROW, instead manage the growth of these files manually. You may leave AUTOGROW ON for safety reasons, but you should proactively manage the growth of the data files. "

Optimizing tempdb Performance http://msdn.microsoft.com/en-us/library/ms175527.aspx

Posted by CindyGross | 2 Comments
More Posts Next page »
 
Page view tracker