-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-16335: Include deadlock detail information in SHOW WARNINGS #4492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
MDEV-16335: Include deadlock detail information in SHOW WARNINGS #4492
Conversation
cc12800 to
67920e9
Compare
Signed-off-by: Varun Deep Saini <[email protected]>
67920e9 to
19592c6
Compare
63a7517 to
0cf376f
Compare
storage/innobase/lock/lock0lock.cc
Outdated
| static_cast<size_t>(len), | ||
| lock_latest_err_file); | ||
| if (deadlock_info_len && deadlock_info[deadlock_info_len - 1] == '\n') | ||
| --deadlock_info_len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot read more than ftell returned: deadlock_info is a temporary file and we access it under lock.
We can put assert
ut_ad(len >= deadlock_info_len);
maybe +1 somewhere -- please check.
Then this if is not needed, as well as zero assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we know is that fread can return only less bytes than ftell did:
https://en.cppreference.com/w/c/io/fread#:~:text=stream%20to%20read-,Return%20value,-Number%20of%20objects
Description
Currently, deadlock information is only available globally via
SHOW ENGINE INNODB STATUS, so a client can never be certain that the information shown is for their own session's deadlock.This patch stores deadlock information in the victim transaction's structure when a deadlock is detected, making it accessible via
SHOW WARNINGS.Implementation
deadlock_infofields totrx_lock_tto store per-session deadlock informationDeadlock::report(), copy deadlock info to the victim transaction (only whensrv_print_all_deadlocksis set)convert_error_code_to_mysql(), push deadlock info as a warning viapush_warning_printf()Release Notes
When
innodb_print_all_deadlocks=ON, deadlock detail information is now available per-session viaSHOW WARNINGSafter a deadlock error (ER_LOCK_DEADLOCK).How can this PR be tested?
Basing the PR against the correct MariaDB version
mainbranch.PR quality check