Skip to content

Missing max_rollover_files option in definition of event session target file leads to lost of coverage info #81

@DmytroHavrylov

Description

@DmytroHavrylov

When using SQLCover.dll to gather coverage information on large project with great amount of TSQLT tests we found that MSSQLServer creates only 5 trace files (SQLCover-Trace-*.xel), and then overwrites older files. Each file size is close to 1GB.

@@Version = Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0 (X64) Oct 28 2016 18:17:30 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Datacenter 6.3 (Build 14393: ) (Hypervisor)

The reason of the problem: when creating event session with asynchronous_file_target, parameter max_rollover_files is not defined. Default value for max_rollover_files in MSSQL is 5, therefore after writing 5 files it overwrites first one, so coverage information for first tests gets lost before reading.

Fix: to solve that problem we had to modify \src\SQLCover\SQLCoverLib\Trace\SqlTraceController.cs by adding max_rollover_files=(999) into definition of target in constant CreateTrace. Fixed line with max_rollover_files added looks like this:

 protected const string CreateTrace = @"CREATE EVENT SESSION [{0}] ON SERVER 
ADD EVENT sqlserver.sp_statement_starting(action (sqlserver.plan_handle, sqlserver.tsql_stack) where ([sqlserver].[database_id]=({1})))
ADD TARGET package0.asynchronous_file_target(
     SET filename='{2}', max_rollover_files=(999))
WITH (MAX_MEMORY=100 MB,EVENT_RETENTION_MODE=NO_EVENT_LOSS,MAX_DISPATCH_LATENCY=1 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) 
";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions