1

I tried the following code to create an extended event session.

CREATE EVENT SESSION xetest
ON SERVER
    ADD EVENT rpc_completed
    ADD TARGET package0.event_file
    (SET filename = N'result.xel', max_file_size = (60), max_rollover_files = (5))
WITH (
    MAX_MEMORY = 512000KB,
    EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS,
    MAX_DISPATCH_LATENCY = 30 SECONDS,
    MAX_EVENT_SIZE = 0KB,
    MEMORY_PARTITION_MODE = NONE,
    TRACK_CAUSALITY = OFF,
    STARTUP_STATE = OFF
);

However, I got below error messages when I run it.

Msg 25641, Level 16, State 0, Line 13
For target, "package0.event_file", the parameter "max_file_size" passed is invalid.
Target parameter at index 1 is invalid

I did some investigation and found this:

max_file_size must be larger than the current size of the session buffers. If it is not, the file target will fail to initialize, reporting that the max_file_size is invalid. To view the current size of the buffers, query the buffer_size column in the sys.dm_xe_sessions dynamic management view.

The problem is that sys.dm_xe_sessions Returns information about server-scoped active extended events sessions. Since the extended event session that I was trying to create hasn't exist yet. So I'm not able to query sys.dm_xe_sessions and get its buffer_size column. In this case, how can I know the correct minimum max_file_size value that can be used in the CREATE EVENT SESSION statement?

0

1 Answer 1

2

Your mistake is in this line:

MAX_MEMORY = 512000KB

That's the buffer size for your extended event. As the error says, your max_file_size setting must be larger than this. Obviously, the number you used (60 MB) is not larger than the number you used for MAX_MEMORY (500 MB).

Also, as was mentioned in one of the comments, 500 MB is quite a large buffer size for an extended events session. You should normally need no more than 8 MB or even 16 MB at most.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.