EXEC master.dbo.xp_create_subdir 'd:\XE'
CREATE EVENT SESSION [SQLTAG_BASELINE_01_B_2012] ON SERVER
ADD EVENT sqlos.WAIT_INFO(
WHERE ([package0].[greater_than_equal_uint64]([duration],(3)))),
ADD EVENT sqlos.WAIT_INFO_EXTERNAL(
WHERE ([package0].[greater_than_equal_uint64]([duration],(3)))),
ADD EVENT sqlserver.RPC_COMPLETED(SET collect_statement=(1)
ACTION(sqlserver.query_hash,sqlserver.sql_text)
WHERE ([package0].[greater_than_equal_uint64]([duration],(3000)))),
ADD EVENT sqlserver.SP_STATEMENT_COMPLETED(SET collect_object_name=(1),collect_statement=(1)
ACTION(sqlserver.query_hash,sqlserver.sql_text)
WHERE ([package0].[greater_than_equal_int64]([duration],(3000)))),
ADD EVENT sqlserver.SQL_BATCH_COMPLETED(SET collect_batch_text=(1)
ACTION(sqlserver.query_hash,sqlserver.sql_text)
WHERE ([package0].[greater_than_equal_uint64]([duration],(3000)))),
ADD EVENT sqlserver.SQL_STATEMENT_COMPLETED(SET collect_parameterized_plan_handle=(0),collect_statement=(1)
ACTION(sqlserver.query_hash,sqlserver.sql_text)
WHERE ([package0].[greater_than_equal_int64]([duration],(3000))))
ADD TARGET package0.event_file(SET filename=N'D:\XE\SQLTAG_BASELINE_01_B_2012.XEL',max_file_size=(100),max_rollover_files=(1000))
WITH (MAX_MEMORY=10240 KB,EVENT_RETENTION_MODE=ALLOW_MULTIPLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=5 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=PER_CPU,TRACK_CAUSALITY=ON,STARTUP_STATE=ON)
GO
CREATE EVENT SESSION [SQLTAG_BLOCKED_REPORTS_03_R_2012] ON SERVER
ADD EVENT sqlserver.BLOCKED_PROCESS_REPORT(
ACTION(package0.callstack,sqlos.cpu_id,sqlos.task_time,sqlserver.client_app_name,sqlserver.client_connection_id,sqlserver.client_hostname,sqlserver.client_pid,sqlserver.database_id,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.sql_text,sqlserver.tsql_stack,sqlserver.username))
ADD TARGET package0.event_file(SET filename=N'D:\XE\SQLTAG_BLOCKED_REPORTS_03_R_2012.XEL',max_file_size=(100),max_rollover_files=(10))
WITH (MAX_MEMORY=10240 KB,EVENT_RETENTION_MODE=ALLOW_MULTIPLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=5 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=PER_CPU,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
GO
CREATE EVENT SESSION [SQLTAG_ERROR_02_E_2012] ON SERVER
ADD EVENT sqlserver.ERROR_REPORTED(
ACTION(sqlos.task_time,sqlserver.client_app_name,sqlserver.client_connection_id,sqlserver.client_hostname,sqlserver.client_pid,sqlserver.database_id,sqlserver.database_name,sqlserver.is_system,sqlserver.nt_username,sqlserver.plan_handle,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.sql_text,sqlserver.tsql_frame,sqlserver.tsql_stack,sqlserver.username)
WHERE ([PACKAGE0].[NOT_EQUAL_INT64]([ERROR_NUMBER],(8153)) AND [PACKAGE0].[NOT_EQUAL_INT64]([ERROR_NUMBER],(5707)) AND [ERROR_NUMBER]<>(5701) AND [ERROR_NUMBER]<>(8153)))
ADD TARGET package0.event_file(SET filename=N'D:\XE\SQLTAG_ERROR_02_E_2012.XEL',max_file_size=(100),max_rollover_files=(10))
WITH (MAX_MEMORY=10240 KB,EVENT_RETENTION_MODE=ALLOW_MULTIPLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=5 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=PER_CPU,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
GO
ALTER EVENT SESSION [SQLTAG_BASELINE_01_B_2012]
ON SERVER
STATE = start;
ALTER EVENT SESSION [SQLTAG_BLOCKED_REPORTS_03_R_2012]
ON SERVER
STATE = start;
ALTER EVENT SESSION [SQLTAG_ERROR_02_E_2012]
ON SERVER
STATE = start;
EXEC SP_CONFIGURE 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC SP_CONFIGURE 'blocked process threshold (s)', 2
GO
RECONFIGURE WITH OVERRIDE
GO
Lisa,
We are just starting to use Availablility Groups so should we make our transaction logs bigger than they were on say SQL2005/SQL2008R2? We also have percent log used alerts to fire off log backups. Will these be affected by the lazy log truncation? We have these set at 65%. Should we change this down or up?
Thanks
Chris
Even though VLFs are not set as cleared, they are still able to be archived and will be in subsequent tlog backups. The space will show as empty when you look at % used (via DBCC SQLPERF for example). The point to keep in mind is that any log fragments that have not yet been hardened on replicas cannot be cleared/overwritten. Therefore, if you have a very long duration of time where a replica is disconnected from the primary, the used tlog space may grow. So, lazy log truncation does not affect the percent used, but other factors may. If you are familiar with mirroring, replication, or CDC, the same scenario is in play because there are now multiple points of truncation in the log..
Brilliant blog post and the answer to the question (Question was also well composed, with thoughts in it). Appreciate it.
Great post Lisa, I ran into this scenario this morning when testing some new availability groups and could not figure out why I was still seeing active vlfs using dbcc loginfo, your post has helped me understand.
We've run into an issue where we need to shrink a tx log. We've run a full backup and a transaction log backup. DBCc SQLPERF now indicates that only 0.16% of the log is used. Sys.databases log_reuse_wait_desc = nothing. But all VLFs have a status of 2. Is Lazy Truncation likely the issue here? Any ideas how we can shrink the log?
Hello,
I know this is an old thread but I thought I'd ask similar question about VLF's. I'm a "DBA" not by choice for a medium sized company ~40 SQL instances. We typically run our DB's in Simple recovery if anything for reduced maintenance. Anyway I have a SQL 2012 database that supports a help desk app (Trackit) that is in Simple mode. I typically set log autogrowth from default % to a set Megabyte value (256Meg in this case). After a few months of use the logfile has fragmented into 605 VLF's and counting and 13Gig.
No big deal right? The weird things is the status on ALL but one of the 605 VLF's is = 2. So this log has one unused VLF and is 99% full. The data file is still at the 256Meg I set it to at the beginning. I'm guessing all relevant data is stuck in the log file. Any ideas for how to fix this situation if indeed it is a problem.
Thanks for any insight
Ron
Just realized I hadn't logged on so I wouldn't get any notifications about the post I just placed.. doh!