amachanic / sp_whoisactive

sp_whoisactive
GNU General Public License v3.0
1.14k stars 281 forks source link

Arithmetic overflow error converting expression to data type int #43

Closed imajaydwivedi closed 2 years ago

imajaydwivedi commented 3 years ago

Hi @amachanic ,

I have deployed sp_WhoIsActive (v11.35 (2020-10-04)) baselining with below combinations of parameters in my environment. Most of the time it is successful. But once in a while, below statement fails with following error message -

Arithmetic overflow error converting expression to data type int

EXEC dbo.sp_WhoIsActive @get_outer_command=1, @get_task_info=2, @find_block_leaders=1, @get_plans=1, @get_avg_time=1, @get_additional_info=1, @delta_interval = 10
                ,@output_column_list = @output_column_list
                ,@destination_table = @staging_table;

Attaching the @destination_table definition I have.

CREATE TABLE [dbo].[who_is_active_staging](
    [collection_time] [datetime] NOT NULL,
    [dd hh:mm:ss.mss] [varchar](8000) NULL,
    [session_id] [smallint] NOT NULL,
    [program_name] [nvarchar](128) NULL,
    [login_name] [nvarchar](128) NOT NULL,
    [database_name] [nvarchar](128) NULL,
    [CPU] [varchar](30) NULL,
    [CPU_delta] [varchar](30) NULL,
    [used_memory] [varchar](30) NULL,
    [used_memory_delta] [varchar](30) NULL,
    [open_tran_count] [varchar](30) NULL,
    [status] [varchar](30) NOT NULL,
    [wait_info] [nvarchar](4000) NULL,
    [sql_command] [xml] NULL,
    [blocked_session_count] [varchar](30) NULL,
    [blocking_session_id] [smallint] NULL,
    [sql_text] [xml] NULL,
    [dd hh:mm:ss.mss (avg)] [varchar](15) NULL,
    [physical_io] [varchar](30) NULL,
    [reads] [varchar](30) NULL,
    [physical_reads] [varchar](30) NULL,
    [writes] [varchar](30) NULL,
    [tempdb_allocations] [varchar](30) NULL,
    [tempdb_current] [varchar](30) NULL,
    [context_switches] [varchar](30) NULL,
    [physical_io_delta] [varchar](30) NULL,
    [reads_delta] [varchar](30) NULL,
    [physical_reads_delta] [varchar](30) NULL,
    [writes_delta] [varchar](30) NULL,
    [tempdb_allocations_delta] [varchar](30) NULL,
    [tempdb_current_delta] [varchar](30) NULL,
    [context_switches_delta] [varchar](30) NULL,
    [tasks] [varchar](30) NULL,
    [query_plan] [xml] NULL,
    [percent_complete] [varchar](30) NULL,
    [host_name] [nvarchar](128) NULL,
    [additional_info] [xml] NULL,
    [start_time] [datetime] NOT NULL,
    [login_time] [datetime] NULL,
    [request_id] [int] NULL
)
GO

Please let me know if I missed anything here. I created above table with CREATE TABLE statement generated by stored procedure itself.

amachanic commented 3 years ago

Did you get a line number or anything? I think this might be an issue with the CPU column in the #sessions temp table. Do you want to try changing that to bigint and see what happens? If it works, please create a PR.