Skip to content
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

MDEV-27952 Improve error log messages with descriptive text already present in the code #3058

Open
wants to merge 1 commit into
base: 11.4
Choose a base branch
from

Conversation

grooverdan
Copy link
Member

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

Description


This is explicitly for the test case:

CREATE TABLE t (c INT) ENGINE=InnoDB;
ALTER TABLE t DISCARD TABLESPACE;
ALTER TABLE t ADD INDEX (c);
SELECT * FROM t;

That had an error:
[ERROR] Got error 194 when reading table './test/t'

194 is the code from HA_ERR_TABLESPACE_MISSING.

As these code are at the handler level, based on the existing code the table name is assumed. There is a built in function my_get_err_msg that translates the number to a format with its argument that can be assumed to be a table string.

The error is now:

2024-02-13 19:08:44 3 [ERROR] Tablespace is missing for table './test/t'

Release Notes

Per title

How can this PR be tested?

Manual test per MDEV

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch.
  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.

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.

@grooverdan
Copy link
Member Author

grooverdan commented Feb 13, 2024

+    sql_print_error("Error %M", error, table->s->path.str);

Generates:

2024-02-13 19:49:55 4 [ERROR] Error 194 "Tablespace is missing for a table"

which isn't correct because it doesn't have the tablename.

@grooverdan grooverdan force-pushed the 11.4-MDEV-27952-error-messages-not-codes-in-errlog branch from 3e2a5a8 to 80dde62 Compare February 14, 2024 05:14
@grooverdan grooverdan requested a review from dr-m February 14, 2024 05:22
@grooverdan grooverdan force-pushed the 11.4-MDEV-27952-error-messages-not-codes-in-errlog branch from 80dde62 to c6cf3a7 Compare February 14, 2024 06:15
…resent in the code

This is explictly for the test case:

CREATE TABLE t (c INT) ENGINE=InnoDB;
ALTER TABLE t DISCARD TABLESPACE;
ALTER TABLE t ADD INDEX (c);
SELECT * FROM t;

That had an error:
  [ERROR] Got error 194 when reading table './test/t'

194 is the code from HA_ERR_TABLESPACE_MISSING.

As these code are at the handler level, based on the existing
code the table name is assumed. There is a built in function
my_get_err_msg that translates the number to a format with its
argument that can be assumed to be a table string.

The error is now:

2024-02-13 19:08:44 3 [ERROR] Tablespace is missing for table './test/t'

Occasionally an index gets called with report_error so the path
form is still there as opposed to changing format or doing a db.table
string.

A few tests ajusted for the exact error.

Achive storage engine fixed for all its incorrect returning of errno
instead of a HA_ERR_{code}.

Reported BINLOG messages correctly to opposed to unknown error.
@grooverdan grooverdan force-pushed the 11.4-MDEV-27952-error-messages-not-codes-in-errlog branch from c6cf3a7 to 00fd647 Compare February 14, 2024 06:25
Comment on lines 2 to +3
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
call mtr.add_suppression("Table './test/t1' is marked as crashed and should be repaired");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we edit the existing suppressions instead:

call mtr.add_suppression("Table '.*t1' is marked as crashed and should be repaired");

@@ -8,6 +8,7 @@

--disable_query_log
call mtr.add_suppression("Flagged corruption of.* in table .* in .*");
call mtr.add_suppression("Index ./test/corrupt_bit_test_@1s is corrupted");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we convert the filename-safe table name to the user-specified name test.corrupt_bit_test_ā with something like this?

static void dict_table_open_failed(const table_name_t &name)
{
  my_printf_error(ER_TABLE_CORRUPT,
                  "Table %`.*s.%`s is corrupted."
                  " Please drop the table and recreate.",
                  MYF(ME_ERROR_LOG),
                  int(name.dblen()), name.m_name, name.basename());
}

Or would it require a different format variant to be implemented?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not use &table_name_t ; Please use pointers instead.
If possible, use C syntax cast instead of C++ syntax cast.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that when using a table name for error messages inside InnoDB, you have to use conversion functions to change it from filename format to table name format.
You have to use innobase_convert_to_system_charset() when converting filenames to table names.

@@ -6,6 +6,7 @@

CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
call mtr.add_suppression("Table './test/t1' is marked as crashed and should be repaired");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please ensure that we do not use '/' in the suppression. (Will not work on windows)

Copy link
Contributor

@montywi montywi left a comment

Choose a reason for hiding this comment

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

Please fix the commented issues.

@@ -287,7 +287,7 @@ static int archive_discover(handlerton *hton, THD* thd, TABLE_SHARE *share)
if (!(azopen(&frm_stream, az_file, O_RDONLY|O_BINARY)))
{
if (errno == EROFS || errno == EACCES)
DBUG_RETURN(my_errno= errno);
DBUG_RETURN(HA_ERR_TABLE_READONLY);
Copy link
Contributor

Choose a reason for hiding this comment

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

You MUST set my_errno here!

Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change errno to HA_ERR_CRASHED_ON_USAGE.
This will hide the original error !

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of changing errno, you can instead change handler::print_error() to give more information about the error

@@ -990,7 +990,7 @@ int ha_archive::write_row(const uchar *buf)

if (!share->archive_write_open && share->init_archive_writer())
{
rc= errno;
rc= HA_ERR_CRASHED_ON_USAGE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change errno to HA_ERR_CRASHED_ON_USAGE.
This will hide the original error !

@@ -1228,7 +1228,7 @@ int ha_archive::rnd_init(bool scan)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);

if (init_archive_reader())
DBUG_RETURN(errno);
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change errno to HA_ERR_CRASHED_ON_USAGE.
This will hide the original error !

@@ -1556,7 +1556,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
if (init_archive_reader())
{
mysql_mutex_unlock(&share->mutex);
DBUG_RETURN(errno);
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change errno to HA_ERR_CRASHED_ON_USAGE.
This will hide the original error !

@@ -1771,7 +1777,7 @@ int ha_archive::info(uint flag)
if (flag & HA_STATUS_AUTO)
{
if (init_archive_reader())
DBUG_RETURN(errno);
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change errno to HA_ERR_CRASHED_ON_USAGE.
This will hide the original error !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants