Bug #109633 Display DB (Schema) name the thread is using in the logs during a crash
Submitted: 13 Jan 2023 22:48 Modified: 16 Jan 2023 5:26
Reporter: Mitch Hagstrand (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S4 (Feature request)
Version:Any, 8.0 OS:Any
Assigned to: CPU Architecture:Any

[13 Jan 2023 22:48] Mitch Hagstrand
Description:
If a thread in MySQL causes a segfault, the signal handler will output information about that thread including the query it was executing. Below is an example of this message:

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7fd94c421e50): select city,state,sleep(10) from offices
Connection ID (thread ID): 13
Status: NOT_KILLED

This information does not contain the DB name the thread was using. If the MySQL instance has many DBs with identical table names it can be difficult to determine on which DB the query was executing. As a result identifying a corrupted table or index can not be done easily.

How to repeat:
Wait for a thread to crash or use `kill SIGSEGV <pid of thread>` to crash a thread

Suggested fix:
Add DB name to the logging when a thread receives a segfault. This an example of a possible output:

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7fd94c421e50): select city,state,sleep(10) from offices
DB (7fd94c324ce0): classicmodels
Connection ID (thread ID): 13
Status: NOT_KILLED
[16 Jan 2023 5:26] MySQL Verification Team
Hello Mitch Hagstrand,

Thank you for the feature request.

regards,
Umesh
[17 Jan 2023 16:19] Mitch Hagstrand
Patch to show DB name when logging crash

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 438.patch.txt (text/plain), 1016 bytes.

[17 Jan 2023 16:56] OCA Admin
Contribution submitted via Github - Bug #109633: Display DB (Schema) name the thread is using in the logs during a c 
(*) Contribution by Mitch Hagstrand (Github mhagstrand, mysql-server/pull/438#issuecomment-1382652484): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1197359885.txt (text/plain), 1016 bytes.