[MDEV-27087] Add thread ID and database / table, where the error occured to SQL error plugin Created: 2021-11-19 Updated: 2024-01-31 Resolved: 2024-01-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Plugin - SQL_ERROR_LOG |
| Fix Version/s: | 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2, 11.4.1 |
| Type: | New Feature | Priority: | Blocker |
| Reporter: | Richard Stracke | Assignee: | Rucha Deodhar |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | Preview_11.4, plugins, sql_error_log | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
For debug purposes, it will useful, if threadID and database/ table name (if available) will be added to the SQL ERROR Plugin log entries. Error messages should also be extended so that the database and table name is present for errors related to tables. |
| Comments |
| Comment by Sergei Golubchik [ 2022-04-27 ] | ||||
|
thread id — yes, this is very easy to add. | ||||
| Comment by Ralf Gebhardt [ 2022-05-13 ] | ||||
|
serg, the audit plugin provides a table event (read/write) with a query id, and a query event with the same query id and an error code. So that could not be used here? | ||||
| Comment by Sergei Golubchik [ 2022-05-15 ] | ||||
|
example:
and indeed, you can guess from the last table write event what table was it for. But, really, the error message should mention the table name, it's very confusing for the end user now.
this may not even have a table name, it might apply to an expression in SET or WHERE, not to a specific table. This error message doesn't have a table name, and that's correct. | ||||
| Comment by Ralf Gebhardt [ 2022-05-16 ] | ||||
|
serg, so you are saying that we should change the error messages themselves where a database and table name where appropriate instead? Only the table name is not enough | ||||
| Comment by Sergei Golubchik [ 2022-05-16 ] | ||||
|
Yes, we should, where it's not obvious from the context. "Duplicate entry" error can happen in a multi-table UPDATE, so it should include a table name. | ||||
| Comment by Ralf Gebhardt [ 2023-10-19 ] | ||||
|
monty, one question as you added an estimate. I this 1 day to add the thread id to the SQL ERROR Plugin log entries or to change all error messages to include database/table names? | ||||
| Comment by Sergei Golubchik [ 2023-10-30 ] | ||||
|
so, we'll add a thread id and in the error message "Can't write; duplicate key in table 'tab1'." (from the original customer's request) we'll add a db name. Neither of this has to be 11.4+, can be done in earlier versions too | ||||
| Comment by Rucha Deodhar [ 2023-11-24 ] | ||||
|
Patch: https://github.com/MariaDB/server/commit/7dc25883ae368b9ac923a09e3f9a870feaf7ba30 Error message change as mentioned in the comment (with table name) is already present in 10.6:
| ||||
| Comment by Oleksandr Byelkin [ 2023-11-24 ] | ||||
|
OK to push (for testing probably) | ||||
| Comment by Michael Widenius [ 2023-12-04 ] | ||||
|
About the error message. We should also write the name of the key in the error message! | ||||
| Comment by Rucha Deodhar [ 2023-12-18 ] | ||||
|
So after talking to serg found out that in very old MySQL there was ER_DUP_KEY error and then we added ER_DUP_KEYNAME because it is more user friendly error message. | ||||
| Comment by Ramesh Sivaraman [ 2024-01-16 ] | ||||
|
ok to push | ||||
| Comment by Rucha Deodhar [ 2024-01-23 ] | ||||
|
pushed to 10.6 | ||||
| Comment by Rucha Deodhar [ 2024-01-23 ] | ||||
|
A new global variable with_db_and_thread_info for the error logging plugin is added. If set to 1(enabled), it prints the database name and the thread ID in the log in addition to already existing columns. Default value is 0. It cannot be set at runtime to keep the entire log with same formatting. Example when select is done from a non existing table with enabled with_db_and_thread_info, the log will have: 2023-10-31 15:54:37 4 root[root] @ localhost [] `test` ERROR 1146: Table 'test.t_doesnt_exist' doesn't exist : select * from t_doesnt_exist If no database is selected, then there is NULL in place of database instead of being empty. | ||||
| Comment by Ralf Gebhardt [ 2024-01-23 ] | ||||
|
Hi rucha174, as discussed with serg please change the order to
I am reopening the ticket | ||||
| Comment by Rucha Deodhar [ 2024-01-24 ] | ||||
|
made changes to format of log. fixed and pushed to 10.6 |