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

print error code with more meaningful name #2286

Closed
wants to merge 0 commits into from
Closed

print error code with more meaningful name #2286

wants to merge 0 commits into from

Conversation

gueFDF
Copy link

@gueFDF gueFDF commented Mar 3, 2023

What problem does this PR solve?

Issue Number: #2185

Problem Summary:

What is changed and how it works?

What's Changed:
Added some log information, print error code with more meaningful name.

How it Works:
Call the LibCurveErrorName(LIBCURVE_ERROR ret) function to return the specific error information corresponding to the error number.

Side effects(Breaking backward compatibility? Performance regression?):
Basically no side effects.

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

LibCurveAioCallBack cb;
void* buf;
void *buf;
} CurveAioContext;

#endif // INCLUDE_CLIENT_LIBCURVE_DEFINE_H_
Copy link

Choose a reason for hiding this comment

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

a brief code review.

  1. The enum LIBCURVE_ERROR and LIBCURVE_OP have been defined to provide clarity and consistency when writing code.
  2. The function signature for LibCurveAioCallBack has been changed to better reflect its purpose.
  3. off_t, size_t, and int have been used consistently in CurveAioContext, ensuring that all types are properly aligned.
  4. A comment has been added to the Client_NOT_SUPPORT_SNAPSHOT line to explain why it is not supported.
  5. The #endif comment has been added to the end of the file.

} // namespace client
} // namespace curve
} // namespace client
} // namespace curve
Copy link

Choose a reason for hiding this comment

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

code review

  1. The logic of the code is clear and easy to understand.
  2. About the coding style, it meets the standard.
  3. There is no bug risk.
  4. For improvement suggestion, it would be better to add some comments to make the code more readable.

currentTasks.emplace(kv.first);
}
}

for (const auto& timerId : currentTasks) {
for (const auto &timerId : currentTasks) {
int ret = bthread_timer_del(timerId);

if (ret == 0) {
Copy link

Choose a reason for hiding this comment

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

with the code review.

  1. Proper indentation: The code is formatted properly, which helps make it easier to read.

  2. Variable naming: Variable names are descriptive and easy to understand.

  3. Type safety: The code uses the correct types for variables, such as uint64_t for offset and FileSegment* for fileSegment.

  4. Error handling: The code checks for errors and logs them if they occur.

Overall, the code looks well written and follows best practices.

} // namespace client
} // namespace curve
} // namespace client
} // namespace curve
Copy link

Choose a reason for hiding this comment

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

with the code review:

  1. The code is generally well written and organized, but there are some small changes that could be made for better readability and maintainability. For example, the line containing "// namespace client" and "// namespace curve" should be indented to match the indentation of the corresponding code blocks.

  2. The variable names used in the code seem to be descriptive, which is a good practice.

  3. In LeaseExecutor::Start(), the parameter fi is not used in the method. This should either be removed or used in the code.

  4. In LeaseExecutor::RefreshLease(), the “if” statement should include an “else” clause to handle the case when the refresh was successful.

  5. In LeaseExecutor::CheckNeedUpdateFileInfo(), the variable newSn is not used in the method. This should either be removed or used in the code.

Overall, the code looks good and there are no major risk areas.

@@ -115,4 +115,5 @@ int cbd_libcurve_increase_epoch(const char* filename) {
return IncreaseEpoch(filename);
}


} // extern "C"
Copy link

Choose a reason for hiding this comment

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

the code review

This code appears to be a C++ function named cbd_libcurve_increase_epoch() that takes a single argument, a const char* filename. The intention of the function is to increase the epoch value of the file indicated by the filename argument. The function ends with an extern "C" block, which indicates that this function is meant to be used from a C program.

The code looks correct, however there are a few potential issues that should be considered:

  1. The function does not check the filename argument for validity - it is possible to pass a null pointer or invalid filename to the function.
  2. The function does not check the return value of IncreaseEpoch() to ensure that it was successful.
  3. The code does not indicate what type of error handling will be done if IncreaseEpoch() fails.

These potential issues should be addressed to ensure that the function is robust and reliable.


if (ret != LIBCURVE_ERROR::OK) {
LOG(INFO) << "GetSnapshotSegmentInfo failed, ret = " << ret;
LOG(INFO) << "GetSnapshotSegmentInfo failed, ret = " << ret
<< LibCurveErrorName((LIBCURVE_ERROR)ret);
return -ret;
}

Copy link

Choose a reason for hiding this comment

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

code review

  1. In the GetSnapshotSegmentInfo function, it is suggested to add log information and print the name of the error code in addition to the return value.
  2. In the CreateCloneFile function, it is recommended to add a log output and consider adding an exception handling.
  3. In the GetFileInfo function, it is recommended to print the name of the error code in addition to the return value when calling the GetFileInfo function in the mdsclient_.
  4. In the GetOrAllocateSegmentInfo function, it is recommended to add log information and print the name of the error code in addition to the return value.

@@ -175,7 +175,8 @@ int SourceReader::Read(const std::vector<RequestContext*>& reqCtxVec,
UserDataType::IOBuffer);
if (ret != LIBCURVE_ERROR::OK) {
LOG(ERROR) << "Read curve failed failed, filename = " << fileName
<< ", error = " << ret;
<< ", error = " << ret
<< LibCurveErrorName((LIBCURVE_ERROR)ret);
delete curveCombineCtx;
return -1;
} else {
Copy link

Choose a reason for hiding this comment

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

the code review:

The code patch looks fine. It adds more information to an error log message in case of a failed read operation from libCurve. This should be helpful for debugging purposes. There are no evident bug risks and no further improvement suggestions.

<< ", ret = " << ret;
<< ", ret = " << ret
<< LibCurveErrorName((LIBCURVE_ERROR)ret);

return ret;
}
return LIBCURVE_ERROR::OK;
Copy link

Choose a reason for hiding this comment

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

with a brief code review

The code patch looks good and appears to be well written. There doesn't seem to be any immediate bug risks, but it would be beneficial to add more logging so that errors can be more easily identified and tracked in the future. Additionally, it may be beneficial to add more comments in the code to make it easier to understand what is happening in each section of the code.

@gueFDF gueFDF changed the title Signed-off-by: gueFDF <[email protected]> print error code with more meaningful name Mar 3, 2023
@wu-hanqing
Copy link
Contributor

cicheck

@gueFDF gueFDF closed this Mar 3, 2023
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