Skip to content

MDEV-39050: Improve error message for missing table share in GetTableShare() - #5466

Open
chhsch wants to merge 1 commit into
MariaDB:10.11from
chhsch:MDEV-39050
Open

MDEV-39050: Improve error message for missing table share in GetTableShare()#5466
chhsch wants to merge 1 commit into
MariaDB:10.11from
chhsch:MDEV-39050

Conversation

@chhsch

@chhsch chhsch commented Jul 28, 2026

Copy link
Copy Markdown

Handle the case in tabutil.cpp where GetTableShare() must report an error after open_table_def() has already failed.
open_table_def() stores the underlying system error in s->open_errno before returning, so if opening the .frm file fails with ENOENT, that information is preserved on the share. We use these recorded values to determine the most appropriate error message:

  1. s->error == OPEN_FRM_OPEN_ERROR indicates the table definition file failed to open.
  2. s->open_errno == ENOENT indicates the failure was due to a "not found" condition.
  3. check_db_dir_existence(db) then distinguishes whether the missing path corresponds to an unknown database, versus a generic open/share error.

…Share()

Handle the case in tabutil.cpp where GetTableShare() must report an error after open_table_def() has already failed.

open_table_def() stores the underlying system error in s->open_errno before returning, so if opening the .frm file fails with ENOENT, that information is preserved on the share. We use these recorded values to determine the most appropriate error message:

1. s->error == OPEN_FRM_OPEN_ERROR indicates the table definition file failed to open.
2. s->open_errno == ENOENT indicates the failure was due to a "not found" condition.
3. check_db_dir_existence(db) then distinguishes whether the missing path corresponds to an unknown database, versus a generic open/share error.
@CLAassistant

CLAassistant commented Jul 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Aug 3, 2026
@gkodinov gkodinov self-assigned this Aug 3, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your contribution! This is a preliminary review.

if (thd->is_error())
thd->clear_error(); // Avoid stopping info commands

snprintf(g->Message, sizeof(g->Message), "Error %d opening share", s->error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if there's a more concrete error into the THD itself before it gets cleaned by clear_error() up above. It would make sense to print these errors first IMHO, if present.
And I'd also try to make sure there are errors if something goes wrong too.

The call to check_db_dir_existence() is a nice touch. But I do not believe it's done for normal tables on open. It's mostly done on db change (e.g. USE) and on DDL statements. I'd say stick to that pattern.

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.

3 participants