Skip to content

MCOL-4869: More detailed error report about BufferedFile open failure. #3575

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

Merged
merged 1 commit into from
Jun 9, 2025

Conversation

mariadb-NedeljkoStefanovic
Copy link
Contributor

The BufferedFile constructor is improved about more descriptive error report about file open failure by using errno.

@mariadb-LeonidFedorov mariadb-LeonidFedorov changed the title More detailed error report about BufferedFile open failure. MCOL-4869: More detailed error report about BufferedFile open failure. Jun 3, 2025

if (m_fp == NULL)
{
throw std::runtime_error("unable to open Buffered file ");
static string message = "D 35 CAL0002: Failed to open file: ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to add any numbers here.

it should be "unable to open Buffered file" with filename and errno explanation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


TEST(BufferedFileTest, NoError)
{
mkdir("/data", 0777);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this wil requre root permissions, unittests are not supposed to have

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The remote system setup is that this is impossible to create directory in home directory (/home/ubuntu). Also, I can not write to files in /var/lib/mysql/test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

try {
idbdatafile::BufferedFile bf(fname, "r", 0);
} catch(...) {
catched = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

EXPECT_NO_THROW instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

idbdatafile::BufferedFile bf(fname, "r", 0);
} catch(const std::runtime_error &e) {
catched = true;
EXPECT_EQ(e.what(), message(fname, ENOENT));
Copy link
Collaborator

Choose a reason for hiding this comment

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

EXPECT_THROW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

idbdatafile::BufferedFile bf(fname, "r", 0);
} catch(const std::runtime_error &e) {
catched = true;
EXPECT_EQ(std::string(e.what()), message(fname, ENOTDIR));
Copy link
Collaborator

Choose a reason for hiding this comment

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

EXPECT_THROW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

throw std::runtime_error("unable to open Buffered file ");
static string message = "unable to open file: ";

throw std::runtime_error(message+fname+", exception: "+strerror(err));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add spaces around '+'
We are following Google Codestyle for c++
https://google.github.io/styleguide/cppguide.html#Horizontal_Whitespace
You can also use clang-format or as we have config for it in the root of codebase
There is also a clang-format extension for VSCode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -101,6 +101,10 @@ if(WITH_UNITTESTS)
columnstore_link(bytestream ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} ${CPPUNIT_LIBRARIES} cppunit)
add_test(NAME columnstore:bytestream COMMAND bytestream)

add_executable(BufferedFile BufferedFile.cpp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please set a test executable_name
idbdatafile_test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mariadb-LeonidFedorov mariadb-LeonidFedorov merged commit ddfbeb1 into stable-23.10 Jun 9, 2025
1 check failed
@mariadb-LeonidFedorov mariadb-LeonidFedorov deleted the MCOL-4869 branch June 9, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants