Skip to content
/ server Public

Conversation

@varundeepsaini
Copy link
Contributor

@varundeepsaini varundeepsaini commented Dec 22, 2025

  • The Jira issue number for this PR is: MDEV-16335

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

  • Added deadlock_info fields to trx_lock_t to store per-session deadlock information
  • In Deadlock::report(), copy deadlock info to the victim transaction (only when srv_print_all_deadlocks is set)
  • In convert_error_code_to_mysql(), push deadlock info as a warning via push_warning_printf()
  • Clear deadlock info when a new transaction starts or when the transaction is freed

Release Notes

When innodb_print_all_deadlocks=ON, deadlock detail information is now available per-session via SHOW WARNINGS after a deadlock error (ER_LOCK_DEADLOCK).

How can this PR be tested?

./mtr --suite=innodb deadlock_session_info

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the main branch.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@CLAassistant
Copy link

CLAassistant commented Dec 22, 2025

CLA assistant check
All committers have signed the CLA.

@varundeepsaini varundeepsaini marked this pull request as draft December 22, 2025 19:46
@varundeepsaini varundeepsaini force-pushed the MDEV-16335-deadlock-info-show-warnings branch 3 times, most recently from 67920e9 to 19592c6 Compare December 22, 2025 21:23
@varundeepsaini varundeepsaini force-pushed the MDEV-16335-deadlock-info-show-warnings branch from 63a7517 to 0cf376f Compare December 24, 2025 05:04
@varundeepsaini varundeepsaini marked this pull request as ready for review December 24, 2025 05:22
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Dec 29, 2025
Copy link
Contributor

@FooBarrior FooBarrior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Contributor

@dr-m dr-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test for this functionality is only executed in debug-instrumented builds. I think that new functionality had better tested with all builds, so that the functionality will be better covered. For example, GNU/Linux distributions that package MariaDB themselves will likely not use CMAKE_BUILD_TYPE=Debug at all. We should test what we ship.

@FooBarrior
Copy link
Contributor

You didn't check

I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.

@varundeepsaini varundeepsaini force-pushed the MDEV-16335-deadlock-info-show-warnings branch from 4f63d11 to 5a59a74 Compare January 21, 2026 19:31
@varundeepsaini varundeepsaini requested a review from dr-m January 23, 2026 08:17
@varundeepsaini varundeepsaini force-pushed the MDEV-16335-deadlock-info-show-warnings branch from 11ae15e to 374a9d7 Compare January 28, 2026 05:05
Copy link
Contributor

@dr-m dr-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this looks okay to me after addressing these points. Please rebase to the latest main branch and squash everything to a single commit, with a carefully written commit message.

@varundeepsaini varundeepsaini force-pushed the MDEV-16335-deadlock-info-show-warnings branch from 374a9d7 to df5836e Compare January 29, 2026 16:37
When innodb_print_all_deadlocks=ON, push the deadlock report to the
session warning list so it can be retrieved via SHOW WARNINGS
@varundeepsaini varundeepsaini force-pushed the MDEV-16335-deadlock-info-show-warnings branch from df5836e to 55481e0 Compare January 29, 2026 16:39
Copy link
Contributor

@FooBarrior FooBarrior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well, thanks @varundeepsaini!

@dr-m dr-m merged commit 55481e0 into MariaDB:main Jan 30, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

7 participants